@import url("https://fonts.googleapis.com/css2?family=Chivo:wght@400;700&family=Space+Grotesk:wght@400;500;700&display=swap");

:root {
    --bg-1: #f7f4ea;
    --bg-2: #d9ecff;
    --card: #fffdf8;
    --ink: #1f2430;
    --muted: #5b6476;
    --line: #d8dfe8;
    --accent: #0f766e;
    --accent-2: #0b5f58;
    --good: #dcfce7;
    --bad: #fee2e2;
    --good-border: #1f9d55;
    --bad-border: #dc2626;
    --shadow: 0 20px 60px rgba(31, 36, 48, 0.14);
}

body[data-theme="dark"] {
    --bg-1: #0f172a;
    --bg-2: #111827;
    --card: #101a2c;
    --ink: #e6edf7;
    --muted: #a8b5c7;
    --line: #2a3b57;
    --accent: #14b8a6;
    --accent-2: #0d9488;
    --good: #113828;
    --bad: #452128;
    --good-border: #3ddc84;
    --bad-border: #ff6678;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1000px 600px at -10% -10%, #ffe8bf 0%, transparent 60%),
        radial-gradient(900px 600px at 110% 10%, #c8ecff 0%, transparent 55%),
        linear-gradient(135deg, var(--bg-1), var(--bg-2));
    display: grid;
    place-items: center;
    padding: 24px;
}

.container {
    width: min(900px, 100%);
    background: color-mix(in oklab, var(--card) 86%, white 14%);
    border: 1px solid color-mix(in oklab, var(--line) 70%, white 30%);
    padding: 32px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    animation: rise-in 650ms ease;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

img.logo {
    width: 20%;
    margin-bottom: 20px;
    object-fit: contain;
}

h1 {
    margin: 0 0 22px;
    text-align: center;
    font-family: "Chivo", sans-serif;
    font-size: clamp(2rem, 4vw, 2.7rem);
    letter-spacing: 0.03em;
}

.theme-toggle {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, color-mix(in oklab, var(--card) 92%, white 8%), color-mix(in oklab, var(--card) 80%, black 20%));
    color: var(--ink);
    border-radius: 999px;
    padding: 9px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 140ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    border-color: color-mix(in oklab, var(--accent) 35%, var(--line) 65%);
    box-shadow: 0 6px 16px rgba(31, 36, 48, 0.15);
}

.theme-toggle:active {
    transform: translateY(0);
}

.hidden {
    display: none;
}

.setup {
    text-align: center;
    margin-bottom: 24px;
    animation: fade-up 500ms ease;
}

.setup label {
    font-size: 1.1rem;
    font-weight: 500;
    margin-right: 8px;
}

.setup input {
    width: 110px;
    padding: 10px;
    font-size: 1rem;
    margin-right: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    text-align: center;
    outline: none;
    transition: box-shadow 180ms ease, border-color 180ms ease;
}

.setup input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, white 80%);
}

#startBtn,
.next-btn,
.restart-btn {
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border: none;
    border-radius: 12px;
    transition: transform 160ms ease, box-shadow 200ms ease, filter 180ms ease;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.25);
}

#startBtn:hover,
.next-btn:hover,
.restart-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.04);
}

#startBtn:active,
.next-btn:active,
.restart-btn:active {
    transform: translateY(0);
}

.next-btn {
    margin-top: 25px;
    padding: 12px 25px;
    font-size: 1.08rem;
}

.limit-info {
    margin: 12px 0 0;
    font-size: 0.92rem;
    color: var(--muted);
}

.stats {
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.stats-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid color-mix(in oklab, var(--accent) 24%, var(--line) 76%);
    background:
        linear-gradient(140deg, color-mix(in oklab, var(--accent) 16%, white 84%), color-mix(in oklab, var(--card) 85%, white 15%));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.stats-label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.stats-value {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--accent-2);
}

body[data-theme="dark"] .stats-item {
    background:
        linear-gradient(140deg, color-mix(in oklab, var(--accent) 24%, #0f2034 76%), color-mix(in oklab, var(--card) 86%, black 14%));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.timer {
    margin-bottom: 18px;
    padding: 10px 12px;
    border: 1px solid color-mix(in oklab, var(--accent) 24%, var(--line) 76%);
    border-radius: 14px;
    background: linear-gradient(140deg, color-mix(in oklab, var(--accent) 12%, white 88%), color-mix(in oklab, var(--card) 88%, white 12%));
}

.timer-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 700;
}

.timer-value {
    color: var(--accent-2);
    font-size: 1rem;
}

.timer-track {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid color-mix(in oklab, var(--line) 80%, var(--accent) 20%);
    background: color-mix(in oklab, var(--card) 75%, black 25%);
}

.timer-fill {
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #34d399, #0ea5a4);
    transition: width 120ms linear, background 180ms ease;
}

.timer.warning .timer-fill {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.timer.danger .timer-fill {
    background: linear-gradient(90deg, #fb7185, #ef4444);
}

body[data-theme="dark"] .timer {
    background: linear-gradient(140deg, color-mix(in oklab, var(--accent) 18%, #0f2034 82%), color-mix(in oklab, var(--card) 88%, black 12%));
}

body[data-theme="dark"] .timer-track {
    background: color-mix(in oklab, var(--card) 70%, black 30%);
}

.question {
    font-family: "Chivo", sans-serif;
    font-size: clamp(1.2rem, 2.4vw, 1.5rem);
    margin-bottom: 18px;
}

.answer-btn {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 14px 16px;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, #f6f9fc);
    transition: transform 140ms ease, border-color 160ms ease, box-shadow 160ms ease;
    animation: fade-up 380ms ease both;
}

.answer-btn.correct {
    background: var(--good);
    border-color: var(--good-border);
    color: #0f2b1e;
    font-weight: 700;
}

.answer-btn.incorrect {
    background: var(--bad);
    border-color: var(--bad-border);
    color: #3a1219;
    font-weight: 700;
}

body[data-theme="dark"] .answer-btn.correct {
    color: #eafff2;
    background: #145131;
}

body[data-theme="dark"] .answer-btn.incorrect {
    color: #ffecef;
    background: #5a2631;
}

.answer-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: color-mix(in oklab, var(--accent) 35%, var(--line) 65%);
    box-shadow: 0 10px 20px rgba(31, 36, 48, 0.1);
}

.answer-btn:disabled {
    opacity: 0.95;
    cursor: not-allowed;
}

.explanation {
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(180deg, #eef7ff, #e6f4ff);
    border: 1px solid #c8e2f8;
    border-left: 6px solid #2c7da0;
    border-radius: 12px;
    color: #1d3b53;
}

.result {
    position: relative;
    overflow: hidden;
    text-align: center;
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    padding: 20px;
    animation: fade-up 500ms ease;
}

.result-content {
    position: relative;
    z-index: 2;
}

.result-title {
    font-family: "Chivo", sans-serif;
    font-size: clamp(1.8rem, 3vw, 2.3rem);
    letter-spacing: 0.02em;
}

.result-note {
    margin-top: 16px;
    font-size: clamp(1rem, 1.7vw, 1.2rem);
    font-weight: 700;
    color: var(--muted);
}

.result-effects {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.fx-particle {
    position: absolute;
    border-radius: 999px;
    opacity: 0;
    transform: translate(0, 0) scale(0.6);
    animation-name: particle-burst;
    animation-timing-function: cubic-bezier(0.22, 0.66, 0.18, 1);
    animation-fill-mode: forwards;
    box-shadow: 0 0 14px color-mix(in oklab, currentColor 45%, white 55%);
}

.result-effects.tier-excellent .fx-particle {
    filter: saturate(1.25);
}

.result-effects.tier-medium .fx-particle {
    filter: saturate(1.05);
}

.result-effects.tier-low .fx-particle {
    opacity: 0.9;
}

.result:has(.result-effects.tier-excellent) {
    background: radial-gradient(700px 260px at 50% -25%, rgba(251, 191, 36, 0.23), transparent 56%);
}

.result:has(.result-effects.tier-medium) {
    background: radial-gradient(650px 230px at 50% -22%, rgba(45, 212, 191, 0.2), transparent 58%);
}

.result:has(.result-effects.tier-low) {
    background: radial-gradient(600px 210px at 50% -20%, rgba(148, 163, 184, 0.18), transparent 60%);
}

.restart-btn {
    margin-top: 20px;
}

.app-footer {
    margin-top: 26px;
    padding-top: 14px;
    border-top: 1px dashed color-mix(in oklab, var(--line) 70%, var(--accent) 30%);
    text-align: center;
    font-size: 0.92rem;
    color: var(--muted);
    line-height: 1.4;
}
.ada-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes particle-burst {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.5);
    }
    14% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0.15);
    }
}

@media (max-width: 700px) {
    body {
        padding: 14px;
    }

    .container {
        padding: 20px;
        border-radius: 18px;
    }

    .topbar {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 12px;
        padding-bottom: 12px;
    }

    img.logo {
        width: min(100px, 50%);
        margin-bottom: 0;
    }

    h1 {
        margin: 0;
    }

    .theme-toggle {
        align-self: center;
    }

    .setup {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        justify-items: center;
    }

    .setup input {
        margin-right: 0;
        width: 130px;
    }

    .question {
        margin-top: 4px;
    }

    .stats {
        grid-template-columns: 1fr;
    }
}
