:root {
    --app-bg: #d9dbe1;
    --panel: #f8f9fb;
    --line: #d8dce4;
    --text: #0e1621;
    --muted: #6a7483;
    --white: #ffffff;
    --pink: #ef0050;
    --blue: #1988cc;
    --orange: #f5aa1c;
    --green: #09a85c;
    --cyan: #24acc7;
    --shadow-soft: 0 6px 16px rgba(14, 22, 33, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", sans-serif;
    color: var(--text);
    background: var(--app-bg);
}

.app-shell {
    width: min(780px, 100%);
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    background: var(--app-bg);
}

.top-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 20px 28px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.brand-block {
    display: grid;
    grid-template-columns: auto auto;
    gap: 16px;
    align-items: end;
}

.brand-block h1 {
    margin: 0;
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 700;
}

.stats-hint {
    font-size: 1.8rem;
    line-height: 1;
    color: var(--muted);
    font-family: "Instrument Serif", serif;
}

.top-stats {
    display: grid;
    grid-template-columns: auto repeat(3, auto) auto;
    gap: 24px;
    align-items: center;
}

.pool-picker {
    display: grid;
    gap: 6px;
}

.pool-picker span {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.pool-picker select {
    min-width: 190px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 34px 10px 12px;
    background: #f6f7fb;
    color: #314054;
    font: inherit;
    font-weight: 700;
}

.stat-item {
    text-align: center;
}

.stat-item span {
    display: block;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.stat-item strong {
    font-size: 2rem;
    line-height: 1.05;
}

.reset-button {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
    background: #f6f7fb;
    color: #4d5a6d;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.reset-button:hover {
    background: #eceff6;
}

.quiz-area {
    padding: 30px 24px 18px;
}

.quiz-card {
    width: min(640px, 100%);
    margin: 0 auto;
    background: #f2f3f5;
    border-radius: 20px;
    border: 1px solid #d8dce4;
    box-shadow: var(--shadow-soft);
    padding: 16px;
}

.portrait-wrap {
    width: min(160px, 100%);
    height: min(160px, 100%);
    margin: 0 auto;
    border-radius: 16px;
    background: #d7dce0;
    overflow: hidden;
}

.portrait-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.feedback {
    min-height: 24px;
    margin: 12px 4px 14px;
    font-size: 0.95rem;
    text-align: center;
    color: var(--muted);
}

.feedback.is-correct {
    color: #0f8a50;
    font-weight: 700;
}

.feedback.is-wrong {
    color: #c21649;
    font-weight: 700;
}

.choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.choice-button {
    height: 56px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    color: var(--white);
    font: inherit;
    font-size: 0.98rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0 10px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.choice-button:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.choice-button:disabled {
    cursor: default;
}

.choice-button.is-correct {
    box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px #0ea25a;
}

.choice-button.is-wrong {
    box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px #8f1638;
}

.choice-button.is-muted {
    opacity: 0.46;
}

.loaded-footer {
    text-align: center;
    padding: 8px 12px 30px;
    color: var(--muted);
    font-size: 1rem;
}

.footer-credit {
    margin: 10px 0 0;
    font-size: 0.92rem;
    line-height: 1.5;
}

.footer-credit a {
    color: inherit;
    font-weight: 700;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
}

@media (max-width: 820px) {
    .top-bar {
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 16px;
    }

    .top-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
    }

    .pool-picker {
        grid-column: 1 / -1;
    }

    .reset-button {
        grid-column: 1 / -1;
    }

    .quiz-area {
        padding: 18px 12px 8px;
    }

    .stat-item strong {
        font-size: 1.45rem;
    }
}

@media (max-width: 520px) {
    .brand-block {
        grid-template-columns: 1fr;
        gap: 4px;
        align-items: start;
    }

    .stats-hint {
        font-size: 1.3rem;
    }
}