:root {
    --primary-color: #0067ac; /* Woori Bank Blue */
    --accent-color: #0088d2;
    --secondary-color: #55acee;
    --danger-color: #e53935;
    --background-color: #f4f7fa;
    --text-color: #2c3e50;
    --white: #ffffff;
    --shadow-color: rgba(0, 103, 172, 0.08);
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-image: linear-gradient(180deg, #e1f5fe 0%, #f4f7fa 100%);
    overflow-x: hidden;
}

.top-bar {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 1.5rem;
    box-sizing: border-box;
}

#lang-toggle, #history-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 18px;
    font-size: 0.85rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

#history-btn:hover, #lang-toggle:hover {
    background-color: var(--primary-color);
    color: white;
}

main {
    text-align: center;
    background: var(--white);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 10px 30px var(--shadow-color);
    max-width: 95%;
    width: 600px;
    margin-bottom: 3rem;
}

h1 {
    color: var(--text-color);
    margin-bottom: 2.5rem;
    line-height: 1.3;
    letter-spacing: -0.8px;
}

h1 span.light {
    font-size: 1.2rem;
    font-weight: 500;
    color: #7f8c8d;
    display: block;
    margin-bottom: 8px;
}

h1 span.bold {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--primary-color);
}

h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.2rem;
    text-align: center;
}

section {
    margin-bottom: 2.5rem;
}

/* Generator Controls */
.generator-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 2rem;
}

.icon-btn {
    background: rgba(0, 103, 172, 0.05);
    color: var(--primary-color);
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    border: 1px solid rgba(0, 103, 172, 0.1);
    cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.icon-btn:disabled {
    opacity: 0.2;
}

#generate-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: var(--white);
    padding: 1.1rem 3rem;
    font-size: 1.25rem;
    border-radius: 50px;
    box-shadow: 0 6px 20px rgba(0, 103, 172, 0.25);
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
}

#generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 103, 172, 0.35);
}

#save-favorite-btn, #fate-btn {
    background: var(--primary-color);
    color: white;
    width: 100%;
    max-width: 350px;
    padding: 1rem;
    font-size: 1.1rem;
    margin: 1.5rem auto;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

/* Secondary Buttons - Transparent Style */
.edit-btn, .del-btn, #randomize-excluded-btn, #clear-excluded-btn {
    background: rgba(0, 0, 0, 0.04);
    color: #555;
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.edit-btn:hover { background: rgba(255, 193, 7, 0.15); color: #856404; border-color: rgba(255, 193, 7, 0.2); }
.del-btn:hover { background: rgba(229, 57, 53, 0.1); color: #c62828; border-color: rgba(229, 57, 53, 0.2); }
#randomize-excluded-btn:hover { background: rgba(0, 103, 172, 0.1); color: var(--primary-color); border-color: var(--primary-color); }
#clear-excluded-btn:hover { background: rgba(0, 0, 0, 0.08); color: #333; }

/* Info Box & Details */
details, .info-box {
    background: rgba(0, 103, 172, 0.03);
    border-radius: 16px;
    padding: 12px 16px; /* Minimized padding */
    margin-bottom: 1.2rem;
    text-align: center;
    border: 1px solid rgba(0, 103, 172, 0.08);
}

summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--primary-color);
    outline: none;
    font-size: 0.9rem;
    text-align: left;
    display: list-item;
}

#energy-desc {
    font-weight: 700;
    color: var(--primary-color);
    outline: none;
    font-size: 0.9rem;
    margin: 0;
}

.details-content {
    padding-top: 18px;
}

#number-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
}

.grid-number {
    text-align: center;
    padding: 10px 0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid #eee;
    transition: all 0.2s;
}

.grid-number:hover {
    border-color: var(--primary-color);
    background: #f5f5f5;
}

.grid-number.excluded {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* Favorites Section */
#favorites-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.favorite-item {
    display: flex;
    flex-direction: row; /* Horizontal alignment */
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid #f0f0f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    transition: all 0.3s ease;
}

.favorite-item:hover {
    background-color: #fcfdfe;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 103, 172, 0.08);
}

.fav-nums-wrapper {
    display: flex;
    justify-content: flex-start;
    flex: 1;
}

.fav-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

/* Energy Image Styling */
.energy-section {
    text-align: left; /* Header alignment within details */
}

.energy-image-container {
    margin-top: 15px;
    display: flex;
    justify-content: flex-start; /* Left align image */
}

.energy-image {
    max-width: 100%; /* Grow to full container width if needed */
    width: 400px;    /* Larger target size */
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Modal Popup Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 3rem;
    border: none;
    width: 85%;
    max-width: 850px;
    border-radius: 30px;
    position: relative;
    line-height: 1.8;
    box-shadow: 0 30px 60px rgba(0,0,0,0.3);
    animation: popupScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    cursor: default;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 2.5rem;
    font-weight: 300;
    color: #999;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.close-btn:hover {
    color: var(--primary-color);
}

@keyframes popupScale {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}


/* Instant Tooltip */
.instant-tooltip {
    position: fixed;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    z-index: 9999;
    pointer-events: none;
    display: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

/* Emoji Rain Animation */
.rain-emoji {
    position: fixed;
    top: -60px;
    z-index: 10000;
    user-select: none;
    pointer-events: none;
    animation: rain linear forwards;
}

@keyframes rain {
    to { transform: translateY(110vh) rotate(360deg); }
}

/* Fate Section Result */
.fate-result-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.fate-emoji {
    font-size: 2.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer */
footer {
    width: 100%;
    padding: 2rem 1.5rem;
    background: rgba(0, 103, 172, 0.02);
    margin-top: auto;
}

.footer-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    color: #7f8c8d;
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.footer-desc {
    margin-top: 10px;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 500px) {
    #number-grid { grid-template-columns: repeat(7, 1fr); }
    main { padding: 1.5rem; }
    h1 span.bold { font-size: 1.6rem; }
    .favorite-item { flex-direction: column; gap: 12px; }
    
    .fate-result-wrapper {
        flex-direction: column;
        gap: 15px;
    }
    
    .fate-emoji {
        font-size: 3rem;
    }
    
    /* Ensure lotto numbers in fate result fit in one line */
    lotto-numbers.fate-lotto-numbers {
        --ball-size: 38px;
        --font-size: 0.85rem;
        --gap: 4px;
    }
}
