/* Park Car 3D - "valet ticket" interface: cream paper tickets with ink text, chunky key-fob buttons, a license plate for the title,
   level tiles drawn as key tags. All sizes are in rem; js/game.js sets the root font size from the window size so everything scales together. */
@font-face {
    font-family: "VR Display";
    src: url(../assets/fonts/titan-one-latin-400-normal.woff2) format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "VR Text";
    src: url(../assets/fonts/fredoka-latin-500-normal.woff2) format("woff2");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "VR Text";
    src: url(../assets/fonts/fredoka-latin-700-normal.woff2) format("woff2");
    font-weight: 700;
    font-display: swap;
}

:root {
    --ink: #1c2150;
    --ink2: #2b3278;
    --paper: #fff4d9;
    --paper2: #f6e6bd;
    --orange: #ff6a2b;
    --sun: #ffd23f;
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --hd: "VR Display", "Impact", "Arial Black", sans-serif;
    --bd: "VR Text", "Segoe UI", system-ui, sans-serif;
}
* {
    box-sizing: border-box;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}
html {
    font-size: 14px;
    height: 100%;
    overflow: hidden;
    background: #ff6a2b;
}
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
    height: 100%;
    overflow: hidden;
    font-family: var(--bd);
    font-weight: 700;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1.25;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    overscroll-behavior: none;
}
img {
    display: block;
    -webkit-user-drag: none;
}
button {
    font: inherit;
    color: inherit;
    border: 0;
    background: none;
    cursor: pointer;
    padding: 0;
}
[hidden] {
    display: none !important;
}
#stage {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}
#app {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

/* ---------- screens ---------- */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    padding: calc(var(--sat) + 1rem) calc(var(--sar) + 1.2rem) calc(var(--sab) + 1rem) calc(var(--sal) + 1.2rem);
    pointer-events: none;
}
.screen.active {
    display: flex;
    animation: scr 0.35s ease both;
}
@keyframes scr {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.screen button,
.screen .ticket,
.screen .chip,
.screen .plate,
.screen .paint {
    pointer-events: auto;
}
/* menu + game share one grid: portrait = top block, free middle (the lot), bottom block. wide game = left column, lot, right column */
#menu.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    row-gap: 0.8rem;
}
#game.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    row-gap: 0.8rem;
}
.mid {
    position: relative;
    min-height: 0;
    pointer-events: none;
}
.side-l,
.side-r {
    width: 100%;
    max-width: 46rem;
    justify-self: center;
}

/* ---------- buttons: chunky key-fobs with a solid bottom edge ---------- */
.btn {
    --l: #7fe69b;
    --b: #22b95c;
    --d: #0f7a3a;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 4.1rem;
    padding: 0 1.1rem;
    border-radius: 1.2rem;
    color: #fff;
    font-family: var(--hd);
    font-size: 1.5rem;
    letter-spacing: 0.03em;
    line-height: 1;
    background: linear-gradient(180deg, var(--l), var(--b) 66%);
    box-shadow:
        0 0.38rem 0 var(--d),
        0 0.8rem 1rem rgba(10, 14, 60, 0.32),
        inset 0 0.12rem 0 rgba(255, 255, 255, 0.6),
        inset 0 -0.18rem 0.3rem rgba(0, 0, 0, 0.12);
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.28);
    transition: box-shadow 0.1s;
    pointer-events: auto;
    cursor: pointer;
    top: 0;
}
.btn img {
    width: 2.1rem;
    height: 2.1rem;
    flex: none;
}
.btn span {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}
.btn small {
    font-family: var(--bd);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0;
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.25);
    opacity: 0.95;
}
.btn:active {
    top: 0.3rem;
    box-shadow:
        0 0.08rem 0 var(--d),
        0 0.2rem 0.4rem rgba(10, 14, 60, 0.3),
        inset 0 0.12rem 0 rgba(255, 255, 255, 0.5);
}
@media (hover: hover) {
    .btn:not(:disabled):hover::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: rgba(255, 255, 255, 0.14);
        pointer-events: none;
    }
}
.btn:focus-visible,
.tile:focus-visible,
.switch:focus-visible,
.pad:focus-visible,
.sw:focus-visible {
    outline: 0.28rem solid #fff;
    outline-offset: 0.2rem;
}
.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}
.btn:disabled::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(120, 120, 120, 0.55);
}
.b-green {
    --l: #7fe69b;
    --b: #22b95c;
    --d: #0f7a3a;
}
.b-blue {
    --l: #8fd0ff;
    --b: #2f8bff;
    --d: #1650b8;
}
.b-violet {
    --l: #d0b2ff;
    --b: #8a55f0;
    --d: #4d26a6;
}
.b-teal {
    --l: #7fefe4;
    --b: #10b7a8;
    --d: #07746a;
}
.b-red {
    --l: #ff9fae;
    --b: #f23d5e;
    --d: #a01634;
}
.b-orange {
    --l: #ffb36b;
    --b: #ff6a2b;
    --d: #b83a05;
}
.b-ink {
    --l: #5d68c4;
    --b: #2f3883;
    --d: #121748;
}
.btn.round {
    width: 4.2rem;
    min-height: 4.2rem;
    padding: 0;
    border-radius: 1.3rem;
}
.btn.round img {
    width: 2.2rem;
    height: 2.2rem;
}
.btn.wide {
    width: 100%;
}
.btn.small {
    min-height: 3.4rem;
    font-size: 1.3rem;
    padding: 0 1.1rem;
    border-radius: 1.1rem;
}
.btn.xl {
    min-height: 5.8rem;
    font-size: 2.3rem;
    gap: 1rem;
    border-radius: 1.7rem;
    width: 100%;
    box-shadow:
        0 0.5rem 0 var(--d),
        0 1rem 1.4rem rgba(10, 14, 60, 0.36),
        inset 0 0.14rem 0 rgba(255, 255, 255, 0.65),
        inset 0 -0.22rem 0.4rem rgba(0, 0, 0, 0.12);
}
.btn.xl img {
    width: 3.2rem;
    height: 3.2rem;
}
.btn.xl small {
    font-size: 1.2rem;
}

/* ---------- tickets (cream paper panels), chips ---------- */
.ticket {
    position: relative;
    color: var(--ink);
    border-radius: 1.5rem;
    background: linear-gradient(180deg, #fffaea, var(--paper));
    border: 0.22rem solid var(--ink);
    box-shadow:
        0 0.45rem 0 #0e1238,
        0 1rem 1.6rem rgba(10, 14, 60, 0.34),
        inset 0 0 0 0.16rem #fff;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 1.1rem 0.4rem 0.7rem;
    border-radius: 2rem;
    background: var(--ink);
    border: 0.16rem solid rgba(255, 255, 255, 0.55);
    font-family: var(--hd);
    font-size: 1.5rem;
    box-shadow: 0 0.3rem 0 rgba(8, 12, 60, 0.5);
}
.chip img {
    width: 2.1rem;
    height: 2.1rem;
}
.chip.small {
    font-size: 1.4rem;
    padding: 0.3rem 0.9rem 0.3rem 0.55rem;
}
.chip.small img {
    width: 1.8rem;
    height: 1.8rem;
}

/* ---------- the license plate (title) ---------- */
.plate {
    --k: 1;
    display: flex;
    align-items: stretch;
    border-radius: calc(1.4rem * var(--k));
    background: linear-gradient(180deg, #fffef6, #f3ebd0);
    border: calc(0.32rem * var(--k)) solid var(--ink);
    box-shadow:
        0 calc(0.5rem * var(--k)) 0 #0e1238,
        0 1.2rem 1.6rem rgba(8, 12, 60, 0.36),
        inset 0 0 0 calc(0.16rem * var(--k)) #fff;
    overflow: hidden;
}
.pl-l {
    flex: none;
    width: calc(4.4rem * var(--k));
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #3d78ff, #1b3fb4);
}
.pl-l img {
    width: calc(2.3rem * var(--k));
    height: calc(2.3rem * var(--k));
}
.pl-t {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: calc(0.7rem * var(--k)) calc(1.5rem * var(--k)) calc(0.8rem * var(--k)) calc(1.3rem * var(--k));
    line-height: 0.92;
}
.p1 {
    font-family: var(--hd);
    font-size: calc(2.5rem * var(--k));
    letter-spacing: 0.2em;
    color: var(--ink);
}
.p2 {
    display: flex;
    align-items: center;
    gap: calc(0.7rem * var(--k));
    font-family: var(--hd);
    font-size: calc(4.9rem * var(--k));
    letter-spacing: 0.03em;
    color: var(--orange);
    text-shadow: 0 calc(0.22rem * var(--k)) 0 #a33a0a;
}
.p2 em {
    font-style: normal;
    font-size: calc(1.7rem * var(--k));
    padding: calc(0.35rem * var(--k)) calc(0.8rem * var(--k));
    border-radius: calc(0.8rem * var(--k));
    background: var(--ink);
    color: var(--sun);
    text-shadow: none;
    letter-spacing: 0.04em;
}
.tagline {
    margin-top: 1rem;
    text-align: center;
    font-family: var(--hd);
    font-weight: 400;
    font-size: 1.5rem;
    letter-spacing: 0.02em;
    color: #fff;
    text-shadow:
        0 0.14rem 0 rgba(10, 14, 70, 0.85),
        0 0 0.6rem rgba(10, 14, 70, 0.55);
}

/* ---------- loading ---------- */
#loader {
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #ff8a3d, #ffd9a0);
    pointer-events: auto;
}
.ld-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    width: min(100%, 32rem);
}
.ld-road {
    position: relative;
    width: 100%;
    height: 1.8rem;
    border-radius: 1rem;
    background: var(--ink);
    border: 0.2rem solid #fff;
    box-shadow: 0 0.3rem 0 rgba(8, 12, 60, 0.35);
}
.ld-road i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-radius: 1rem;
    background: repeating-linear-gradient(135deg, #ffd23f 0 0.9rem, #ff9a1f 0.9rem 1.8rem);
    transition: width 0.2s;
}
.ld-road img {
    position: absolute;
    bottom: 0.4rem;
    right: -0.4rem;
    height: 3.4rem;
    width: auto;
}
.ld-txt {
    color: #fff;
    font-size: 1.5rem;
    text-shadow: 0 0.14rem 0 rgba(10, 14, 70, 0.8);
}

/* ---------- menu ---------- */
.m-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0.2rem;
    max-width: none;
}
.dock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    max-width: 36rem;
}
.row3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
    width: 100%;
}
.row3 .btn {
    flex-direction: column;
    gap: 0.35rem;
    min-height: 5.4rem;
    padding: 0.6rem 0.3rem;
    font-size: 1.25rem;
}
.row3 .btn span {
    align-items: center;
}
.row3 .btn img {
    width: 2.3rem;
    height: 2.3rem;
}
.row3 .btn small {
    font-size: 1.05rem;
}
.paint-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}
.paint {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    padding: 0.45rem 0.8rem;
    border-radius: 2rem;
    background: var(--ink);
    border: 0.16rem solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 0.3rem 0 rgba(8, 12, 60, 0.5);
}
.sw {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--c);
    border: 0.2rem solid #fff;
    box-shadow: 0 0.16rem 0 rgba(0, 0, 0, 0.4);
    transition: transform 0.12s;
}
.sw.on {
    transform: scale(1.18);
    box-shadow:
        0 0 0 0.22rem var(--sun),
        0 0.16rem 0 0.22rem rgba(0, 0, 0, 0.4);
}
.ver {
    position: absolute;
    right: calc(var(--sar) + 1rem);
    bottom: calc(var(--sab) + 0.4rem);
    font-size: 1.1rem;
    opacity: 0.75;
    pointer-events: none;
    text-shadow: 0 0.1rem 0 rgba(10, 14, 70, 0.8);
}

/* ---------- level select ---------- */
#levels.active {
    flex-direction: column;
    gap: 0.9rem;
    align-items: center;
    pointer-events: auto;
    background: linear-gradient(180deg, var(--s0, #8fa2c8) 0, var(--s1, #dfe6f5) 36%, var(--g, #6e7587) 36.1%, var(--g, #6e7587) 100%);
}
#levels.active::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0) 0 3rem, rgba(255, 255, 255, 0.1) 3rem 6rem);
}
#levels > * {
    position: relative;
}
#levels > * {
    width: 100%;
    max-width: 62rem;
}
.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.bar h2 {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 2.1rem;
    white-space: nowrap;
    color: #fff;
    text-shadow:
        0 0.16rem 0 rgba(10, 14, 70, 0.85),
        0 0 0.6rem rgba(10, 14, 70, 0.5);
}
.world-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0.8rem;
    border-radius: 1.5rem;
    background: linear-gradient(180deg, #fffaea, var(--paper));
    border: 0.22rem solid var(--ink);
    box-shadow: 0 0.4rem 0 #0e1238;
    color: var(--ink);
}
.w-info {
    flex: 1;
    min-width: 0;
    text-align: center;
}
.w-info small {
    font-size: 1.15rem;
    opacity: 0.75;
}
.w-info h3 {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 1.7rem;
    line-height: 1.1;
    white-space: nowrap;
    color: var(--orange);
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.15);
}
.w-info p {
    font-size: 1.15rem;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.arrow {
    flex: none;
}
.arrow img {
    width: 2.1rem;
    height: 2.1rem;
}
.dots {
    display: flex;
    justify-content: center;
    gap: 0.7rem;
}
.dots i {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0.12rem 0 rgba(8, 12, 60, 0.5);
}
.dots i.on {
    width: 2.6rem;
    border-radius: 1rem;
    background: var(--sun);
}
.lv-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    gap: 0.8rem;
    max-height: 46rem;
    align-content: stretch;
    padding-bottom: 0.4rem;
}
.tile {
    --c1: var(--a1, #5b6aa8);
    --c2: var(--a2, #47558f);
    --cd: var(--ad, #232f6a);
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 1.2rem;
    background: linear-gradient(180deg, var(--c1), var(--c2));
    box-shadow:
        0 0.38rem 0 var(--cd),
        0 0.8rem 1rem rgba(8, 12, 60, 0.3);
    color: #fff;
    overflow: hidden;
    pointer-events: auto;
    top: 0;
}
.tile::before {
    content: "";
    position: absolute;
    left: 0.8rem;
    top: 50%;
    width: 1.4rem;
    height: 1.4rem;
    margin-top: -0.7rem;
    border-radius: 50%;
    background: rgba(10, 14, 60, 0.45);
    box-shadow:
        inset 0 0.14rem 0.22rem rgba(0, 0, 0, 0.45),
        0 0.08rem 0 rgba(255, 255, 255, 0.35);
}
.tile:active {
    top: 0.3rem;
}
.tile .no {
    position: absolute;
    left: 3rem;
    top: 0.7rem;
    font-family: var(--hd);
    font-weight: 400;
    font-size: 2.5rem;
    line-height: 1;
    text-shadow: 0 0.14rem 0 rgba(10, 14, 70, 0.55);
}
.tile .ts {
    position: absolute;
    left: 2.9rem;
    bottom: 0.8rem;
    display: flex;
    gap: 0.1rem;
}
.tile .ts img {
    width: 1.5rem;
    height: 1.5rem;
}
.tile .pc {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    margin-top: -1.2rem;
    width: 2.4rem;
    height: 2.4rem;
    opacity: 0.85;
}
.tile.new {
    --c1: #ffc166;
    --c2: #ff8a2b;
    --cd: #b34a05;
    color: #4a1f00;
    animation: pulse 1.4s ease-in-out infinite;
}
.tile.new .no {
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    text-shadow: 0 0.1rem 0 rgba(255, 255, 255, 0.5);
}
.tile.new .go {
    position: absolute;
    right: 1rem;
    top: 50%;
    margin-top: -1.2rem;
    width: 2.4rem;
    height: 2.4rem;
    filter: brightness(0) opacity(0.55);
}
@keyframes pulse {
    50% {
        box-shadow:
            0 0.38rem 0 var(--cd),
            0 0 0 0.35rem rgba(255, 255, 255, 0.55),
            0 0.8rem 1rem rgba(8, 12, 60, 0.3);
    }
}
.tile.lock {
    --c1: #59638a;
    --c2: #464f74;
    --cd: #1f2655;
    background: repeating-linear-gradient(135deg, #59638a 0 1.2rem, #4c5679 1.2rem 2.4rem);
}
.tile.lock .no {
    opacity: 0.6;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
}
.tile.lock .lk {
    position: absolute;
    right: 1.1rem;
    top: 50%;
    margin-top: -1.2rem;
    width: 2.4rem;
    height: 2.4rem;
    opacity: 0.85;
}

/* ---------- game HUD ---------- */
.g-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.7rem;
    width: 100%;
    max-width: 46rem;
    justify-self: center;
}
.g-btns {
    display: contents;
}
#pauseBtn {
    order: 1;
}
.info {
    order: 2;
}
#restartBtn {
    order: 3;
}
.info {
    min-width: 0;
    padding: 0.6rem 0.9rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.i-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 0.18rem dashed rgba(28, 33, 80, 0.35);
}
.i-top b {
    white-space: nowrap;
    font-family: var(--hd);
    font-weight: 400;
    font-size: 1.6rem;
    letter-spacing: 0.03em;
    color: var(--orange);
    text-shadow: 0 0.08rem 0 rgba(0, 0, 0, 0.12);
}
.i-top small {
    font-size: 1.15rem;
    white-space: nowrap;
    opacity: 0.8;
}
.i-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    min-width: 0;
}
.timer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.timer img {
    width: 2rem;
    height: 2rem;
    filter: brightness(0) saturate(100%) invert(14%) sepia(40%) saturate(2800%) hue-rotate(218deg) brightness(90%);
}
.timer strong {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 2.4rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stars3 {
    display: flex;
    gap: 0;
    flex: none;
}
.stars3 img {
    width: 1.7rem;
    height: 1.7rem;
}
.dmg {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.dmg > img {
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    filter: brightness(0) saturate(100%) invert(30%) sepia(90%) saturate(2400%) hue-rotate(345deg);
}
.pips {
    flex: 1;
    display: flex;
    gap: 0.25rem;
    min-width: 0;
}
.pips i {
    flex: 1;
    height: 1.1rem;
    border-radius: 0.4rem;
    background: rgba(28, 33, 80, 0.18);
    box-shadow: inset 0 0.1rem 0.15rem rgba(0, 0, 0, 0.2);
}
.pips i.on {
    background: linear-gradient(180deg, #8cf0a4, #27b95e);
    box-shadow: inset 0 0.1rem 0 rgba(255, 255, 255, 0.6);
}
.pips[data-h="3"] i.on,
.pips[data-h="2"] i.on {
    background: linear-gradient(180deg, #ffd77a, #ff9a1f);
}
.pips[data-h="1"] i.on {
    background: linear-gradient(180deg, #ff9aa8, #e92f50);
    animation: blink 0.5s ease-in-out infinite alternate;
}
@keyframes blink {
    to {
        opacity: 0.55;
    }
}
.cones {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 1.2rem;
    flex: none;
}
.cones img {
    width: 1.4rem;
    height: 1.4rem;
    filter: brightness(0) saturate(100%) invert(48%) sepia(90%) saturate(1800%) hue-rotate(2deg);
}
.cones b {
    font-family: var(--hd);
    font-weight: 400;
}
.coach {
    position: absolute;
    left: 0;
    right: 0;
    top: 0.2rem;
    display: flex;
    justify-content: center;
    transition: opacity 0.4s;
    pointer-events: none;
}
.coach span {
    display: block;
    padding: 0.5rem 1.1rem;
    border-radius: 1.6rem;
    background: var(--ink);
    border: 0.16rem solid rgba(255, 255, 255, 0.55);
    font-size: 1.25rem;
    text-align: center;
    line-height: 1.2;
}
.coach span b {
    color: var(--sun);
}
.coach.hide {
    opacity: 0;
}

/* driving pads (hold to use) */
.g-bot {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.8rem;
    width: 100%;
    max-width: 46rem;
    justify-self: center;
}
.steer,
.pedals {
    display: flex;
    gap: 0.7rem;
}
.pad {
    --l: #6f7bd6;
    --b: #3a4496;
    --d: #161c58;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    width: 5.4rem;
    height: 5.4rem;
    border-radius: 1.4rem;
    color: #fff;
    font-family: var(--hd);
    font-size: 1.15rem;
    letter-spacing: 0.06em;
    line-height: 1;
    background: linear-gradient(180deg, var(--l), var(--b) 66%);
    box-shadow:
        0 0.4rem 0 var(--d),
        0 0.8rem 1rem rgba(10, 14, 60, 0.32),
        inset 0 0.12rem 0 rgba(255, 255, 255, 0.55),
        inset 0 -0.18rem 0.3rem rgba(0, 0, 0, 0.12);
    text-shadow: 0 0.08rem 0 rgba(0, 0, 0, 0.3);
    touch-action: none;
    pointer-events: auto;
    -webkit-touch-callout: none;
    transition: box-shadow 0.06s;
    position: relative;
    top: 0;
}
.pad img {
    width: 2.4rem;
    height: 2.4rem;
    pointer-events: none;
}
.pad span {
    pointer-events: none;
}
.pad.wide {
    width: 6.8rem;
}
.pad.down,
.pad:active {
    top: 0.32rem;
    box-shadow:
        0 0.08rem 0 var(--d),
        0 0.2rem 0.4rem rgba(10, 14, 60, 0.3),
        inset 0 0.12rem 0 rgba(255, 255, 255, 0.45);
}
.p-steel {
    --l: #7d8be8;
    --b: #4452b0;
    --d: #1a2062;
}
.p-green {
    --l: #7fe69b;
    --b: #1fb558;
    --d: #0b6f35;
}
.p-red {
    --l: #ff9a8a;
    --b: #ee4a3a;
    --d: #9a1d12;
}
.p-steel img {
    width: 2.8rem;
    height: 2.8rem;
}

/* pop-up texts over the lot */
#pops {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}
.pop {
    position: absolute;
    translate: -50% -50%;
    font-family: var(--hd);
    font-size: 2.3rem;
    color: #fff;
    white-space: nowrap;
    text-shadow:
        0 0.16rem 0 rgba(10, 14, 70, 0.9),
        0 0 0.5rem rgba(10, 14, 70, 0.5);
    animation: pop 0.95s ease-out both;
}
.pop.bad {
    color: #ff8a8a;
}
.pop.warn {
    color: #ffd27a;
}
.pop.good {
    color: #a8ffc4;
}
.pop.big {
    font-size: 3rem;
    color: var(--sun);
}
@keyframes pop {
    0% {
        opacity: 0;
        transform: translateY(0.8rem) scale(0.6);
    }
    15% {
        opacity: 1;
        transform: translateY(0) scale(1.15);
    }
    30% {
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-3.6rem) scale(1);
    }
}

/* ---------- wide screens: game goes to three columns ---------- */
@media (min-aspect-ratio: 5/4) {
    .plate.big {
        --k: 0.82;
    }
    #game.active {
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-columns: minmax(0, 1fr) var(--bw, 24rem) minmax(0, 1fr);
        column-gap: 1.4rem;
        row-gap: 0;
    }
    .g-top,
    .g-bot {
        display: contents;
    }
    .info {
        grid-column: 1;
        grid-row: 1;
        justify-self: end;
        width: var(--pw, 18rem);
    }
    .g-btns {
        display: flex;
        grid-column: 3;
        grid-row: 1;
        justify-self: start;
        width: var(--pw, 18rem);
        gap: 0.8rem;
    }
    .g-btns {
        align-self: start;
    }
    .g-btns .btn.round {
        flex: 1;
        width: auto;
    }
    .steer {
        grid-column: 1;
        grid-row: 3;
        justify-self: end;
        width: var(--pw, 18rem);
    }
    .pedals {
        grid-column: 3;
        grid-row: 3;
        justify-self: start;
        width: var(--pw, 18rem);
    }
    .steer .pad,
    .pedals .pad {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }
    .pedals .pad.wide {
        flex: 1.35 1 0;
    }
    #game .mid {
        grid-column: 2;
        grid-row: 1/4;
    }
    .dock {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 76rem;
        justify-content: center;
        gap: 1rem;
        align-items: stretch;
    }
    .dock .paint-wrap {
        flex: 0 0 100%;
    }
    .dock .btn.xl {
        width: auto;
        flex: 1 1 24rem;
    }
    .dock .row3 {
        flex: 1.5 1 36rem;
        width: auto;
    }
    .row3 .btn {
        flex-direction: row;
        gap: 0.8rem;
        min-height: 5.8rem;
        font-size: 1.5rem;
    }
    .row3 .btn span {
        align-items: flex-start;
    }
    .lv-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        max-height: 30rem;
    }
    .coach {
        top: -0.3rem;
    }
    .stars3 img {
        width: 1.5rem;
        height: 1.5rem;
    }
    .timer strong {
        font-size: 2.2rem;
    }
    .timer img {
        width: 1.8rem;
        height: 1.8rem;
    }
    .info {
        padding: 0.6rem 0.8rem 0.7rem;
    }
    .i-top b {
        font-size: 1.5rem;
    }
}
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
    .plate.big {
        --k: 0.7;
    }
    .tagline {
        font-size: 1.3rem;
        margin-top: 0.5rem;
    }
    .btn.xl,
    .dock .btn.xl,
    .row3 .btn {
        min-height: 4.8rem;
    }
    .btn.xl {
        font-size: 2rem;
    }
    .dock {
        gap: 0.6rem;
    }
    .paint {
        padding: 0.3rem 0.7rem;
    }
    .sw {
        width: 2.1rem;
        height: 2.1rem;
    }
    .lv-grid {
        max-height: 20rem;
    }
    .bar h2 {
        font-size: 2rem;
    }
    .world-card {
        padding: 0.4rem 0.7rem;
    }
    .w-info h3 {
        font-size: 1.7rem;
    }
    .w-info p {
        display: none;
    }
    .pad {
        height: 4.6rem;
    }
    .info {
        padding: 0.5rem 0.8rem 0.6rem;
        gap: 0.35rem;
    }
    .timer strong {
        font-size: 2.1rem;
    }
}

/* ---------- dialogs ---------- */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.4rem;
    background: rgba(10, 14, 70, 0.55);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.25s,
        visibility 0s 0.25s;
    z-index: 20;
    overflow: hidden;
}
.modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.25s;
}
.dlg {
    width: min(100%, 28rem);
    max-height: calc(100% - 1rem);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 3.2rem 1.4rem 1.4rem;
    overflow: visible;
    animation: dlg 0.3s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.modal:not(.show) .dlg {
    animation: none;
}
@keyframes dlg {
    from {
        opacity: 0;
        scale: 0.9;
    }
}
.dlg .btn {
    pointer-events: auto;
}
.ribbon {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: max-content;
    top: -1.7rem;
    white-space: nowrap;
    padding: 0.6rem 2rem;
    border-radius: 1.1rem;
    font-family: var(--hd);
    font-size: 1.8rem;
    letter-spacing: 0.04em;
    color: #fff;
    background: linear-gradient(180deg, #ff9b52, #ff6a2b);
    border: 0.22rem solid #fff;
    box-shadow:
        0 0.4rem 0 #b83a05,
        0 0.9rem 1.2rem rgba(10, 14, 70, 0.35);
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.3);
    z-index: 2;
}
.ribbon.bad {
    background: linear-gradient(180deg, #ff8a9c, #f23d5e);
    box-shadow:
        0 0.4rem 0 #a01634,
        0 0.9rem 1.2rem rgba(10, 14, 70, 0.35);
}
.dlg h3 {
    font-family: var(--hd);
    font-weight: 400;
    text-align: center;
    font-size: 2.1rem;
    line-height: 1.1;
    color: var(--ink);
}
.msg {
    text-align: center;
    font-weight: 700;
    font-size: 1.35rem;
    color: #3c4382;
}
.stars {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}
.stars img {
    width: 5rem;
    height: 5rem;
}
.stars img.on {
    animation: starpop 0.55s cubic-bezier(0.3, 1.8, 0.5, 1) both;
}
.stars img:nth-child(2).on {
    animation-delay: 0.25s;
}
.stars img:nth-child(3).on {
    animation-delay: 0.5s;
}
@keyframes starpop {
    from {
        scale: 0;
        rotate: -120deg;
    }
}
.facts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}
.facts div {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.3rem;
    border-radius: 1rem;
    background: var(--paper2);
    border: 0.14rem dashed rgba(28, 33, 80, 0.4);
}
.facts small {
    font-size: 1.1rem;
    font-weight: 700;
    opacity: 0.75;
}
.facts b {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 1.8rem;
}
.row2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.7rem;
}
.row2 .btn {
    font-size: 1.3rem;
    gap: 0.5rem;
    padding: 0 0.6rem;
    min-width: 0;
}
.row2 .btn img {
    width: 2rem;
    height: 2rem;
}
.how {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
}
.how li {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.22;
    color: var(--ink);
}
.how b {
    color: #d4470a;
}
.how .n {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--orange);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: normal;
    font-family: var(--hd);
    font-size: 1.4rem;
    box-shadow: 0 0.2rem 0 #b83a05;
}
.set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1.4rem;
    color: var(--ink);
}
.set-row span {
    display: flex;
    flex-direction: column;
}
.set-row small {
    font-size: 1.1rem;
    opacity: 0.75;
    font-weight: 500;
}
.switch {
    flex: none;
    position: relative;
    width: 5.2rem;
    height: 3rem;
    border-radius: 2rem;
    background: #a7aed8;
    box-shadow:
        inset 0 0.2rem 0.4rem rgba(0, 0, 0, 0.3),
        0 0 0 0.16rem var(--ink);
    transition: background 0.2s;
    pointer-events: auto;
}
.switch i {
    position: absolute;
    left: 0.3rem;
    top: 0.3rem;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0.2rem 0.3rem rgba(0, 0, 0, 0.35);
    transition: left 0.2s;
}
.switch.on {
    background: #22b95c;
}
.switch.on i {
    left: 2.5rem;
}
.ver-line {
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.65;
    color: var(--ink);
}
@media (min-aspect-ratio: 5/4) {
    .dlg {
        padding-top: 3rem;
        gap: 0.6rem;
    }
    .how {
        gap: 0.5rem;
    }
    .how li {
        font-size: 1.2rem;
    }
    .how .n {
        width: 2.2rem;
        height: 2.2rem;
    }
}
@media (max-height: 640px) {
    .dlg {
        padding: 3rem 1.3rem 1.2rem;
        gap: 0.55rem;
    }
    .how {
        gap: 0.45rem;
    }
    .how li {
        font-size: 1.15rem;
        line-height: 1.15;
    }
    .how .n {
        width: 2.1rem;
        height: 2.1rem;
        font-size: 1.2rem;
    }
    .ribbon {
        font-size: 1.6rem;
        padding: 0.5rem 1.6rem;
    }
    .btn.wide {
        min-height: 3.8rem;
    }
    .stars img {
        width: 4rem;
        height: 4rem;
    }
    .dlg h3 {
        font-size: 1.8rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- small-screen safety ---------- */
@media (max-width: 360px) {
    .plate.big {
        --k: 0.9;
    }
    .i-top b {
        font-size: 1.45rem;
    }
    .timer strong {
        font-size: 2.2rem;
    }
    .stars3 img {
        width: 1.5rem;
        height: 1.5rem;
    }
    .tagline {
        font-size: 1.3rem;
    }
    .pad {
        width: 5rem;
        height: 5rem;
    }
    .pad.wide {
        width: 6.2rem;
    }
    .btn.round {
        width: 4rem;
        min-height: 4rem;
    }
    .bar h2 {
        font-size: 1.9rem;
    }
    .w-info h3 {
        font-size: 1.7rem;
    }
}
@media (max-width: 600px) and (max-aspect-ratio: 5/4) {
    .ver {
        display: none;
    }
}
