:root {
  --gold: #f2b544;
  --gold-hi: #ffd27a;
  --ink: #000000;
  --glass: rgba(0, 0, 0, .72);
  --line: rgba(255, 255, 255, .14);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, .62);
  --danger: #ff5a46;
  --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);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); overflow: hidden;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none;
  user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
#stage, #hud, #touch, #touch *, .marker { touch-action: none; }
.screen { touch-action: pan-y; }
.hidden { display: none !important; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-zone, .hud-objective, .hud-right > * { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; }
.hud-zone { position: absolute; top: calc(10px + var(--sat)); left: calc(12px + var(--sal)); padding: 6px 14px;
  display: flex; flex-direction: column; line-height: 1.15; border-radius: 14px; }
.hud-zone span:first-child { font-size: 10px; letter-spacing: .18em; color: var(--gold); font-weight: 800; }
.hud-zone span:last-child { font-size: 14px; font-weight: 700; }
.hud-objective { position: absolute; top: calc(10px + var(--sat)); left: 50%; transform: translateX(-50%);
  padding: 7px 16px; font-size: 13px; font-weight: 600; max-width: 46vw; text-align: center; border-radius: 14px; }
.hud-right { position: absolute; top: calc(10px + var(--sat)); right: calc(12px + var(--sar)); display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.hearts { padding: 6px 12px; font-size: 15px; letter-spacing: 2px; color: var(--danger); }
.timer { padding: 6px 12px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.icon-btn { width: 36px; height: 36px; font-weight: 900; font-size: 12px; background: var(--glass); border: 1px solid var(--line); border-radius: 50%; }
.alert { position: absolute; top: calc(58px + var(--sat)); left: 50%; transform: translateX(-50%); font-weight: 900;
  letter-spacing: .14em; font-size: 13px; padding: 5px 14px; border-radius: 999px; opacity: 0; transition: opacity .2s; }
.alert.sus { opacity: 1; background: rgba(242, 181, 68, .18); color: var(--gold-hi); border: 1px solid rgba(242, 181, 68, .5); }
.alert.seen { opacity: 1; background: rgba(255, 90, 70, .22); color: #ffd0c8; border: 1px solid rgba(255, 90, 70, .6); }
.race { position: absolute; top: calc(92px + var(--sat)); left: 50%; transform: translateX(-50%); font-size: 30px; font-weight: 900;
  color: var(--gold-hi); text-shadow: 0 2px 12px #000; font-variant-numeric: tabular-nums; }
#minimap { position: absolute; right: calc(12px + var(--sar)); top: calc(58px + var(--sat)); width: 160px; height: 120px;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .7); }
.toast { position: absolute; bottom: calc(150px + var(--sab)); left: 50%; transform: translateX(-50%); max-width: 80vw;
  padding: 10px 16px; border-radius: 14px; background: rgba(0, 0, 0, .9); border: 1px solid rgba(242, 181, 68, .45);
  font-size: 14px; text-align: center; opacity: 0; transition: opacity .25s; }
.toast.show { opacity: 1; }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; }
.stick { position: absolute; left: calc(24px + var(--sal)); bottom: calc(24px + var(--sab)); width: 132px; height: 132px;
  border-radius: 50%; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); pointer-events: auto; touch-action: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(255, 255, 255, .22); border: 1px solid rgba(255, 255, 255, .35); }
.buttons { position: absolute; right: calc(20px + var(--sar)); bottom: calc(22px + var(--sab)); display: grid;
  grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 12px; pointer-events: auto; align-items: end; }
.tbtn { width: 70px; height: 70px; border-radius: 50%; background: rgba(0, 0, 0, .62); border: 1px solid var(--line);
  font-weight: 800; font-size: 11px; letter-spacing: .06em; touch-action: none; }
.tbtn.on { background: rgba(242, 181, 68, .3); border-color: var(--gold); }
.tbtn.big { width: 92px; height: 92px; grid-row: 1 / span 2; grid-column: 2; align-self: center;
  background: radial-gradient(circle at 50% 35%, var(--gold-hi), var(--gold) 60%, #d99a1e); color: #000000; font-size: 15px; border: 0; }
#btnSneak { grid-column: 1; grid-row: 1; }
#btnAction { grid-column: 1; grid-row: 2; }
#btnJump { grid-column: 2; grid-row: 1; }
.tbtn.big { grid-row: 2; grid-column: 2; }
.buttons { grid-template-columns: auto auto; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0, 0, 0, .9); z-index: 20; }
.title-card { max-width: 520px; text-align: center; }
.kicker { font-size: 11px; letter-spacing: .26em; color: var(--gold); font-weight: 800; margin: 0 0 8px; }
.title-card h1 { font-size: clamp(56px, 14vw, 96px); margin: 0; letter-spacing: .04em; font-weight: 900;
  background: linear-gradient(180deg, #fff3d8, var(--gold) 70%, #d99a1e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.title-card h2 { font-size: 34px; margin: 0 0 16px; }
.sub { margin: 0 0 14px; font-size: 18px; color: var(--muted); font-weight: 600; }
.blurb { color: var(--muted); line-height: 1.5; margin: 0 auto 22px; max-width: 420px; }
.title-buttons { display: flex; gap: 12px; justify-content: center; }
.title-buttons.col { flex-direction: column; align-items: center; }
.primary { padding: 14px 40px; border-radius: 999px; border: 0; font-weight: 900; font-size: 17px; color: #000000;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); min-width: 180px; }
.primary:disabled { opacity: .45; }
.ghost { padding: 12px 26px; border-radius: 999px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); font-weight: 700; min-width: 180px; }
.loading { color: var(--muted); font-size: 13px; margin-top: 14px; min-height: 1em; }
.how { margin-top: 10px; color: var(--muted); font-size: 13px; text-align: left; }
.how summary { cursor: pointer; text-align: center; }

@media (max-height: 420px) {
  .stick { width: 112px; height: 112px; }
  .tbtn { width: 60px; height: 60px; }
  .tbtn.big { width: 80px; height: 80px; }
  #minimap { width: 120px; height: 90px; }
  .hud-objective { font-size: 12px; }
}

.hud-objective.pulse { animation: objPulse 2.4s ease-out; }
@keyframes objPulse {
  0% { transform: translateX(-50%) scale(1.25); background: rgba(242, 181, 68, .9); color: #000000; }
  40% { transform: translateX(-50%) scale(1.12); background: rgba(242, 181, 68, .9); color: #000000; }
  100% { transform: translateX(-50%) scale(1); }
}

/* ---------- the mix: one channel per part of the song ---------- */
.mixer { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--sab)); display: flex; gap: 6px;
  padding: 6px 8px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); }
.mixer:empty { display: none; }
.mixer .ch { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 62px; opacity: .45; }
.mixer .ch.on { opacity: 1; }
.mixer .bar { width: 10px; height: 26px; border-radius: 5px; background: rgba(255, 255, 255, .1); position: relative; overflow: hidden; }
.mixer .bar i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--c); transition: height .6s; }
.mixer .ch.on .bar i { height: 100%; animation: level 0.5s ease-in-out infinite alternate; }
@keyframes level { from { height: 70%; } to { height: 100%; } }
.mixer b { font-size: 10px; font-weight: 800; letter-spacing: .04em; color: var(--c); white-space: nowrap; }
@media (pointer: coarse) { .mixer { bottom: calc(8px + var(--sab)); gap: 2px; padding: 4px 6px; } .mixer .ch { width: 46px; } .mixer b { font-size: 9px; } .mixer .bar { height: 18px; } }
.tip { position: absolute; left: calc(12px + var(--sal)); top: calc(66px + var(--sat)); max-width: min(320px, 44vw); padding: 10px 14px;
  border-radius: 14px; background: rgba(0, 0, 0, .9); border: 1px solid rgba(127, 227, 154, .45); font-size: 13px; line-height: 1.4;
  opacity: 0; transition: opacity .3s; }
.tip.show { opacity: 1; }
.tip::before { content: "TIP  "; color: #7fe39a; font-weight: 900; font-size: 11px; letter-spacing: .1em; }

/* ---------- mission list ---------- */
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 16px auto 0; max-width: 480px; }
.mission { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line); text-align: left; font-size: 12px; }
.mission span { color: var(--gold); font-weight: 900; width: 16px; }
.mission b { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mission em { font-style: normal; font-weight: 900; color: var(--gold-hi); font-size: 11px; }
.mission.locked { opacity: .35; cursor: default; }
.mission.locked em { color: var(--muted); font-weight: 600; }

/* ---------- card ---------- */
.card { background: rgba(0, 0, 0, .9); border: 1px solid var(--line); border-radius: 22px; padding: 24px 26px; width: min(560px, 94vw); }
.card .placeholder { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.card .lines { text-align: left; margin: 0 0 14px; }
.card .lines p { margin: 0 0 8px; font-size: 16px; line-height: 1.45; }
.card .lines b { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin-right: 6px; }
.card .goal { margin: 0 0 18px; padding: 10px 14px; border-radius: 12px; background: #000; border: 1px solid rgba(242, 181, 68, .35);
  font-size: 14px; line-height: 1.45; text-align: left; }
.card .hint { margin: 10px 0 0; font-size: 11px; color: var(--muted); letter-spacing: .06em; }

/* ---------- score ---------- */
.grade { font-size: 84px; font-weight: 900; line-height: 1; margin: 4px 0 12px; color: var(--gold-hi); text-shadow: 0 4px 30px rgba(242, 181, 68, .5); }
.rows { width: min(360px, 90vw); margin: 0 auto 10px; text-align: left; }
.rows div { display: flex; justify-content: space-between; padding: 5px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.rows div span { color: var(--muted); }
.rows .total { border: 0; font-size: 18px; padding-top: 10px; }
.rows .total span { color: var(--text); font-weight: 800; }
.mix { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
@media (max-height: 520px) { .grade { font-size: 52px; } .rows div { padding: 3px 2px; font-size: 13px; } .card { padding: 16px 18px; } }

/* Short screens (phones on their side): everything fits, and scrolls if it must. */
.screen { overflow-y: auto; align-items: safe center; }
@media (max-height: 520px) {
  .title-card h1 { font-size: 48px; }
  .sub { font-size: 14px; margin-bottom: 6px; }
  .blurb { font-size: 12px; margin-bottom: 10px; }
  .kicker { margin-bottom: 4px; }
  .primary { padding: 10px 30px; font-size: 15px; }
  .ghost { padding: 9px 22px; }
  .missions { margin-top: 10px; }
  .mission { padding: 5px 8px; }
  .card h2, .title-card h2 { font-size: 24px; margin-bottom: 6px; }
  .card .lines p { font-size: 13px; margin-bottom: 4px; }
  .card .goal { font-size: 12px; padding: 7px 10px; margin-bottom: 10px; }
  .card .hint, .card .placeholder { display: none; }
  .card { padding: 12px 16px; }
  .card .kicker { font-size: 10px; }
  .tip { top: calc(56px + var(--sat)); font-size: 12px; padding: 7px 10px; max-width: 40vw; }
  .title-buttons.col { gap: 8px; }
}

.timer.low { color: #ff5a46; animation: low 1s steps(2) infinite; }
@keyframes low { 50% { opacity: .55; } }
.rows .fail { margin: 6px 0 4px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- the marker over the objective ---------- */
.marker { position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none; display: flex; flex-direction: column; align-items: center;
  will-change: transform; margin-left: 0; }
.marker .text { transform: translateX(-50%); position: absolute; left: 0; bottom: 14px; white-space: nowrap; padding: 5px 11px; border-radius: 999px;
  background: rgba(242, 181, 68, .95); color: #000000; font-weight: 900; font-size: 12px; letter-spacing: .06em; box-shadow: 0 4px 16px rgba(0, 0, 0, .45); }
.marker .pin { position: absolute; left: -6px; bottom: 2px; width: 12px; height: 12px; background: rgba(242, 181, 68, .95); transform: rotate(45deg); border-radius: 2px; }
.marker .arrow { display: none; position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; text-align: center; line-height: 24px;
  color: var(--gold-hi); font-size: 20px; text-shadow: 0 2px 8px #000; }
.marker.edge .arrow { display: block; }
.marker.edge .pin { display: none; }
.marker.edge .text { bottom: 18px; font-size: 11px; }

/* ---------- the beat, pops, boost ---------- */
.beat { width: 14px; height: 14px; border-radius: 50%; background: rgba(242, 181, 68, .25); border: 1px solid rgba(242, 181, 68, .6); }
.beat.hit { animation: beatHit .28s ease-out; }
.beat.hit.bar { animation-name: barHit; }
@keyframes beatHit { 0% { transform: scale(1.5); background: var(--gold-hi); } 100% { transform: scale(1); } }
@keyframes barHit { 0% { transform: scale(1.9); background: #fff; } 100% { transform: scale(1); } }
.pop { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(.8); font-weight: 900; font-size: 26px; letter-spacing: .08em;
  color: var(--gold-hi); text-shadow: 0 3px 14px #000; opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none; white-space: nowrap; }
.pop.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pop.good { color: #7fe39a; }
.pop.bad { color: #ff7a66; }
.tbtn.boost { --m: 1; grid-column: 1 / span 2; grid-row: 3; width: auto; height: 44px; border-radius: 22px;
  background: linear-gradient(90deg, rgba(90, 209, 255, .55) calc(var(--m) * 100%), rgba(0, 0, 0, .62) calc(var(--m) * 100%)); }

/* mission tints */
.tint { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
.tint.water { background: radial-gradient(ellipse 70% 60% at 50% 45%, rgba(20, 90, 110, .05), rgba(2, 20, 34, .85)); }

/* ---------- danger glow at the screen edge ---------- */
.edge { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.edge i { position: absolute; opacity: 0; transition: opacity .25s; --c: 242, 181, 68; }
.edge i.red { --c: 255, 70, 50; }
.edge .t { left: 0; right: 0; top: 0; height: 22vh; background: linear-gradient(to bottom, rgba(var(--c), .85), rgba(var(--c), 0)); }
.edge .b { left: 0; right: 0; bottom: 0; height: 22vh; background: linear-gradient(to top, rgba(var(--c), .85), rgba(var(--c), 0)); }
.edge .l { top: 0; bottom: 0; left: 0; width: 18vw; background: linear-gradient(to right, rgba(var(--c), .85), rgba(var(--c), 0)); }
.edge .r { top: 0; bottom: 0; right: 0; width: 18vw; background: linear-gradient(to left, rgba(var(--c), .85), rgba(var(--c), 0)); }

/* danger: glowing edges and arcs toward the guards */
.edge { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  box-shadow: inset 0 0 70px 18px rgba(242, 181, 68, .55); }
.edge.red { box-shadow: inset 0 0 80px 22px rgba(255, 60, 45, .65); }
.danger { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cover { position: absolute; left: 50%; bottom: calc(76px + var(--sab)); transform: translateX(-50%); padding: 4px 12px; border-radius: 999px;
  background: rgba(127, 227, 154, .18); border: 1px solid rgba(127, 227, 154, .6); color: #c9f5d5; font-weight: 900; font-size: 11px; letter-spacing: .14em;
  opacity: 0; transition: opacity .2s; }
.cover.show { opacity: 1; }

/* round radar on the left, under the quadrant name */
#radar { position: absolute; left: calc(12px + var(--sal)); top: calc(62px + var(--sat)); width: 140px; height: 140px; border-radius: 50%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .45); }
.tip { left: calc(162px + var(--sal)); max-width: min(300px, 34vw); }
@media (max-height: 520px) { #radar { width: 104px; height: 104px; top: calc(52px + var(--sat)); } .tip { left: calc(124px + var(--sal)); } }

/* the big map on the pause screen */
.pause-wrap { display: flex; gap: 22px; align-items: center; justify-content: center; width: min(1100px, 96vw); }
.map-card { flex: 1 1 auto; min-width: 0; background: rgba(0, 0, 0, .9); border: 1px solid var(--line); border-radius: 20px; padding: 12px 14px; }
.map-card .kicker { margin: 2px 0 8px; text-align: left; }
#bigmap { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 70vh; border-radius: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.lg-you { background: #fff; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.lg-goal { background: #ffd27a; transform: rotate(45deg); }
.lg-mud { background: #8c6038; } .lg-roof { background: rgba(255, 210, 122, .5); } .lg-done { background: #2c3a30; border: 1px solid #7fe39a; }
.pause-wrap .title-card { flex: 0 0 auto; }
@media (max-width: 760px), (max-height: 520px) {
  .pause-wrap { flex-direction: row; gap: 10px; align-items: stretch; }
  #bigmap { max-height: 72vh; }
  .pause-wrap .title-card h2 { font-size: 20px; }
  .pause-wrap .title-buttons.col .primary, .pause-wrap .title-buttons.col .ghost { min-width: 130px; padding: 9px 16px; font-size: 13px; }
}

/* phones: the round radar does the job of the square map, and the objective leaves room for the hearts */
@media (pointer: coarse) { #minimap { display: none; } }
@media (max-height: 520px) { .hud-objective { max-width: 30vw; font-size: 11px; padding: 6px 12px; } }

/* hearts under the clock; the objective gets the top centre to itself */
.hud-right { flex-direction: column; align-items: flex-end; gap: 6px; }
.hud-right > .hud-row { display: flex; gap: 8px; align-items: center; background: none; border: 0; }
.hud-row > .timer, .hud-row > .icon-btn { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; }
.hud-objective { max-width: min(560px, 52vw); }
@media (max-height: 520px) { .hud-objective { max-width: 44vw; } .hearts { font-size: 13px; padding: 4px 10px; } }

/* one map on screen: the round one, bottom left (top left on phones, where the stick isn't) */
#minimap { display: none !important; }
#radar { top: auto; bottom: calc(16px + var(--sab)); left: calc(16px + var(--sal)); width: 150px; height: 150px; }
.tip { left: calc(12px + var(--sal)); top: calc(66px + var(--sat)); }
@media (pointer: coarse) {
  #radar { bottom: auto !important; top: 40% !important; transform: translateY(-50%); width: 104px; height: 104px; }   /* phones: middle of the left side, above the stick */
  .tip { left: calc(124px + var(--sal)); }
}
@media (max-height: 520px) and (pointer: fine) { #radar { width: 116px; height: 116px; } }

.hitside { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
.hitside.on { animation: hitside .45s ease-out; }
@keyframes hitside { 0% { opacity: 1; } 100% { opacity: 0; } }

/* The city's time of day, beside the mission timer. */
.dayclock { font: 700 12px/1 Inter, system-ui, sans-serif; color: #ffd27a; background: rgba(0, 0, 0,.72); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 6px 9px; font-variant-numeric: tabular-nums; }
.dayclock::before { content: "☀ "; }
.dayclock[data-night="1"] { color: #b9c8ff; }
.dayclock[data-night="1"]::before { content: "☾ "; }

/* Phones play in landscape only: held upright, the game waits behind this. */
.turn { display: none; position: fixed; inset: 0; z-index: 999; background: #0b0a10; color: #ece8f4; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; font-family: Inter, system-ui, sans-serif; }
.turn p { font-size: 18px; font-weight: 700; margin: 0; }
.turn small { color: #a59fb3; }
.turn-phone { width: 46px; height: 80px; border: 3px solid #ffd27a; border-radius: 10px; animation: turnphone 2.2s ease-in-out infinite; }
@keyframes turnphone { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (pointer: coarse) and (orientation: portrait) { .turn { display: flex; } }
@media (prefers-reduced-motion: reduce) { .turn-phone { animation: none; transform: rotate(-90deg); } }

/* Camera view switch, beside pause. */
.view-btn { font: 700 11px/1 Inter, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: #ece8f4; background: rgba(0, 0, 0,.72); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 8px 11px; cursor: pointer; }
.view-btn:hover { border-color: #ffd27a; }

/* Build mode */
body.building .hud-zone, body.building .hud-objective, body.building #timer, body.building #beat, body.building #pauseBtn,
body.building #hearts, body.building #mixer, body.building #race, body.building #tip, body.building #cover, body.building #touch .tbtn:not(#btnJump) { display: none !important; }
.build { position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(920px, calc(100vw - 24px)); z-index: 30;
  background: rgba(0, 0, 0,.88); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 8px; font-family: Inter, system-ui, sans-serif; color: #ece8f4; }
.build.hidden { display: none; }
.build-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.build-head span { color: #a59fb3; font-size: 12px; }
.build-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.bcat { font: 700 12px Inter, sans-serif; padding: 5px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); background: transparent; color: #ece8f4; cursor: pointer; }
.bcat.on { background: #ffd27a; color: #2a1f05; border-color: #ffd27a; }
.build-items { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.bitem { flex: 0 0 auto; width: 74px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 3px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); color: #ece8f4; cursor: pointer; font: 600 10.5px/1.15 Inter, sans-serif; }
.bitem img { width: 48px; height: 48px; object-fit: contain; }
.bitem i { font-style: normal; font-size: 26px; height: 48px; display: grid; place-items: center; color: #ffd27a; }
.bitem.on { border-color: #ffd27a; box-shadow: 0 0 0 1px #ffd27a inset; }
.build-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.build-actions button { flex: 1 1 auto; font: 700 12.5px Inter, sans-serif; padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); color: #ece8f4; cursor: pointer; }
.build-actions button.go { background: #ffd27a; color: #2a1f05; border-color: #ffd27a; }
.build-actions button:disabled { opacity: .4; cursor: default; }
@media (pointer: coarse) { .build { left: auto; right: 10px; transform: none; width: min(560px, 58vw); } .bitem { width: 62px; } .bitem img, .bitem i { width: 40px; height: 40px; } }

/* Pause: the map fills the screen, the way a GTA map does. Buttons sit in a bar at the top centre. */
#pause { padding: 0; overflow: hidden; background: #0c0b10; touch-action: none; }
#pause #bigmap { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; aspect-ratio: auto; border-radius: 0; cursor: grab; }
#pause #bigmap:active { cursor: grabbing; }
.pause-bar { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, .82); border: 1px solid var(--line); border-radius: 16px; padding: 8px 12px 4px; max-width: calc(100vw - 24px); }
.pause-bar .kicker { margin: 0; text-align: center; letter-spacing: .14em; }
.pause-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pause-btns button { min-width: 0; padding: 8px 18px; font-size: 14px; }
.pause-bar.closed .pause-btns { display: none; }
.pause-toggle { background: none; border: 0; color: var(--muted); font-size: 11px; padding: 0 12px; line-height: 1.2; cursor: pointer; }
.pause-bar.closed .pause-toggle { transform: rotate(180deg); }
.map-zoom { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: 50px; display: flex; flex-direction: column; gap: 6px; }
.map-zoom button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, .85); color: #fff; font-size: 20px; font-weight: 800; cursor: pointer; }
.map-legend { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: 10px; margin: 0; background: rgba(0, 0, 0, .8); border-radius: 10px; padding: 6px 10px; color: #ddd; }
.lg-route { background: #c86bff; height: 4px !important; width: 14px !important; }
.lg-road { background: #e8e3d6; border: 1px solid #111; }
.lg-hill { background: #6e6a62; }
button.padfocus { outline: 3px solid #ffd27a; outline-offset: 3px; }

/* Title: Koda's moves drift past behind, slowly zooming and fading; the menu sits on the left. */
#title { justify-content: flex-start; align-items: stretch; padding: 0; background: #000; overflow: hidden; }
.title-show { position: absolute; inset: 0; overflow: hidden; }
.title-show img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0;
  transform-origin: 60% 45%; animation: showZoom 10s linear forwards, showFade 10s ease-in-out forwards; }
@keyframes showZoom { from { transform: scale(1.02); } to { transform: scale(1.16); } }
@keyframes showFade { 0% { opacity: 0; } 16% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.title-show::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.94) 0%, rgba(0,0,0,.86) 30%, rgba(0,0,0,.35) 58%, rgba(0,0,0,.1) 100%); }
#title .title-card { position: relative; z-index: 1; text-align: left; max-width: none; width: min(500px, 52vw); height: 100%; overflow-y: auto;
  padding: max(22px, env(safe-area-inset-top)) 22px 22px max(28px, env(safe-area-inset-left)); display: flex; flex-direction: column; justify-content: safe center; }
#title .title-buttons { justify-content: flex-start; flex-wrap: wrap; }
#title .missions { margin-left: 0; margin-right: 0; }
@media (max-height: 520px) { #title .title-card h1 { font-size: 40px; } #title .blurb { display: none; } }

/* Build mode: pieces down the left, actions down the right, Koda clear in the middle. */
.build { left: 0; right: 0; top: 0; bottom: 0; transform: none; width: auto; background: none; border: 0; padding: 0; pointer-events: none; display: block; }
.build > * { pointer-events: auto; }
.build-left { position: absolute; left: max(10px, env(safe-area-inset-left)); top: 64px; bottom: 12px; width: min(236px, 26vw);
  display: flex; flex-direction: column; gap: 8px; background: rgba(0,0,0,.82); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 10px; }
.build-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; min-height: 0; align-content: start; scrollbar-width: none; }
.build-items::-webkit-scrollbar, .missions::-webkit-scrollbar { display: none; }
.build .bitem { width: auto; padding: 4px 2px; font-size: 9.5px; }
.build .bitem img, .build .bitem i { width: 40px; height: 40px; font-size: 22px; }
.build-actions { position: absolute; right: max(10px, env(safe-area-inset-right)); top: 64px; width: min(150px, 18vw); display: flex; flex-direction: column; gap: 6px;
  background: rgba(0,0,0,.82); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 10px; }
.build-actions button { flex: 0 0 auto; }
.bcat.on, .build-actions button.go { color: #000; }
@media (pointer: coarse) { .build { left: 0; right: 0; width: auto; } .build-left { width: min(200px, 30vw); top: 54px; bottom: 170px; } .build-actions { width: min(120px, 18vw); top: 54px; } }

/* Title fits the screen: no scrolling. */
#title .title-card { width: min(640px, 50vw); overflow: hidden; justify-content: center; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: 16px; }
#title .title-card h1 { font-size: clamp(40px, 11vh, 96px); }
#title .sub { font-size: clamp(13px, 2.2vh, 18px); margin-bottom: 1.2vh; }
#title .blurb { font-size: clamp(12px, 1.9vh, 16px); margin: 0 0 2vh; max-width: 520px; }
#title .title-buttons { flex-wrap: nowrap; }
#title .title-buttons .primary, #title .title-buttons .ghost { min-width: 0; padding: clamp(8px, 1.5vh, 14px) clamp(18px, 2.4vw, 34px); font-size: clamp(13px, 2vh, 17px); }
#title .loading { margin-top: 1vh; }
#title .missions { grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 1.5vh; max-width: none; overflow: hidden; }
#title .mission { padding: clamp(3px, .8vh, 7px) 8px; font-size: clamp(11px, 1.6vh, 13px); }
#title .how { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: 16px; max-width: min(440px, 44vw); margin: 0; z-index: 2;
  background: rgba(0,0,0,.85); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 8px 14px; }
#title .how[open] { padding-bottom: 12px; }
@media (max-height: 520px) { #title .title-card h1 { font-size: 36px; } #title .blurb { display: none; } #title .kicker { font-size: 9px; } }
html, body, .screen { scrollbar-width: none; }
.screen::-webkit-scrollbar { display: none; }

.pause-travel { align-items: center; }
.pause-travel button { padding: 6px 12px; font-size: 12.5px; }
.travel-label { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.pause-bar.closed .pause-travel { display: none; }
.lg-shrine { background: #ffd27a; border-radius: 50% !important; box-shadow: 0 0 6px #ffa83a; }

/* Play together */
.coop-card { text-align: center; }
.coop-colours { display: flex; gap: 10px; justify-content: center; margin: 6px 0 16px; }
.coop-colours button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.coop-colours button.on { border-color: #fff; box-shadow: 0 0 0 2px #000; }
.coop-row { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.coop-or { color: var(--muted); font-size: 13px; margin: 12px 0 2px; }
#coopCode { width: 130px; text-align: center; font: 900 24px/1 Inter, sans-serif; letter-spacing: .25em; text-transform: uppercase; background: #000; color: var(--gold-hi); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.coop-status { min-height: 1.2em; color: var(--gold-hi); font-weight: 800; letter-spacing: .06em; }
.coop-status big { font-size: 34px; letter-spacing: .3em; display: block; margin-top: 6px; }
.coop-pill { font: 800 11px/1 Inter, sans-serif; letter-spacing: .08em; color: #000; background: var(--gold); border-radius: 999px; padding: 7px 10px; }

/* My worlds */
.world-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 46vh; overflow-y: auto; scrollbar-width: none; }
.world-list::-webkit-scrollbar { display: none; }
.world-row { display: flex; gap: 8px; align-items: center; background: #000; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.world-row b { flex: 1; text-align: left; font-size: 15px; }
.world-row small { color: var(--muted); font-size: 11px; }
.world-row button { min-width: 0; padding: 8px 14px; font-size: 13px; }
.world-pill { font: 800 11px/1 Inter, sans-serif; letter-spacing: .08em; color: #000; background: #7fe39a; border-radius: 999px; padding: 7px 10px; }

/* Title on phones: every mission fits, three across, nothing cut off. */
#title .missions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#title .mission { min-width: 0; }
#title .mission b { min-width: 0; }
@media (max-width: 900px), (max-height: 520px) {
  #title .title-card { width: min(560px, 62vw); padding-right: 12px; }
  #title .mission { gap: 4px; padding: 4px 6px; font-size: 11px; }
  #title .mission span { width: 12px; }
  #title .mission em { font-size: 9px; }
  #title .title-buttons { flex-wrap: wrap; gap: 6px; }
  #title .title-buttons .primary, #title .title-buttons .ghost { padding: 7px 12px; font-size: 12px; }
}
.world-name { flex: 1; min-width: 0; font: 700 15px Inter, sans-serif; background: #111; color: #fff; border: 1px solid var(--gold); border-radius: 8px; padding: 6px 8px; }

.title-show { pointer-events: none; }
#worlds, #coop { z-index: 40; }

.inv { display: inline-flex; gap: 8px; font: 800 12px/1 Inter, sans-serif; color: #fff; background: rgba(0,0,0,.72); border: 1px solid rgba(255,255,255,.14); border-radius: 999px; padding: 6px 10px; }
.inv b { font-weight: 800; }

/* Phones and small windows: the objective gets its own line under the top bar, nothing overlaps. */
@media (max-width: 1100px), (max-height: 560px) {
  .hud-objective { top: calc(54px + var(--sat)); max-width: min(62vw, 560px); font-size: 11.5px; padding: 6px 12px; line-height: 1.3; white-space: normal; text-align: center; }
  .hud-right > .hud-row { gap: 5px; }
  .hud-right .timer, .hud-right .dayclock, .view-btn, .coop-pill, .world-pill, .inv { font-size: 10.5px; padding: 6px 8px; }
  .hud-zone { padding: 5px 10px; }
  .hud-zone span:last-child { font-size: 13px; }
  #radar { top: auto; }
}
body.roam #timer, body.roam #beat, body.roam #mixer { display: none !important; }
/* Shop and chat */
.shop-row { display: flex; align-items: center; gap: 8px; background: #000; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin: 6px 0; }
.shop-row b { flex: 1; text-align: left; } .shop-row small { color: var(--muted); }
.shop-row button { min-width: 0; padding: 7px 12px; font-size: 13px; }
.chat-log { position: absolute; left: calc(12px + var(--sal)); bottom: 200px; max-width: min(420px, 60vw); display: flex; flex-direction: column; gap: 4px; pointer-events: none; z-index: 6; }
.chat-log p { margin: 0; background: rgba(0,0,0,.7); border-radius: 10px; padding: 5px 9px; font: 600 12.5px/1.35 Inter, sans-serif; color: #fff; transition: opacity .6s; }
.chat-log p b { margin-right: 6px; }
.chat-box { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); display: flex; gap: 6px; z-index: 8; }
.chat-box input { width: min(420px, 70vw); font: 600 15px Inter, sans-serif; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--gold); background: #000; color: #fff; }
.view-btn.on { background: var(--gold); color: #000; }
/* The objective always has its own line under the top bar, so nothing on the right can cover it. */
.hud-objective { top: calc(54px + var(--sat)); }

a.exit-link { display: inline-flex; align-items: center; justify-content: center; color: inherit; text-decoration: none; font: inherit; font-weight: 700; }
#turnBtn { margin: 6px 0; padding: 12px 26px; }

/* Koda's style */
#style { z-index: 40; background: transparent; justify-content: flex-end; }
.style-card { max-width: 380px; margin-right: 4vw; background: rgba(8, 8, 10, .82); }
.style-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.style-grid button { padding: 10px 6px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.style-grid button.on { background: rgba(242,181,68,.2); border-color: #f2b544; color: #ffd27a; }
.style-grid button.sel { outline: 2px solid #fff; }
.style-colours { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.style-colours button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.style-colours button.on { border-color: #fff; }

/* Messages: square bubbles on the right, like texts, that come and go */
#objective, #toast, #tip { display: none !important; }
.msgs { position: absolute; right: calc(14px + var(--sar)); top: 30%; width: min(290px, 30vw); display: flex; flex-direction: column; gap: 8px; pointer-events: none; z-index: 6; }
.msg { background: rgba(10, 10, 12, .88); border: 1px solid rgba(255, 255, 255, .12); border-left: 4px solid var(--gold); border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35); transform: translateX(120%); opacity: 0; transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .35s; }
.msg b { display: block; font-size: 10px; letter-spacing: .18em; color: var(--gold); margin-bottom: 3px; }
.msg.in { transform: none; opacity: 1; }
.msg.out { transform: translateX(120%); opacity: 0; }
.msg-tip { border-left-color: #7fe39a; } .msg-tip b { color: #7fe39a; }
.msg-note { border-left-color: #9fd3ff; } .msg-note b { color: #9fd3ff; }
@media (pointer: coarse) { .msgs { top: 22%; width: min(240px, 34vw); } .msg { font-size: 12px; padding: 8px 10px; } }
body.building .msgs { top: auto; bottom: calc(16px + var(--sab)); right: auto; left: 50%; transform: translateX(-50%); }
/* Phones without a controller: no build buttons (they come back when a controller connects) */
body.no-build #buildBtn, body.no-build #worldsBtn, body.no-build #btnBuildHud { display: none !important; }
.style-card { max-height: 86vh; overflow-y: auto; }
.style-grid button.locked { opacity: .7; border-style: dashed; }
.style-colours button { width: 30px; height: 30px; }
.style-colours button.off { background: transparent; border-color: var(--line); color: #ece8f4; }
.style-pick { position: relative; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; cursor: pointer; background: conic-gradient(#ff3b30, #ffd84d, #22c55e, #22d3ee, #3b82f6, #d58cff, #ff3b30); display: grid; place-items: center; }
.style-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.style-pick span { font-weight: 900; color: #fff; text-shadow: 0 1px 3px #000; pointer-events: none; }
.style-finish { display: flex; gap: 6px; margin-bottom: 12px; }
.style-finish button { flex: 1; padding: 8px 4px; border-radius: 10px; background: rgba(255,255,255,.06); border: 1px solid var(--line); font-weight: 700; font-size: 12px; }
.style-finish button.on { background: rgba(242,181,68,.2); border-color: #f2b544; color: #ffd27a; }
.style-lock { font-size: 13px; line-height: 1.45; color: #d8d4cc; margin: 0; }
/* Title buttons: one line each, text in the middle */
#title .title-buttons { flex-wrap: wrap; }
#title .title-buttons button, #title .title-buttons a { display: inline-flex; align-items: center; justify-content: center; text-align: center; white-space: nowrap; border-radius: 999px; min-height: 0; line-height: 1.15; }

.padhint { font-size: 12px; color: rgba(255,255,255,.55); margin: 6px 0 0; }
.padhint.on { color: #7fe39a; }
