﻿:root {
    --ink: #202528;
    --muted: #5a6469;
    --paper: #fbfff5;
    --panel: #ffffff;
    --line: #d9e4dc;
    --lime: #b7f000;
    --lime-strong: #87c800;
    --teal: #00a99d;
    --coral: #ff6f61;
    --amber: #ffc857;
    --charcoal: #253037;
    --shadow: 0 18px 50px rgba(32, 37, 40, 0.12);
    --radius: 8px;
    --radius-small: 6px;
    --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: var(--font);
    background:
        linear-gradient(90deg, rgba(0, 169, 157, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(135, 200, 0, 0.08) 1px, transparent 1px),
        var(--paper);
    background-size: 32px 32px, 32px 32px, auto;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

:focus-visible {
    outline: 3px solid var(--coral);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: 0.75rem;
    z-index: 20;
    transform: translateY(-160%);
    background: var(--charcoal);
    color: #fff;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-small);
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(1rem, 2.2vw, 1.5rem) clamp(1rem, 4vw, 3rem);
    background: rgba(251, 255, 245, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.mascot {
    width: clamp(86px, 13vw, 136px);
    height: auto;
    flex: 0 0 auto;
}

.mascot-shadow ellipse {
    fill: rgba(32, 37, 40, 0.16);
}

.scooter-deck {
    fill: var(--lime);
    stroke: var(--charcoal);
    stroke-width: 5;
    stroke-linejoin: round;
}

.wheel {
    fill: var(--charcoal);
    stroke: var(--ink);
    stroke-width: 4;
}

.wheel-core {
    fill: var(--amber);
}

.stem,
.handle,
.smile,
.spark {
    fill: none;
    stroke: var(--charcoal);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.helmet {
    fill: var(--teal);
    stroke: var(--charcoal);
    stroke-width: 5;
    stroke-linejoin: round;
}

.face {
    fill: #fff8d7;
    stroke: var(--charcoal);
    stroke-width: 5;
}

.eye {
    fill: var(--charcoal);
}

.bolt {
    fill: var(--amber);
    stroke: var(--charcoal);
    stroke-width: 4;
    stroke-linejoin: round;
}

.spark {
    stroke: var(--coral);
}

.eyebrow {
    margin: 0 0 0.25rem;
    color: #516007;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(1.45rem, 3vw, 2.35rem);
    line-height: 1.05;
}

h2 {
    margin: 0;
    font-size: clamp(1.35rem, 2.2vw, 1.85rem);
    line-height: 1.15;
}

h3 {
    margin: 0;
    font-size: 1rem;
}

.header-actions,
.button-row,
.question-actions,
.score-pills,
.order-buttons {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.app-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 1.25rem auto 3rem;
}

.screen {
    display: none;
}

.screen.is-active {
    display: block;
}

.layout-grid,
.game-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.85fr);
    gap: 1rem;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1rem, 2.4vw, 1.45rem);
}

.start-panel,
.question-panel,
.result-panel {
    min-width: 0;
}

.panel-heading,
.game-topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.setup-form {
    display: grid;
    gap: 1rem;
    margin-top: 1.1rem;
}

.mode-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.mode-fieldset legend {
    margin-bottom: 0.55rem;
    font-weight: 800;
}

.mode-card {
    min-height: 116px;
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    padding: 0.9rem;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: #f7fbf7;
    transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.mode-card:hover {
    transform: translateY(-1px);
    border-color: var(--teal);
}

.mode-card input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--teal);
    flex: 0 0 auto;
    margin-top: 0.12rem;
}

.mode-card:has(input:checked) {
    border-color: var(--lime-strong);
    background: #f0ffd2;
}

.mode-card strong,
.mode-card small {
    display: block;
}

.mode-card small {
    margin-top: 0.25rem;
    color: var(--muted);
    line-height: 1.35;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

label span {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 800;
}

input[type="text"] {
    width: 100%;
    min-height: 46px;
    border: 2px solid var(--line);
    border-radius: var(--radius-small);
    padding: 0.65rem 0.75rem;
    background: #fff;
    color: var(--ink);
}

input[type="text"]:focus {
    border-color: var(--teal);
}

.primary-button,
.secondary-button,
.icon-button {
    border: 0;
    border-radius: var(--radius-small);
    font-weight: 900;
    min-height: 44px;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button,
.secondary-button {
    padding: 0.72rem 1rem;
}

.primary-button {
    background: var(--charcoal);
    color: #fff;
    box-shadow: 0 8px 0 #11181c;
}

.primary-button:hover {
    transform: translateY(-1px);
    background: #11181c;
}

.secondary-button {
    background: #eef7ec;
    color: var(--charcoal);
    border: 2px solid var(--line);
}

.secondary-button:hover {
    border-color: var(--teal);
}

.compact {
    min-height: 38px;
    padding: 0.5rem 0.75rem;
}

.icon-button {
    width: 46px;
    height: 46px;
    display: inline-grid;
    place-items: center;
    background: var(--charcoal);
    color: #fff;
    font-size: 1rem;
}

.icon-button[aria-pressed="true"] {
    background: var(--teal);
    color: #fff;
}

.icon-button.small {
    width: 38px;
    height: 38px;
    min-height: 38px;
}

.mission-strip {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.45rem;
}

.mission-chip {
    min-height: 58px;
    border-radius: var(--radius-small);
    border: 1px solid var(--line);
    background: #fff;
    padding: 0.5rem;
    display: grid;
    align-content: center;
    gap: 0.15rem;
}

.mission-chip strong {
    font-size: 0.82rem;
}

.mission-chip span {
    color: var(--muted);
    font-size: 0.76rem;
}

.leaderboard-panel {
    position: sticky;
    top: 114px;
}

.muted,
.status-box {
    color: var(--muted);
    line-height: 1.5;
}

.leaderboard-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.55rem;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.65rem;
    align-items: center;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    padding: 0.55rem 0.65rem;
    background: #fbfffb;
}

.leaderboard-rank {
    width: 2rem;
    height: 2rem;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: var(--lime);
    color: var(--charcoal);
    font-weight: 900;
}

.leaderboard-name {
    min-width: 0;
    font-weight: 850;
}

.leaderboard-meta {
    color: var(--muted);
    font-size: 0.82rem;
}

.leaderboard-score {
    font-weight: 900;
    color: var(--teal);
    white-space: nowrap;
}

.charge-wrap {
    margin: 1rem 0;
}

.charge-wrap span {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 850;
    color: var(--muted);
}

.charge-track {
    min-height: 20px;
    border: 2px solid var(--charcoal);
    border-radius: 999px;
    background: #fff;
    overflow: hidden;
}

.charge-fill {
    height: 100%;
    width: 0%;
    min-height: 16px;
    background: linear-gradient(90deg, var(--lime), var(--teal));
    transition: width 240ms ease;
}

.score-pill {
    min-width: 108px;
    min-height: 44px;
    display: grid;
    align-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    padding: 0.35rem 0.6rem;
    background: #f7fbf7;
}

.score-pill strong {
    font-size: 0.9rem;
}

.score-pill span {
    color: var(--muted);
    font-size: 0.78rem;
}

.turn-label {
    margin: 0.6rem 0 0;
    color: var(--teal);
    font-weight: 900;
}

.prompt {
    margin: 1rem 0;
    font-size: 1.12rem;
    line-height: 1.55;
}

.hint-text,
.feedback-body {
    line-height: 1.55;
}

.hint-text {
    margin: 0.75rem 0 0;
    padding: 0.75rem;
    border-left: 5px solid var(--amber);
    background: #fff7df;
    border-radius: 0 var(--radius-small) var(--radius-small) 0;
}

.answer-area {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.choice-option,
.match-row,
.order-row {
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.choice-option {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    min-height: 58px;
    padding: 0.8rem;
}

.choice-option input {
    width: 1.15rem;
    height: 1.15rem;
    accent-color: var(--teal);
    margin-top: 0.15rem;
}

.choice-option.is-correct,
.match-row.is-correct,
.order-row.is-correct {
    border-color: var(--lime-strong);
    background: #f4ffd9;
}

.choice-option.is-wrong,
.match-row.is-wrong,
.order-row.is-wrong {
    border-color: var(--coral);
    background: #fff0ee;
}

.match-row.is-partial {
    border-color: var(--amber);
    background: #fff8e6;
}

.match-missing-note {
    grid-column: 1 / -1;
    color: var(--muted);
    font-weight: 700;
}

.match-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(0, 1.45fr);
    gap: 0.75rem;
    padding: 0.75rem;
}

.match-item-text {
    font-weight: 850;
    line-height: 1.35;
}

.match-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.match-chip {
    position: relative;
}

.match-chip input {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.match-chip span {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border: 2px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    background: #f8fbf8;
    font-weight: 800;
}

.match-chip input:checked + span {
    border-color: var(--teal);
    background: #e2fff7;
}

.match-chip input:focus-visible + span {
    outline: 3px solid var(--coral);
    outline-offset: 2px;
}

.order-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.65rem;
}

.order-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    min-height: 64px;
    padding: 0.65rem;
}

.order-index {
    width: 2rem;
    height: 2rem;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: var(--charcoal);
    color: #fff;
    font-weight: 900;
}

.order-text {
    font-weight: 820;
    line-height: 1.35;
}

.order-buttons button {
    min-width: 44px;
    min-height: 36px;
    border: 2px solid var(--line);
    border-radius: var(--radius-small);
    background: #f7fbf7;
    font-weight: 900;
}

.feedback-panel {
    min-height: 300px;
}

.feedback-panel.is-good {
    border-color: var(--lime-strong);
}

.feedback-panel.is-partial {
    border-color: var(--amber);
}

.feedback-panel.is-miss {
    border-color: var(--coral);
}

.solution-list {
    margin: 0.75rem 0;
    padding-left: 1.2rem;
}

.solution-list li {
    margin: 0.25rem 0;
}

.sticky-actions {
    margin-top: 1rem;
}

.final-scores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.final-score-card,
.report-row {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfffb;
    padding: 0.85rem;
}

.final-score-card strong {
    display: block;
    font-size: 1.45rem;
    color: var(--teal);
}

.mission-report {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.report-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: start;
}

.report-row p {
    margin: 0.35rem 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.report-score {
    font-weight: 900;
    color: var(--charcoal);
    white-space: nowrap;
}

.status-box {
    min-height: 24px;
    margin: 1rem 0;
}

.status-box.is-ok {
    color: #1f6f36;
}

.status-box.is-error {
    color: #ad2f26;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 920px) {
    .layout-grid,
    .game-grid {
        grid-template-columns: 1fr;
    }

    .leaderboard-panel {
        position: static;
    }

    .mode-fieldset,
    .form-grid,
    .mission-strip {
        grid-template-columns: 1fr;
    }

    .mode-card {
        min-height: 86px;
    }
}

@media (max-width: 640px) {
    .site-header {
        align-items: flex-start;
        position: static;
    }

    .brand-block {
        align-items: flex-start;
    }

    .mascot {
        width: 78px;
    }

    .header-actions {
        flex-direction: column;
    }

    .app-shell {
        width: min(100% - 1rem, 1180px);
        margin-top: 0.75rem;
    }

    .panel {
        padding: 0.9rem;
    }

    .panel-heading,
    .game-topline,
    .report-row,
    .match-row {
        grid-template-columns: 1fr;
        display: grid;
    }

    .order-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .order-buttons {
        grid-column: 1 / -1;
    }

    .button-row,
    .question-actions {
        align-items: stretch;
    }

    .primary-button,
    .secondary-button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

.score-pill.is-active {
    border-color: var(--teal);
    background: #e9fff9;
}
