/* Games page: hub cards + shared game stage. Palette: neutrals, one blue, semantic green/red. */
body.games-page {
    --g-surface: var(--ui-surface, #ffffff);
    --g-surface-soft: var(--ui-surface-soft, #f1f5f9);
    --g-text: var(--ui-text, #0f172a);
    --g-text-soft: var(--ui-text-soft, #475569);
    --g-text-faint: var(--ui-text-faint, #94a3b8);
    --g-border: var(--ui-border, #e2e8f0);
    --g-blue: var(--ui-blue, #2451c4);
    --g-blue-soft: var(--ui-blue-soft, #eaf0fc);
    --g-green: #10b981;
    --g-red: #ef4444;
}
:root.dark-theme body.games-page {
    --g-green: #34d399;
    --g-red: #f87171;
}

.games-wrapper { max-width: 980px; }

/* Arcade Hero Banner */
.arcade-hero {
    position: relative;
    padding: 28px 24px;
    border-radius: 24px;
    background: radial-gradient(120% 120% at 50% 0%, rgba(36,81,196,0.10) 0%, rgba(36,81,196,0) 70%), var(--g-surface);
    border: 1px solid var(--g-border);
    box-shadow: var(--ui-shadow-sm);
    text-align: center;
    margin-bottom: 22px;
    overflow: hidden;
}
:root.dark-theme .arcade-hero {
    background: radial-gradient(120% 120% at 50% 0%, rgba(59,130,246,0.15) 0%, rgba(15,23,42,0) 75%), var(--g-surface);
    border-color: rgba(255,255,255,0.08);
}
.arcade-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: var(--g-blue-soft);
    color: var(--g-blue);
    border: 1px solid rgba(36,81,196,0.18);
}
.arcade-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--g-green);
    box-shadow: 0 0 8px var(--g-green);
    animation: arcadePulse 1.8s infinite;
}
@keyframes arcadePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}
.arcade-title {
    font-size: clamp(26px, 4vw, 36px);
    font-weight: 900;
    letter-spacing: -0.025em;
    margin: 12px 0 8px;
    color: var(--g-text);
    line-height: 1.15;
}
.arcade-subtitle {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--g-text-soft);
    max-width: 620px;
    margin: 0 auto 20px;
}
.arcade-features-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}
.arcade-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--g-surface-soft);
    border: 1px solid var(--g-border);
    font-size: 12px;
    font-weight: 600;
    color: var(--g-text-soft);
    transition: border-color .15s ease, transform .15s ease;
}
.arcade-pill:hover {
    border-color: var(--g-blue);
    color: var(--g-text);
    transform: translateY(-1px);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.game-card {
    display: flex;
    flex-direction: column;
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 20px;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    box-shadow: var(--ui-shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--ui-shadow-lg); border-color: var(--ui-blue-border, rgba(36,81,196,.25)); }
.game-card:focus-visible { outline: 3px solid var(--g-blue); outline-offset: 3px; }
.game-card:active { transform: translateY(-1px) scale(.995); }

.game-card-art {
    position: relative;
    aspect-ratio: 2 / 1;
    background: var(--g-surface-soft);
    border-bottom: 1px solid var(--g-border);
    overflow: hidden;
}
.game-card-art svg { width: 100%; height: 100%; display: block; }

.art-badge-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 6px;
    z-index: 2;
    pointer-events: none;
}
.art-chip {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.art-chip-blue {
    background: rgba(36,81,196,0.92);
    color: #ffffff;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.art-chip-emerald {
    background: rgba(16,185,129,0.92);
    color: #ffffff;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.art-chip-dark {
    background: rgba(15,23,42,0.8);
    color: #cbd5e1;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Card illustrations */
.art-ground { fill: #e9eef5; }
.art-road { fill: none; stroke: #c7d0dd; stroke-width: 22; stroke-linecap: round; }
.art-road-line { fill: none; stroke: #ffffff; stroke-width: 2; stroke-dasharray: 8 8; }
.art-traffic { fill: none; stroke: var(--g-red); stroke-width: 6; stroke-linecap: round; opacity: .85; }
.art-stop { fill: #ffffff; stroke: var(--g-blue); stroke-width: 4; }
.art-stop-end { fill: var(--g-green); stroke: #ffffff; }
.art-bus { fill: var(--g-blue); }
.art-bus-roof { fill: rgba(255,255,255,.22); }
.art-bus-glass { fill: #dbe6ff; }
.art-desk { fill: #f7f4ee; }
.art-lines line { stroke: rgba(36,81,196,.16); stroke-width: 1.4; }
.art-lines .art-margin { stroke: rgba(239,68,68,.35); }
.art-pen-blue { fill: var(--g-blue); }
.art-pen-red { fill: var(--g-red); }
.art-pen-cap-blue { fill: #15306b; }
.art-pen-cap-red { fill: #b91c1c; }
.art-pen-tip { fill: #94a3b8; }
.art-flick { stroke: var(--g-text-faint); stroke-width: 3; stroke-linecap: round; fill: none; }

:root.dark-theme .art-ground { fill: #131c2e; }
:root.dark-theme .art-road { stroke: #26324a; }
:root.dark-theme .art-road-line { stroke: #4b5a76; }
:root.dark-theme .art-stop { fill: #101624; }
:root.dark-theme .art-stop-end { stroke: #101624; }
:root.dark-theme .art-desk { fill: #1a2233; }
:root.dark-theme .art-lines line { stroke: rgba(147,197,253,.12); }
:root.dark-theme .art-lines .art-margin { stroke: rgba(248,113,113,.3); }
:root.dark-theme .art-pen-cap-blue { fill: #1e3a8a; }

.game-card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-card-head h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--g-text); letter-spacing: -.01em; }
.game-tag {
    font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
    background: var(--g-blue-soft); color: var(--ui-blue-text, #2451c4); white-space: nowrap;
}
.tag-blue { background: rgba(36, 81, 196, 0.12); color: #2451c4; }
:root.dark-theme .tag-blue { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.tag-emerald { background: rgba(16, 185, 129, 0.12); color: #059669; }
:root.dark-theme .tag-emerald { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }

.game-card-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.card-feature-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--g-surface-soft);
    color: var(--g-text-soft);
    border: 1px solid var(--g-border);
    white-space: nowrap;
}

.game-card-body p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--g-text-soft); }
.game-card-meta { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--g-text-faint); font-weight: 600; }
.game-card-cta {
    display: inline-flex; align-items: center; gap: 4px; padding: 8px 14px; border-radius: 999px;
    background: var(--g-blue); color: #fff; font-size: 13px; font-weight: 700;
}
.game-card-cta svg { width: 15px; height: 15px; }

/* Personal Records & Achievements Shelf */
.arcade-stats-shelf {
    margin-top: 28px;
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 20px;
    padding: 20px 24px;
    box-shadow: var(--ui-shadow-sm, 0 1px 3px rgba(0,0,0,0.05));
}
.stats-shelf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--g-border);
}
.shelf-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--g-text);
}
.shelf-title-wrap svg {
    color: var(--g-blue);
    flex-shrink: 0;
}
.shelf-title-wrap h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.shelf-note {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--g-text-faint);
    background: var(--g-surface-soft);
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--g-border);
    white-space: nowrap;
}
.stats-shelf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--g-surface-soft);
    border: 1px solid var(--g-border);
    border-radius: 14px;
    transition: transform .15s ease, border-color .15s ease;
}
.stat-card:hover {
    border-color: var(--g-blue);
    transform: translateY(-1px);
}
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.stat-icon-blue {
    background: rgba(36, 81, 196, 0.12);
    color: #2451c4;
}
:root.dark-theme .stat-icon-blue {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}
.stat-icon-emerald {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}
:root.dark-theme .stat-icon-emerald {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}
.stat-icon-purple {
    background: rgba(139, 92, 246, 0.12);
    color: #7c3aed;
}
:root.dark-theme .stat-icon-purple {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
}
.stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--g-text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--g-text);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-sub {
    font-size: 10.5px;
    color: var(--g-text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Quick Controls & Cheat-Sheet */
.arcade-controls-guide {
    margin-top: 18px;
    background: var(--g-surface);
    border: 1px solid var(--g-border);
    border-radius: 20px;
    padding: 18px 24px 22px;
}
.guide-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--g-text);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--g-border);
}
.guide-header svg {
    color: var(--g-blue);
    flex-shrink: 0;
}
.guide-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.guide-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.guide-game-title {
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--g-blue);
}
:root.dark-theme .guide-game-title {
    color: #93c5fd;
}
.guide-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12.5px;
    color: var(--g-text-soft);
    line-height: 1.5;
}
.guide-list li {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}
.guide-list strong {
    color: var(--g-text);
    font-weight: 600;
}
.key-cap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 5px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    color: var(--g-text);
    background: var(--g-surface-soft);
    border: 1px solid var(--g-border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

/* Stage */
.game-stage { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 560px; margin: 0 auto; }
.game-stage[hidden], .games-hub[hidden] { display: none; }
.game-toolbar { display: flex; align-items: center; gap: 10px; }
.game-toolbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.game-toolbar-title strong { font-size: 17px; color: var(--g-text); line-height: 1.2; }
.game-toolbar-title span { font-size: 12.5px; color: var(--g-text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-icon-btn {
    width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
    border: 1px solid var(--g-border); background: var(--g-surface); color: var(--g-text); cursor: pointer;
}
.game-icon-btn svg { width: 19px; height: 19px; }
.game-icon-btn:hover { border-color: var(--g-blue); color: var(--g-blue); }

.game-hud { display: flex; gap: 8px; flex-wrap: wrap; }
.game-hud:empty { display: none; }
.hud-chip {
    flex: 1 1 0; min-width: 72px; padding: 7px 10px; border-radius: 12px;
    background: var(--g-surface); border: 1px solid var(--g-border);
    display: flex; flex-direction: column; gap: 1px;
}
.hud-chip small { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--g-text-faint); }
.hud-chip { min-width: 0; }
.hud-chip small, .hud-chip b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-chip b { font-size: 15px; color: var(--g-text); font-variant-numeric: tabular-nums; }
.hud-chip.is-good b { color: var(--g-green); }
.hud-chip.is-bad b { color: var(--g-red); }
.hud-chip.is-blue b { color: var(--g-blue); }

.game-canvas-wrap {
    position: relative; width: 100%; border-radius: 20px; overflow: hidden;
    background: var(--g-surface-soft); border: 1px solid var(--g-border);
    box-shadow: var(--ui-shadow-md); touch-action: none; user-select: none; -webkit-user-select: none;
}
.game-canvas-wrap > canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.game-overlay {
    position: absolute; inset: 0; display: grid; place-items: center; padding: 20px;
    background: rgba(248, 250, 252, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
:root.dark-theme .game-overlay { background: rgba(9, 13, 22, .72); }
.game-overlay[hidden] { display: none; }
.overlay-card {
    width: min(340px, 100%); background: var(--g-surface); border: 1px solid var(--g-border);
    border-radius: 20px; padding: 20px; text-align: center; box-shadow: var(--ui-shadow-lg);
    display: flex; flex-direction: column; gap: 10px; animation: overlayIn .22s ease;
}
@keyframes overlayIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.overlay-card h3 { margin: 0; font-size: 20px; color: var(--g-text); }
.overlay-card p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--g-text-soft); }
.overlay-card .overlay-big { font-size: 34px; font-weight: 800; color: var(--g-blue); font-variant-numeric: tabular-nums; }
.overlay-card .overlay-big.is-good { color: var(--g-green); }
.overlay-card .overlay-big.is-bad { color: var(--g-red); }
.overlay-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.overlay-select {
    width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--g-border);
    background: var(--g-surface-soft); color: var(--g-text); font: inherit; font-size: 14px; padding: 0 12px;
}
.game-btn {
    height: 44px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px;
    transition: transform .12s ease, background .15s ease;
}
.game-btn:active { transform: scale(.97); }
.game-btn-primary { background: var(--g-blue); color: #fff; }
.game-btn-primary:hover { background: var(--ui-blue-hover, #15306b); }
.game-btn-ghost { background: var(--g-surface-soft); color: var(--g-text); border-color: var(--g-border); }
.game-btn svg { width: 17px; height: 17px; }

.game-controls { display: flex; gap: 10px; }
.game-controls:empty { display: none; }
.pedal {
    flex: 1; height: 64px; border-radius: 16px; border: 1px solid var(--g-border); background: var(--g-surface);
    color: var(--g-text); font: inherit; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
    touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
}
.pedal svg { width: 20px; height: 20px; }
.pedal.is-down { transform: scale(.97); }
.pedal-gas.is-down { background: var(--g-green); border-color: var(--g-green); color: #fff; }
.pedal-brake.is-down { background: var(--g-red); border-color: var(--g-red); color: #fff; }
.pedal-steer { flex: 0 0 64px; }
.pedal-steer.is-down { background: var(--g-blue); border-color: var(--g-blue); color: #fff; }

.game-hint { font-size: 12px; color: var(--g-text-faint); text-align: center; margin: 0; }

@media (max-width: 768px) {
    .stats-shelf-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .guide-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

@media (max-width: 480px) {
    .arcade-hero { padding: 18px 14px 20px; border-radius: 16px; }
    .arcade-title { font-size: 22px; }
    .arcade-subtitle { font-size: 13px; }
    .arcade-features-row { gap: 6px; }
    .arcade-pill { padding: 4px 8px; font-size: 11px; }
    .arcade-stats-shelf, .arcade-controls-guide { padding: 16px 14px; border-radius: 16px; margin-top: 14px; }
    .stat-card { padding: 10px 12px; }
    .stat-icon { width: 34px; height: 34px; }
    .stat-value { font-size: 16px; }
    .stats-shelf-header, .guide-header { margin-bottom: 12px; padding-bottom: 8px; }
    .guide-list { font-size: 12px; }

    .games-grid { gap: 14px; margin-top: 12px; }
    .game-card { border-radius: 16px; }
    .game-card-body { padding: 14px; }
    .game-canvas-wrap { border-radius: 16px; }
    .pedal { height: 58px; }
    .game-hud { gap: 6px; }
    .hud-chip { padding: 6px 8px; flex-basis: auto; }
    .hud-chip small { font-size: 9.5px; }
    .hud-chip b { font-size: 13.5px; }
}

@media (max-width: 360px) {
    .arcade-hero { padding: 14px 10px 16px; }
    .arcade-title { font-size: 20px; }
    .arcade-stats-shelf, .arcade-controls-guide { padding: 12px 10px; }
    .shelf-note { display: none; }
    .stat-info { gap: 1px; }
    .stat-label { font-size: 10px; }
    .stat-value { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
    .game-card, .game-btn, .overlay-card { transition: none; animation: none; }
}

/* Sound toggle */
.game-icon-btn .snd-off { display: none; }
.game-icon-btn.is-muted .snd-on { display: none; }
.game-icon-btn.is-muted .snd-off { display: block; }
.game-icon-btn.is-muted { color: var(--g-text-faint); }

/* Pen picker */
.pen-picker { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.pen-picker-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--g-text-faint); }
.pen-picker-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pen-chip {
    display: flex; flex-direction: column; gap: 1px; align-items: center; padding: 7px 2px; border-radius: 10px;
    border: 1px solid var(--g-border); background: var(--g-surface-soft); color: var(--g-text); font: inherit; cursor: pointer; min-width: 0;
}
.pen-chip b { font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pen-chip small { font-size: 9.5px; color: var(--g-text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pen-chip.is-active { border-color: var(--g-blue); background: var(--g-blue-soft); box-shadow: inset 0 0 0 1px var(--g-blue); }
.pen-picker[data-picker="1"] .pen-chip.is-active { border-color: var(--g-red); background: rgba(239, 68, 68, .10); box-shadow: inset 0 0 0 1px var(--g-red); }
.game-overlay { overflow-y: auto; }
.overlay-card { margin: auto; }

/* Wide stage for the 3D simulator */
.game-stage.game-stage-wide { max-width: 980px; }

/* ---------- 3D Bus Simulator ---------- */
.overlay-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sim-help { margin: 0; padding-left: 18px; text-align: left; font-size: 13px; line-height: 1.5; color: var(--g-text-soft); display: flex; flex-direction: column; gap: 5px; }
.sim-help b { color: var(--g-text); }
.sim-result { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: left; }
.sim-result div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 9px; border-radius: 9px; background: var(--g-surface-soft); font-size: 12px; color: var(--g-text-soft); }
.sim-result b { color: var(--g-text); font-variant-numeric: tabular-nums; white-space: nowrap; }

.sim-ui { position: absolute; inset: 0; color: #f8fafc; font-family: var(--ui-font, inherit); }
.sim-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #bcd7f0; }
:root.dark-theme .sim-canvas { background: #1a2238; }
.sim-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.sim-next { display: flex; flex-direction: column; gap: 1px; padding: 8px 12px; border-radius: 14px; background: rgba(8, 12, 20, .72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); max-width: 62%; min-width: 0; }
.sim-next small { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #93c5fd; }
.sim-next b { color: #f8fafc; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-next span { font-size: 11px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-mini { width: 96px; height: 96px; border-radius: 16px; background: rgba(255, 255, 255, .86); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); flex: none; }
:root.dark-theme .sim-mini { background: rgba(203, 213, 225, .9); }
.sim-mirror { position: absolute; border: 3px solid #0b0f16; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, .35); pointer-events: none; box-sizing: border-box; }
.sim-mirror span { position: absolute; left: 6px; bottom: 3px; font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 2px #000; }
.sim-mirror[hidden], .sim-toast[hidden], .sim-ring[hidden] { display: none; }
.sim-toast { position: absolute; top: 26%; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); pointer-events: none; }
.sim-toast.is-good { background: #10b981; color: #04261a; }
.sim-toast.is-bad { background: #ef4444; color: #fff; }
.sim-ring { position: absolute; top: 40%; left: 50%; width: 92px; height: 92px; transform: translate(-50%, -50%); display: grid; place-items: center; pointer-events: none; }
.sim-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.sim-ring-bg { fill: rgba(8, 12, 20, .55); stroke: rgba(255, 255, 255, .22); stroke-width: 7; }
.sim-ring-fg { fill: none; stroke: #34d399; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 276.5; stroke-dashoffset: 276.5; }
.sim-ring b { color: #f8fafc; position: relative; font-size: 12px; font-weight: 700; }

.sim-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; background: linear-gradient(to top, rgba(8, 12, 20, .55), rgba(8, 12, 20, 0)); }
.sim-bottom > * { pointer-events: auto; }
.sim-side { position: absolute; top: 118px; display: flex; flex-direction: column; gap: 6px; }
.sim-side-left { left: 10px; }
.sim-side-right { right: 10px; }
.sim-btn {
    pointer-events: auto; width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(8, 12, 20, .68);
    color: #e2e8f0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; cursor: pointer; padding: 0;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); touch-action: manipulation; user-select: none; -webkit-user-select: none; font: inherit;
}
.sim-btn svg { width: 19px; height: 19px; }
.sim-btn small { font-size: 8px; font-weight: 700; letter-spacing: .03em; line-height: 1; margin-top: 1px; color: #94a3b8; }
.sim-btn b { color: inherit; font-size: 16px; font-weight: 800; line-height: 1; }
.sim-ui b { color: inherit !important; }
.sim-next b, .sim-ring b { color: #f8fafc !important; }
.sim-btn.is-on { background: #2451c4; border-color: #93c5fd; color: #fff; }
.sim-btn.is-on small { color: #dbeafe; }
.sim-btn[data-act="hand"].is-on { background: #b91c1c; border-color: #fca5a5; }
.sim-btn[data-act="indL"].is-on, .sim-btn[data-act="indR"].is-on { background: #047857; border-color: #6ee7b7; }
.sim-btn:active { transform: scale(.94); }
.sim-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; pointer-events: none; }
.sim-row > * { pointer-events: auto; }
.sim-wheel {
    width: 112px; height: 112px; flex: none; border-radius: 50%; color: #e2e8f0; background: rgba(8, 12, 20, .5); touch-action: none; cursor: grab;
    user-select: none; -webkit-user-select: none; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); will-change: transform;
}
.sim-wheel svg { width: 100%; height: 100%; display: block; }
.sim-wheel-mark { fill: #ef4444; }
.sim-dash { flex: 1 1 auto; min-width: 0; height: 112px; max-width: 380px; margin: 0 auto; pointer-events: none; }
.sim-pedals { display: flex; gap: 8px; flex: none; }
.sim-pedal {
    width: 58px; height: 112px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(8, 12, 20, .68); color: #e2e8f0;
    font: inherit; font-size: 11px; font-weight: 700; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px; cursor: pointer;
    touch-action: none; user-select: none; -webkit-user-select: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    background-image: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .07) 0 3px, transparent 3px 11px);
}
.sim-pedal-brake { width: 66px; height: 92px; }
.sim-pedal.is-down { transform: translateY(3px) scale(.97); }
.sim-pedal-gas.is-down { background-color: #047857; border-color: #6ee7b7; }
.sim-pedal-brake.is-down { background-color: #b91c1c; border-color: #fca5a5; }

/* phone layout: buttons, then the gauges, then wheel and pedals */
.sim-narrow .sim-bottom { padding: 8px; gap: 6px; }
.sim-narrow .sim-btn { width: 38px; height: 38px; border-radius: 10px; }
.sim-narrow .sim-side { top: 100px; gap: 5px; }
.sim-narrow .sim-side-left { left: 8px; }
.sim-narrow .sim-side-right { right: 8px; }
.sim-narrow .sim-dash { height: 84px; align-self: flex-end; }
.sim-narrow .sim-pedal { width: 52px; }
.sim-narrow .sim-pedal-brake { width: 58px; }
.sim-narrow .sim-wheel { width: 104px; height: 104px; }
.sim-narrow .sim-pedal { height: 100px; }
.sim-narrow .sim-pedal-brake { height: 84px; }
.sim-narrow .sim-mini { width: 78px; height: 78px; border-radius: 13px; }
.sim-narrow .sim-next b { font-size: 13.5px; }

/* ---------- full-screen play ---------- */
.game-icon-btn .fs-off { display: none; }
.game-icon-btn.is-on .fs-on { display: none; }
.game-icon-btn.is-on .fs-off { display: block; }
body.game-immersive { overflow: hidden; }
body.game-immersive .game-stage, .game-stage:fullscreen {
    position: fixed; inset: 0; z-index: 2147483000; max-width: none; width: auto; margin: 0; gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: var(--ui-bg, #f8fafc); box-sizing: border-box; overflow: hidden;
}
body.game-immersive .game-toolbar { gap: 6px; }
body.game-immersive .game-icon-btn { width: 34px; height: 34px; border-radius: 10px; }
body.game-immersive .game-toolbar-title strong { font-size: 14px; }
body.game-immersive .game-toolbar-title span { font-size: 11px; }
body.game-immersive .game-hud { gap: 5px; }
body.game-immersive .hud-chip { padding: 3px 8px; flex-direction: row; align-items: baseline; gap: 6px; border-radius: 9px; }
body.game-immersive .hud-chip small { font-size: 9px; }
body.game-immersive .hud-chip b { font-size: 12.5px; }
body.game-immersive .game-canvas-wrap { border-radius: 12px; }
/* on a short landscape phone the toolbar and score chips share one line */
@media (max-height: 480px) and (orientation: landscape) {
    body.game-immersive .game-stage { flex-direction: row; flex-wrap: wrap; align-items: center; }
    body.game-immersive .game-toolbar { flex: 0 0 auto; }
    body.game-immersive .game-toolbar-title { display: none; }
    body.game-immersive .game-hud { flex: 1 1 0; min-width: 0; }
    body.game-immersive .game-canvas-wrap { flex: 0 0 100%; }
}

/* short simulator view (landscape phone): two-column side buttons, smaller map and wheel */
.sim-short .sim-side { top: 66px; display: grid; grid-template-columns: repeat(2, auto); gap: 5px; }
.sim-short .sim-btn { width: 36px; height: 36px; border-radius: 10px; }
.sim-short .sim-mini { width: 62px; height: 62px; border-radius: 11px; }
.sim-short .sim-next { padding: 5px 10px; }
.sim-short .sim-next b { font-size: 13px; }
.sim-short .sim-wheel { width: 96px; height: 96px; }
.sim-short .sim-dash { height: 88px; }
.sim-short .sim-pedal { height: 92px; }
.sim-short .sim-pedal-brake { height: 78px; }
.sim-short .sim-bottom { padding: 6px 10px; }
