/* DeepInTime Build: game UI. Chunky rounded panels with an ink outline and a hard drop,
   bold rounded type (Fredoka, SIL OFL 1.1, see fonts/OFL-Fredoka.txt) and a bright palette.
   No backdrop blur anywhere: it costs GPU time on the canvas behind it. */
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/fredoka-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/fredoka-latin-700-normal.woff2) format('woff2'); }

:root {
  --ink: #1d2a44; --ink2: #34456b; --paper: #fff7e3; --paper2: #ffeec2; --text: #1d2a44; --mute: #5b6a8c;
  --sun: #ffc42e; --sun2: #ff9f1c; --sky: #3fb6ff; --mint: #2ed3a6; --coral: #ff5c6c; --grape: #8b6cff;
  --good: #1fb86a; --bad: #ff4d5e; --accent: var(--sun);
  --r: 16px; --line: 3px; --drop: 0 4px 0 var(--ink);
  --font: 'Fredoka', 'Trebuchet MS', 'Segoe UI Rounded', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3f5; font: 600 15px/1.35 var(--font); color: var(--text); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#view { display: block; width: 100vw; height: 100vh; cursor: pointer; touch-action: none; }
button { font: inherit; color: inherit; }
svg.ic { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.ic.fill { fill: currentColor; stroke: none; }
kbd { font: 700 12px var(--font); background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; padding: 0 5px; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* Panels and chunky buttons. */
.panel { background: var(--paper); color: var(--text); border: var(--line) solid var(--ink); border-radius: var(--r); box-shadow: var(--drop); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; cursor: pointer; text-decoration: none;
  background: #fff; color: var(--ink); border: var(--line) solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); font-weight: 700; transition: transform .06s, box-shadow .06s; }
.btn:hover { background: var(--paper2); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.go { background: var(--sun); }
.btn.go:hover { background: #ffd35e; }
.btn.danger { background: #ffd9dd; }

.hud { position: fixed; padding: 8px 12px; pointer-events: none; font-size: 15px; }
#status { left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--paper); border: var(--line) solid var(--ink); border-radius: var(--r); box-shadow: var(--drop); }
#status[hidden] { display: none; }
#hint { left: 12px; bottom: 96px; transition: opacity .3s; font-size: 13px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; max-width: min(430px, calc(50vw - 110px)); }
#spd { position: fixed; right: 16px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 78px); z-index: 9; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 3px 0 var(--ink); padding: 4px 12px 6px; text-align: right; pointer-events: none; }
#spd b { font: 800 32px var(--font); font-variant-numeric: tabular-nums; line-height: 1; }
#spd small { font: 700 11px var(--font); margin-left: 3px; color: var(--mute); }
#spd .odo { display: block; font: 700 12px var(--font); color: var(--ink2); font-variant-numeric: tabular-nums; }
#spd[hidden] { display: none; }
#hint.dim { opacity: .35; }
#hint[hidden] { display: none; }
#fps { right: 12px; bottom: 96px; font: 700 11px var(--font); background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; padding: 3px 8px; display: none; }
body.showfps #fps { display: block; }
#vig { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(20,40,80,.22) 100%); }

/* Top bar: coins, worth, visitors, online. */
#top { position: fixed; left: 12px; top: 12px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; max-width: calc(100vw - 150px); z-index: 12; }
#top button.pill { pointer-events: auto; cursor: pointer; font: inherit; font-weight: 700; color: inherit; }
#top[hidden], #mini[hidden], #bar[hidden] { display: none; }
.pill { background: var(--paper); border: var(--line) solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); padding: 3px 14px 3px 8px; display: flex; gap: 7px; align-items: center; font-weight: 700; min-height: 38px; }
.pill small { font-weight: 600; color: var(--mute); }
.coin { width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3a8, var(--sun) 55%, var(--sun2)); border: 2.5px solid var(--ink); display: inline-block; flex: none; position: relative; }
.coin::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; border: 2px solid rgba(29,42,68,.35); }
#coins { font-size: 19px; }
#coins.bump { animation: bump .4s; }
@keyframes bump { 35% { transform: scale(1.22) rotate(-3deg); } }
.live { width: 11px; height: 11px; border-radius: 50%; background: var(--good); border: 2px solid var(--ink); display: inline-block; }

/* Minimap. */
#mini { position: fixed; right: 12px; top: 12px; width: 156px; height: 156px; border-radius: 50%; overflow: hidden; border: 4px solid var(--ink); box-shadow: 0 4px 0 var(--ink); cursor: pointer; background: #445; z-index: 5; }
#mini canvas { width: 100%; height: 100%; display: block; }

/* Dock (walk) and tool rail (build). */
#bar { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 6px; padding: 7px; z-index: 10;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 20px; box-shadow: var(--drop); }
#bar button { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; min-width: 62px; min-height: 56px; padding: 4px 8px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0; font-size: 12px; font-weight: 700; box-shadow: 0 3px 0 var(--ink); transition: transform .06s, box-shadow .06s; }
#bar button .i { display: flex; font-size: 22px; }
#bar button:hover { background: var(--paper2); }
#bar button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#bar button.on { background: var(--sun); }
#bar button[data-act=build] { background: var(--sun); }
#bar [data-mode=build] { display: none; }
body.building #bar [data-mode=build] { display: flex; }
body.building #bar [data-mode=walk] { display: none; }
body.building #bar { left: 12px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px); transform: none; flex-direction: column; border-radius: 22px; max-height: calc(100vh - 220px); overflow-y: auto; }
body.building #bar button { min-width: 58px; min-height: 52px; }
body.building #bar [data-act=done] { background: var(--mint); }

/* Hotbar: numbered slots for the pieces you place most. */
#hotbar { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10; display: none; gap: 6px; padding: 7px;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 20px; box-shadow: var(--drop); max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
body.building #hotbar { display: flex; }
#hotbar::-webkit-scrollbar { display: none; }
#hotbar .slot { position: relative; flex: 0 0 auto; width: 62px; height: 66px; border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; cursor: pointer; padding: 0; box-shadow: 0 3px 0 var(--ink); transition: transform .08s; }
#hotbar .slot img { width: 46px; height: 46px; display: block; margin: 3px auto 0; pointer-events: none; }
#hotbar .slot .num { position: absolute; left: 4px; top: 2px; font-size: 12px; font-weight: 700; color: var(--mute); }
#hotbar .slot .cost { position: absolute; right: 5px; bottom: 2px; font-size: 11px; font-weight: 700; display: flex; gap: 2px; align-items: center; }
#hotbar .slot .cost i { width: 9px; height: 9px; border-radius: 50%; background: var(--sun); border: 1.5px solid var(--ink); display: inline-block; }
#hotbar .slot:hover { transform: translateY(-2px); }
#hotbar .slot.on { background: var(--sun); transform: translateY(-5px); box-shadow: 0 6px 0 var(--ink); }
#hotbar .slot.poor img { opacity: .4; }
#hotbar .slot.poor .cost { color: var(--bad); }
#hotbar .sep { width: 3px; background: var(--ink); opacity: .2; border-radius: 3px; margin: 4px 1px; flex: none; }
#hotbar .all { flex: 0 0 auto; width: 62px; height: 66px; border: 2.5px solid var(--ink); border-radius: 14px; background: var(--sky); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; box-shadow: 0 3px 0 var(--ink); color: var(--ink); }
#hotbar .all .ic { font-size: 22px; }

/* Piece drawer ("All"): categories, search, cards, colours. */
#build { position: fixed; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px); transform: translateX(-50%); width: min(780px, calc(100vw - 100px)); z-index: 9;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 18px; box-shadow: var(--drop); padding: 10px 12px; }
#build[hidden] { display: none; }
#build .head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#build.closed .head, #build.closed #pieces { display: none; }
#cats { display: flex; gap: 6px; flex-wrap: wrap; }
#build button { background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 4px 13px; cursor: pointer; min-height: 36px; font-weight: 700; box-shadow: 0 2px 0 var(--ink); }
#build button.on { background: var(--sun); }
#search { flex: 1; min-width: 120px; background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; color: var(--ink); padding: 6px 14px; font: inherit; user-select: text; -webkit-user-select: text; }
#pieces { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 8px; scrollbar-width: thin; }
#pieces .card { flex: 0 0 auto; width: 92px; border-radius: 14px; padding: 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; box-shadow: 0 3px 0 var(--ink); }
#pieces .card img { width: 58px; height: 58px; background: var(--paper2); border-radius: 10px; }
#pieces .card .nm { font-size: 12px; line-height: 1.12; min-height: 2.3em; display: flex; align-items: center; }
#pieces .card .pr { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
#pieces .card .pr::before { content: ''; width: 11px; height: 11px; border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); }
#pieces .card.poor { opacity: .5; }
#build .foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; }
#colors { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
#build #colors button { width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 50%; border: 2.5px solid var(--ink); box-shadow: none; position: relative; }
#build #colors button.on { outline: 3px solid var(--sky); outline-offset: 2px; }
#colors .tag { font-size: 11px; font-weight: 700; background: var(--grape); color: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; margin-left: 6px; display: inline-flex; align-items: center; gap: 3px; }
#colors .tag svg { width: 11px; height: 11px; }
#colors button.finish::after { content: '✦'; position: absolute; right: -4px; top: -8px; font-size: 12px; color: #fff; text-shadow: 0 0 3px #000; }
#colors button.locked { opacity: .75; }
#colors button.locked::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: rgba(29,42,68,.45); }
.dim2 { color: var(--mute); }
#msg { color: var(--bad); }
#reason { position: fixed; left: 0; top: 0; pointer-events: none; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 10px; padding: 2px 10px; font-size: 14px; font-weight: 700; color: #138a4d; white-space: nowrap; z-index: 15; }
#reason[hidden] { display: none; }
#reason.bad { color: #d12a3b; }
#reason{max-width:calc(100vw - 16px);white-space:normal;overflow-wrap:anywhere;box-sizing:border-box}
.tworld{padding:10px 12px;border-radius:12px;background:var(--paper);font-size:14px;line-height:1.5}
#worldBanner{position:fixed;bottom:100px;left:50%;transform:translateX(-50%);max-width:min(620px,calc(100vw - 24px));width:max-content;padding:10px 44px 10px 14px;border:2px solid var(--ink);border-radius:14px;background:var(--paper);color:var(--ink);z-index:25;font-size:14px;line-height:1.5;box-shadow:0 3px 0 #0002}
#worldBanner[hidden],.bwplotlabel[hidden]{display:none}
#worldBanner button{position:absolute;right:4px;top:2px;width:36px;height:36px;padding:0;border:0;background:none;box-shadow:none;font-size:24px}
.bwplotlabel{position:fixed;transform:translate(-50%,-100%);max-width:260px;min-height:36px;border:1px solid #fff7;border-radius:10px;padding:6px 10px;background:#182d39bb;color:white;box-shadow:none;font-size:12px;z-index:12;overflow-wrap:anywhere}
@media(max-width:640px){#worldBanner{bottom:280px}.bwplotlabel{max-width:210px}}
.toast:has(.world-link){display:grid;grid-template-columns:28px minmax(0,1fr);width:min(520px,92vw);box-sizing:border-box}
.toast:has(.world-link) .ti{grid-column:1;grid-row:1 / span 2}
.toast:has(.world-link)>span:not(.ti),.toast a.world-link{grid-column:2;min-width:0;white-space:normal;overflow-wrap:anywhere}

/* Toasts and coin pops. */
#toasts { position: fixed; left: 50%; top: 66px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; z-index: 35; width: max-content; max-width: 92vw; }
.toast { display: flex; gap: 8px; align-items: center; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); padding: 7px 16px 7px 10px; animation: tin .32s cubic-bezier(.3,1.6,.5,1); max-width: 92vw; text-align: left; }
.toast .ti { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--ink); display: flex; align-items: center; justify-content: center; background: var(--sky); flex: none; }
.toast .ti svg { width: 16px; height: 16px; stroke-width: 3; }
.toast.good .ti { background: var(--mint); } .toast.bad .ti { background: var(--coral); }
.toast.out { animation: tout .25s forwards; }
.toast a { pointer-events: auto; font-weight: 700; color: var(--ink); white-space: nowrap; }
@keyframes tin { from { opacity: 0; transform: translateY(-14px) scale(.8); } }
@keyframes tout { to { opacity: 0; transform: translateY(-8px) scale(.9); } }
.pop { position: fixed; left: 0; top: 0; pointer-events: none; color: var(--sun); font: 700 24px var(--font); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; animation: pop 1.3s ease-out forwards; z-index: 12; }
@keyframes pop { 15% { scale: 1.3; } to { margin-top: -56px; opacity: 0; } }
/* Endless score (main.js paintScore): total, combo with its timer, a tumble's live turns, best. */
#score { position: fixed; left: 50%; top: 12px; translate: -50% 0; z-index: 11; pointer-events: none; text-align: center; color: #fff7e3; font-family: var(--font); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
#score[hidden] { display: none; }
#score .sc-total { font: 700 30px/1 var(--font); letter-spacing: .5px; transition: scale .12s ease-out; }
#score.flash .sc-total { scale: 1.18; color: var(--sun); }
#score .sc-row { display: flex; gap: 8px; justify-content: center; align-items: baseline; min-height: 22px; margin-top: 2px; }
#score .sc-combo { font: 700 20px/1 var(--font); color: var(--sun); position: relative; }
#score .sc-combo:not(:empty)::after { content: ''; position: absolute; left: 0; right: 0; bottom: -5px; height: 3px; border-radius: 2px; background: var(--sun); transform-origin: left; scale: var(--combo, 0) 1; }
#score .sc-live { font: 700 17px/1 var(--font); }
#score .sc-zone { font: 700 15px/1 var(--font); color: #ffcf3f; margin-top: 4px; }
#score .sc-zone:empty { display: none; }
#score .sc-best { font: 700 13px/1 var(--font); opacity: .85; -webkit-text-stroke-width: 3px; margin-top: 3px; }
#score .sc-trail { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; margin-top: 5px; padding: 4px 10px 4px 6px; border: 2px solid var(--ink); border-radius: 999px; background: rgba(43, 35, 64, .72); color: #fff7e3; font: 700 12px/1 var(--font); -webkit-text-stroke: 0; cursor: pointer; }
#score .sc-trail::before { content: ''; width: 14px; height: 14px; border-radius: 50%; background: var(--trail, #ff9a3c); box-shadow: 0 0 6px var(--trail, #ff9a3c); }
#score .sc-trail:empty { display: none; }
@media (max-width: 640px) {   /* phones: above the speed readout, clear of the toasts at the top */
  #score { top: auto; bottom: 214px; left: auto; right: 12px; translate: none; text-align: right; }
  #score .sc-row { justify-content: flex-end; }
  #score .sc-total { font-size: 24px; }
}

/* Onboarding card. */
#guide { position: fixed; left: 12px; top: 66px; width: 290px; z-index: 11; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 18px; box-shadow: var(--drop); padding: 10px 14px 12px; animation: tin .35s cubic-bezier(.3,1.6,.5,1); }
#guide[hidden] { display: none; }
#guide .pips { display: flex; gap: 5px; margin-bottom: 6px; align-items: center; }
#guide .pips i { width: 26px; height: 8px; border-radius: 6px; background: #fff; border: 2px solid var(--ink); }
#guide .pips i.done { background: var(--mint); } #guide .pips i.cur { background: var(--sun); }
#guide h3 { margin: 0 0 2px; font: 700 18px var(--font); }
#guide p { margin: 0 0 8px; font-size: 14px; color: var(--ink2); }
#guide .row { display: flex; gap: 8px; justify-content: flex-end; }
#guide .btn { min-height: 34px; padding: 0 14px; font-size: 14px; box-shadow: 0 3px 0 var(--ink); }
#beacon { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 8; width: 0; height: 0; }
#beacon::before { content: ''; position: absolute; left: -16px; top: -34px; width: 32px; height: 32px; background: var(--sun); border: 3px solid var(--ink); border-radius: 50% 50% 50% 0; transform: rotate(-45deg) ; animation: hop .9s ease-in-out infinite; }
#beacon[hidden] { display: none; }
@keyframes hop { 50% { translate: 0 -12px; } }

/* Sheets: photo, map, pause. */
.sheet { position: fixed; inset: 0; background: rgba(20,32,60,.5); display: flex; align-items: center; justify-content: center; z-index: 40; }
.sheet[hidden] { display: none; }
.sheet .box { background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 var(--ink); padding: 18px; width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; animation: tin .3s cubic-bezier(.3,1.6,.5,1); }
.sheet h2 { margin: 0 0 12px; font: 700 28px var(--font); letter-spacing: .3px; }
.sheet h3 { margin: 14px 0 6px; font: 700 17px var(--font); }
.sheet video.shot { width: 100%; border-radius: 12px; display: block; border: 3px solid var(--ink); background: #000; }
.sheet video.shot[hidden], .sheet img.shot[hidden] { display: none; }
.sheet img.shot { width: 100%; border-radius: 12px; display: block; border: 3px solid var(--ink); }
.sheet .acts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.sheet .acts > * { flex: 1; }
.sheet ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet li a { display: block; padding: 8px 12px; border-radius: 12px; background: #fff; border: 2.5px solid var(--ink); color: inherit; text-decoration: none; font-weight: 700; box-shadow: 0 3px 0 var(--ink); }
.sheet li a:hover { background: var(--paper2); }
.sheet li a small { display: block; color: var(--mute); font-weight: 600; }
.menu .stack { display: flex; flex-direction: column; gap: 10px; }
.menu .stack .btn { justify-content: flex-start; width: 100%; font-size: 17px; }
.menu .stack .btn.resume { background: var(--sun); min-height: 54px; font-size: 20px; justify-content: center; }
.menu .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu .back { margin-bottom: 8px; padding: 0 12px; min-height: 36px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 2px dashed rgba(29,42,68,.18); }
.set label, .set .lb { font-weight: 700; }
.set input[type=range] { width: 52%; accent-color: var(--coral); height: 28px; }
.set select { width: 52%; height: 34px; border-radius: 10px; border: 2px solid #1b1510; background: #fff8e8; font: inherit; font-weight: 700; padding: 0 8px; }
.set .seg { display: flex; gap: 4px; }
.set .seg button { min-height: 36px; padding: 0 12px; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 700; box-shadow: 0 2px 0 var(--ink); }
.set .seg button.on { background: var(--sun); }
.how { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 15px; margin: 0; }
.how dt { text-align: right; white-space: nowrap; } .how dd { margin: 0; color: var(--ink2); }
#bigmap { width: 100%; aspect-ratio: 1; border-radius: 12px; display: block; border: 3px solid var(--ink); }
body.photo #top, body.photo #mini, body.photo #bar, body.photo #hint, body.photo #fps, body.photo #build, body.photo #guide, body.photo #reason, body.photo #hotbar, body.photo #vig, body.photo #beacon { display: none !important; }
#shutter { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: none; gap: 12px; align-items: center; z-index: 20; }
body.photo #shutter { display: flex; }
#shutter .btn { min-height: 50px; }
#shutter .snap { width: 74px; height: 74px; padding: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 5px var(--ink), 0 6px 0 5px var(--ink); border: 0; }
#use { position: fixed; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 86px); transform: translateX(-50%); min-height: 54px; padding: 0 28px; font-size: 19px; z-index: 11; }
#use[hidden] { display: none; }
#unstuck { position: fixed; left: 50%; top: calc(max(12px, env(safe-area-inset-top)) + 120px); transform: translateX(-50%); min-height: 48px; padding: 0 22px; font-size: 17px; z-index: 11; background: var(--coral); color: #fff; animation: trk .6s ease-in-out infinite alternate; }
#unstuck[hidden] { display: none; }
body.building #unstuck, body.photo #unstuck { display: none; }
body.building #use, body.photo #use { display: none; }
#hoverTag { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 12; padding: 3px 12px; border-radius: 999px; background: var(--paper); border: 2.5px solid var(--ink); font-size: 14px; font-weight: 700; white-space: nowrap; }
#hoverTag[hidden] { display: none; }
#popover { position: fixed; z-index: 30; min-width: 210px; padding: 8px; border-radius: 18px; background: var(--paper); border: var(--line) solid var(--ink); box-shadow: var(--drop); display: flex; flex-direction: column; gap: 6px; }
#popover[hidden] { display: none; }
#popover .popTitle { font-weight: 700; font-size: 16px; padding: 4px 8px 2px; }
#popover button { text-align: left; min-height: 44px; padding: 0 14px; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
#popover button:hover, #popover button:focus-visible { background: var(--sun); }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 39; transition: opacity .35s; }

/* Touch: a large stick on the left, jump and drift on the right. */
#stick { position: fixed; left: 18px; bottom: 96px; width: 168px; height: 168px; border-radius: 50%; background: rgba(255,247,227,.35); border: 4px solid var(--ink); display: none; touch-action: none; z-index: 6; }
#stick i { position: absolute; left: 50%; top: 50%; width: 74px; height: 74px; margin: -37px; border-radius: 50%; background: var(--sun); border: 4px solid var(--ink); }
#jump { position: fixed; right: 22px; bottom: 108px; width: 96px; height: 96px; border-radius: 50%; border: 4px solid var(--ink); background: var(--sun); box-shadow: 0 5px 0 var(--ink); display: none; touch-action: none; align-items: center; justify-content: center; font-size: 34px; z-index: 6; }
body.touch:not(.building):not(.photo) #stick { display: block; }
body.touch:not(.building):not(.photo) #jump { display: flex; }
#speedfx { position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0; transition: opacity .25s linear; background: repeating-conic-gradient(from 3deg at 50% 54%, rgba(255,255,255,0) 0deg 5deg, rgba(255,255,255,.5) 5.4deg 5.8deg, rgba(255,255,255,0) 6.2deg 11deg); -webkit-mask-image: radial-gradient(ellipse 70% 62% at 50% 54%, transparent 55%, #000 100%); mask-image: radial-gradient(ellipse 70% 62% at 50% 54%, transparent 55%, #000 100%); }
@media (prefers-reduced-motion: reduce) { #speedfx { display: none; } }
body.building #speedfx, body.photo #speedfx { display: none; }
#flip { position: fixed; left: 62px; bottom: 278px; width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--ink); background: var(--paper); box-shadow: 0 4px 0 var(--ink); display: none; touch-action: none; align-items: center; justify-content: center; font-size: 26px; z-index: 6; }
body.touch.drive:not(.building):not(.photo):not(.flying) #flip { display: flex; }
#drift { --chg: 0; --dc: #f4f7fb; position: fixed; right: 132px; bottom: 112px; width: 104px; height: 104px; padding: 0; border: 0; border-radius: 50%; background: transparent; display: none; align-items: center; justify-content: center; z-index: 7; touch-action: none; cursor: pointer; }
#drift[hidden] { display: none !important; }
body:is(.racing, .endless) #drift { display: flex; }
#drift .dring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--dc) calc(var(--chg) * 100%), rgba(255,247,227,.35) 0); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 12px), #000 calc(100% - 10px)); mask: radial-gradient(farthest-side, transparent calc(100% - 12px), #000 calc(100% - 10px)); }
#drift .dface { position: relative; width: 72px; height: 72px; border-radius: 50%; background: var(--paper); border: 4px solid var(--ink); box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; justify-content: center; font: 800 14px var(--font); color: var(--ink); }
#drift.lv2 { --dc: #3ec6ff; }
#drift.lv3 { --dc: #ff7a18; }
#drift.flash .dring { filter: brightness(1.7); }
body.endless #drift.empty .dface { opacity: .55; }
/* The vehicle jump meter: fills while the jump is held (main.js), full is the highest jump. */
#jumpMeter { --jc: 0; position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); pointer-events: none; font: 800 13px var(--font); color: var(--ink); }
#jumpMeter[hidden] { display: none; }
#jumpMeter .jbar { width: 150px; height: 12px; border-radius: 999px; background: rgba(0,0,0,.12); overflow: hidden; }
#jumpMeter .jbar i { display: block; height: 100%; width: calc(var(--jc) * 100%); border-radius: inherit; background: #3ec6ff; }
#jumpMeter.full .jbar i { background: #ff7a18; }
body.touch #jumpMeter { bottom: auto; top: 140px; }
#itemBtn { position: fixed; right: 22px; bottom: 222px; width: 92px; height: 92px; border-radius: 22px; border: 4px solid var(--ink); background: rgba(255,247,227,.9); box-shadow: 0 5px 0 var(--ink); display: none; align-items: center; justify-content: center; z-index: 7; touch-action: none; cursor: pointer; font-size: 36px; }
#itemBtn[hidden] { display: none !important; }
body.racing #itemBtn { display: flex; }
#itemBtn.ready { background: var(--sun); animation: ritemPulse 1.1s ease-in-out infinite alternate; }
#itemBtn.spin { background: linear-gradient(90deg, #ffd23f, #5fd0ff, #ff5c7a); background-size: 200% 100%; animation: ritemSpin .45s linear infinite; }
#itemBtn.active { background: var(--mint); }
body:is(.racing, .endless):not(.touch) #drift { right: 22px; bottom: 22px; width: 88px; height: 88px; }
body:is(.racing, .endless):not(.touch) #drift .dface { width: 60px; height: 60px; font-size: 13px; }
body.racing:not(.touch) #itemBtn { right: auto; left: 22px; bottom: 22px; width: 88px; height: 88px; }
body.racing #flip { display: none !important; }
/* Narrow phones upright: the stick needs the left, so drift and the item stack above jump on the right. */
@media (max-width: 440px) and (min-height: 501px) {
  body:is(.racing, .endless).touch #drift { right: 18px; bottom: 214px; }
  body.racing.touch #itemBtn { right: 26px; bottom: 330px; width: 80px; height: 80px; }
}
@media (max-height: 500px) {
  body.racing #itemBtn { right: 12px; bottom: 12px; width: 72px; height: 72px; }
  body:is(.racing, .endless) #drift { bottom: 12px; right: 96px; width: 80px; height: 80px; }
  body:is(.racing, .endless) #drift .dface { width: 54px; height: 54px; }
}
#jump b { display: none; font: 700 17px var(--font); color: var(--ink); }
#jump.lbl b { display: block; } #jump.lbl span { display: none; }
#jump.trk { background: var(--coral); animation: trk .5s ease-in-out infinite alternate; } #jump.trk b { color: #fff; }
@keyframes trk { to { transform: scale(1.1); } }
body.touch #hint { display: none; }
body.touch #hotbar .slot, body.touch #hotbar .all { width: 64px; height: 72px; }

/* Title screen (Home Hub): a launcher over the live fly-over. One play-now bar, a card per game, the live rooms and
   the site links. The raid parts ([data-raid]) stay hidden until title.js turns them on: .raid adds the dark Raid
   card, .feat makes it the featured slot beside Race and Build. Panels stay at .94+ opacity over the 3D world. */
#title { --ember: #ff8a3d; --crystal: #6ad7cf; --night: #08121b; --card: rgba(255,247,227,.96); --sub: #3a4560;
  position: fixed; inset: 0; z-index: 50; overflow-y: auto; display: grid; gap: 14px 18px; padding: 18px 28px 16px; text-align: left;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: auto minmax(300px,1fr) auto auto;
  grid-template-areas: "top top" "race build" "rooms rooms" "foot foot";
  background: linear-gradient(180deg, rgba(18,36,78,.28) 0%, rgba(18,36,78,.06) 35%, rgba(18,36,78,.1) 65%, rgba(18,36,78,.5) 100%); transition: opacity .6s, visibility .6s; }
#title.raid { grid-template-columns: minmax(0,1.45fr) minmax(0,1fr) minmax(0,1fr); grid-template-areas: "top top top" "raid race build" "rooms rooms rooms" "foot foot foot"; }
#title.feat { grid-template-columns: minmax(0,1.5fr) minmax(0,1fr) minmax(0,1fr); }
#title[hidden], html.nt #title { display: none; }
#title.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
#title [hidden] { display: none !important; }
#title .m { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top row: wordmark, play-now bar, Continue, account. Without a featured slot the bar takes its own row. */
.ttop { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; min-width: 0; }
.logo { margin: 0; flex: none; line-height: 1; transform: rotate(-2deg); filter: drop-shadow(0 4px 0 var(--ink)); animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: rotate(-1.2deg) translateY(-3px); } }
.logo .w { display: block; font: 700 40px/1 var(--font); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; letter-spacing: .5px; }
.logo .w b { color: var(--sun); font-weight: 700; }
.tplay { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; background: var(--card); border: 3.5px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); }
#title:not(.feat) .tplay { order: 3; flex-basis: 100%; padding: 12px 14px 12px 18px; }
.tdot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--mint); border: 2px solid var(--ink); }
.tplay-txt { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; line-height: 1.2; }
.tplay-txt b { font-size: 17px; }
.tplay-txt small { font-size: 12.5px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.tquick { flex: none; min-height: 48px; padding: 0 20px; font-size: 18px; border-radius: 15px; background: var(--sun); }
.btn.tquick:hover { background: #ffd35e; }
#title.raid #tQuick { background: var(--ember); color: var(--night); }
#title.raid #tQuick:hover { background: #ff9d5c; }
.tcode { flex: none; display: flex; align-items: center; gap: 8px; margin: 0; padding-left: 12px; border-left: 2px solid rgba(58,69,96,.3); }
.tcode label { font-size: 13px; color: var(--sub); }
.tcode input { width: 148px; height: 44px; padding: 0 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink);
  font: 700 15px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; text-transform: uppercase; user-select: text; -webkit-user-select: text; }
.tcode input::placeholder { color: #a3abbb; text-transform: none; }
.btn.tjoin { min-height: 44px; padding: 0 14px; font-size: 16px; border-radius: 12px; background: var(--sky); box-shadow: 0 3px 0 var(--ink); }
.btn.tjoin:hover { background: #6cc6ff; }
/* Continue where you left off: this device's last game, or the account's from another device. */
.tcont { flex: none; display: flex; align-items: center; gap: 10px; max-width: 280px; min-height: 48px; padding: 4px 14px; background: var(--mint); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 15px; box-shadow: 0 4px 0 var(--ink); text-decoration: none; }
.tcont:hover, .tcont:focus-visible { background: #56e3ba; }
.tcont:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.tcont-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.tcont-info small { font-size: 11px; }
.tcont-info b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcont-info #tContS, .tcont-go { display: none; }
/* Account: "Sign in", or your initial and a menu once signed in (site/me.js). */
.tsite-top { flex: none; margin-left: auto; display: flex; }
#title:not(.feat) .tcont { margin-left: auto; }
#title:not(.feat) .tcont:not([hidden]) + .tsite-top { margin-left: 0; }
.tsite-top a.tacct, .tsite-top .dt-me-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 6px; background: var(--card); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 22px; font: 700 15px/1 var(--font); text-decoration: none; }
.tsite-top a.tacct::before { content: '?'; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--sky); border: 2px solid var(--ink); font-size: 13px; }
.tsite-top a.tacct:hover, .tsite-top .dt-me-btn:hover, .tsite-top .dt-me-btn[aria-expanded=true] { background: #fff; border-color: var(--ink); }
.tsite-top .dt-me-label { color: var(--ink); }
.tsite-top .dt-me-av { width: 30px; height: 30px; font-size: 14px; background: var(--sky); box-shadow: none; }
.tsite-top .dt-me-menu { --me-line: var(--ink); }

/* Raid: a featured slot (art with a tight dark copy panel) or, unfeatured, a dark card like the cream ones. */
.traid { grid-area: raid; position: relative; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; color: #f4f3e8;
  background: #1a2636; border: 3.5px solid var(--ink); border-radius: 24px; box-shadow: 0 6px 0 var(--ink); }
.traid::before { content: ''; position: absolute; inset: 0; background: url(img/hub/cerberus.webp) 50% 0 / cover no-repeat; filter: contrast(1.05); }
.traid::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,18,27,.55) 0%, rgba(8,18,27,0) 30%); }
.ttag { position: absolute; left: 16px; top: 16px; z-index: 1; padding: 4px 12px; background: var(--sun); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 12px; font-size: 14px; font-weight: 700; }
.traid-body { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; margin: 14px; padding: 18px 20px 20px; background: rgba(8,18,27,.88); border-radius: 18px; }
.traid-eyebrow { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--crystal); }
.traid h2 { margin: 0; font: 700 44px/1 var(--font); letter-spacing: -.01em; }
.traid p { margin: 0; font-size: 16px; line-height: 1.4; color: #c9d6db; }
.traid-acts { display: flex; gap: 10px; margin-top: 2px; }
.traid-acts .btn { flex: 1; min-height: 56px; padding: 0 12px; font-size: 20px; border-radius: 16px; }
.btn.traid-solo { background: var(--ember); color: var(--night); }
.btn.traid-solo:hover { background: #ff9d5c; }
.btn.traid-squad { background: rgba(8,18,27,.6); color: #f4f3e8; border: 2px solid var(--crystal); box-shadow: none; }
.btn.traid-squad:hover { background: rgba(8,18,27,.85); }
#title.raid:not(.feat) .traid { border-radius: 22px; background: #0b1520; }
#title.raid:not(.feat) .traid::before { background-position: 58% 46%; background-size: 200%; filter: brightness(.45) contrast(1.25) saturate(.7); }
#title.raid:not(.feat) .traid::after { background: radial-gradient(90% 60% at 0% 100%, rgba(74,36,24,.9), rgba(74,36,24,0) 70%),
  linear-gradient(0deg, rgba(8,18,27,.97) 0%, rgba(8,18,27,.85) 40%, rgba(8,18,27,0) 75%); }
#title.raid:not(.feat) .traid-body { margin: 0; padding: 18px 20px 20px; background: none; }
#title.raid:not(.feat) .traid h2 { font-size: 34px; }

/* Race and Build: media on top (it takes the spare height), then the title, a line and one big button. */
.tcard { color: var(--ink); background: var(--card); border: 3.5px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); }
.tgame { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-radius: 24px; }
.tcard-race { grid-area: race; }
.tcard-build { grid-area: build; }
.tmedia { flex: 1; min-height: 110px; background: #5c8 50% 50% / cover no-repeat; border-bottom: 3.5px solid var(--ink); }
.tcard-race .tmedia { background-image: url(img/hub/race.webp); background-position: 50% 70%; }
.tcard-build .tmedia { background-color: #4a4; background-image: url(img/hub/build.webp); background-position: 50% 55%; }
.tgame-body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; }
.tgame h2 { margin: 0; font: 700 34px/1.05 var(--font); }
.tgame p { margin: 0; min-height: 2.6em; font-size: 16px; line-height: 1.3; color: var(--sub); }
.tgame .btn { width: 100%; min-height: 54px; font-size: 19px; border-radius: 16px; }
#playBtn:disabled, .btn.build-go:disabled { background: var(--paper2); cursor: progress; }
.btn.build-go { background: var(--mint); }
.btn.build-go:hover:not(:disabled) { background: #56e3ba; }

/* Live rooms (races and worlds from the presence feed), or the quiet state's "Ready now with CPUs" rows. */
.trooms-card { grid-area: rooms; min-width: 0; padding: 10px 14px 14px; }
.trooms-card .tl { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0 4px 8px; }
.trooms-card .tl b { font-size: 17px; }
.trooms-card .tl span { font-size: 13px; color: var(--sub); }
.trooms, .tready { margin: 0; padding: 0; list-style: none; }
.trooms { display: flex; gap: 10px; }
.trooms li { flex: 1 1 0; min-width: 0; }
.troom { width: 100%; min-height: 58px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 11px; cursor: pointer; text-align: left; color: var(--ink);
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; }
.troom:hover { background: #fffbea; }
.troom.on { background: #fff3c4; }
.troom.full { opacity: .7; }
.troom-k { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #4a5570; }
.troom-k::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: var(--k); }
.troom b { max-width: 100%; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.troom small { font-size: 12.5px; color: var(--sub); }
[data-kind=race] { --k: var(--sun); }
[data-kind=world] { --k: var(--mint); }
[data-kind=raid] { --k: var(--ember); }
.tready { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.tready-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px 6px 4px 10px; cursor: pointer; text-align: left; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 14px; }
.tready-row:hover { background: #fffbea; }
.tready-row:hover .btn { filter: brightness(1.06); }
.tready-row:active .btn { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tready-k { width: 68px; flex: none; padding: 3px 0; text-align: center; font-size: 13px; background: var(--k); border: 2px solid var(--ink); border-radius: 9px; }
.tready b { flex: 1; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tready small { font-size: 14px; color: var(--sub); white-space: nowrap; }
.tready .btn { min-height: 44px; padding: 0 16px; font-size: 15px; border-radius: 12px; background: var(--k); box-shadow: 0 3px 0 var(--ink); }

.tfoot { grid-area: foot; justify-self: center; max-width: 100%; }
.tsite { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 4px; padding: 0 10px; background: var(--card); border: 2.5px solid var(--ink); border-radius: 14px; }
.tsite a { padding: 5px 10px; font-size: 14px; color: var(--ink); text-decoration: none; }
.tsite a:hover { text-decoration: underline; }
.tsite a.tlab { color: #4a5570; }
@media (pointer: coarse) { .tsite a { display: flex; align-items: center; min-height: 44px; } }

/* Narrow desktop: the play bar takes its own row. Tablet: Raid on top, Race and Build side by side, the rooms scroll. */
@media (max-width: 1180px) { #title.feat .tplay { order: 3; flex-basis: 100%; } #title.feat .tcont { margin-left: auto; } #title.feat .tcont:not([hidden]) + .tsite-top { margin-left: 0; } }
@media (max-width: 900px) {
  #title, #title.raid, #title.feat { grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: none; grid-auto-rows: max-content; gap: 14px 12px; padding: 14px 14px 24px;
    grid-template-areas: "top top" "race build" "rooms rooms" "foot foot"; }
  #title.raid, #title.feat { grid-template-areas: "top top" "raid raid" "race build" "rooms rooms" "foot foot"; }
  .traid { min-height: 400px; }
  .tmedia { flex: none; height: 150px; }
  .trooms { overflow-x: auto; margin-right: -14px; padding: 0 14px 4px 0; scrollbar-width: none; }
  .trooms li { flex: none; width: 168px; }
  .tready { grid-template-columns: 1fr; }
}
/* Phone: the hero comes first with the wordmark and account on it, then Continue, the play bar, the two game cards. */
@media (max-width: 640px) {
  #title { scrollbar-width: none; }
  #title::-webkit-scrollbar { display: none; }
  #title .d { display: none; }
  #title .m { display: inline; }
  .logo .w { font-size: 30px; -webkit-text-stroke: 5px var(--ink); }
  .ttop { gap: 12px; }
  .tplay, #title:not(.feat) .tplay { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .tplay-txt b { font-size: 18px; }
  .btn.tquick { min-height: 50px; padding: 0 16px; font-size: 17px; }
  #tRaceCpu { order: 2; flex-basis: 100%; }
  .tcode { order: 3; flex: 1 1 100%; flex-wrap: wrap; padding-left: 0; border-left: 0; }
  .tcode label { flex-basis: 100%; font-size: 12.5px; }
  .tcode input { flex: 1; min-width: 0; width: auto; height: 48px; font-size: 16px; border-radius: 14px; }
  .btn.tjoin { min-height: 48px; border-radius: 14px; }
  .tcont, #title:not(.feat) .tcont, #title.feat .tcont { order: 2; flex: 1 1 100%; max-width: none; margin: 0; padding: 10px 10px 10px 14px; background: var(--card); border-width: 3.5px; border-radius: 20px; box-shadow: 0 5px 0 var(--ink); }
  .tcont-info { flex: 1; line-height: 1.2; }
  .tcont-info small { font-size: 12px; color: #4a5570; }
  .tcont-info b { font-size: 16px; white-space: normal; }
  .tcont-go { display: inline-flex; align-items: center; min-height: 46px; padding: 0 14px; font: 700 16px/1 var(--font); background: var(--mint); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
  .tsite-top a.tacct, .tsite-top .dt-me-btn { font-size: 14px; }
  #title:not(.feat) .tcont:not([hidden]) + .tsite-top { margin-left: auto; }
  #title.feat { grid-template-areas: "raid raid" "cont cont" "play play" "race build" "rooms rooms" "foot foot"; }
  #title.feat .ttop { display: contents; }
  #title.feat .logo { grid-area: raid; align-self: start; justify-self: start; z-index: 2; margin-top: 2px; }
  #title.feat .logo .w { -webkit-text-stroke-color: var(--night); }
  #title.feat .tsite-top { grid-area: raid; align-self: start; justify-self: end; z-index: 2; margin: 0; }
  #title.feat .tcont { grid-area: cont; }
  #title.feat .tplay { grid-area: play; }
  #title.feat .traid { height: 470px; min-height: 0; margin: -14px -14px 0; border-width: 0 0 3.5px; border-radius: 0 0 26px 26px; box-shadow: none; }
  #title.feat .traid::before { background-position: 50% 40%; background-size: 400%; }
  #title.feat .traid::after { background: linear-gradient(180deg, rgba(8,18,27,.7) 0%, rgba(8,18,27,0) 22%); }
  #title.feat .ttag { top: 70px; left: 14px; font-size: 13px; padding: 3px 10px; }
  .traid-body, #title.raid:not(.feat) .traid-body { gap: 8px; margin: 10px; padding: 14px; }
  .traid-eyebrow { font-size: 11.5px; letter-spacing: .16em; }
  .traid h2, #title.raid:not(.feat) .traid h2 { font-size: 34px; }
  .traid p { font-size: 14.5px; }
  .traid-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .traid-acts .btn { min-height: 52px; font-size: 18px; border-radius: 15px; }
  .tgame { border-radius: 20px; }
  .tmedia { height: 130px; border-bottom-width: 3px; }
  .tcard-race .tmedia { background-image: url(img/hub/race-sm.webp); background-position: 50% 50%; }
  .tgame-body { gap: 6px; padding: 10px 10px 12px; }
  .tgame h2 { font-size: 24px; }
  .tgame p { min-height: 34px; font-size: 13px; }
  .tgame .btn { min-height: 48px; font-size: 16px; border-radius: 14px; }
  .trooms-card { padding: 10px 12px 12px; }
  .trooms-card .tl { flex-direction: column; gap: 0; margin: 0 0 8px; }
  .trooms { margin-right: -12px; padding-right: 12px; }
  .trooms li { width: 162px; }
  .troom { min-height: 62px; padding: 7px 10px; }
  .tready-row { gap: 10px; min-height: 56px; padding: 4px 5px 4px 8px; }
  .tready-k { width: 54px; font-size: 12px; }
  .tready b { font-size: 15.5px; }
  .tready small { display: none; }
  .tsite { padding: 4px; border-radius: 16px; }
  .tsite a { display: flex; align-items: center; min-height: 44px; padding: 0 10px; }
}

@media (max-width: 700px) {
  #mini { width: 96px; height: 96px; border-width: 3px; }
  #bar { gap: 3px; padding: 4px; }
  #bar button { min-width: 45px; min-height: 50px; padding: 2px 3px; }
  body:not(.building) #bar button .t { font-size: 10.5px; }
  body.building #bar button .t { display: none; }
  body.building #bar button { min-width: 48px; min-height: 48px; }
  #guide { width: auto; right: 12px; top: 112px; }
  body.building #guide { display: none; }
  .pill small { display: none; }
  #build { width: calc(100vw - 88px); left: 76px; transform: none; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 90px); }
  #pieces .card { width: 80px; }
  body.building #bar { max-height: calc(100vh - 250px); }
}
@media (max-height: 560px) { body.building #bar [data-act=photo], body.building #bar [data-act=map] { display: none; } }
@media (prefers-reduced-motion: reduce) { .logo, #playBtn, #beacon::before { animation: none !important; } }

.bwname { position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none; padding: 1px 8px; border-radius: 10px; background: rgba(22, 24, 28, 0.62); color: #fff; font: 700 12px/1.4 var(--font, system-ui), system-ui, sans-serif; white-space: nowrap; will-change: transform; }
/* Game controller (gamepad.js): glyphs in the hint bars, focus ring while a pad drives the menus, build cursor. */
kbd.pad { display: inline-block; min-width: 22px; text-align: center; border-radius: 999px; padding: 0 6px; font-size: 11px; line-height: 17px; }
kbd.pad.face { width: 22px; padding: 0; border-radius: 50%; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
kbd.pad.a { background: #2fa14f; } kbd.pad.b { background: #d9453d; } kbd.pad.x { background: #2f7fd1; } kbd.pad.y { background: #d6a21c; }
body.padnav :focus { outline: 4px solid var(--sky); outline-offset: 3px; }
body.padnav .btn:focus, body.padnav button:focus { transform: translateY(-2px); }
body.padnav input[type=range]:focus { outline-offset: 6px; }
#padHint { left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 156px); transform: translateX(-50%); font-size: 13px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; max-width: min(900px, calc(100vw - 220px)); text-align: center; z-index: 12; }
body.photo #padHint { bottom: 124px; }
#padHint[hidden] { display: none; }
#padReticle { position: fixed; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ink); pointer-events: none; z-index: 11; }
#padReticle::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: var(--sun); border-radius: 50%; }
#padReticle[hidden] { display: none; }

/* Vehicles: the picker (V or the bar button) and the plane's power slider and readout. */
#vehPick { position: fixed; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 152px); transform: translateX(-50%); z-index: 14; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; width: min(500px, calc(100vw - 24px)); background: var(--paper); border: var(--line) solid var(--ink); border-radius: 20px; box-shadow: var(--drop); }
#vehPick[hidden] { display: none; }
#vehPick button { flex: 1 1 0; min-width: 0; min-height: 88px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; line-height: 1.1; }
#vehPick button .vi { font-size: 30px; display: flex; color: var(--ink2); }
#vehPick button b { font-size: 14px; }
#vehPick button small { font-size: 10.5px; font-weight: 600; color: var(--mute); text-align: center; }
#vehPick button:hover:not(:disabled), #vehPick button:focus-visible { background: var(--sun); }
#vehPick button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#vehPick button.on { background: var(--mint); }
#vehPick .veh-paints { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 4px; }
#vehPick .veh-paints button { flex: 0 1 auto; min-height: 28px; min-width: 0; padding: 4px 8px; font: 700 11px var(--font); }
#vehPick button:disabled { opacity: .45; cursor: not-allowed; }
body.building #vehPick, body.photo #vehPick { display: none; }
#bar button[data-act=vehicles] { background: var(--sky); }
#bar button[data-act=races] { background: var(--mint); }
body.racing #guide, body.racing #hint, body.racing #bar { display: none !important; }
#thr { position: fixed; right: 18px; bottom: 118px; width: 64px; z-index: 7; display: none; flex-direction: column; gap: 6px; touch-action: none; }
body.flying #thr { display: flex; }
body.flying #jump { display: none !important; }
body.building #thr, body.photo #thr { display: none; }
#flt { background: var(--paper); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink); padding: 3px 4px; text-align: center; font-size: 11px; line-height: 1.2; }
#flt b { display: block; font-size: 12px; }
#flt.stall { background: var(--coral); color: #fff; }
#fltHeat { display: block; font-weight: 700; font-size: 10px; }
#fltHeat[hidden] { display: none; }
#thrTrack { position: relative; height: min(150px, calc(100vh - 330px)); min-height: 70px; background: rgba(255,247,227,.55); border: 4px solid var(--ink); border-radius: 18px; overflow: hidden; touch-action: none; cursor: ns-resize; }
#thrFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--sun); border-top: 4px solid var(--ink); pointer-events: none; }
#thrTrack span { position: absolute; left: 0; right: 0; top: 4px; text-align: center; font-size: 11px; font-weight: 700; color: var(--ink); pointer-events: none; }

/* ---- races ------------------------------------------------------------------------------------ */
#race { position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 54px); left: 0; right: 0; width: max-content; max-width: calc(100vw - 24px); margin-inline: auto; transform: none; z-index: 9; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 14px; min-width: 190px; background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 4px 0 var(--ink); pointer-events: none; }
#race[hidden] { display: none; }
#race .rt-row { display: flex; align-items: baseline; gap: 8px; }
#race .rt { font: 700 26px var(--font); font-variant-numeric: tabular-nums; line-height: 1; }
#race .rspd { font: 800 26px var(--font); font-variant-numeric: tabular-nums; line-height: 1; }
#race .rspd small { font: 700 10px var(--font); margin-left: 2px; color: var(--mute); }
#race .rodo { font: 700 11px var(--font); color: var(--mute); font-variant-numeric: tabular-nums; line-height: 1; }
#race .rpos { font: 800 13px var(--font); padding: 2px 7px; background: var(--sun); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; line-height: 1.1; white-space: nowrap; }
#race .rs { font: 600 13px var(--font); color: var(--mute); min-height: 16px; font-variant-numeric: tabular-nums; }
#race .rs.ahead { color: #1f9d55; } #race .rs.behind { color: #d64545; }
#race .rg { display: flex; align-items: center; gap: 8px; font: 700 13px var(--font); }
#race .ra { display: inline-block; font-size: 22px; line-height: 1; color: var(--ink); }
#raceCorner { position: fixed; right: 12px; top: 176px; z-index: 9; display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-end; gap: 6px; pointer-events: none; max-width: calc(100vw - 16px); }
#raceSpeed { order: 2; flex: 0 0 auto; width: 156px; box-sizing: border-box; text-align: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); padding: 4px 8px 5px; }
#raceCorner .racts { order: 1; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; max-width: calc(100vw - 180px); pointer-events: auto; }
#raceActsBtn { box-sizing: border-box; font: 800 15px var(--font); height: 40px; min-height: 40px; padding: 0 14px; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 2px 0 var(--ink); cursor: pointer; }
#raceActsBtn.on { background: var(--mint); }
#raceActs[hidden] { display: none !important; }
#race .rb { display: flex; gap: 6px; pointer-events: auto; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: min(440px, calc(100vw - 24px)); }
#race .rb button { font: 800 15px var(--font); padding: 6px 12px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 2px 0 var(--ink); cursor: pointer; min-height: 40px; min-width: 64px; }
#race .rb button:active { transform: translateY(2px); box-shadow: none; }
#race .rb button.rtoggle { background: rgba(255,255,255,.88); color: var(--ink2); transition: background .12s, transform .08s; }
#race .rb button.rtoggle.on { background: var(--mint); color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
#race #raceItem { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.72); color: var(--mute); border-style: dashed; padding: 4px 10px; transition: transform .12s, background .15s; }
#race #raceItem.ready { background: var(--sun); color: var(--ink); border-style: solid; animation: ritemPulse 1.1s ease-in-out infinite alternate; }
#race #raceItem.ready.spin { background: linear-gradient(90deg, #ffd23f, #5fd0ff, #ff5c7a); background-size: 200% 100%; animation: ritemSpin .35s linear infinite; }
#race #raceItem.active { background: var(--mint); color: var(--ink); border-style: solid; }
#race #raceItem .ri-ico { font-size: 14px; line-height: 1; }
#race #raceItem .ri-key { font-size: 10px; padding: 1px 4px; background: rgba(26,43,74,.12); border-radius: 5px; margin-left: 2px; }
@keyframes ritemPulse { from { transform: scale(1); } to { transform: scale(1.05); } }
@keyframes ritemSpin { 0% { background-position: 0% 50%; transform: scale(1.03); } 100% { background-position: 200% 50%; transform: scale(0.98); } }
/* Starting grid (race.js renderLobbyUi): a card at the foot of the screen, a bottom sheet on phones. */
#raceLobby { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 13; width: min(860px, calc(100vw - 28px)); max-height: calc(100vh - 36px); overflow: auto; padding: 16px 20px 12px; background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); display: flex; flex-direction: column; gap: 10px; }
#raceLobby[hidden] { display: none; }
body.raceLobby #race, body.raceLobby #racecount { display: none !important; }
.rl-grab { display: none; }
.rl-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rl-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rl-pill { width: fit-content; font: 800 10.5px var(--font); letter-spacing: .06em; padding: 2px 9px; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; color: var(--ink); }
.rl-pill.priv { background: var(--mint); }
.rl-title h3 { margin: 0; font: 800 22px/1.1 var(--font); color: var(--ink); }
.rl-title small { font: 600 13px var(--font); color: var(--mute); }
.rl-code { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; flex-shrink: 0; }
.rl-code b { font: 800 17px var(--font); letter-spacing: .14em; color: var(--ink); }
.rl-inv, .rl-qrb { font: 800 12px var(--font); padding: 4px 10px; border: 2px solid var(--ink); border-radius: 8px; background: var(--sun); color: var(--ink); cursor: pointer; }
.rl-qrb { background: #fff; }
.rl-code.rl-mk { flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 14px; cursor: pointer; box-shadow: 0 3px 0 var(--ink); font: inherit; }
.rl-mk b { font-size: 14px; letter-spacing: 0; }
.rl-mk small { font: 700 11px var(--font); color: var(--mute); }
.rl-qr { display: flex; align-items: center; gap: 14px; padding: 8px; border: 2px dashed var(--ink); border-radius: 14px; background: #fff; font: 600 13px/1.4 var(--font); color: var(--ink); }
.rl-qr svg { flex-shrink: 0; border-radius: 6px; }
.rl-qr b { font-size: 17px; letter-spacing: .14em; }
.rl-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding-top: 4px; }
.rl-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 9px; row-gap: 7px; align-items: center; padding: 10px 11px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); min-width: 0; }
.rl-card > div { min-width: 0; }
.rl-card b { display: block; font: 800 15px/1.15 var(--font); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-card small { display: block; margin: 0; font: 600 11.5px var(--font); color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-card.you { border-color: #e59400; box-shadow: 0 0 0 2px var(--sun), 0 3px 0 var(--ink); }
.rl-card.new { box-shadow: 0 0 0 3px var(--mint), 0 3px 0 var(--ink); }
.rl-card.open { border-style: dashed; box-shadow: none; background: transparent; }
.rl-ico { width: 40px; height: 40px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 10px; background: color-mix(in srgb, var(--sw) 24%, #fff); }
.rl-ico svg { width: 30px; height: auto; }
.rl-ico.plus { font: 700 20px var(--font); color: var(--ink); border-style: dashed; background: transparent; }
.rl-state { grid-column: 1 / -1; width: fit-content; font: 800 11px var(--font); padding: 2px 9px; border: 2px dashed var(--ink); border-radius: 999px; color: var(--mute); }
.rl-state.ready { border-style: solid; background: #c8fff1; color: var(--ink); }
.rl-tag { position: absolute; top: -11px; right: 10px; font: 800 9.5px var(--font); font-style: normal; letter-spacing: .05em; padding: 1px 7px; background: var(--mint); border: 2px solid var(--ink); border-radius: 999px; color: var(--ink); }
.rl-cpus { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 2px dashed rgba(29,42,68,.3); border-radius: 12px; font: 700 13px var(--font); color: var(--mute); }
.rl-cput { flex: 1; min-width: 0; }
.rl-cput .s { display: none; }
.rl-dots { display: flex; gap: 3px; }
.rl-dots i { width: 20px; height: 20px; display: grid; place-items: center; border: 1.5px dashed var(--mute); border-radius: 50%; font: 800 10px var(--font); font-style: normal; }
.rl-link { background: none; border: 0; padding: 0; font: 800 13px var(--font); color: var(--ink); text-decoration: underline; cursor: pointer; }
.rl-paints { display: flex; align-items: center; gap: 10px; font: 800 12px var(--font); color: var(--ink); }
.rl-paints > span { flex-shrink: 0; }
.rl-paints > div { display: flex; gap: 6px; flex-wrap: wrap; padding: 3px; }
.rl-sw { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--ink); background: var(--sw); padding: 0; cursor: pointer; }
.rl-sw.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4.5px var(--ink); }
.rl-btns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.rl-btns.solo { grid-template-columns: 1fr; }
.rl-ready, .rl-start { min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 10px; font: 800 17px var(--font); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.rl-ready { background: #fff; }
.rl-ready.on { background: #c8fff1; }
.rl-start { background: linear-gradient(90deg, #ffa21f var(--fill, 0%), var(--sun) var(--fill, 0%)); }
.rl-start.on { background: linear-gradient(90deg, #4fd8b2 var(--fill, 0%), #c8fff1 var(--fill, 0%)); }
.rl-auto { font: 800 12px var(--font); padding: 2px 9px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); font-variant-numeric: tabular-nums; }
.rl-ready:active, .rl-start:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.rl-fine { margin: 0; text-align: center; font: 600 12px var(--font); color: var(--mute); }
.rl-fine .rl-link { font-size: 12px; }
@media (max-width: 700px) {
  #raceLobby { left: 0; right: 0; bottom: 0; transform: none; width: auto; max-height: 74vh; border-radius: 22px 22px 0 0; border-bottom: 0; box-shadow: 0 -4px 0 var(--ink); padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); gap: 9px; }
  .rl-grab { display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(29,42,68,.25); margin: 0 auto 2px; }
  .rl-top { flex-direction: column; gap: 8px; }
  .rl-title h3 { font-size: 19px; }
  .rl-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rl-cpus { gap: 8px; padding: 7px 10px; }
  .rl-cput .l { display: none; }
  .rl-cput .s { display: inline; }
  .rl-dots i:nth-child(n+3) { display: none; }
  .rl-paints > div { flex-wrap: nowrap; overflow-x: auto; }
  .rl-ready, .rl-start { min-height: 48px; font-size: 15px; gap: 7px; }
  body.raceLobby #drift, body.raceLobby #itemBtn { display: none !important; }
}
#racecount { position: fixed; left: 50%; top: 34%; transform: translate(-50%, -50%); z-index: 12; font: 800 clamp(72px, 18vw, 140px) var(--font); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; pointer-events: none; }
#racecount[hidden] { display: none; }
#racecount.go { color: var(--sun); }
#racecount.pop { animation: countPop .32s ease-out; }
@keyframes countPop { from { transform: translate(-50%, -50%) scale(1.4); } to { transform: translate(-50%, -50%) scale(1); } }
.sheet .box.race { width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 36px); overflow-y: auto; }
.rhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.rhead h2 { margin: 0; }
.rroom-badge { font: 700 12px var(--font); padding: 4px 10px; background: var(--mint); border: 2px solid var(--ink); border-radius: 999px; }
.rveh-bar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin: 6px 0 8px; padding: 6px 8px; background: rgba(26,43,74,.06); border-radius: 12px; }
.rveh-lbl { font: 700 12px var(--font); color: var(--mute); margin-right: 4px; }
.rveh-btn { font: 700 12px var(--font); padding: 4px 9px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; cursor: pointer; }
.rveh-btn.on { background: var(--sun); }
.rrow { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 2px dashed rgba(26,43,74,.18); }
.rrow.off { opacity: .55; }
.rrow b { font: 700 18px var(--font); display: block; } .rrow small { color: var(--mute); font-weight: 600; }
.rrow .rbest { font: 700 16px var(--font); font-variant-numeric: tabular-nums; }
.rcls { margin: 0 0 4px; color: var(--mute); font-weight: 600; }
.rboard { margin-top: 10px; padding: 8px 10px; background: rgba(255,255,255,.72); border: 2px solid var(--ink); border-radius: 14px; }
.rboard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.rbtabs { display: flex; gap: 4px; }
.rbtab { font: 700 11.5px var(--font); padding: 3px 8px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; cursor: pointer; }
.rbtab.on { background: var(--sky); }
.rfriend { display: flex; gap: 4px; align-items: center; }
.rfriend input { font: 600 12px var(--font); padding: 4px 8px; width: 145px; border: 2px solid var(--ink); border-radius: 9px; }
.rfriend .btn { padding: 4px 8px; font-size: 11.5px; min-height: 28px; }
.rboard-ghosts { font: 600 12px var(--font); color: var(--mute); margin-bottom: 6px; }
.rlb-list { display: flex; flex-direction: column; gap: 3px; }
.rlb-row { display: flex; justify-content: space-between; font: 600 13px var(--font); padding: 3px 6px; border-radius: 8px; background: rgba(26,43,74,.05); font-variant-numeric: tabular-nums; }
.rlb-empty, .rboard-loading { font: 600 12.5px var(--font); color: var(--mute); padding: 4px 0; }
.rbig { font: 800 56px var(--font); text-align: center; font-variant-numeric: tabular-nums; margin: 6px 0; }
.rmedal { text-align: center; font: 700 20px var(--font); padding: 6px 10px; border: 3px solid var(--ink); border-radius: 14px; background: var(--m, #eee); margin: 4px auto; width: fit-content; }
.rmedal.none { background: #fff; font-size: 15px; }
.rline { text-align: center; margin: 6px 0; font-weight: 600; } .rline.good { color: #1f9d55; font-weight: 700; } .rline.mute { color: var(--mute); font-size: 13px; }
.tdaily { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-top: auto; padding: 8px 12px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
.tdaily[hidden] { display: none; }
.tsave { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: auto; padding: 10px 12px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); text-decoration: none; color: var(--ink); }
.tsave[hidden] { display: none; }
.tsave:hover, .tsave:focus-visible { background: #fffbea; transform: translateY(-1px); }
.tsave:not([hidden]) + .tdaily { margin-top: 0; }
/* The hub's keep-your-progress card (play/js/title.js): under the live rooms; signed in, it carries a squadmate's invite. */
.trooms-card .tsave { margin-top: 10px; }
.tsave.invite { background: #eafff6; }
.tsave-ico { font-size: 22px; flex-shrink: 0; }
.tsave-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; text-align: left; }
.tsave-info b { font: 700 13.5px var(--font); }
.tsave-info small { font-size: 12px; opacity: .75; }
.tsave-go { flex-shrink: 0; font: 800 13px var(--font); padding: 6px 12px; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink); }
.tdaily #dailyBtn { min-height: 38px; padding: 0 14px; font-size: 13.5px; flex-shrink: 0; }
.tdaily-info { display: flex; flex-direction: column; text-align: left; gap: 2px; min-width: 0; }
.tdaily-pill { display: inline-block; width: fit-content; font: 800 10px var(--font); letter-spacing: .06em; padding: 2px 7px; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; }
.tdaily-info b { font: 700 13.5px var(--font); color: var(--ink); }
.tdaily-info small { font: 600 11.5px var(--font); color: var(--mute); }
#tRaces button.race-room-btn { background: #fff7d6; border-color: var(--ink); }
#tRaces button.race-room-btn.full { opacity: .82; }
body.photo #race, body.building #race { display: none; }

/* ---- Home Hub Online Rooms Advertising & Live Status Banner ---- */
.tbadge.online { background: #c5f7df; }
.tonline-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; width: min(860px, 100%); margin-top: 4px; padding: 7px 12px; background: rgba(255, 247, 227, 0.96); border: 2.5px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink); text-align: left; }
.tonline-banner[hidden] { display: none; }
.tonline-status { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font: 600 13px/1.2 var(--font); color: var(--ink); }
.tonline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); border: 2px solid var(--ink); flex-shrink: 0; animation: liveDot 1.6s ease-in-out infinite; }
@keyframes liveDot { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(31, 184, 106, .55); } 50% { transform: scale(1.15); box-shadow: 0 0 0 5px rgba(31, 184, 106, 0); } }
.tonline-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.tonline-btn { font: 700 12px/1.1 var(--font); padding: 5px 11px; border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink); cursor: pointer; background: #fff; color: var(--ink); transition: transform .06s, background .1s; }
.tonline-btn.race { background: var(--sun); }
.tonline-btn.race:hover { background: #ffd35e; }
.tonline-btn.world { background: var(--mint); }
.tonline-btn.world:hover { background: #56e3ba; }
.tonline-btn:active { transform: translateY(2px); box-shadow: none; }

.places.trooms li, .places.tworlds li { flex: 1 1 200px; }
.places.trooms button, .places.tworlds button { display: flex; flex-direction: column; gap: 3px; padding: 7px 11px; min-height: 52px; border-width: 2.5px; transition: transform .06s, background .1s; }
.places.tworlds button.world-room-btn { background: #ecfff8; }
.places.tworlds button.world-room-btn:hover { background: #d0faeb; }
.places.tworlds button.world-room-btn.active-room { background: #bdf7e2; border-color: var(--ink); box-shadow: 0 3px 0 var(--ink), inset 0 0 0 1.5px var(--good); }
#tRaces button.race-room-btn.active-room { background: #ffe484; box-shadow: 0 3px 0 var(--ink), inset 0 0 0 1.5px var(--sun2); }
.room-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; }
.room-title { font: 700 13px/1.15 var(--font); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-pill { font: 800 10.5px/1.1 var(--font); padding: 2px 7px; border-radius: 999px; border: 1.5px solid var(--ink); flex-shrink: 0; white-space: nowrap; }
.room-pill.live { background: var(--good); color: #fff; }
.room-pill.open { background: #fff; color: var(--ink2); }
.room-pill.full { background: var(--coral); color: #fff; }

/* ---- Build Mode Expanded Tool Rail ---- */
body.building #bar { gap: 4px; padding: 6px; max-height: calc(100vh - 190px); }
body.building #bar button { min-width: 54px; min-height: 44px; padding: 3px 6px; font-size: 11px; }
body.building #bar button .i { font-size: 19px; }

/* ---- Map Fast-Travel & Live Players Directory ---- */
#bigmap { cursor: crosshair; }
.mapTravel { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.mapTravel:empty { display: none; }
.mapTravel-wp { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 11px; background: #e8f7ff; border: 2.5px solid var(--ink); border-radius: 12px; font-size: 13.5px; }
.mapTravel-sec { display: flex; flex-direction: column; gap: 6px; }
.mapTravel-sec h3 { margin: 4px 0 0; font: 700 15.5px var(--font); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mapTravel-sec h3 small { font: 600 12px var(--font); color: var(--mute); }
.mapTravel-list { display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow-y: auto; padding-right: 2px; }
.mapTravel-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 0 2.5px 0 var(--ink); }
.mapTravel-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mapTravel-info b { font: 700 14px/1.15 var(--font); color: var(--ink); display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapTravel-info small { font: 600 11.5px/1.15 var(--font); color: var(--mute); }
.mapTravel-acts { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.btn.mini { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 10px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
.mapTravel-empty { margin: 0; padding: 8px 10px; background: rgba(255,255,255,.65); border: 2px dashed rgba(29,42,68,.25); border-radius: 12px; font-size: 12.5px; color: var(--mute); }

@media (max-width: 700px) and (orientation: portrait) { #race { top: 168px; padding: 8px 10px; max-width: calc(100vw - 16px); } #raceCorner { top: 114px; } #raceSpeed { width: 96px; } #race .rspd { font-size: 20px; } #race .rb { gap: 6px; max-width: calc(100vw - 32px); } #race .rb button { font-size: 15px; padding: 6px 12px; min-height: 40px; min-width: 64px; } #raceLobby { padding: 10px 12px; } .rlobby-slots { grid-template-columns: 1fr; } .tonline-banner { border-radius: 16px; } }
@media (max-height: 430px) { #top { max-width: calc(100vw - 400px); } #mini { width: 108px; height: 108px; } #raceCorner { top: 126px; } #raceSpeed { width: 108px; } #race { top: calc(max(6px, env(safe-area-inset-top)) + 4px); left: auto; right: 132px; margin: 0; transform: none; padding: 6px 8px; min-width: 0; max-width: 280px; gap: 4px; } #race .rt { font-size: 17px; } #race .rpos { font-size: 12px; padding: 2px 6px; } #race .rs { font-size: 12px; min-height: 14px; } #race .rg { display: none; } #race .rodo { display: none; } #race .rb { gap: 6px; max-width: min(420px, calc(100vw - 150px)); } #race .rb button { min-height: 40px; min-width: 64px; padding: 6px 12px; font-size: 15px; } }
/* The Menu button's tray (tray.js) and the pet picker: cream cards over the bar, chunky buttons. */
#tray { position: fixed; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px); transform: translateX(-50%); z-index: 14; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px; width: min(440px, calc(100vw - 24px));
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 20px; box-shadow: var(--drop); animation: trayIn .14s ease-out; }
#tray[hidden], #petPick[hidden] { display: none; }
#tray button { min-width: 0; min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; line-height: 1.1; color: var(--ink); font: inherit; }
#tray button .ti { font-size: 28px; display: flex; color: var(--ink2); }
#tray button b { font-size: 14px; }
#tray button small { font-size: 10.5px; font-weight: 600; color: var(--mute); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
#tray button:hover, #tray button:focus-visible { background: var(--sun); }
#tray button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#tray button[data-tray=pet] { background: var(--paper2); }
#tray button[data-tray=menu] { background: var(--sky); }
@keyframes trayIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
#petPick { position: fixed; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px); transform: translateX(-50%); z-index: 15; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 140px); display: flex; flex-direction: column; padding: 8px 10px 10px;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 20px; box-shadow: var(--drop); }
#petPick .pphead { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px 6px; font-size: 16px; }
#petPick .ppx { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 0 2px 0 var(--ink); cursor: pointer; color: var(--ink); }
#petPick .ppgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; overflow-y: auto; padding: 2px 2px 4px; }
#petPick .ppgrid button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 4px 6px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; font: inherit; color: var(--ink); line-height: 1.1; }
#petPick .ppgrid img, #petPick .ppgrid .ppic { width: 76px; height: 76px; border-radius: 10px; background: var(--paper2); object-fit: contain; display: flex; align-items: center; justify-content: center; font-size: 36px; }
#petPick .ppgrid b { font-size: 12.5px; text-align: center; }
#petPick .ppgrid button:hover, #petPick .ppgrid button:focus-visible { background: var(--paper2); }
#petPick .ppgrid button.on { background: var(--sun); }
#petPick .ppgrid button.busy { opacity: .6; cursor: progress; }
#petPick .ppgrid button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
body.building #tray, body.photo #tray, body.building #petPick, body.photo #petPick { display: none; }
@media (max-width: 420px) { #tray button { min-height: 76px; } #tray button .ti { font-size: 24px; } #petPick .ppgrid { grid-template-columns: repeat(3, 1fr); } }

/* Racing on a phone: the status pills, the long timer panel and the big minimap covered the road. During a race only
   Home stays up top, the timer is a compact strip beside it, and the minimap is smaller. (The Get out button is hidden
   in main.js while a race is on.) */
body.racing.touch #top > :not(#homeBtn) { display: none; }
body.racing.touch #homeBtn { padding: 6px 10px; }
body.racing.touch #mini { width: 76px; height: 76px; border-width: 3px; opacity: .92; }
body.racing.touch #race { top: calc(max(10px, env(safe-area-inset-top)) + 2px); left: 100px; right: 100px; width: auto; max-width: none; min-width: 0; margin: 0; padding: 5px 8px; gap: 2px; border-width: 2px; border-radius: 14px; box-shadow: 0 2px 0 var(--ink); opacity: .94; }
body.racing.touch #race .rt { font-size: 20px; }
body.racing.touch #race .rodo, body.racing.touch #race .rs:not(.ahead):not(.behind) { display: none; }
body.racing.touch #race .rg { font-size: 12px; gap: 5px; }
body.racing.touch #race .ra { font-size: 16px; }
body.racing.touch #raceCorner { top: 96px; }

/* Endless uses the normal driving HUD; fixed-map activities are unavailable. */
body.endless #mini, body.endless #guide, body.endless [data-act="build"], body.endless [data-act="races"], body.endless [data-act="map"] { display: none !important; }

body.endless #top > :not(#homeBtn) { display: none; }
body.endless:not(.touch) #spd { bottom: 128px; }
body.endless.touch #spd { top: 66px; left: 12px; right: auto; bottom: auto; }
body.endless.touch #use { top: 66px; right: 12px; left: auto; bottom: auto; transform: none; }
@media (max-height: 500px) {
  body.endless.touch #spd { top: 12px; right: 12px; left: auto; }
  body.endless.touch #use { top: 90px; }
  body.endless.touch #flip { left: 200px; top: 12px; bottom: auto; }
}
