:root {
  --pink: #ff3d9a;
  --cyan: #19e3ff;
  --ink: #0b0618;
  --glass: rgba(14, 8, 34, 0.72);
  --line: rgba(255, 255, 255, 0.18);
  --display: 'Gi Sans Display SemiBold', sans-serif;
  --body: 'Gi Sans Text', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: #fff; font-family: var(--body); touch-action: none; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
h1, h2, .car-name, .sel-title { font-family: var(--display); font-weight: normal; margin: 0; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; z-index: 20; text-align: left; }
.screen.dim { background: rgba(8, 4, 20, 0.78); backdrop-filter: blur(6px); }
.card { background: var(--glass); border: 1px solid var(--line); border-radius: 18px; padding: 28px 30px; max-width: 520px; width: 100%; box-shadow: 0 0 40px rgba(255, 61, 154, 0.25); backdrop-filter: blur(10px); }
.card.wide { max-width: 640px; }
.card h2 { font-size: 30px; margin-bottom: 12px; }
.card p { line-height: 1.55; font-size: 16px; margin: 0 0 20px; color: #e8e4f4; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.22em; font-size: 13px; color: var(--cyan); margin: 0 0 8px; }
.sub { color: #e8e4f4; font-size: 18px; margin: 10px 0 24px; white-space: pre-line; }
.small { font-size: 13px; color: #b9b2d0; margin: 10px 0 0; }
.msg { color: var(--cyan); min-height: 1.5em; margin-bottom: 14px !important; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }

.btn { font-family: var(--body); font-size: 16px; color: #fff; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 999px; padding: 12px 26px; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 18px rgba(25, 227, 255, 0.45); }
.btn.primary { background: linear-gradient(90deg, var(--pink), #ff7a3d); border-color: transparent; box-shadow: 0 0 22px rgba(255, 61, 154, 0.5); }

/* title */
#scr-title { text-align: center; background: linear-gradient(180deg, rgba(8,4,20,.55), rgba(8,4,20,.1) 60%, rgba(8,4,20,.55)); }
.title-wrap { display: flex; flex-direction: column; align-items: center; padding: 34px 48px; border-radius: 24px; background: radial-gradient(ellipse at center, rgba(8,4,20,.88) 0%, rgba(8,4,20,.78) 55%, rgba(8,4,20,0) 100%); backdrop-filter: blur(5px); }
#logo-slot { min-height: 0; margin-bottom: 8px; }
#game-title { font-size: clamp(44px, 9vw, 112px); line-height: 1; letter-spacing: 0.02em; background: linear-gradient(180deg, #fff 20%, #ff9ac8 55%, #ff3d9a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(255, 61, 154, 0.55)); }

/* select */
#scr-select { justify-content: flex-end; padding-bottom: 36px; background: none; pointer-events: none; }
#scr-select > * { pointer-events: auto; }
.sel-title { position: absolute; top: 28px; left: 0; right: 0; text-align: center; font-size: clamp(26px, 4vw, 44px); text-shadow: 0 0 20px var(--pink); }
.sel-panel { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.sel-info { background: var(--glass); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; width: min(420px, 78vw); backdrop-filter: blur(8px); }
.car-name { font-size: 30px; }
.car-tag { color: var(--cyan); margin-bottom: 12px; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; }
.stat { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; font-size: 13px; margin: 6px 0; color: #dcd6ee; }
.bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width 0.35s; }
.arrow { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.arrow:hover { box-shadow: 0 0 18px var(--cyan); }

/* hud */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }
.hud-left { position: absolute; left: 16px; top: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#minimap { width: 160px; height: 160px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); box-shadow: 0 0 22px rgba(25, 227, 255, 0.4); background: #0b0618; }
#discoveries { font-size: 14px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }
#route-msg { font-size: 13px; max-width: 220px; color: var(--cyan); text-shadow: 0 0 8px #000; }
.hud-right { position: absolute; right: 16px; top: 16px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 60vw; }
.mini { font-family: var(--body); font-size: 12px; color: #fff; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.mini:hover { box-shadow: 0 0 12px var(--cyan); }
.mini.rec { background: #c01540; }
.speedo { position: absolute; right: 22px; bottom: 54px; text-align: right; text-shadow: 0 0 10px #000; }
#speed-val { font-family: var(--display); font-size: 64px; line-height: 1; text-shadow: 0 0 18px var(--cyan); }
.unit { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: #cfc8e6; }
.boost { width: 150px; height: 8px; margin: 8px 0 3px auto; border-radius: 4px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
#boost-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--pink), #ffd23d); }
#hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; font-size: 12px; color: #d8d2ee; text-shadow: 0 0 6px #000; padding: 0 20px; }
#district-banner { position: absolute; top: 22%; left: 50%; transform: translate(-50%, 0); font-family: var(--display); font-size: clamp(28px, 6vw, 64px); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; opacity: 0; color: #fff; text-shadow: 0 0 12px var(--glow, #ff3d9a), 0 0 34px var(--glow, #ff3d9a); }
#district-banner.show { animation: banner 3.4s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 14px) scale(0.96); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }
#toast { position: absolute; top: 40%; left: 50%; transform: translateX(-50%); max-width: min(560px, 86vw); text-align: center; background: var(--glass); border: 1px solid var(--cyan); border-radius: 14px; padding: 12px 18px; font-size: 16px; line-height: 1.45; opacity: 0; transition: opacity 0.3s; box-shadow: 0 0 24px rgba(25, 227, 255, 0.4); }
#toast.show { opacity: 1; }
#artist-tag { position: fixed; right: 10px; bottom: 6px; z-index: 30; font-size: 11px; color: rgba(255, 255, 255, 0.8); background: rgba(0, 0, 0, 0.45); padding: 2px 8px; border-radius: 6px; pointer-events: none; }

#ep-list { margin: 0 0 18px; padding-left: 20px; line-height: 1.7; color: #e8e4f4; }

/* touch */
#touch { display: none; }
body.touch #touch { display: block; }
body.touch #hint { display: none; }
.tgrp { position: absolute; bottom: 18px; display: flex; gap: 12px; align-items: flex-end; }
.tgrp.left { left: 18px; }
.tgrp.right { right: 18px; }
.tbtn { pointer-events: auto; width: 76px; height: 76px; border-radius: 50%; border: 1px solid var(--line); background: rgba(14, 8, 34, 0.6); color: #fff; font-size: 22px; font-family: var(--body); touch-action: none; }
.tbtn.small { width: 56px; height: 56px; font-size: 12px; }
.tbtn.gas { background: rgba(255, 61, 154, 0.55); width: 88px; height: 88px; font-size: 16px; }
.tbtn:active, .tbtn.on { background: rgba(25, 227, 255, 0.5); }
body.touch .speedo { bottom: 130px; right: 18px; }
body.touch .speedo #speed-val { font-size: 44px; }

#boot-error { position: fixed; inset: 0; z-index: 99; background: #1a0a20; color: #fff; padding: 40px; font-size: 16px; }

@media (max-width: 640px) {
  #minimap { width: 110px; height: 110px; }
  .card h2 { font-size: 24px; }
  .sel-panel { gap: 8px; }
  .arrow { width: 42px; height: 42px; }
  .tools { max-width: 52vw; }
}

/* logo: height only, width auto, never recoloured or given effects; clear space ~0.25 x height */
.logo-title { display: block; height: 44px; width: auto; margin: 0 auto 11px; }
.logo-card { display: block; height: 28px; width: auto; margin: 0 0 14px; }
#logo-slot { margin-bottom: 0; }
#route-msg { display: none; }
/* title: text block on the left so the Epoque hero shot sits to its right */
#scr-title { align-items: flex-start; text-align: left; padding-left: 7vw; background: linear-gradient(90deg, rgba(8,4,20,.65), rgba(8,4,20,.15) 55%, rgba(8,4,20,0)); }
.title-wrap { align-items: flex-start; background: radial-gradient(ellipse at 40% 50%, rgba(8,4,20,.88) 0%, rgba(8,4,20,.74) 60%, rgba(8,4,20,0) 100%); }
.title-wrap .logo-title { margin-left: 0; }
@media (max-width: 700px) {
  .logo-title { height: 32px; margin-bottom: 8px; }
  #scr-title { align-items: center; text-align: center; padding-left: 24px; }
  .title-wrap { align-items: center; }
  .title-wrap .logo-title { margin-left: auto; }
}

/* ---- intro ---- */
#intro { position: fixed; inset: 0; z-index: 100; --mh: min(22vh, 40vw, 370px); font-family: var(--body); }
#intro .panel { position: absolute; top: 0; bottom: 0; width: 50.1vw; background: #000; transition: transform 1.05s cubic-bezier(.65, 0, .35, 1); }
#intro .pl { left: 0; } #intro .pr { right: 0; }
#intro .half { position: absolute; top: calc(42vh - var(--mh) / 2); height: var(--mh); width: auto; opacity: 0; transition: opacity .6s ease; }
#intro .pl .half { right: 0; } #intro .pr .half { left: 0; }
#intro.mark .half { opacity: 1; }
#intro.open .pl { transform: translateX(-101%); } #intro.open .pr { transform: translateX(101%); }
#intro-seam { position: absolute; left: 50%; top: calc(42vh - var(--mh) * 0.58); height: calc(var(--mh) * 1.16); width: 2px; margin-left: -1px; opacity: 0;
  background: linear-gradient(180deg, rgba(227,179,92,0), #E3B35C 18%, #FFD9A0 50%, #E3B35C 82%, rgba(227,179,92,0)); }
#intro.opening #intro-seam { opacity: 1; transition: opacity .19s; }
#intro.open #intro-seam { opacity: 0; transition: opacity .75s .19s; }
#intro-text { position: absolute; left: 0; right: 0; top: calc(42vh + var(--mh) / 2 + 4vh); text-align: center; transition: opacity .23s; }
#intro.opening #intro-text { opacity: 0; }
#intro-text .wordmark { display: block; width: min(60vw, 631px); height: auto; margin: 0 auto; opacity: 0; transition: opacity .45s; }
#intro-text .grey-sub { opacity: 0; transition: opacity .45s .23s; margin: 2.6vh 0 0; }
#intro.text .wordmark, #intro.text .grey-sub { opacity: 1; }
#intro-progress { width: min(40vw, 260px); height: 1px; margin: 4vh auto 0; background: rgba(160, 160, 160, .25); opacity: 0; transition: opacity .3s; }
#intro.text #intro-progress { opacity: 1; } #intro.loaded #intro-progress { opacity: 0; }
#intro-progress i { display: block; height: 100%; width: 0; background: #E3B35C; transition: width .3s; }
.grey-sub { font-family: var(--body); color: #A0A0A0; letter-spacing: .35em; text-transform: uppercase; font-size: 13px; margin: 10px 0 22px; }
.screen { animation: sfade .5s ease-out; }
@keyframes sfade { from { opacity: 0; } to { opacity: 1; } }

/* ---- logos on title and card ---- */
.logo-title { height: 120px; }
.title-wrap .grey-sub { margin: 12px 0 26px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-head .logo-card { margin: 0; }
.mark-card { height: 36px; width: auto; display: block; }

/* ---- title layout: panel max 44% wide on the left, towers on the right; stacked when narrow ---- */
#game-title { font-size: clamp(34px, 5vw, 92px); }
@media (min-width: 721px) { #scr-title { padding-left: 6vw; } .title-wrap { max-width: 44vw; } }
@media (max-width: 720px) {
  .logo-title { height: 84px; }
  #scr-title { justify-content: flex-end; align-items: center; padding: 24px 24px 8vh; text-align: center; background: linear-gradient(0deg, rgba(8,4,20,.7), rgba(8,4,20,0) 70%); }
  .title-wrap { align-items: center; max-width: 100%; padding: 20px 24px; }
  .title-wrap .logo-title { margin-left: auto; }
}

/* ---- on-screen text lives in a top band, never over the car ---- */
#sun-clock { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; font-size: 14px; white-space: nowrap; }
#district-banner { top: 54px; font-size: clamp(22px, 2.6vw, 32px); letter-spacing: 0.08em; max-width: 640px; }
#toast { top: 100px; font-size: 15px; line-height: 1.35; max-width: min(640px, 86vw); padding: 8px 18px; border-radius: 16px; }
#toast { background: rgba(10, 6, 24, 0.82); }
/* medium widths: the tool buttons span the top row, so the clock and band drop below them */
@media (min-width: 641px) and (max-width: 1180px) {
  #sun-clock { top: 96px; }
  #district-banner { top: 138px; }
  #toast { top: 184px; }
}
@media (max-width: 640px) {
  #sun-clock { top: 128px; font-size: 13px; }
  #district-banner { top: 160px; font-size: 20px; max-width: 90vw; white-space: normal; text-align: center; }
  #toast { top: 196px; font-size: 14px; }
}
/* ---- briefing and mission complete ---- */
a.btn { text-decoration: none; display: inline-block; text-align: center; box-sizing: border-box; }
.card.complete { max-width: 720px; max-height: 94vh; overflow: auto; }
.logo-epoque { display: block; height: 84px; width: auto; margin: 0 auto 10px; }
.card.complete h2 { text-align: center; }
.stats-row { display: flex; justify-content: space-between; gap: 14px; margin: 6px 0 16px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats-row div { flex: 1; text-align: center; }
.stats-row b { display: block; font-family: var(--display); font-weight: normal; font-size: 22px; }
.stats-row span { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: #A0A0A0; }
ul.two-col { columns: 2; column-gap: 28px; padding-left: 18px; margin: 0 0 18px; font-size: 14px; line-height: 1.55; color: #e8e4f4; }
.card-foot { margin-top: 16px; }
.card-foot .logo-card { height: 24px; margin: 0; }
@media (max-width: 720px) { ul.two-col { columns: 1; } .stats-row b { font-size: 16px; } .logo-epoque { height: 64px; } }

/* ================= mobile and touch ================= */
:root { --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --tb: clamp(64px, 19vw, 80px); --band: 12px; }
html, body { width: 100%; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
#c, #hud, #touch, .tbtn { touch-action: none; }
.btn, .mini, .arrow, .tbtn { -webkit-touch-callout: none; touch-action: manipulation; }
.tbtn { touch-action: none; }
.screen { padding: max(16px, var(--sat)) max(16px, var(--sar)) max(16px, var(--sab)) max(16px, var(--sal)); }
.card { min-width: 0; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.card.complete { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.arrow { position: relative; flex: none; }
.arrow::after { content: ''; position: absolute; inset: -10px; }
.hud-left { left: max(12px, var(--sal)); top: max(12px, var(--sat)); }
.hud-right { right: max(12px, var(--sar)); top: max(12px, var(--sat)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#btn-menu { display: none; }
.stats-row div { min-width: 0; overflow-wrap: anywhere; }
@media (hover: none) { .btn:hover { transform: none; } }

/* HUD on small screens: one menu button opens a sheet with the tools */
body.compact #btn-menu { display: block; width: 48px; height: 48px; padding: 0; font-size: 26px; line-height: 1; text-align: center; }
body.compact .tools { display: none; }
body.compact .tools.open { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 6px; min-width: 200px; max-width: none; padding: 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); pointer-events: auto; }
body.compact .tools .mini { width: 100%; min-height: 46px; font-size: 15px; text-align: left; padding: 8px 14px; border-radius: 10px; }
body.compact #minimap { width: 100px; height: 100px; }
body.compact #discoveries { font-size: 12px; padding: 4px 10px; }
body.compact #speed-val { font-size: 40px; }
body.compact .boost { width: 100px; }
body.compact #artist-tag { left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--sab) + 2px); font-size: 10px; white-space: nowrap; }
/* top band: sun clock, district banner and toast sit below the minimap and menu in portrait, between them in landscape */
body.compact #sun-clock { top: calc(var(--band) + var(--sat)); font-size: 13px; max-width: 92vw; }
body.compact #district-banner { top: calc(var(--band) + var(--sat) + 38px); width: max-content; max-width: 92vw; white-space: normal; text-align: center; font-size: 20px; }
body.compact #toast { top: calc(var(--band) + var(--sat) + 76px); width: max-content; max-width: 92vw; font-size: 14px; }
@media (orientation: portrait) { body.compact { --band: 156px; } }
@media (orientation: landscape) { body.compact #toast, body.compact #district-banner { max-width: calc(100vw - 280px); } }
@media (orientation: landscape) and (max-height: 520px) { body.compact #minimap { width: 96px; height: 96px; } }

#rotate-hint { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--band) + var(--sat) + 130px); width: max-content; max-width: 88vw; text-align: center; font-size: 14px; line-height: 1.4; padding: 10px 16px; background: rgba(10, 6, 24, 0.86); border: 1px solid var(--cyan); border-radius: 14px; pointer-events: auto; }
#rotate-hint span { margin-left: 8px; font-size: 18px; vertical-align: -1px; }

/* touch controls: steer left, gas cluster right, each at least 64 px */
body.touch .kbd-hint, body.touch #pause-hint { display: none; }
.tgrp { bottom: calc(var(--sab) + 22px); }
.tgrp.left { left: max(12px, var(--sal)); gap: 10px; }
.tgrp.right { right: max(12px, var(--sar)); display: grid; grid-template-columns: var(--tb) calc(var(--tb) * 1.45); grid-template-rows: var(--tb) var(--tb); gap: 8px; align-items: end; justify-items: end; }
.tbtn { width: var(--tb); height: var(--tb); min-width: 64px; min-height: 64px; padding: 0; font-size: 26px; line-height: 1.1; border: 1.5px solid rgba(255, 255, 255, 0.35); background: rgba(14, 8, 34, 0.5); transition: transform 0.06s, background 0.06s; outline: none; }
.tbtn i { display: block; font-style: normal; font-size: 10px; opacity: 0.8; }
.tbtn[data-act="boost"], .tbtn[data-act="brake"] { font-size: 13px; }
.tbtn[data-act="boost"] { grid-column: 1; grid-row: 1; width: var(--tb); height: var(--tb); }
.tbtn[data-act="brake"] { grid-column: 1; grid-row: 2; }
.tbtn.gas { grid-column: 2; grid-row: 1 / span 2; width: calc(var(--tb) * 1.45); height: calc(var(--tb) * 1.45); font-size: 18px; align-self: end; }
.tbtn.on { transform: scale(0.94); }
body.touch .speedo { left: max(14px, var(--sal)); right: auto; bottom: calc(var(--sab) + 22px + var(--tb) + 12px); text-align: left; }
body.touch .speedo #speed-val { font-size: 34px; }
body.touch .boost { margin: 6px auto 3px 0; width: 90px; }
body.touch .speedo .unit { font-size: 10px; }
@media (orientation: landscape) and (max-height: 520px) {
  .tgrp.right { grid-template-columns: var(--tb) var(--tb) calc(var(--tb) * 1.45); grid-template-rows: auto; }
  .tbtn[data-act="boost"] { grid-column: 1; grid-row: 1; }
  .tbtn[data-act="brake"] { grid-column: 2; grid-row: 1; }
  .tbtn.gas { grid-column: 3; grid-row: 1; }
}

/* cards and screens on phones */
@media (max-width: 640px) {
  .card { padding: 20px 18px; border-radius: 16px; }
  .card.wide, .card.complete { max-width: 100%; }
  .card p { font-size: 15px; margin-bottom: 16px; }
  .btn { display: flex; align-items: center; justify-content: center; width: 100%; max-width: 420px; min-height: 48px; padding: 12px 20px; text-align: center; }
  a.btn { display: flex; }
  .row { flex-direction: column; flex-wrap: nowrap; gap: 10px; }
  .row .btn { max-width: none; }
  .card.complete { padding: 16px; }
  .logo-epoque { height: 52px; }
  .stats-row { gap: 6px; padding: 10px 0; }
  .stats-row b { font-size: 15px; }
  .stats-row span { font-size: 9px; letter-spacing: 0.1em; }
  ul.two-col { columns: 1; font-size: 13px; }
  .sel-panel { width: 100%; max-width: 520px; gap: 8px; margin-bottom: 12px; }
  .sel-info { width: auto; flex: 1; min-width: 0; padding: 12px 14px; }
  .car-name { font-size: 24px; }
  .car-tag { margin-bottom: 6px; font-size: 12px; }
  .stat { grid-template-columns: 82px 1fr; font-size: 12px; margin: 4px 0; gap: 8px; }
  .arrow { width: 48px; height: 48px; font-size: 30px; }
}
@media (max-width: 720px) {
  .logo-title { height: 64px; margin-bottom: 6px; }
  .title-wrap { padding: 16px 18px; }
  .title-wrap .grey-sub { margin: 8px 0 14px; font-size: 11px; letter-spacing: 0.28em; }
  #game-title { font-size: clamp(30px, 9vw, 48px); }
  .sub { font-size: 15px; margin: 8px 0 16px; }
  #scr-title { padding-bottom: max(6vh, calc(var(--sab) + 16px)); }
  .title-wrap .btn { max-width: 360px; }
}
body.touch .arrow { width: 52px; height: 52px; }
#scr-select { padding-bottom: max(24px, calc(var(--sab) + 16px)); }
.sel-title { top: max(16px, calc(var(--sat) + 8px)); }
@media (max-height: 520px) {
  .card { padding: 14px 18px; }
  .card h2 { font-size: 22px; margin-bottom: 8px; }
  .card p { font-size: 14px; margin-bottom: 10px; }
  .logo-title { height: 48px; margin-bottom: 4px; }
  .title-wrap { padding: 12px 22px; }
  .title-wrap .grey-sub { margin: 6px 0 10px; }
  #game-title { font-size: clamp(26px, 5vw, 40px); }
  .sub { font-size: 14px; margin: 6px 0 12px; }
  .btn { min-height: 44px; padding: 8px 22px; }
  .row .btn { min-height: 44px; }
  .logo-epoque { height: 40px; margin-bottom: 6px; }
  .stats-row { padding: 8px 0; margin: 4px 0 10px; }
  ul.two-col { font-size: 13px; line-height: 1.4; margin-bottom: 10px; }
  .card-foot { margin-top: 8px; }
  .sel-title { font-size: 22px; }
  .stat { margin: 2px 0; }
  #scr-select { padding-bottom: max(12px, var(--sab)); }
}

/* ---- r6: one top stack (clock, district, fact pill) on phones; desktop keeps the absolute layout ---- */
#top-stack { display: contents; }
body.compact #top-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; position: absolute; top: calc(8px + var(--sat)); left: 50%; transform: translateX(-50%); width: max-content; max-width: 46vw; pointer-events: none; z-index: 3; }
body.compact #top-stack > * { position: static; transform: none; top: auto; left: auto; margin: 0; }
body.compact #sun-clock { height: 24px; box-sizing: border-box; padding: 0 12px; font-size: 12px; line-height: 22px; max-width: 100%; }
body.compact #district-banner { display: none; opacity: 1; animation: none; font-size: 16px; line-height: 20px; letter-spacing: 0.06em; width: max-content; max-width: 100%; white-space: normal; text-align: center; }
body.compact #district-banner.show { display: block; animation: banner-stack 3.4s ease-out forwards; }
@keyframes banner-stack { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
body.compact #toast { display: none; opacity: 1; transition: none; width: max-content; max-width: 100%; box-sizing: border-box; font-size: 12.5px; line-height: 1.3; padding: 5px 12px; border-radius: 12px; box-shadow: 0 0 14px rgba(25, 227, 255, 0.35); display: none; }
body.compact #toast.show { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; animation: toastin 0.25s ease-out; }
@keyframes toastin { from { opacity: 0; } to { opacity: 1; } }
body.compact #rotate-hint { font-size: 12px; line-height: 1.3; padding: 5px 12px; max-width: 100%; border-radius: 12px; }
body.compact .hud-left { position: absolute; }
body.compact #minimap { width: 84px; height: 84px; }
body.compact #discoveries { position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); white-space: nowrap; font-size: 11px; padding: 2px 8px; }
@media (orientation: portrait) {
  body.compact #top-stack { max-width: 92vw; }
  body.compact #minimap { width: 76px; height: 76px; }
  body.compact #district-banner { max-width: calc(100vw - 190px); }
  body.compact #toast, body.compact #rotate-hint { max-width: 92vw; font-size: 13px; }
  body.compact #toast { margin-top: 72px; }
  body.compact #rotate-hint { margin-top: 72px; }
  body.compact #district-banner.show ~ #toast, body.compact #district-banner.show ~ #rotate-hint { margin-top: 46px; }
  body.compact #rotate-hint:not(.hidden) ~ #toast { margin-top: 0; }
}

/* ---- r6: mission complete card in phone landscape, no scrolling ---- */
@media (orientation: landscape) and (max-height: 500px) {
  .card.complete { display: grid; grid-template-columns: 38fr 62fr; column-gap: 18px; align-content: center; width: 92vw; max-width: 860px; box-sizing: border-box; padding: 14px 16px; max-height: calc(100vh - 16px - var(--sat) - var(--sab)); max-height: calc(100dvh - 16px - var(--sat) - var(--sab)); overflow: auto; }
  .card.complete .logo-epoque { grid-column: 1; grid-row: 1; height: 56px; margin: 0 0 6px; }
  .card.complete h2 { grid-column: 1; grid-row: 2; font-size: 19px; margin: 0 0 6px; text-align: left; }
  .card.complete .stats-row { grid-column: 1; grid-row: 3; margin: 0 0 8px; padding: 6px 0; gap: 4px; }
  .card.complete .stats-row b { font-size: 15px; }
  .card.complete .stats-row span { font-size: 10px; letter-spacing: 0.06em; }
  .card.complete .row { grid-column: 1; grid-row: 4; flex-direction: column; flex-wrap: nowrap; gap: 8px; }
  .card.complete .row .btn { width: 100%; max-width: none; min-height: 40px; padding: 6px 16px; font-size: 14px; }
  .card.complete ul.two-col { grid-column: 2; grid-row: 1 / span 3; columns: 2; column-gap: 18px; font-size: 12.5px; line-height: 1.35; margin: 0; padding-left: 16px; align-self: start; }
  .card.complete ul.two-col li { margin-bottom: 4px; break-inside: avoid; }
  .card.complete .card-foot { grid-column: 2; grid-row: 4; justify-self: end; align-self: end; margin: 0; }
  .card.complete .card-foot .logo-card { height: 20px; }
}
/* short landscape phones (iPhone SE, 360-px-tall Androids): tighten the left column so the complete card fits without scrolling */
@media (orientation: landscape) and (max-height: 400px) {
  .card.complete { padding: 10px 14px; }
  .card.complete .logo-epoque { height: 44px; margin: 0 0 4px; }
  .card.complete h2 { font-size: 17px; margin: 0 0 4px; }
  .card.complete .stats-row { padding: 4px 0; margin: 0 0 6px; }
  .card.complete .row { gap: 6px; }
  .card.complete .row .btn { min-height: 36px; padding: 4px 14px; }
}
/* landscape phones: keep the stats row on one line (the rank cell gets more room) */
@media (orientation: landscape) and (max-height: 500px) {
  .card.complete .stats-row div:last-child { flex: 1.8; }
  .card.complete .stats-row b { font-size: 13.5px; white-space: nowrap; }
  /* stats move to the wider right column, above the highlights; buttons fill the left column under the title */
  .card.complete .stats-row { grid-column: 2; grid-row: 1 / span 2; align-self: start; margin: 0 0 6px; }
  .card.complete ul.two-col { grid-column: 2; grid-row: 3; }
  .card.complete .row { grid-column: 1; grid-row: 3 / span 2; align-self: start; }
  .card.complete .card-foot { grid-column: 2; grid-row: 4; }
}

/* r7: quick camera button beside the menu (phones), sheet stays above the touch buttons */
.hud-btns { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
#btn-view { display: none; }
body.compact #btn-view { display: block; height: 48px; padding: 0 16px; font-size: 14px; border-radius: 999px; white-space: nowrap; }
body.compact .tools #btn-cam { display: none; }
body.compact .hud-right { z-index: 40; }
body.compact .tools.open { position: relative; z-index: 41; background: rgba(12, 7, 30, 0.92); }
@media (orientation: landscape) and (max-height: 500px) {
  body.compact .tools.open { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-width: 300px; }
  body.compact .tools .mini { min-height: 38px; font-size: 14px; padding: 6px 12px; }
}
/* portrait phones: the View button sits under the menu button so the top row stays clear for the sunset clock */
@media (orientation: portrait) {
  body.compact .hud-btns { flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
  body.compact #btn-view { height: 36px; padding: 0 12px; font-size: 12px; }
}

/* r8: the camera is always Auto (far when still, chase at speed), so the view controls are gone */
#btn-view, #btn-cam { display: none !important; }

/* r9: landscape phones: speedometer sits beside the steer buttons, clear of the minimap and keys counter */
@media (orientation: landscape) and (max-height: 520px) {
  body.touch .speedo { left: calc(max(12px, var(--sal)) + var(--tb) * 2 + 28px); bottom: calc(var(--sab) + 18px); }
}
/* full screen button and the iPhone add-to-home-screen card */
.fs-btn.hidden { display: none !important; }
#btn-fs-title { margin-top: 10px; font-size: 14px; padding: 8px 18px; }
#fs-hint { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(4, 2, 12, 0.72); }
#fs-hint.hidden { display: none; }
.fs-card { max-width: 380px; width: 100%; }
.fs-card ol { margin: 8px 0 16px; padding-left: 20px; line-height: 1.6; }

/* r10: room for the 'Powered by Netlify' badge (bottom right, about 40 px tall) on netlify.app */
:root { --bdg: 64px; }
body.netlify-badge .tgrp.right { bottom: calc(var(--sab) + 22px + var(--bdg)); }
body.netlify-badge #scr-select { padding-bottom: calc(max(24px, calc(var(--sab) + 16px)) + var(--bdg)); }
body.netlify-badge #scr-title { padding-bottom: calc(max(6vh, calc(var(--sab) + 16px)) + var(--bdg)); }
body.netlify-badge #artist-tag, body.netlify-badge.compact #artist-tag { left: max(8px, var(--sal)); right: auto; transform: none; bottom: calc(var(--sab) + 4px); }
@media (orientation: landscape) and (max-height: 500px) {
  body.netlify-badge #scr-select { padding-bottom: calc(max(12px, var(--sab)) + var(--bdg)); }
}
