/* arvuralli/style.css — Arvuralli (peastarvutamise trenažöör)
   Disain: variant 1a „Rallirada" + DISAIN.md tokenid.
   Kaheveeruline avaleht (edetabel alati nähtaval), rada autoga mängus,
   poodiumivärvid edetabelis ja projektoril, üks aktsent (kihutamise oranž),
   raadiuste hierarhia (nupp 8 / kaart 12 / paneel 16 / pill 999). */

/* ============ Tokenid ============ */

:root {
    --ar-accent: #ea580c;                       /* kihutamise oranž */
    --ar-accent-2: #f97316;                     /* rajagradiendi hele ots */
    --ar-accent-hover: #c2410c;
    --ar-accent-text: #9a3412;                  /* aktsent TEKSTINA pehmel alusel (WCAG AA) */
    --ar-accent-strong: #c2410c;                /* aktsentpind VÄIKESE valge teksti all (WCAG AA) */
    --ar-accent-contrast: #fff;                 /* tekst aktsendi peal */
    --ar-accent-soft: rgba(234, 88, 12, 0.07);
    --ar-ok: #16a34a;
    --ar-ok-hover: #15803d;
    --ar-bad: #dc2626;
    --ar-warm: #b45309;                         /* seeria/leek — loetav heledal */
    --ar-warm-soft: rgba(245, 158, 11, 0.12);
    --ar-gold: #f59e0b;
    --ar-silver: #94a3b8;
    --ar-bronze: #b45309;
    --ar-shadow-1: 0 1px 2px rgba(17,17,26,.06), 0 4px 12px rgba(17,17,26,.08);
    --ar-shadow-2: 0 2px 4px rgba(17,17,26,.08), 0 12px 24px rgba(17,17,26,.12);
    --ar-dur-fast: 150ms;
    --ar-dur-base: 250ms;
    --ar-ease: cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="dark"] {
    --ar-accent: #fb923c;                       /* desatureeritum ja heledam */
    --ar-accent-2: #f97316;
    --ar-accent-hover: #f97316;
    --ar-accent-text: #fb923c;
    --ar-accent-strong: #fb923c;
    --ar-accent-contrast: #2a1606;              /* hele aktsent vajab tumedat teksti */
    --ar-accent-soft: rgba(251, 146, 60, 0.13);
    --ar-ok: #22c55e;
    --ar-ok-hover: #16a34a;
    --ar-bad: #ef4444;
    --ar-warm: #f59e0b;
    --ar-warm-soft: rgba(245, 158, 11, 0.15);
    --ar-shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
    --ar-shadow-2: 0 2px 4px rgba(0,0,0,.35), 0 12px 24px rgba(0,0,0,.3);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ar-accent: #fb923c;
        --ar-accent-2: #f97316;
        --ar-accent-hover: #f97316;
        --ar-accent-text: #fb923c;
        --ar-accent-strong: #fb923c;
        --ar-accent-contrast: #2a1606;
        --ar-accent-soft: rgba(251, 146, 60, 0.13);
        --ar-ok: #22c55e;
        --ar-ok-hover: #16a34a;
        --ar-bad: #ef4444;
        --ar-warm: #f59e0b;
        --ar-warm-soft: rgba(245, 158, 11, 0.15);
        --ar-shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
        --ar-shadow-2: 0 2px 4px rgba(0,0,0,.35), 0 12px 24px rgba(0,0,0,.3);
    }
}

/* ============ Üldine ============ */

.h-100 { height: 100%; }

.ar-container { max-width: 1120px; }
.ar-section { padding-top: 2rem; }

/* Lehe päis: ikoonikast + pealkiri + alapealkiri */
.ar-page-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}
.ar-page-icon {
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--ar-accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--ar-accent);
}
.ar-page-title {
    margin: 0;
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary, #363636);
}
.ar-page-sub {
    margin: 0.15rem 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #4a4a4a);
}

.ar-field-label {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, #363636);
}
.ar-hint-line {
    margin: 0.65rem 0 0;
    font-size: 0.8rem;
    color: var(--text-secondary, #4a4a4a);
}

/* ============ Seadistus: kaks veergu ============ */

.ar-setup-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 2rem;
    align-items: start;
}
.ar-setup-main { min-width: 0; }

/* Tasemekaardid */
.ar-level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 0.6rem;
}
.ar-level-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--border-color, #dbdbdb);
    border-radius: 12px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #363636);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color var(--ar-dur-fast) var(--ar-ease),
                transform var(--ar-dur-fast) var(--ar-ease),
                box-shadow var(--ar-dur-fast) var(--ar-ease);
}
@media (hover: hover) {
    .ar-level-card:hover {
        border-color: var(--ar-accent);
        box-shadow: var(--ar-shadow-1);
        transform: translateY(-1px);
    }
}
.ar-level-badge {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-secondary, #f4f4f4);
    color: var(--text-muted, #7a7a7a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background var(--ar-dur-fast) var(--ar-ease),
                color var(--ar-dur-fast) var(--ar-ease);
}
.ar-level-txt { min-width: 0; }
.ar-level-name { display: block; font-weight: 700; font-size: 0.9rem; }
.ar-level-desc {
    display: block;
    font-size: 0.72rem;
    color: var(--text-secondary, #4a4a4a);
    word-break: keep-all;
}
.ar-level-card.is-selected {
    border-color: var(--ar-accent);
    background: var(--ar-accent-soft);
}
.ar-level-card.is-selected .ar-level-badge {
    background: var(--ar-accent);
    color: var(--ar-accent-contrast);
}
.ar-level-card.is-selected::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 0.4rem;
    right: 0.55rem;
    font-size: 0.75rem;
    color: var(--ar-accent);
}
.ar-level-card:focus-visible {
    outline: 3px solid var(--ar-accent);
    outline-offset: 2px;
}

/* Režiim + kestus kõrvuti */
.ar-opts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-top: 1rem;
}
.ar-opts-col { min-width: 0; }

/* Segmentlüliti (režiim, edetabeli periood) */
.ar-seg {
    display: inline-flex;
    background: var(--bg-secondary, #eceae6);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
    max-width: 100%;
    flex-wrap: wrap;
}
.ar-seg-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 36px;
    padding: 0 0.9rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary, #4a4a4a);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--ar-dur-fast) var(--ar-ease),
                color var(--ar-dur-fast) var(--ar-ease);
}
.ar-seg-btn i { color: var(--text-muted, #7a7a7a); }
.ar-seg-btn:hover { color: var(--text-primary, #363636); }
.ar-seg-btn.is-selected {
    background: var(--ar-accent-strong);
    color: var(--ar-accent-contrast);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(17,17,26,.1);
    pointer-events: none;
}
.ar-seg-btn.is-selected i { color: inherit; }
.ar-seg-btn:focus-visible {
    outline: 3px solid var(--ar-accent);
    outline-offset: 2px;
}
/* Väike variant: valik on vaikne (valge alus), mitte aktsent */
.ar-seg-sm { border-radius: 999px; padding: 2px; }
.ar-seg-sm .ar-seg-btn {
    height: 26px;
    padding: 0 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
}
.ar-seg-sm .ar-seg-btn.is-selected {
    background: var(--bg-card, #fff);
    color: var(--text-primary, #363636);
}

/* Kestuse pillid */
.ar-durs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ar-dur-btn {
    height: 36px;
    padding: 0 1rem;
    border: 1.5px solid var(--border-color, #dbdbdb);
    border-radius: 999px;
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #4a4a4a);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--ar-dur-fast) var(--ar-ease),
                color var(--ar-dur-fast) var(--ar-ease);
}
@media (hover: hover) {
    .ar-dur-btn:hover { border-color: var(--ar-accent); color: var(--text-primary, #363636); }
}
.ar-dur-btn.is-selected {
    border-color: var(--ar-accent);
    background: var(--ar-accent-soft);
    color: var(--ar-accent-text);
    font-weight: 600;
    pointer-events: none;
}
.ar-dur-btn:focus-visible {
    outline: 3px solid var(--ar-accent);
    outline-offset: 2px;
}

/* Alustamisnupp */
.ar-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    height: 56px;
    margin-top: 1.1rem;
    border: 0;
    border-radius: 8px;
    background: var(--ar-accent);
    color: var(--ar-accent-contrast);
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--ar-shadow-1);
    transition: background var(--ar-dur-fast) var(--ar-ease),
                box-shadow var(--ar-dur-fast) var(--ar-ease);
}
.ar-start-btn i { font-size: 0.85em; }
.ar-start-btn:hover { background: var(--ar-accent-hover); box-shadow: var(--ar-shadow-2); }
.ar-start-btn:focus-visible { outline: 3px solid var(--ar-accent); outline-offset: 2px; }
.ar-start-btn.is-loading { color: transparent; position: relative; pointer-events: none; }
.ar-start-btn.is-loading::after {
    content: "";
    position: absolute;
    top: calc(50% - 0.6em);
    left: calc(50% - 0.6em);
    width: 1.2em;
    height: 1.2em;
    border: 2px solid var(--ar-accent-contrast);
    border-right-color: transparent;
    border-top-color: transparent;
    border-radius: 50%;
    animation: arSpin 0.6s linear infinite;
}
@keyframes arSpin { to { transform: rotate(360deg); } }

/* Aktsentnupp (Salvesta, Mängi uuesti) */
.button.ar-btn-accent {
    background: var(--ar-accent);
    border-color: transparent;
    color: var(--ar-accent-contrast);
    font-weight: 600;
}
.button.ar-btn-accent:hover, .button.ar-btn-accent:focus {
    background: var(--ar-accent-hover);
    border-color: transparent;
    color: var(--ar-accent-contrast);
}

/* Vaikne ääristatud nupp (Minu toad, Katkesta) */
.ar-ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 36px;
    padding: 0 0.85rem;
    border: 1.5px solid var(--border-color, #dbdbdb);
    border-radius: 8px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #363636);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: border-color var(--ar-dur-fast) var(--ar-ease),
                color var(--ar-dur-fast) var(--ar-ease);
}
.ar-ghost-btn i { color: var(--text-muted, #7a7a7a); }
@media (hover: hover) {
    .ar-ghost-btn:hover { border-color: var(--ar-accent); color: var(--text-primary, #363636); }
}
.ar-ghost-btn:focus-visible { outline: 3px solid var(--ar-accent); outline-offset: 2px; }

/* Õpetaja rida */
.ar-row-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, var(--border-color, #dbdbdb));
    border-radius: 12px;
}
.ar-row-icon { flex: none; color: var(--text-muted, #7a7a7a); font-size: 1rem; }
.ar-row-text { flex: 1; min-width: 12rem; }
.ar-row-title { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--text-primary, #363636); }
.ar-row-desc { margin: 0; font-size: 0.78rem; color: var(--text-secondary, #4a4a4a); }

/* ============ Edetabel (kõrvalveerg) ============ */

.ar-lb-card {
    min-width: 0;
    padding: 1.25rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, var(--border-color, #dbdbdb));
    border-radius: 16px;
    box-shadow: var(--ar-shadow-1);
}
.ar-lb-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}
.ar-lb-title {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #363636);
}
.ar-lb-title i { color: var(--ar-accent); }
.ar-lb-sub { margin: 0 0 0.85rem; font-size: 0.75rem; color: var(--text-secondary, #4a4a4a); }
.ar-lb-list { display: flex; flex-direction: column; gap: 0.35rem; }
.ar-lb-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
}
.ar-lb-1 { background: rgba(245, 158, 11, 0.10); }
.ar-lb-2 { background: rgba(148, 163, 184, 0.12); }
.ar-lb-3 { background: rgba(180, 83, 9, 0.10); }
.ar-lb-rank {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    background: var(--bg-secondary, #f4f4f4);
}
.ar-lb-1 .ar-lb-rank { background: var(--ar-gold); }
.ar-lb-2 .ar-lb-rank { background: var(--ar-silver); color: #1f2937; }
.ar-lb-3 .ar-lb-rank { background: var(--ar-bronze); }
.ar-lb-rank.is-plain {
    background: transparent;
    color: var(--text-muted, #7a7a7a);
}
.ar-lb-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary, #363636);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ar-lb-score {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-primary, #363636);
    font-variant-numeric: tabular-nums;
}
.ar-lb-acc {
    flex: none;
    width: 2.6rem;
    text-align: right;
    font-size: 0.72rem;
    color: var(--text-muted, #7a7a7a);
    font-variant-numeric: tabular-nums;
}
.ar-lb-empty {
    padding: 1.5rem 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted, #7a7a7a);
}
.ar-lb-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light, var(--border-color, #ededed));
}
.ar-lb-best { font-size: 0.75rem; color: var(--text-muted, #7a7a7a); }
.ar-lb-best strong { color: var(--text-primary, #363636); }

/* ============ Mängu ülariba ============ */

.ar-game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    max-width: 440px;
    margin: 0 auto 0.75rem;
}
.ar-topbar-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.ar-context-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 30px;
    padding: 0 0.75rem;
    border-radius: 999px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, var(--border-color, #ededed));
    color: var(--text-secondary, #4a4a4a);
    font-size: 0.8rem;
    font-weight: 600;
}
.ar-context-chip i { color: var(--ar-accent); font-size: 0.75rem; }
.ar-game-topbar .ar-ghost-btn { height: 30px; font-size: 0.8rem; border-width: 1px; }

/* ============ Mängumootor ============ */

.ar-engine {
    max-width: 440px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
}

/* Statistikapillid: aeg | seeria | õiged */
.ar-eng-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}
.ar-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.85rem;
    border-radius: 999px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, var(--border-color, #ededed));
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary, #363636);
    font-variant-numeric: tabular-nums;
}
.ar-stat-pill i { font-size: 0.75em; color: var(--text-muted, #7a7a7a); }
.ar-stat-ok i { color: var(--ar-ok); }
.ar-stat-streak {
    background: var(--ar-warm-soft);
    border-color: transparent;
    color: var(--ar-warm);
}
.ar-stat-streak i { color: inherit; font-size: 0.85em; }
.ar-stat-streak.ar-streak-hot { color: var(--ar-bad); background: rgba(220, 38, 38, 0.12); }
.ar-stat-hidden { visibility: hidden; }

/* Rallirada: auto sõidab finišilipu poole */
.ar-eng-track {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}
.ar-eng-trackbar {
    flex: 1;
    position: relative;
    height: 14px;
    border-radius: 7px;
    background: var(--bg-secondary, #e5e1da);
}
.ar-eng-trackclip {
    position: absolute;
    inset: 0;
    border-radius: 7px;
    overflow: hidden;
}
.ar-eng-trackfill {
    height: 100%;
    width: 0;
    border-radius: 7px;
    background: linear-gradient(90deg, var(--ar-accent-2), var(--ar-accent));
    transition: width var(--ar-dur-base) linear;
}
.ar-eng-trackdash {
    position: absolute;
    top: 6px;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(255,255,255,0.55) 22px 30px);
}
/* Auto keskkoht libiseb täitejoonel, aga jääb alati raja piiridesse
   (JS nihutab poole auto laiuse võrra sisse — vt engine.js setProgress) */
/* scaleX(-1): 🏎️ on emoji-fontides vasakule suunatud, aga rada kulgeb
   vasakult paremale finišilipu poole — ilma peegelduseta sõidab auto tagurpidi.
   Peegeldus käib translate'i JÄREL, seega paigutus ei muutu. */
.ar-eng-car {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translate(-50%, -76%) scaleX(-1);
    font-size: 1.5rem;
    line-height: 1;
    transition: left var(--ar-dur-base) linear;
}
.ar-eng-flag { flex: none; color: var(--text-muted, #7a7a7a); font-size: 0.85rem; }
.ar-eng-track.ar-time-low .ar-eng-trackfill { background: var(--ar-bad); }

/* Küsimusekaart */
.ar-eng-question-area {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 1.15rem 0.75rem 0.75rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, var(--border-color, #ededed));
    border-radius: 16px;
    box-shadow: var(--ar-shadow-1);
    margin-bottom: 0.85rem;
    min-height: 160px;
}
.ar-eng-question-area::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--ar-ok);
    opacity: 0;
    pointer-events: none;
}
.ar-eng-qrow {
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    column-gap: 0.7rem;
}
.ar-eng-question {
    font-size: clamp(2.2rem, 9vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary, #363636);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.ar-eng-input {
    font-size: clamp(2.2rem, 9vw, 3.2rem);
    font-weight: 800;
    line-height: 1.15;
    min-height: 1.15em;
    min-width: 1.5ch;
    color: var(--ar-accent);
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: baseline;
}
.ar-eng-caret {
    display: inline-block;
    width: 3px;
    height: 0.85em;
    margin-left: 3px;
    background: var(--ar-accent);
    animation: arBlink 1s step-end infinite;
}
.ar-eng-feedback {
    min-height: 1.5rem;
    font-size: 1rem;
    font-weight: 600;
}
.ar-fb-bad { color: var(--ar-bad); }
.ar-eng-hint {
    min-height: 1.3rem;
    font-size: 0.85rem;
    color: var(--text-muted, #7a7a7a);
    padding: 0 0.5rem;
}

@keyframes arBlink { 50% { opacity: 0; } }
@keyframes arPop { 0% { transform: scale(1.4); } 100% { transform: scale(1); } }

.ar-flash-ok::after { animation: arFlashOk 0.35s var(--ar-ease); }
@keyframes arFlashOk {
    0% { opacity: 0.22; }
    100% { opacity: 0; }
}
.ar-flash-bad { animation: arShake 0.3s var(--ar-ease); }
@keyframes arShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

/* Numbriklahvistik */
.ar-eng-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.ar-key {
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    min-height: 58px;
    border: 1px solid var(--border-light, var(--border-color, #dbdbdb));
    border-radius: 12px;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #363636);
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: var(--ar-shadow-1);
    font-variant-numeric: tabular-nums;
    transition: background var(--ar-dur-fast) var(--ar-ease),
                box-shadow var(--ar-dur-fast) var(--ar-ease),
                transform 80ms var(--ar-ease);
}
@media (hover: hover) {
    .ar-key:not(:disabled):hover {
        box-shadow: var(--ar-shadow-2);
        transform: translateY(-1px);
    }
}
.ar-key:active, .ar-key.ar-key-press {
    background: var(--bg-hover, #eee);
    transform: scale(0.96);
    box-shadow: none;
}
.ar-key:focus-visible {
    outline: 3px solid var(--ar-accent);
    outline-offset: 2px;
}
.ar-key-off { opacity: 0.25; cursor: default; box-shadow: none; }
.ar-key-back { color: var(--ar-bad); font-size: 1.25rem; }
.ar-key-ok {
    grid-column: span 2;
    min-height: 54px;
    background: var(--ar-ok);
    border-color: transparent;
    color: #fff;
    font-size: 1.15rem;
}
.ar-key-ok-full { grid-column: 1 / -1; }
.ar-key-ok:active, .ar-key-ok.ar-key-press { background: var(--ar-ok-hover); }
@media (hover: hover) {
    .ar-key-ok:not(:disabled):hover { background: var(--ar-ok-hover); }
}
.ar-key-ok:disabled { opacity: 0.4; cursor: default; box-shadow: none; }

/* ============ Tulemuste vaade ============ */

.ar-res-wrap { max-width: 680px; margin: 0 auto; }

.ar-res-card {
    padding: 1.5rem;
    text-align: center;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, var(--border-color, #ededed));
    border-radius: 16px;
    box-shadow: var(--ar-shadow-1);
}
.ar-res-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--ar-accent-soft);
    color: var(--ar-accent);
    font-size: 1.5rem;
}
.ar-res-title {
    margin: 0.6rem 0 0.25rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary, #363636);
}
.ar-res-sub { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--ar-accent-text); }
.ar-res-sub.is-quiet { color: var(--text-muted, #7a7a7a); font-weight: 500; }
.ar-res-context { margin: 1rem 0 0; font-size: 0.78rem; color: var(--text-muted, #7a7a7a); }

.ar-res-figures {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1.1rem;
}
.ar-donut {
    position: relative;
    flex: none;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Läbimata osa peab olema nähtav nii heledal kui tumedal kaardil */
    background: conic-gradient(var(--ar-accent) 0 calc(var(--ar-pct, 0) * 1%),
                               rgba(127, 127, 127, 0.22) 0);
}
.ar-donut-hole {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--bg-card, #fff);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.ar-donut-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary, #363636);
    font-variant-numeric: tabular-nums;
}
.ar-donut-label { font-size: 0.65rem; color: var(--text-muted, #7a7a7a); }

/* Kolm numbrit — jagatud play.php lõpuvaatega */
.ar-res-stats { display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: center; }
.ar-res-stat { display: flex; flex-direction: column; align-items: center; }
.ar-res-num {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary, #363636);
    font-variant-numeric: tabular-nums;
}
.ar-res-num.is-ok { color: var(--ar-ok); }
.ar-res-num.is-bad { color: var(--ar-bad); }
.ar-res-num.is-streak { color: var(--ar-warm); }
.ar-res-label { font-size: 0.72rem; color: var(--text-muted, #7a7a7a); }

/* Edetabelisse salvestamise bänner */
.ar-lb-submit {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--ar-accent);
    border-radius: 12px;
    background: var(--ar-accent-soft);
}
.ar-lb-submit-label {
    margin: 0;
    flex: 1;
    min-width: 12rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary, #363636);
}
.ar-lb-submit-label i { color: var(--ar-accent); margin-right: 0.4rem; }
.ar-lb-submit-field { display: flex; }
.ar-lb-submit-field .input {
    max-width: 160px;
    border-radius: 8px 0 0 8px;
    border-right: 0;
}
.ar-lb-submit-field .button { border-radius: 0 8px 8px 0; }

/* Oskused + vead kõrvuti */
.ar-res-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 0.9rem;
    margin-top: 0.9rem;
    align-items: start;
}
.ar-res-grid > .is-hidden { display: none; }
.ar-res-grid:has(> .ar-res-panel.is-hidden) { grid-template-columns: 1fr; }
.ar-res-panel {
    padding: 1rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, var(--border-color, #ededed));
    border-radius: 12px;
}
.ar-res-panel-title {
    margin: 0 0 0.7rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary, #363636);
}

.ar-skill-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.45rem;
}
.ar-skill-row:last-child { margin-bottom: 0; }
/* Sildiveerg kohaneb: kitsas tulemuspaneelis ~130px, laias õpetajavaates kuni 220px */
.ar-skill-label { flex: 0 0 clamp(120px, 40%, 220px); font-size: 0.75rem; color: var(--text-primary, #363636); }
.ar-skill-bar {
    flex: 1;
    height: 10px;
    border-radius: 5px;
    background: var(--bg-secondary, #eee);
    overflow: hidden;
}
.ar-skill-fill { height: 100%; background: #22c55e; border-radius: 5px; }
.ar-skill-fill.is-mid { background: var(--ar-gold); }
.ar-skill-fill.is-bad { background: #ef4444; }
.ar-skill-val { flex: none; font-size: 0.72rem; color: var(--text-muted, #7a7a7a); font-variant-numeric: tabular-nums; }

/* Vigade loend: kiipidena (tulemus) ja ridadena (play.php) */
.ar-mistake-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ar-mistake-chip {
    flex: none;
    white-space: nowrap;
    padding: 0.3rem 0.55rem;
    border-radius: 8px;
    background: var(--bg-secondary, #f8f6f3);
    border: 1px solid var(--border-light, var(--border-color, #ededed));
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary, #363636);
}
.ar-mistake-count { color: var(--ar-bad); font-weight: 700; margin-left: 0.4rem; }
.ar-mistake-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.45rem 0.25rem;
    border-bottom: 1px solid var(--border-light, var(--border-color, #ededed));
    font-variant-numeric: tabular-nums;
}
.ar-mistake-row:last-child { border-bottom: 0; }
.ar-mistake-q { font-weight: 600; color: var(--text-primary, #363636); }
.ar-mistake-ans { color: var(--text-muted, #7a7a7a); font-size: 0.9rem; text-align: right; }
.ar-mistake-given { color: var(--ar-bad); }
.ar-mistake-right { color: var(--ar-ok); font-weight: 700; }

/* ============ Õpilase vaade (play.php) ============ */

.ar-hw-info {
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border-color, #dbdbdb);
    margin-bottom: 1rem;
}
.ar-attempt-list { max-width: 460px; margin: 0 auto; }
.ar-attempt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    background: var(--bg-secondary, #f5f5f5);
    margin-bottom: 0.35rem;
    color: var(--text-primary, #363636);
}
.ar-attempt-me { outline: 2px solid var(--ar-accent); }
.ar-lobby-pulse {
    color: var(--ar-accent);
    animation: arPulse 1.6s ease-in-out infinite;
}
@keyframes arPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

/* ============ Jagamiskast (room.php) ============ */

.ar-share-box {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border-color, #dbdbdb);
}
.ar-share-box code {
    word-break: break-all;
    background: var(--bg-card, #fff);
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    color: var(--text-primary, #363636);
}

/* ============ Oskuste valik (rooms.php) ============ */

.ar-skill-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.2rem 0.75rem;
    padding: 0.6rem 0.8rem;
    border: 1px dashed var(--border-color, #dbdbdb);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
}
.ar-skill-picker label { display: block; }

/* ============ Soojuskaart ============ */

.ar-heatmap {
    display: grid;
    grid-template-columns: repeat(10, minmax(28px, 44px));
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}
.ar-hm-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #363636);
}
.ar-hm-head {
    font-weight: 700;
    background: transparent;
    color: var(--text-muted, #7a7a7a);
}

/* ============ Projektorivaade (host.php) ============ */

.ar-host-body {
    background: #0f172a;
    min-height: 100vh;
    min-height: 100svh;
}
.ar-host-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}
.ar-host-sub { color: #94a3b8; }

.ar-join-banner {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 2.5rem;
    border-radius: 16px;
    background: #1e293b;
    border: 2px solid #334155;
}
.ar-join-url { font-size: 1.5rem; color: #94a3b8; font-weight: 600; }
.ar-join-code {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 800;
    letter-spacing: 0.15em;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.ar-lobby-players {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    max-width: 900px;
    margin: 0 auto;
}
.ar-player-chip {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: #1e293b;
    color: #e2e8f0;
    font-size: 1.05rem;
    font-weight: 600;
    animation: arPop 0.25s var(--ar-ease);
}

.ar-race-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.ar-race-title {
    color: #e2e8f0;
    font-size: 1.35rem;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ar-race-timer {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.ar-race-timer.ar-time-low { color: #ef4444; animation: arPulse 1s ease-in-out infinite; }

.ar-race-teams {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.ar-team-card {
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    background: #1e293b;
    border: 2px solid #334155;
}
.ar-team-name { font-size: 1.2rem; font-weight: 700; }
.ar-team-score {
    font-size: 2.4rem;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.ar-team-bar { height: 10px; border-radius: 5px; background: #0f172a; overflow: hidden; margin-top: 0.4rem; }
.ar-team-fill { height: 100%; border-radius: 5px; transition: width 0.6s var(--ar-ease); }

/* Rajad + finišijoon */
.ar-race-lanes {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 26px;
}
.ar-race-lanes::after {
    content: "";
    position: absolute;
    top: -6px;
    bottom: -6px;
    right: 0;
    width: 18px;
    border-radius: 4px;
    opacity: 0.8;
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #0f172a 0% 50%) 0 0 / 9px 9px;
}
.ar-lane {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.ar-lane-pos {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e293b;
    color: #94a3b8;
    font-weight: 700;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
.ar-lane-pos.is-1 { background: var(--ar-gold); color: #fff; }
.ar-lane-pos.is-2 { background: var(--ar-silver); color: #0f172a; }
.ar-lane-pos.is-3 { background: var(--ar-bronze); color: #fff; }
.ar-lane-name {
    flex: 0 0 140px;
    color: #e2e8f0;
    font-weight: 600;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ar-lane-track {
    flex: 1;
    position: relative;
    height: 30px;
    border-radius: 15px;
    background: #1e293b;
}
.ar-lane-clip {
    position: absolute;
    inset: 0;
    border-radius: 15px;
    overflow: hidden;
}
.ar-lane-fill {
    height: 100%;
    width: 0;
    border-radius: 15px;
    background: linear-gradient(90deg, #334155, #475569);
    transition: width 0.8s var(--ar-ease);
}
.ar-lane-dash {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg, transparent 0 30px, rgba(255,255,255,0.22) 30px 40px);
}
.ar-lane-car {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translate(-50%, -76%) scaleX(-1);   /* vt .ar-eng-car */
    font-size: 1.7rem;
    line-height: 1;
    transition: left 0.8s var(--ar-ease);
}
.ar-lane-leader .ar-lane-fill { background: linear-gradient(90deg, #334155, var(--ar-accent, #fb923c)); }
.ar-lane-score {
    flex: 0 0 2.8rem;
    color: #fff;
    font-weight: 800;
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.ar-lane-more {
    text-align: center;
    color: #94a3b8;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.5rem 0.9rem;
}

/* Poodium */
.ar-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}
.ar-podium-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    width: min(200px, 28vw);
}
.ar-podium-medal { font-size: 2.5rem; }
.ar-podium-name {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ar-podium-score { color: var(--ar-gold); font-weight: 800; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.ar-podium-block {
    width: 100%;
    border-radius: 10px 10px 0 0;
    background: linear-gradient(180deg, #334155, #1e293b);
}
.ar-podium-1 .ar-podium-block { height: 130px; background: linear-gradient(180deg, #f59e0b, #92400e); }
.ar-podium-2 .ar-podium-block { height: 95px; background: linear-gradient(180deg, #94a3b8, #475569); }
.ar-podium-3 .ar-podium-block { height: 70px; background: linear-gradient(180deg, #b45309, #78350f); }

.ar-final-list { max-width: 560px; margin: 1.5rem auto 0; }
.ar-final-row {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    background: #1e293b;
    color: #e2e8f0;
    margin-bottom: 0.3rem;
    font-size: 1.05rem;
}

/* ============ Kitsad ekraanid ============ */

/* Edetabel läheb valikute alla enne, kui veerud kitsaks jäävad */
@media (max-width: 1023px) {
    .ar-setup-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .ar-container { max-width: 700px; }
}

@media (max-width: 768px) {
    .ar-res-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .ar-section { padding-top: 1.25rem; }
    .ar-page-head { gap: 0.75rem; margin-bottom: 1rem; }
    .ar-page-icon { width: 46px; height: 46px; border-radius: 12px; font-size: 1.2rem; }
    .ar-page-title { font-size: 1.5rem; }
    .ar-page-sub { font-size: 0.82rem; }
    .ar-opts-row { flex-direction: column; gap: 0.9rem; }
    .ar-seg { width: 100%; }
    .ar-seg-btn { flex: 1; justify-content: center; padding: 0 0.5rem; }
    .ar-lb-card { padding: 1rem; }
    .ar-res-card { padding: 1.1rem; }
    .ar-res-figures { gap: 1.25rem; }
    .ar-res-stats { gap: 1.1rem; }
    .ar-res-num { font-size: 1.7rem; }
    .ar-skill-label { flex-basis: clamp(100px, 38%, 160px); font-size: 0.7rem; }
    .ar-lane-name { flex-basis: 90px; font-size: 0.9rem; }
    .ar-lane-score { font-size: 1.05rem; flex-basis: 2.2rem; }
    .ar-lane-track { height: 24px; border-radius: 12px; }
    .ar-lane-clip, .ar-lane-fill { border-radius: 12px; }
    .ar-lane-dash { top: 11px; }
    .ar-key { min-height: 52px; }
    .ar-eng-question-area { min-height: 140px; }
    .ar-skill-picker { grid-template-columns: 1fr; }
    .ar-lb-submit-field { width: 100%; }
    .ar-lb-submit-field .input { max-width: none; flex: 1; }
}

/* ============ Mahutamine ekraanile (mängu vaade ei tohi kerida) ============ */

section.section:has(.ar-engine) {
    padding-top: 0.75rem;
    padding-bottom: 1rem;
}

/* Uus küljendus mahub tavalisele sülearvutile täissuuruses — kokkusurumine
   algab alles siis, kui aken on päriselt madal (nt maastikuvaates telefon) */
@media (max-height: 720px) {
    .ar-game-topbar { margin-bottom: 0.5rem; }
    .ar-eng-stats { margin-bottom: 0.4rem; }
    .ar-stat-pill { font-size: 0.95rem; padding: 0.15rem 0.7rem; }
    .ar-eng-track { margin-bottom: 0.5rem; }
    .ar-eng-question-area {
        min-height: 108px;
        padding: 0.6rem 0.5rem 0.4rem;
        margin-bottom: 0.5rem;
    }
    .ar-eng-question { font-size: clamp(1.9rem, 5vh, 2.8rem); }
    .ar-eng-input { font-size: clamp(1.9rem, 5vh, 2.8rem); }
    .ar-eng-feedback { min-height: 1.2rem; font-size: 0.95rem; }
    .ar-eng-hint { min-height: 1.1rem; font-size: 0.8rem; }
    .ar-eng-pad { gap: 6px; }
    /* 44px = puutesihtmärgi miinimum, jääb alati tagatuks */
    .ar-key { min-height: clamp(44px, 6.2vh, 58px); font-size: 1.3rem; }
    .ar-key-ok { min-height: clamp(44px, 5.6vh, 54px); }
}

/* Maastikuvaates telefonil (madal ja lai) ei mahu tehe + klahvistik üksteise alla —
   klahvistik läheb kõrvale, muidu jääks „Vasta" ekraanilt välja */
@media (max-height: 520px) and (orientation: landscape) {
    .ar-game-topbar { max-width: 720px; }
    .ar-engine {
        max-width: 720px;
        display: grid;
        grid-template-columns: 1fr 280px;
        grid-template-areas: "stats pad" "track pad" "question pad";
        column-gap: 1rem;
        align-content: start;
    }
    .ar-eng-stats { grid-area: stats; }
    .ar-eng-track { grid-area: track; }
    .ar-eng-question-area { grid-area: question; margin-bottom: 0; min-height: 96px; }
    .ar-eng-pad { grid-area: pad; }
    .ar-eng-hint { display: none; }
}

/* Avavaade kompaktsemaks madalatel akendel */
@media (max-height: 760px) {
    .ar-section { padding-top: 1.25rem; }
    .ar-page-head { margin-bottom: 0.9rem; }
    .ar-level-card { padding: 0.45rem 0.7rem; }
    .ar-start-btn { height: 50px; margin-top: 0.9rem; }
    .ar-row-card { margin-top: 0.9rem; }
}

/* ============ Reduced motion — liikumine kaob, tagasiside jääb ============ */

@media (prefers-reduced-motion: reduce) {
    .ar-flash-ok::after, .ar-flash-bad, .ar-player-chip,
    .ar-lobby-pulse, .ar-race-timer.ar-time-low, .ar-start-btn.is-loading::after { animation: none; }
    .ar-key, .ar-level-card, .ar-seg-btn, .ar-dur-btn, .ar-start-btn,
    .ar-eng-trackfill, .ar-eng-car, .ar-lane-fill, .ar-lane-car, .ar-team-fill { transition: none; }
    .ar-eng-caret { animation: none; opacity: 1; }
}
