@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

:root {
    --bg-color: #f0f2f5;
    --container-bg: #ffffff;
    --text-color: #333;
    --header-color: #2c3e50;
    --button-bg: #3498db;
    --button-hover-bg: #2980b9;
    --button-shadow: rgba(52, 152, 219, 0.3);
    --button-hover-shadow: rgba(52, 152, 219, 0.4);
    --number-text-color: white;
    --separator-color: #7f8c8d;
    --bonus-label-color: #7f8c8d;
    --range1-bg: linear-gradient(145deg, #f1c40f, #f39c12);
    --range1-shadow: rgba(241, 196, 15, 0.4);
    --range2-bg: linear-gradient(145deg, #3498db, #2980b9);
    --range2-shadow: rgba(52, 152, 219, 0.35);
    --range3-bg: linear-gradient(145deg, #e74c3c, #c0392b);
    --range3-shadow: rgba(231, 76, 60, 0.35);
    --range4-bg: linear-gradient(145deg, #95a5a6, #7f8c8d);
    --range4-shadow: rgba(127, 140, 141, 0.35);
    --range5-bg: linear-gradient(145deg, #2ecc71, #27ae60);
    --range5-shadow: rgba(46, 204, 113, 0.35);
    --bonus-bg: linear-gradient(145deg, #e74c3c, #c0392b);
    --bonus-shadow: rgba(231, 76, 60, 0.35);
    --container-shadow: rgba(0, 0, 0, 0.1);
    --theme-slider-bg: #ccc;
    --theme-slider-fg: white;
    --theme-slider-icon: '☀️';
    --secondary-btn-bg: #27ae60;
    --secondary-btn-hover: #219a52;
    --history-bg: #f8f9fa;
    --history-item-bg: #ffffff;
    --history-border: #e0e0e0;
    --danger-btn-bg: #e74c3c;
    --danger-btn-hover: #c0392b;
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --container-bg: #2c2c2c;
    --text-color: #f0f0f0;
    --header-color: #ffffff;
    --button-bg: #bb86fc;
    --button-hover-bg: #a16ae8;
    --button-shadow: rgba(187, 134, 252, 0.25);
    --button-hover-shadow: rgba(187, 134, 252, 0.35);
    --separator-color: #888;
    --bonus-label-color: #aaa;
    --range1-shadow: rgba(241, 196, 15, 0.5);
    --range2-shadow: rgba(52, 152, 219, 0.45);
    --range3-shadow: rgba(231, 76, 60, 0.45);
    --range4-shadow: rgba(127, 140, 141, 0.45);
    --range5-shadow: rgba(46, 204, 113, 0.45);
    --bonus-shadow: rgba(231, 76, 60, 0.45);
    --container-shadow: rgba(0, 0, 0, 0.4);
    --theme-slider-bg: #555;
    --theme-slider-fg: #222;
    --theme-slider-icon: '🌙';
    --secondary-btn-bg: #03dac6;
    --secondary-btn-hover: #00c4b4;
    --history-bg: #1e1e1e;
    --history-item-bg: #333;
    --history-border: #444;
    --danger-btn-bg: #cf6679;
    --danger-btn-hover: #b55464;
}

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(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    color: var(--text-color);
    transition: background-color 0.4s, color 0.4s;
}

.container {
    background-color: var(--container-bg);
    padding: 35px 40px;
    border-radius: 24px;
    box-shadow: 0 12px 35px var(--container-shadow);
    text-align: center;
    width: 90%;
    max-width: 550px;
    transition: background-color 0.4s, box-shadow 0.4s;
    position: relative;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-bottom: 35px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-btn {
    background: var(--button-bg);
    color: var(--number-text-color);
    border: none;
    padding: 8px 14px;
    font-size: 0.9em;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.lang-btn:hover {
    background: var(--button-hover-bg);
    transform: translateY(-1px);
}

.lang-btn:focus {
    outline: 3px solid var(--header-color);
    outline-offset: 2px;
}

h1 {
    font-size: 2.4em;
    font-weight: 700;
    color: var(--header-color);
    margin: 0;
}

.theme-switcher {
    position: relative;
    width: 56px;
    height: 28px;
}

#theme-toggle {
    display: none;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--theme-slider-bg);
    transition: .4s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: var(--theme-slider-icon);
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: var(--theme-slider-fg);
    transition: .4s;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    line-height: 1;
}

#theme-toggle:checked + .slider {
    background-color: var(--button-bg);
}

#theme-toggle:checked + .slider:before {
    transform: translateX(28px);
}


.number {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    color: var(--number-text-color);
    font-size: 1.9em;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.15);
    transition: transform 0.3s ease, background 0.4s, box-shadow 0.4s;
}

.number:hover {
    transform: scale(1.1) rotate(5deg);
}

.number.is-new {
    animation: pop-in 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.number.bonus {
    background: var(--bonus-bg);
    box-shadow: 0 5px 20px var(--bonus-shadow);
}

.number.range-1 {
    background: var(--range1-bg);
    box-shadow: 0 5px 20px var(--range1-shadow);
}

.number.range-2 {
    background: var(--range2-bg);
    box-shadow: 0 5px 20px var(--range2-shadow);
}

.number.range-3 {
    background: var(--range3-bg);
    box-shadow: 0 5px 20px var(--range3-shadow);
}

.number.range-4 {
    background: var(--range4-bg);
    box-shadow: 0 5px 20px var(--range4-shadow);
}

.number.range-5 {
    background: var(--range5-bg);
    box-shadow: 0 5px 20px var(--range5-shadow);
}

.separator {
    display: flex;
    align-items: center;
    font-size: 2.2em;
    font-weight: 700;
    color: var(--separator-color);
    padding: 0 8px;
}

.bonus-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bonus-label {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--bonus-label-color);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

#generate-btn {
    background-color: var(--button-bg);
    color: var(--number-text-color);
    border: none;
    padding: 16px 32px;
    font-size: 1.25em;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, transform 0.2s;
    box-shadow: 0 5px 18px var(--button-shadow);
    will-change: transform;
}

#generate-btn:hover {
    background-color: var(--button-hover-bg);
    box-shadow: 0 7px 22px var(--button-hover-shadow);
    transform: translateY(-2px);
}

#generate-btn:active {
    transform: translateY(0);
}

@keyframes pop-in {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    70% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

.bonus-wrap.is-new {
    animation: pop-in 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
}

.set-label {
    font-weight: 600;
    font-size: 1em;
}

#set-count {
    padding: 8px 16px;
    font-size: 1em;
    border-radius: 8px;
    border: 2px solid var(--button-bg);
    background-color: var(--container-bg);
    color: var(--text-color);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.3s, background-color 0.3s;
}

#set-count:focus {
    outline: 3px solid var(--button-bg);
    outline-offset: 2px;
}

.lotto-sets {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.lotto-set {
    background: var(--history-item-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px var(--container-shadow);
}

.set-header {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--bonus-label-color);
    margin-bottom: 12px;
    text-align: left;
}

.lotto-numbers {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

#copy-btn {
    background-color: var(--secondary-btn-bg);
    color: var(--number-text-color);
    border: none;
    padding: 16px 32px;
    font-size: 1.25em;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, transform 0.2s;
    box-shadow: 0 5px 18px rgba(39, 174, 96, 0.3);
}

#copy-btn:hover {
    background-color: var(--secondary-btn-hover);
    transform: translateY(-2px);
}

#copy-btn:active {
    transform: translateY(0);
}

#copy-btn:focus,
#generate-btn:focus {
    outline: 3px solid var(--header-color);
    outline-offset: 2px;
}

.history-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--history-border);
}

.history-section h2 {
    font-size: 1.2em;
    margin: 0 0 15px 0;
    color: var(--header-color);
}

#clear-history-btn {
    background-color: var(--danger-btn-bg);
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background-color 0.3s, transform 0.2s;
}

#clear-history-btn:hover {
    background-color: var(--danger-btn-hover);
    transform: translateY(-1px);
}

#clear-history-btn:focus {
    outline: 3px solid var(--danger-btn-bg);
    outline-offset: 2px;
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    background: var(--history-item-bg);
    border: 1px solid var(--history-border);
    border-radius: 10px;
    padding: 12px 15px;
    margin-bottom: 10px;
    font-size: 0.9em;
    transition: background-color 0.3s;
}

.history-item:hover {
    background: var(--history-bg);
}

.history-time {
    font-size: 0.8em;
    color: var(--bonus-label-color);
    margin-bottom: 5px;
}

.history-numbers {
    font-weight: 600;
    word-break: break-all;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--header-color);
    color: white;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 600;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 600px) {
    .container {
        padding: 25px 20px;
        border-radius: 16px;
    }

    h1 {
        font-size: 1.6em;
    }

    .number {
        width: 48px;
        height: 48px;
        font-size: 1.4em;
    }

    .separator {
        font-size: 1.6em;
        padding: 0 4px;
    }

    .lotto-numbers {
        gap: 8px;
    }

    #generate-btn,
    #copy-btn {
        padding: 14px 24px;
        font-size: 1.1em;
    }

    .button-group {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-switcher {
        width: 48px;
        height: 24px;
    }

    .slider:before {
        height: 18px;
        width: 18px;
        font-size: 10px;
    }

    #theme-toggle:checked + .slider:before {
        transform: translateX(24px);
    }

    .controls {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 400px) {
    .number {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    .bonus-wrap .number {
        width: 40px;
        height: 40px;
    }

    h1 {
        font-size: 1.4em;
    }
}
