:root {
    --bg: #f5f7fb;
    --bg-accent: rgba(37, 99, 235, 0.14);
    --bg-start: #f5f7fb;
    --bg-end: #eef2f7;
    --surface: #ffffff;
    --surface-alpha: rgba(255, 255, 255, 0.92);
    --surface-border: rgba(255, 255, 255, 0.7);
    --row-bg: #f8fafc;
    --text: #172033;
    --muted: #697386;
    --line: #e6eaf2;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --shadow: 0 18px 45px rgba(30, 41, 59, 0.14);
}

[data-theme="dark"] {
    --bg: #101624;
    --bg-accent: rgba(96, 165, 250, 0.18);
    --bg-start: #101624;
    --bg-end: #172033;
    --surface: #172033;
    --surface-alpha: rgba(23, 32, 51, 0.94);
    --surface-border: rgba(148, 163, 184, 0.22);
    --row-bg: #1f293f;
    --text: #f8fafc;
    --muted: #a6b0c2;
    --line: #334155;
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, var(--bg-accent), transparent 34rem),
        linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.app {
    width: 100%;
    max-width: 680px;
    padding: 36px;
    background: var(--surface-alpha);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    text-align: center;
}

header {
    display: grid;
    gap: 16px;
    justify-items: center;
    margin-bottom: 28px;
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    line-height: 1.2;
    letter-spacing: 0;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    background: var(--surface);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
}

.theme-icon {
    width: 20px;
    text-align: center;
}

.lotto-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: center;
    min-height: 330px;
    margin-bottom: 28px;
}

.placeholder-text {
    color: var(--muted);
    font-size: 1rem;
}

.game-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    background: var(--row-bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    animation: fade-in 220ms ease both;
}

.game-label {
    width: 54px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: left;
}

.ball {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    box-shadow:
        inset -5px -7px 12px rgba(0, 0, 0, 0.2),
        inset 4px 5px 10px rgba(255, 255, 255, 0.35),
        0 4px 10px rgba(15, 23, 42, 0.16);
}

.yellow { background: #f2b705; }
.blue { background: #2385d9; }
.red { background: #ef4444; }
.gray { background: #64748b; }
.green { background: #16a34a; }

.generate-btn {
    width: min(100%, 260px);
    min-height: 54px;
    border: none;
    border-radius: 999px;
    color: #ffffff;
    background: var(--primary);
    font-size: 1.08rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
    transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.generate-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.34);
}

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

.history-section {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
    text-align: left;
}

.history-section h2 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    line-height: 1.3;
    letter-spacing: 0;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-empty {
    color: var(--muted);
    font-size: 0.95rem;
    text-align: center;
}

.history-item {
    padding: 14px;
    background: var(--row-bg);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.history-time {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.history-games {
    display: grid;
    gap: 8px;
}

.history-game {
    display: flex;
    align-items: center;
    gap: 7px;
}

.history-game-label {
    width: 42px;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.history-number {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--primary);
    box-shadow: inset -3px -4px 8px rgba(0, 0, 0, 0.18);
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 560px) {
    body {
        align-items: flex-start;
        padding: 16px;
    }

    .app {
        padding: 28px 18px;
        border-radius: 18px;
    }

    header {
        margin-bottom: 22px;
    }

    header h1 {
        font-size: 1.7rem;
    }

    .lotto-container {
        min-height: 300px;
        gap: 12px;
    }

    .game-row {
        gap: 7px;
        padding: 12px 8px;
    }

    .game-label {
        width: 40px;
        font-size: 0.8rem;
    }

    .ball {
        width: clamp(34px, 10.5vw, 42px);
        height: clamp(34px, 10.5vw, 42px);
        font-size: 0.92rem;
    }

    .generate-btn {
        width: 100%;
    }

    .history-section {
        margin-top: 28px;
        padding-top: 24px;
    }

    .history-item {
        padding: 12px 8px;
    }

    .history-game {
        gap: 5px;
    }

    .history-game-label {
        width: 34px;
        font-size: 0.72rem;
    }

    .history-number {
        width: clamp(25px, 8vw, 30px);
        height: clamp(25px, 8vw, 30px);
        font-size: 0.72rem;
    }
}
