/* Parking Jam 3D - "road trip" interface: glossy candy buttons with a solid edge, navy glass panels, a green highway sign for the title,
   level tiles drawn as parking bays. 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: "PJ Display";
    src: url(../assets/fonts/lilita-one-latin-400-normal.woff2) format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "PJ Text";
    src: url(../assets/fonts/nunito-latin-700-normal.woff2) format("woff2");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "PJ Text";
    src: url(../assets/fonts/nunito-latin-900-normal.woff2) format("woff2");
    font-weight: 900;
    font-display: swap;
}

:root {
    --ink: #10194a;
    --navy: #17256b;
    --navy2: #2a3f9c;
    --paper: #ffffff;
    --yellow: #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: "PJ Display", "Impact", "Arial Black", sans-serif;
    --bd: "PJ 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: #2f9bff;
}
body {
    height: 100%;
    overflow: hidden;
    font-family: var(--bd);
    font-weight: 900;
    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;
}
.outl {
    text-shadow:
        0 0.14rem 0 rgba(10, 20, 80, 0.8),
        0 0 0.5rem rgba(10, 20, 80, 0.45);
}

/* ---------- 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 .panel,
.screen .chip,
.screen .sign {
    pointer-events: auto;
}
/* menu + game share one grid: portrait = top panel, free middle (the lot), bottom panel. wide game = left panel, lot, right panel */
#menu.active,
#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: glossy candy with a solid bottom edge ---------- */
.btn {
    --l: #8ff0b0;
    --b: #22c765;
    --d: #0e8a41;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    min-height: 4.8rem;
    padding: 0 1.4rem;
    border-radius: 1.5rem;
    color: #fff;
    font-family: var(--hd);
    font-size: 1.7rem;
    letter-spacing: 0.03em;
    line-height: 1;
    background: linear-gradient(180deg, var(--l), var(--b) 62%);
    box-shadow:
        0 0.42rem 0 var(--d),
        0 0.9rem 1.1rem rgba(8, 16, 70, 0.35),
        inset 0 0.14rem 0 rgba(255, 255, 255, 0.65),
        inset 0 -0.2rem 0.3rem rgba(0, 0, 0, 0.12);
    text-shadow: 0 0.12rem 0 rgba(0, 0, 0, 0.28);
    transition:
        transform 0.1s,
        box-shadow 0.1s,
        filter 0.15s;
    pointer-events: auto;
    cursor: pointer;
}
.btn img {
    width: 2.5rem;
    height: 2.5rem;
    flex: none;
}
.btn span {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}
.btn small {
    font-family: var(--bd);
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 0;
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.25);
    opacity: 0.95;
}
.btn:active {
    transform: translateY(0.34rem);
    box-shadow:
        0 0.08rem 0 var(--d),
        0 0.2rem 0.4rem rgba(8, 16, 70, 0.3),
        inset 0 0.14rem 0 rgba(255, 255, 255, 0.5);
}
@media (hover: hover) {
    .btn:not(:disabled):hover {
        transform: translateY(-0.14rem);
        filter: brightness(1.06);
    }
    .btn:not(:disabled):hover:active {
        transform: translateY(0.34rem);
    }
}
.btn:focus-visible,
.tile:focus-visible,
.switch:focus-visible {
    outline: 0.3rem solid #fff;
    outline-offset: 0.25rem;
}
.btn:disabled {
    filter: grayscale(1) brightness(1.05);
    opacity: 0.55;
    pointer-events: none;
}
.b-green {
    --l: #8ff0b0;
    --b: #22c765;
    --d: #0e8a41;
}
.b-blue {
    --l: #8fd0ff;
    --b: #2f8bff;
    --d: #1650b8;
}
.b-violet {
    --l: #d3b4ff;
    --b: #8a55f0;
    --d: #4d26a6;
}
.b-teal {
    --l: #8cf0e6;
    --b: #12bfb0;
    --d: #08796f;
}
.b-red {
    --l: #ffa9b6;
    --b: #ff4565;
    --d: #a81c3a;
}
.b-yellow {
    --l: #ffe98a;
    --b: #ffb81f;
    --d: #bf7a00;
    color: #4a2a00;
    text-shadow: 0 0.1rem 0 rgba(255, 255, 255, 0.55);
}
.b-yellow small {
    text-shadow: 0 0.1rem 0 rgba(255, 255, 255, 0.5);
}
.b-glass {
    --l: rgba(255, 255, 255, 0.95);
    --b: #c6dcff;
    --d: #6d8ad0;
    color: var(--navy);
    text-shadow: none;
}
.b-glassdark {
    --l: #6b7fd6;
    --b: #4258b8;
    --d: #232f78;
}
.btn.round {
    width: 4.8rem;
    min-height: 4.8rem;
    padding: 0;
    border-radius: 1.6rem;
}
.btn.round img {
    width: 2.7rem;
    height: 2.7rem;
}
.b-glass img {
    filter: drop-shadow(0 0.1rem 0 rgba(255, 255, 255, 0.4)) brightness(0) saturate(100%) invert(14%) sepia(53%) saturate(2930%)
        hue-rotate(222deg) brightness(92%);
}
.btn.wide {
    width: 100%;
}
.btn.small {
    min-height: 3.6rem;
    font-size: 1.3rem;
    padding: 0 1.2rem;
    border-radius: 1.2rem;
}
.btn.xl {
    min-height: 7.4rem;
    font-size: 2.7rem;
    gap: 1.1rem;
    border-radius: 2rem;
    width: 100%;
    box-shadow:
        0 0.55rem 0 var(--d),
        0 1.1rem 1.5rem rgba(8, 16, 70, 0.38),
        inset 0 0.16rem 0 rgba(255, 255, 255, 0.7),
        inset 0 -0.25rem 0.4rem rgba(0, 0, 0, 0.12);
}
.btn.xl img {
    width: 3.8rem;
    height: 3.8rem;
}
.btn.xl small {
    font-size: 1.4rem;
}

/* ---------- panels, chips ---------- */
.panel {
    position: relative;
    border-radius: 1.8rem;
    background: linear-gradient(180deg, rgba(48, 72, 160, 0.95), rgba(24, 38, 108, 0.96));
    border: 0.2rem solid rgba(255, 255, 255, 0.55);
    box-shadow:
        0 0.5rem 0 rgba(8, 14, 60, 0.5),
        0 1.1rem 1.8rem rgba(8, 14, 60, 0.35),
        inset 0 0.16rem 0 rgba(255, 255, 255, 0.28);
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1.3rem 0.5rem 0.8rem;
    border-radius: 2rem;
    background: rgba(20, 32, 100, 0.8);
    border: 0.16rem solid rgba(255, 255, 255, 0.5);
    font-family: var(--hd);
    font-size: 1.7rem;
    box-shadow: 0 0.3rem 0 rgba(8, 14, 60, 0.45);
}
.chip img {
    width: 2.4rem;
    height: 2.4rem;
}
.chip.small {
    font-size: 1.5rem;
    padding: 0.35rem 1rem 0.35rem 0.6rem;
}
.chip.small img {
    width: 2rem;
    height: 2rem;
}

/* ---------- the highway sign (title) ---------- */
.sign {
    --k: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(1.1rem * var(--k));
    padding: calc(0.9rem * var(--k)) calc(1.8rem * var(--k)) calc(0.9rem * var(--k)) calc(0.9rem * var(--k));
    border-radius: calc(1.7rem * var(--k));
    background: linear-gradient(180deg, #17b36a, #0b7e4b);
    border: calc(0.34rem * var(--k)) solid #fff;
    box-shadow:
        0 0 0 calc(0.2rem * var(--k)) #08603a,
        0 calc(0.55rem * var(--k)) 0 calc(0.2rem * var(--k)) #08603a,
        0 1.3rem 1.8rem rgba(0, 20, 60, 0.4);
}
.sign.big {
    --k: 1;
}
.pbadge {
    flex: none;
    width: calc(6.4rem * var(--k));
    height: calc(6.4rem * var(--k));
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: calc(1.3rem * var(--k));
    background: linear-gradient(180deg, #58b0ff, #2a7df0);
    border: calc(0.28rem * var(--k)) solid #fff;
    font: normal 400 calc(4.8rem * var(--k))/1 var(--hd);
    color: #fff;
    text-shadow: 0 0.2rem 0 #153f99;
    box-shadow: inset 0 0.14rem 0 rgba(255, 255, 255, 0.55);
}
.st {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 0.95;
}
.st .s1 {
    font-family: var(--hd);
    font-size: calc(2.6rem * var(--k));
    letter-spacing: 0.08em;
    color: #fff;
    text-shadow: 0 0.18rem 0 #08603a;
}
.st .s2 {
    display: flex;
    align-items: center;
    gap: calc(0.7rem * var(--k));
    font-family: var(--hd);
    font-size: calc(4.6rem * var(--k));
    letter-spacing: 0.04em;
    color: var(--yellow);
    text-shadow:
        0 0.24rem 0 #b66a00,
        0 0.4rem 0 #08603a;
}
.st em {
    font-style: normal;
    font-size: calc(1.6rem * var(--k));
    padding: calc(0.3rem * var(--k)) calc(0.8rem * var(--k));
    border-radius: calc(0.8rem * var(--k));
    background: #ff5a3d;
    color: #fff;
    border: calc(0.16rem * var(--k)) solid #fff;
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.3);
    letter-spacing: 0.04em;
}
.tagline {
    margin-top: 1rem;
    text-align: center;
    font-size: 1.7rem;
    color: #fff;
    text-shadow:
        0 0.14rem 0 rgba(10, 20, 80, 0.8),
        0 0 0.6rem rgba(10, 20, 80, 0.55);
}

/* ---------- loading ---------- */
#loader {
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #46b8ff, #cdeeff 70%, #92e07a);
    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: #4a5a99;
    border: 0.2rem solid #fff;
    box-shadow: 0 0.3rem 0 rgba(8, 14, 60, 0.35);
}
.ld-road::before {
    content: "";
    position: absolute;
    left: 0.8rem;
    right: 0.8rem;
    top: 50%;
    height: 0.2rem;
    translate: 0 -50%;
    background: repeating-linear-gradient(90deg, #fff 0 1rem, transparent 1rem 1.8rem);
    opacity: 0.75;
}
.ld-road i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-radius: 1rem;
    background: linear-gradient(180deg, #ffe98a, #ffb81f);
    transition: width 0.2s;
}
.ld-road img {
    position: absolute;
    top: 50%;
    left: 0;
    height: 3.6rem;
    width: auto;
    translate: -50% -50%;
    transition: left 0.2s;
}
.ld-txt {
    color: #fff;
    font-size: 1.6rem;
    text-shadow: 0 0.14rem 0 rgba(10, 20, 80, 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: 1rem;
    max-width: 36rem;
}
.dock .chip {
    order: -1;
}
.row3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    width: 100%;
}
.row3 .btn {
    flex-direction: column;
    gap: 0.45rem;
    min-height: 6.6rem;
    padding: 0.7rem 0.4rem;
    font-size: 1.4rem;
}
.row3 .btn span {
    align-items: center;
}
.row3 .btn img {
    width: 2.7rem;
    height: 2.7rem;
}
.ver {
    position: absolute;
    right: calc(var(--sar) + 1rem);
    bottom: calc(var(--sab) + 0.4rem);
    font-size: 1.1rem;
    opacity: 0.7;
    pointer-events: none;
    text-shadow: 0 0.1rem 0 rgba(10, 20, 80, 0.8);
}

/* ---------- level select ---------- */
#levels.active {
    flex-direction: column;
    gap: 0.9rem;
    align-items: center;
    pointer-events: auto;
    background: linear-gradient(180deg, var(--s0, #5ec8ff) 0, var(--s1, #d9f4ff) 38%, var(--g, #8ee06a) 38.1%, var(--g, #8ee06a) 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.12) 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.7rem;
    color: #fff;
    text-shadow:
        0 0.16rem 0 rgba(10, 20, 80, 0.85),
        0 0 0.6rem rgba(10, 20, 80, 0.5);
}
.world-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 1.8rem;
    background: linear-gradient(180deg, rgba(48, 72, 160, 0.95), rgba(24, 38, 108, 0.96));
    border: 0.2rem solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 0.4rem 0 rgba(8, 14, 60, 0.5);
}
.w-info {
    flex: 1;
    min-width: 0;
    text-align: center;
}
.w-info small {
    font-size: 1.2rem;
    opacity: 0.85;
}
.w-info h3 {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 2.2rem;
    line-height: 1.1;
    white-space: nowrap;
    color: var(--yellow);
    text-shadow: 0 0.14rem 0 rgba(0, 0, 0, 0.35);
}
.w-info p {
    font-size: 1.1rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.arrow {
    width: 4.6rem;
    min-height: 4.6rem;
}
.arrow img {
    width: 2.2rem;
    height: 2.2rem;
}
.dots {
    display: flex;
    justify-content: center;
    gap: 0.7rem;
}
.dots i {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 0.12rem 0 rgba(8, 14, 60, 0.5);
}
.dots i.on {
    width: 2.6rem;
    border-radius: 1rem;
    background: var(--yellow);
}
.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.2rem;
}
.tile {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 1.3rem;
    background: linear-gradient(180deg, #5b6aa8, #47558f);
    box-shadow:
        0 0.38rem 0 #232f6a,
        0 0.8rem 1rem rgba(8, 14, 60, 0.3);
    color: #fff;
    overflow: hidden;
    pointer-events: auto;
    transition: transform 0.1s;
}
.tile::before,
.tile::after {
    content: "";
    position: absolute;
    left: 0.7rem;
    right: 0.7rem;
    height: 0.28rem;
    border-radius: 0.2rem;
    background: rgba(255, 255, 255, 0.85);
}
.tile::before {
    top: 0.55rem;
}
.tile::after {
    bottom: 0.55rem;
}
.tile:active {
    transform: translateY(0.3rem);
}
.tile .no {
    position: absolute;
    left: 1.1rem;
    top: 1.2rem;
    font-family: var(--hd);
    font-size: 2.9rem;
    line-height: 1;
    text-shadow: 0 0.16rem 0 rgba(10, 20, 80, 0.55);
}
.tile .ts {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    display: flex;
    gap: 0.1rem;
}
.tile .ts img {
    width: 1.55rem;
    height: 1.55rem;
}
.tile .pc {
    position: absolute;
    right: 0.7rem;
    top: 50%;
    translate: 0 -50%;
    width: 48%;
    max-width: 7.6rem;
    height: auto;
}
.tile.new {
    background: linear-gradient(180deg, #ffd75a, #f5a815);
    box-shadow:
        0 0.38rem 0 #a86a00,
        0 0.8rem 1rem rgba(8, 14, 60, 0.3);
    color: #4a2a00;
    animation: pulse 1.4s ease-in-out infinite;
}
.tile.new .no {
    top: 50%;
    translate: 0 -50%;
    text-shadow: 0 0.1rem 0 rgba(255, 255, 255, 0.5);
}
.tile.new .pc {
    display: none;
}
.tile.new .go {
    position: absolute;
    right: 1rem;
    top: 50%;
    translate: 0 -50%;
    width: 2.6rem;
    height: 2.6rem;
}
@keyframes pulse {
    50% {
        transform: scale(1.03);
    }
}
.tile.lock {
    background: repeating-linear-gradient(135deg, #4a5578 0 1.2rem, #3b4566 1.2rem 2.4rem);
    box-shadow: 0 0.38rem 0 #1c2552;
}
.tile.lock::before,
.tile.lock::after {
    display: none;
}
.tile.lock .no {
    opacity: 0.55;
    top: 50%;
    translate: 0 -50%;
}
.tile.lock .lk {
    position: absolute;
    right: 1.1rem;
    top: 50%;
    translate: 0 -50%;
    width: 2.8rem;
    height: 2.8rem;
    opacity: 0.85;
}
.tile.lock .pc,
.tile.lock .ts {
    display: none;
}

/* ---------- game HUD ---------- */
.hud {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.8rem;
}
.info {
    padding: 0.8rem 0.9rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.i-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
}
.i-top b {
    white-space: nowrap;
}
.i-top b {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 1.7rem;
    letter-spacing: 0.04em;
    color: var(--yellow);
    text-shadow: 0 0.12rem 0 rgba(0, 0, 0, 0.35);
}
.i-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}
.timer {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.timer img {
    width: 2.3rem;
    height: 2.3rem;
}
.timer strong {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 2.8rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    min-width: 3.6rem;
    text-shadow: 0 0.16rem 0 rgba(0, 0, 0, 0.35);
}
.stars3 {
    display: flex;
    gap: 0.15rem;
}
.stars3 img {
    width: 1.9rem;
    height: 1.9rem;
    transition:
        opacity 0.2s,
        filter 0.2s,
        scale 0.2s;
}
.stars3 img.off {
    opacity: 0.9;
    filter: none;
}
.i-main small {
    font-size: 1.15rem;
    opacity: 0.9;
    font-weight: 900;
    text-align: right;
    line-height: 1.1;
}
.left-bar {
    position: relative;
    height: 1.9rem;
    border-radius: 1rem;
    background: rgba(7, 14, 60, 0.6);
    overflow: hidden;
    border: 0.14rem solid rgba(255, 255, 255, 0.35);
}
.left-bar i {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-radius: 1rem;
    background: linear-gradient(180deg, #8ff0b0, #22c765);
    transition: width 0.25s;
}
.left-bar span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.5);
}
.coach {
    position: absolute;
    left: 50%;
    bottom: 0.4rem;
    translate: -50% 0;
    display: flex;
    gap: 0.6rem;
    transition: opacity 0.4s;
    white-space: nowrap;
}
.coach span {
    display: flex;
    align-items: center;
    padding: 0.5rem 1.2rem;
    border-radius: 1.6rem;
    background: rgba(14, 24, 90, 0.82);
    border: 0.16rem solid rgba(255, 255, 255, 0.5);
    font-size: 1.35rem;
}
.coach span b {
    color: var(--yellow);
    margin: 0 0.3rem;
}
.coach.hide {
    opacity: 0;
}
.btn .lbl {
    display: none;
}
.controls {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.9rem;
    align-items: stretch;
}
.controls .btn.round {
    width: 7rem;
    min-height: 7rem;
    border-radius: 2rem;
}
.controls .btn.round img {
    width: 3.4rem;
    height: 3.4rem;
}
.hint {
    min-height: 7rem;
    font-size: 2.4rem;
    border-radius: 2rem;
    gap: 1.1rem;
}
.hint img {
    width: 3.6rem;
    height: 3.6rem;
}
.hint small {
    font-size: 1.25rem;
}

/* 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.6rem;
    color: #fff;
    white-space: nowrap;
    text-shadow:
        0 0.16rem 0 rgba(10, 20, 80, 0.9),
        0 0 0.5rem rgba(10, 20, 80, 0.5);
    animation: pop 0.95s ease-out both;
}
.pop.bad {
    color: #ff7d8c;
}
.pop.good {
    color: #a8ffc4;
}
.pop.big {
    font-size: 3.4rem;
    color: var(--yellow);
}
@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) {
    .sign.big {
        --k: 0.82;
    }
    #game.active {
        grid-template-rows: 1fr;
        grid-template-columns: minmax(0, 1fr) var(--bw, 24rem) minmax(0, 1fr);
        align-items: center;
        column-gap: 1.4rem;
    }
    #game .side-l {
        grid-column: 1;
        grid-row: 1;
        justify-self: end;
        width: var(--pw, 20rem);
        max-width: none;
    }
    #game .mid {
        grid-column: 2;
        grid-row: 1;
        align-self: stretch;
    }
    #game .side-r {
        grid-column: 3;
        grid-row: 1;
        justify-self: start;
        width: var(--pw, 20rem);
        max-width: none;
    }
    .hud {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "info info" "pa sa";
        gap: 0.9rem;
    }
    .hud .info {
        grid-area: info;
    }
    .hud #pauseBtn {
        grid-area: pa;
        width: 100%;
    }
    .hud #soundBtn {
        grid-area: sa;
        width: 100%;
    }
    .info {
        padding: 1rem 1.2rem 1.1rem;
        gap: 0.7rem;
    }
    .controls {
        grid-template-columns: 1fr;
        gap: 0.9rem;
    }
    .controls .btn.round {
        width: 100%;
        min-height: 5.4rem;
        border-radius: 1.8rem;
        gap: 0.8rem;
    }
    .controls .btn .lbl {
        display: block;
        font-size: 1.7rem;
    }
    .hint {
        min-height: 9rem;
        font-size: 2.8rem;
    }
    .hint img {
        width: 4.4rem;
        height: 4.4rem;
    }
    #restartBtn {
        order: 2;
    }
    /* menu keeps rows: sign on top, buttons in one wide row at the bottom */
    .dock {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 76rem;
        justify-content: center;
        gap: 1.1rem;
        align-items: stretch;
    }
    .dock .btn.xl {
        width: auto;
        flex: 1 1 24rem;
        min-height: 7.4rem;
    }
    .dock .row3 {
        flex: 1.5 1 36rem;
        width: auto;
    }
    .row3 .btn {
        flex-direction: row;
        gap: 0.9rem;
        min-height: 7.4rem;
        font-size: 1.7rem;
    }
    .dock .chip {
        position: absolute;
        right: calc(var(--sar) + 1.4rem);
        top: calc(var(--sat) + 1.2rem);
        order: 0;
    }
    .lv-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        max-height: 30rem;
    }
    .coach {
        bottom: -0.5rem;
    }
}
@media (max-height: 520px) {
    .sign.big {
        --k: 0.95;
    }
    .tagline {
        font-size: 1.4rem;
        margin-top: 0.6rem;
    }
    .btn.xl,
    .dock .btn.xl,
    .row3 .btn {
        min-height: 5.4rem;
    }
    .btn.xl {
        font-size: 2.2rem;
    }
    .controls .btn.round,
    .hint {
        min-height: 5rem;
    }
    .hint {
        font-size: 2.2rem;
    }
    .lv-grid {
        max-height: 20rem;
    }
    .bar h2 {
        font-size: 2.2rem;
    }
    .world-card {
        padding: 0.5rem 0.8rem;
    }
    .w-info h3 {
        font-size: 1.9rem;
    }
    .w-info p {
        display: none;
    }
    .info {
        gap: 0.4rem;
        padding: 0.7rem 1rem;
    }
    .timer strong {
        font-size: 2.8rem;
    }
    .i-main {
        gap: 0.4rem;
    }
}

/* ---------- dialogs ---------- */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.4rem;
    background: rgba(8, 16, 70, 0.55);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.25s,
        visibility 0s 0.25s;
    z-index: 20;
}
.modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.25s;
}
.dlg {
    width: min(100%, 31rem);
    max-height: calc(100% - 1rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 3.6rem 1.6rem 1.7rem;
    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: 50%;
    top: -1.8rem;
    translate: -50% 0;
    white-space: nowrap;
    padding: 0.75rem 2.4rem;
    border-radius: 1.2rem;
    font-family: var(--hd);
    font-size: 2.1rem;
    letter-spacing: 0.04em;
    color: #4a2a00;
    background: linear-gradient(180deg, #ffe98a, #ffb81f);
    border: 0.22rem solid #fff;
    box-shadow:
        0 0.4rem 0 #bf7a00,
        0 0.9rem 1.2rem rgba(8, 14, 60, 0.35);
    text-shadow: 0 0.1rem 0 rgba(255, 255, 255, 0.5);
    z-index: 2;
}
.ribbon.bad {
    color: #fff;
    background: linear-gradient(180deg, #ff9aa8, #ff4565);
    box-shadow:
        0 0.4rem 0 #a81c3a,
        0 0.9rem 1.2rem rgba(8, 14, 60, 0.35);
    text-shadow: 0 0.1rem 0 rgba(0, 0, 0, 0.3);
}
.dlg h3 {
    font-family: var(--hd);
    font-weight: 400;
    text-align: center;
    font-size: 2.4rem;
    line-height: 1.1;
    text-shadow: 0 0.14rem 0 rgba(0, 0, 0, 0.35);
}
.msg {
    text-align: center;
    font-weight: 900;
    font-size: 1.5rem;
    color: #d9e4ff;
}
.stars {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}
.stars img {
    width: 6rem;
    height: 6rem;
}
.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.7rem;
}
.facts div {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 0.3rem;
    border-radius: 1.1rem;
    background: rgba(5, 12, 60, 0.55);
    border: 0.14rem solid rgba(255, 255, 255, 0.35);
}
.facts small {
    font-size: 1.1rem;
    font-weight: 900;
    opacity: 0.8;
}
.facts b {
    font-family: var(--hd);
    font-weight: 400;
    font-size: 2.1rem;
}
.row2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.8rem;
}
.row2 .btn {
    font-size: 1.45rem;
    gap: 0.5rem;
    padding: 0 0.6rem;
    min-width: 0;
}
.row2 .btn img {
    width: 2.1rem;
    height: 2.1rem;
}
.how {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0;
}
.how li {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    font-size: 1.45rem;
    font-weight: 900;
    line-height: 1.22;
}
.how b {
    color: var(--yellow);
}
.how .n {
    flex: none;
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 50%;
    background: var(--yellow);
    color: #4a2a00;
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: normal;
    font-family: var(--hd);
    font-size: 1.5rem;
    box-shadow: 0 0.2rem 0 #bf7a00;
}
.set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1.6rem;
}
.set-row span {
    display: flex;
    flex-direction: column;
}
.set-row small {
    font-size: 1.1rem;
    opacity: 0.8;
    font-weight: 700;
}
.switch {
    flex: none;
    position: relative;
    width: 5.4rem;
    height: 3.1rem;
    border-radius: 2rem;
    background: #4a5aa8;
    box-shadow:
        inset 0 0.2rem 0.4rem rgba(0, 0, 0, 0.35),
        0 0 0 0.16rem rgba(255, 255, 255, 0.45);
    transition: background 0.2s;
    pointer-events: auto;
}
.switch i {
    position: absolute;
    left: 0.3rem;
    top: 0.3rem;
    width: 2.5rem;
    height: 2.5rem;
    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: #22c765;
}
.switch.on i {
    left: 2.6rem;
}
.ver-line {
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.7;
}
@media (min-aspect-ratio: 5/4) {
    .dlg {
        padding-top: 3.2rem;
        gap: 0.8rem;
    }
    .how {
        gap: 0.55rem;
    }
    .how li {
        font-size: 1.3rem;
    }
    .how .n {
        width: 2.3rem;
        height: 2.3rem;
    }
}
@media (max-height: 520px) {
    .dlg {
        padding: 3rem 1.4rem 1.2rem;
        gap: 0.7rem;
    }
    .how {
        gap: 0.5rem;
    }
    .how li {
        font-size: 1.25rem;
    }
    .stars img {
        width: 4.4rem;
        height: 4.4rem;
    }
    .btn {
        min-height: 4rem;
    }
    .dlg h3 {
        font-size: 1.9rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- small-screen safety (v1.0.1) ---- */
.info {
    min-width: 0;
    overflow: hidden;
}
.i-top {
    justify-content: space-between;
}
.i-top small {
    font-size: 1.15rem;
    opacity: 0.9;
    white-space: nowrap;
}
.i-main {
    min-width: 0;
}
.timer strong {
    min-width: 0;
}
.stars3 img {
    width: 1.8rem;
    height: 1.8rem;
}
.bar h2 {
    white-space: nowrap;
    font-size: 2.3rem;
}
.w-info h3 {
    font-size: 1.9rem;
}
.arrow {
    flex: none;
}
@media (max-width: 600px) and (max-aspect-ratio: 5/4) {
    .ver {
        display: none;
    }
}
@media (max-width: 360px) {
    .i-top b {
        font-size: 1.5rem;
    }
    .timer strong {
        font-size: 2.4rem;
    }
    .stars3 img {
        width: 1.6rem;
        height: 1.6rem;
    }
    .bar h2 {
        font-size: 2rem;
    }
    .w-info h3 {
        font-size: 1.7rem;
    }
    .tagline {
        font-size: 1.5rem;
    }
    .btn.round {
        width: 4.4rem;
        min-height: 4.4rem;
    }
}
.i-main {
    gap: 0.4rem;
}
.timer {
    gap: 0.35rem;
}
.stars3 {
    gap: 0;
    flex: none;
}
@media (max-width: 440px) and (max-aspect-ratio: 5/4) {
    .timer strong {
        font-size: 2.3rem;
    }
    .timer img {
        width: 1.9rem;
        height: 1.9rem;
    }
    .stars3 img {
        width: 1.4rem;
        height: 1.4rem;
    }
    .hud {
        gap: 0.5rem;
    }
}
@media (max-height: 640px) {
    .dlg {
        padding: 3rem 1.3rem 1.2rem;
        gap: 0.6rem;
    }
    .how {
        gap: 0.45rem;
    }
    .how li {
        font-size: 1.2rem;
        line-height: 1.15;
    }
    .how .n {
        width: 2.1rem;
        height: 2.1rem;
        font-size: 1.2rem;
    }
    .ribbon {
        font-size: 1.8rem;
        padding: 0.55rem 1.8rem;
    }
    .btn.wide {
        min-height: 4.2rem;
    }
}

/* ---- v1.0.2: smaller buttons and text so the board stays big and nothing is cut ---- */
.btn {
    min-height: 4.1rem;
    font-size: 1.5rem;
    padding: 0 1.1rem;
    border-radius: 1.3rem;
    gap: 0.55rem;
}
.btn img {
    width: 2.1rem;
    height: 2.1rem;
}
.btn small {
    font-size: 1.05rem;
}
.btn.round {
    width: 4.2rem;
    min-height: 4.2rem;
    border-radius: 1.4rem;
}
.btn.round img {
    width: 2.2rem;
    height: 2.2rem;
}
.btn.xl {
    min-height: 5.8rem;
    font-size: 2.3rem;
}
.btn.xl img {
    width: 3.2rem;
    height: 3.2rem;
}
.btn.xl small {
    font-size: 1.2rem;
}
.row3 .btn {
    min-height: 5.4rem;
    font-size: 1.25rem;
}
.row3 .btn img {
    width: 2.3rem;
    height: 2.3rem;
}
.controls .btn.round {
    width: 5.6rem;
    min-height: 5.6rem;
}
.controls .btn.round img {
    width: 2.8rem;
    height: 2.8rem;
}
.hint {
    min-height: 5.6rem;
    font-size: 2rem;
    gap: 0.9rem;
}
.hint img {
    width: 3rem;
    height: 3rem;
}
.hint small {
    font-size: 1.1rem;
}
.dlg {
    width: min(100%, 28rem);
    gap: 0.8rem;
    padding: 3.2rem 1.4rem 1.4rem;
}
.dlg h3 {
    font-size: 2.1rem;
}
.msg {
    font-size: 1.3rem;
}
.ribbon {
    font-size: 1.8rem;
    padding: 0.6rem 2rem;
}
.stars img {
    width: 5rem;
    height: 5rem;
}
.facts b {
    font-size: 1.8rem;
}
.facts small {
    font-size: 1rem;
}
.how li {
    font-size: 1.25rem;
}
.set-row {
    font-size: 1.4rem;
}
.row2 .btn {
    font-size: 1.3rem;
}
.chip {
    font-size: 1.5rem;
}
.tagline {
    font-size: 1.5rem;
}
.bar h2 {
    font-size: 2.1rem;
}
@media (min-aspect-ratio: 5/4) {
    .controls .btn.round {
        min-height: 4.4rem;
    }
    .hint {
        min-height: 6.6rem;
        font-size: 2.2rem;
    }
    .hint img {
        width: 3.4rem;
        height: 3.4rem;
    }
    .dock .btn.xl,
    .row3 .btn {
        min-height: 5.8rem;
    }
    .controls .btn .lbl {
        font-size: 1.5rem;
    }
}
.modal {
    overflow: hidden;
}
@media (min-aspect-ratio: 5/4) {
    .controls .btn.round {
        width: 100%;
        min-height: 4.6rem;
        padding: 0 1rem;
    }
    .controls .btn .lbl {
        white-space: nowrap;
    }
    .hud .btn.round {
        width: 100%;
    }
}
.info {
    padding-right: 1.1rem;
}
.i-main {
    flex-wrap: nowrap;
    gap: 0.3rem;
}
@media (min-aspect-ratio: 5/4) {
    .info {
        padding: 0.8rem 1rem 0.9rem;
    }
    .timer strong {
        font-size: 2.5rem;
    }
    .timer img {
        width: 2rem;
        height: 2rem;
    }
    .stars3 img {
        width: 1.5rem;
        height: 1.5rem;
    }
    .i-top b {
        font-size: 1.6rem;
    }
}
@media (min-aspect-ratio: 5/4) and (max-height: 430px) {
    .timer strong {
        font-size: 2rem;
    }
    .timer img {
        width: 1.6rem;
        height: 1.6rem;
    }
    .stars3 img {
        width: 1.25rem;
        height: 1.25rem;
    }
    .i-top b {
        font-size: 1.4rem;
    }
    .i-top small {
        font-size: 1rem;
    }
    .info {
        padding: 0.6rem 0.7rem 0.7rem;
    }
    .left-bar {
        height: 1.6rem;
    }
}
