* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

@keyframes bubbleRise {
    0% { transform: translateY(0) translateX(0) scale(var(--bub-s)); opacity: 0; }
    10% { opacity: var(--bub-o); }
    85% { opacity: var(--bub-o); }
    100% { transform: translateY(calc(-100vh - 40px)) translateX(calc(var(--bub-drift) * 1px)) scale(var(--bub-s)); opacity: 0; }
}
@keyframes countPop {
    0% { transform: scale(2.2) rotate(-6deg); opacity: 0; text-shadow: 0 0 0 transparent; }
    30% { opacity: 1; }
    50% { transform: scale(1) rotate(1deg); text-shadow: 0 6px 0 rgba(0,0,0,0.7), 0 12px 0 rgba(0,0,0,0.4), 0 18px 0 rgba(0,0,0,0.15), 0 0 60px var(--marigold-glow); }
    100% { transform: scale(0.7) rotate(0deg); opacity: 0; text-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 40px var(--marigold-glow); }
}
@keyframes waterShimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Palette/radius/easing tokens moved to css/tokens.css (B1.2 — single source of truth) */
html, body { width: 100%; height: 100%; overflow: hidden;
    background: var(--deep);
    font-family: var(--font-body); color: var(--bark); user-select: none; }
canvas { display: block; position: fixed; inset: 0; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 20; gap: 18px; }
.screen.hidden { display: none; }
#bg-dim { position: fixed; inset: 0; z-index: 18; pointer-events: none; display: none;
    /* moderate scrim — lets the live ocean read through on menu screens while keeping a
       legibility floor for bare text near the edges (the loader has no bg-dim → stays vivid) */
    background:
        radial-gradient(ellipse 120% 90% at 50% 50%, transparent 38%, rgba(5,12,25,0.46) 100%),
        linear-gradient(180deg, rgba(5,12,25,0.34) 0%, transparent 32%, transparent 66%, rgba(5,12,25,0.46) 100%); }
#bg-dim.on { display: block; }
#bg-dim::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 80px; pointer-events: none;
    background: linear-gradient(180deg, transparent,
        rgba(88,184,232,0.03) 30%,
        rgba(88,184,232,0.06) 60%,
        rgba(88,184,232,0.04) 100%);
    background-size: 200% 100%;
    animation: waterShimmer 6s linear infinite; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }

#screen-menu { justify-content: flex-start; align-items: flex-start; padding: 0; gap: 0; }

#nametags { position: fixed; inset: 0; z-index: 9; pointer-events: none; overflow: hidden; }
.nametag { position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
    font-family: var(--font-body); font-weight: 700; font-size: 13px; padding: 2px 9px; border-radius: 10px;
    background: var(--paper); color: var(--cream); border: 1px solid var(--paper-border);
    text-shadow: none; box-shadow: 0 2px 8px rgba(0,0,0,0.5); will-change: left, top; }
.nametag.you { color: var(--bark-dark); background: var(--marigold);
    border-color: var(--marigold-dark); font-size: 14px;
    box-shadow: 0 2px 10px var(--marigold-glow); }
#countdown { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
    z-index: 15; font-family: var(--font-head); font-size: clamp(90px,25vw,220px); font-weight: 700; color: var(--cream);
    pointer-events: none; opacity: 0;
    -webkit-text-stroke: 2px rgba(184,128,24,0.4); }

#toast { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 16;
    font-family: var(--font-head); font-size: clamp(22px,6vw,40px); font-weight: 700; opacity: 0; pointer-events: none;
    text-shadow: 0 3px 0 rgba(0,0,0,0.8), 0 6px 0 rgba(0,0,0,0.4), 0 0 30px var(--marigold-glow);
    white-space: nowrap; color: var(--cream);
    padding: 8px 24px; border-radius: 6px;
    background: linear-gradient(135deg, rgba(42,26,14,0.85), rgba(30,18,8,0.75));
    border: 2px solid rgba(200,152,48,0.3); }
#wrongway { position: fixed; top: 38%; left: 50%; transform: translateX(-50%); z-index: 16;
    font-family: var(--font-head); font-size: clamp(16px,4.5vw,28px); font-weight: 700; color: var(--blush); opacity: 0;
    pointer-events: none; transition: opacity .2s;
    text-shadow: 0 2px 0 rgba(0,0,0,0.7), 0 0 20px rgba(255,104,80,0.5);
    white-space: nowrap; animation: wwblink 0.7s steps(2) infinite;
    padding: 6px 20px; border-radius: 6px;
    background: linear-gradient(135deg, rgba(80,20,10,0.85), rgba(60,15,8,0.75));
    border: 2px solid rgba(255,104,80,0.4); }
@keyframes wwblink { 50% { color: var(--marigold); } }

#touch { position: fixed; inset: 0; z-index: 13; display: none; pointer-events: none; touch-action: none; }
#touch.on { display: block; }
/* Touch controls — golden-hour soft glass, color-coded: GAS=yellow (go/pop),
   BRAKE=ruby (stop), JUMP=cyan (secondary), steer=navy glass. */
.tbtn { position: absolute; pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none;
    display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center;
    border-radius: 50%; background: rgba(10,20,40,0.6);
    border: 1px solid rgba(255,255,255,0.16);
    color: var(--cream); font-weight: 800; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
    transition: transform .06s, box-shadow .06s; }
.tbtn .ic { font-size: 1.6em; line-height: 1; pointer-events: none; }
.tbtn .tx { font-family: var(--font-head); font-size: 0.95em; font-weight: 800; letter-spacing: 1px; pointer-events: none;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.tbtn:active, .tbtn.hold { transform: scale(0.92); }
#t-left, #t-right { width: 88px; height: 88px; bottom: calc(28px + env(safe-area-inset-bottom,0px)); font-size: 34px; }
#t-left  { left: 22px; }
#t-right { left: 122px; }
#t-gas   { width: 110px; height: 110px; right: 24px; bottom: calc(40px + env(safe-area-inset-bottom,0px)); font-size: 18px; color: #3a1c0e;
    background: linear-gradient(160deg, var(--gold), var(--gold-hot)); border-color: rgba(255,224,0,0.7); }
#t-gas:active, #t-gas.hold { box-shadow: 0 0 18px rgba(255,224,0,0.6), 0 6px 16px rgba(0,0,0,0.45); }
#t-brake { width: 80px; height: 80px; right: 144px; bottom: calc(34px + env(safe-area-inset-bottom,0px)); font-size: 15px;
    background: linear-gradient(160deg, rgba(255,92,138,0.9), rgba(180,46,80,0.84)); border-color: rgba(255,140,170,0.6); }
#t-jump  { width: 86px; height: 86px; right: 40px; bottom: calc(170px + env(safe-area-inset-bottom,0px)); font-size: 16px; color: #04121E;
    background: linear-gradient(160deg, rgba(0,229,255,0.85), rgba(0,144,168,0.82)); border-color: rgba(127,242,255,0.6); }

.bubble-particle { position: fixed; border-radius: 50%; pointer-events: none; z-index: 19;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.2), rgba(88,184,232,0.08));
    border: 1px solid rgba(88,184,232,0.12);
    animation: bubbleRise var(--bub-dur) ease-in infinite;
    animation-delay: var(--bub-delay); }
.hide { display: none !important; }
