:root {
  --ink:#1d3731;
  --muted:#526c60;
  --line:#d3dfd3;
  --green:#117d68;
  --paper:#f8faf1;
  font:14px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;
}
* { box-sizing:border-box; }
body { margin:0; background:#e9eee4; color:var(--ink); }
main { height:100dvh; padding:12px; }
.workspace,.arena { height:100%; }
.arena { display:grid; grid-template-rows:auto minmax(0,1fr); position:relative; overflow:hidden; background:var(--paper); border:1px solid var(--line); border-radius:18px; }
.hud { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:12px; padding:8px 16px; background:#18332d; color:#f6faf2; }
.identity,.score,.actions { display:flex; gap:9px; align-items:center; min-width:0; }
.identity small { color:#c3d7cd; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.brandmark { background:#a9e0be; color:#17362d; border-radius:8px; width:28px; height:28px; display:grid; place-items:center; flex:none; }
.score { font-variant-numeric:tabular-nums; white-space:nowrap; }
.score strong { font-size:21px; }
.score strong small { font-size:12px; }
.score .label { font-size:11px; color:#c3d7cd; }
.actions { justify-content:flex-end; }
button,select { font:inherit; border:1px solid var(--line); border-radius:9px; color:inherit; background:#fffef8; padding:7px 12px; }
button { cursor:pointer; white-space:nowrap; }
button:disabled { opacity:.45; cursor:default; }
button:focus-visible,select:focus-visible { outline:3px solid #e5bd61; outline-offset:2px; }
.hud button { background:#28483e; border-color:#47675d; font-size:12px; }
.board { position:relative; min-height:0; background:#fff5df; }
canvas { display:block; width:100%; height:100%; outline:none; touch-action:none; }
.overlay { position:absolute; inset:0; z-index:3; display:grid; place-items:center; background:#ecf3e849; padding:12px; }
.overlay[hidden] { display:none; }
.overlay-card { max-width:min(360px,100%); border:1px solid #d7e4d7; border-radius:19px; background:#fbfdf5f7; padding:20px 26px; text-align:center; box-shadow:0 12px 40px #1d373124; }
.overlay h2 { margin:4px 0 8px; font-size:clamp(18px,4vw,24px); }
.overlay p { color:var(--muted); font-size:13px; margin:0 0 14px; }
.eyebrow,.section-label { font-size:11px; letter-spacing:.12em; color:var(--muted); }
.primary { background:var(--green); color:white; border-color:var(--green); min-height:44px; padding-inline:25px; }
.drive-controls { display:none; position:absolute; inset:auto 0 0; z-index:2; pointer-events:none; height:146px; }
.match-active .drive-controls { display:block; }
.drive[hidden] { display:none; }
.joystick { pointer-events:auto; position:absolute; left:24px; bottom:16px; width:112px; height:112px; border-radius:50%; border:1px solid #739484; background:#dce9dfd9; touch-action:none; user-select:none; cursor:grab; }
.stick-cross { position:absolute; inset:0; display:grid; place-items:center; font-size:38px; color:#799b89; pointer-events:none; }
.stick-knob { position:absolute; left:calc(50% - 24px); top:calc(50% - 24px); width:48px; height:48px; border-radius:50%; background:var(--green); border:3px solid #fcfcf6; pointer-events:none; }
.hunter-stick .stick-knob { background:#ae503b; }
.drive button { pointer-events:auto; position:absolute; right:24px; bottom:22px; width:66px; height:66px; border-radius:50%; background:#185b4b; color:white; border-color:#d2eddb; touch-action:none; font-weight:700; }
.dual #hunterStick { left:auto; right:24px; }
.dual #runnerBoost { left:145px; right:auto; }
.dual #hunterBoost { right:145px; }
dialog { color:var(--ink); border:1px solid var(--line); border-radius:18px; background:var(--paper); padding:16px; width:min(460px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); }
dialog::backdrop { background:#071e4a45; }
.dialog-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px; }
.dialog-head h2 { margin:0; font-size:20px; }
.panel { border-top:1px solid var(--line); padding:12px 0; margin-top:12px; }
.panel label { display:block; margin:8px 0 3px; }
.panel select { width:100%; }
.muted { font-size:12px; color:var(--muted); }
.keyrow,.wallet { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.runner-text { color:var(--green); }
.hunter-text { color:#a84937; }
.boost-meter { height:4px; background:#dfe7d8; margin:8px 0; }
.boost-meter span { display:block; height:100%; background:var(--green); }
@media(max-width:760px), (pointer:coarse) {
  main { padding:0; }
  .arena { border:0; border-radius:0; }
  .hud { padding: max(5px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 5px max(8px,env(safe-area-inset-left)); gap:6px; }
  .identity small,.identity b { display:none; }
  .score,.actions { gap:5px; }
  .score strong { font-size:17px; }
  .hud button { padding:6px; min-height:38px; }
  .joystick { left:max(15px,env(safe-area-inset-left)); bottom:calc(12px + env(safe-area-inset-bottom)); width:100px; height:100px; }
  .drive button { right:max(17px,env(safe-area-inset-right)); bottom:calc(17px + env(safe-area-inset-bottom)); width:62px; height:62px; }
  .dual #hunterStick { right:15px; }
  .dual #runnerBoost { left:117px; }
  .dual #hunterBoost { right:117px; }
  .dual .drive button { width:48px; height:48px; font-size:11px; padding:0; }
}
@media (orientation:portrait) and (max-width:600px) {
  dialog { position:fixed; inset:auto 0 0; margin:0; width:100%; max-width:none; max-height:85dvh; border-radius:20px 20px 0 0; padding-bottom:max(16px,env(safe-area-inset-bottom)); }
}
@media(max-height:480px) and (orientation:landscape) {
  .joystick { left:max(28px,env(safe-area-inset-left)); bottom:calc(18px + env(safe-area-inset-bottom)); }
  .drive button { right:max(30px,env(safe-area-inset-right)); bottom:calc(24px + env(safe-area-inset-bottom)); }
}
@media(max-width:760px) {
  .hud { grid-template-columns:auto 1fr auto; }
  .score { justify-content:center; }
}
@media(max-width:360px) {
  .score .label { font-size:10px; }
  .score { gap:3px; }
  .actions { gap:3px; }
  .hud button { padding-inline:4px; }
  .identity .brandmark { width:24px; height:24px; }
}
@media(max-width:420px) {
  .dual #runnerBoost { left:41px; bottom:calc(116px + env(safe-area-inset-bottom)); }
  .dual #hunterBoost { right:41px; bottom:calc(116px + env(safe-area-inset-bottom)); }
}

/* Arena contrast keeps streets and controls readable at a glance. */
.hud { border-bottom: 2px solid #76b895; }
.score strong { color:#d4f3de; }
.overlay-card { border-color:#a9c5af; box-shadow:0 14px 44px #254d3d36; }
.joystick { box-shadow:0 5px 16px #173d3430, inset 0 0 0 5px #eff6ec73; }
.drive button { box-shadow:0 5px 16px #173d3438; }
.room-row { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin-top:12px; }
.room-row input { font:inherit; width:128px; padding:9px; border:1px solid var(--line); border-radius:9px; }
#roomNumber { font-size:26px; letter-spacing:.12em; }
.rotate-tip { display:none; }
@media (pointer:coarse) and (orientation:portrait) {
  .rotate-tip { display:block; position:fixed; bottom:calc(6px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); color:var(--muted); font-size:11px; white-space:nowrap; pointer-events:none; }
  .match-active .rotate-tip { display:none; }
  .hud #view { font-size:0; }
  .hud #view::after { content:'视角'; font-size:12px; }
  body.online-match .hud #openSettings { display:none; }
}
@media (pointer:coarse) and (orientation:landscape) {
  .hud { grid-template-columns:1fr auto 1fr; padding-block:4px; }
  .identity b,.identity small { display:inline; }
  .hud button { min-height:34px; }
  .joystick { width:112px; height:112px; left:max(24px,env(safe-area-inset-left)); }
  .drive button { width:72px; height:72px; right:max(26px,env(safe-area-inset-right)); }
  .overlay-card { padding-block:12px; }
}
@media(max-width:360px) {
  .hud .identity { display:none; }
  .hud { grid-template-columns:1fr auto; }
}

html, body { overflow:hidden; overscroll-behavior:none; touch-action:manipulation; }
main {
  position:fixed;
  inset:var(--screen-y,0px) auto auto var(--screen-x,0px);
  width:var(--screen-width,100vw);
  height:var(--screen-height,100dvh);
  transform:var(--screen-transform,none);
  transform-origin:top left;
}
.hud .brandmark { color:#17362d; background:#a9e0be; width:32px; min-width:32px; height:32px; min-height:32px; padding:0; }
.display-prompt { display:none; margin-left:6px; }
@media (pointer:coarse) {
  .display-prompt { display:inline-block; min-height:44px; }
  .identity small { display:none; }
  .hud { grid-template-columns:auto minmax(0,1fr) auto; }
  .score { justify-content:center; }
}
@media (max-width:360px) {
  .hud .identity { display:flex; }
  .score .label { display:none; }
}
.room-row input { font-size:16px; }

.growth-hero { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; background:#e3f3df; border-radius:12px; padding:12px 16px; }
.growth-kicker,.growth-hero small,.growth-wallet span { display:block; color:var(--muted); }
.growth-hero strong { display:block; font-size:40px; line-height:1.15; font-variant-numeric:tabular-nums; }
.growth-wallet { text-align:right; }
.growth-wallet strong { font-size:25px; }
.growth-stages { list-style:none; padding:0; display:flex; flex-wrap:wrap; gap:4px; }
.growth-stages li { border:1px solid var(--line); border-radius:6px; padding:4px 6px; color:var(--muted); font-size:12px; }
.growth-stages [aria-current] { background:#185b4b; color:white; border-color:#185b4b; }
#growthProgress { width:100%; height:12px; accent-color:var(--green); }
#growthFeedback { color:#185b4b; font-weight:700; }
#growthFeedback:empty { display:none; }
@media(max-width:420px) {
  .hud #view { font-size:0; }
  .hud #view::after { content:'视角'; font-size:12px; }
  .hud .score .label { display:none; }
}

/* Keep the rendering layer independent of controls and modal content. */
.arena { isolation:isolate; }
.board { z-index:0; isolation:isolate; }
.board canvas { position:absolute; inset:0; z-index:0; pointer-events:none; }
/* The backdrop is stationary in screen space. Keep its SVG out of the frame loop. */
#map {
  background:#fff5df url('art/sprint-court.svg?v=21') center / cover no-repeat;
  will-change:transform;
}
.board .overlay { z-index:1; overflow:auto; }
.hud { z-index:3; }
.drive-controls { z-index:2; }
.touch-device main { padding:0; }
.touch-device .arena { border:0; border-radius:0; }
.touch-device .hud {
  padding-left:max(8px,env(safe-area-inset-left,0px));
  padding-right:max(8px,env(safe-area-inset-right,0px));
  padding-top:max(4px,env(safe-area-inset-top,0px));
}
.touch-device .hud button { min-height:38px; }
.touch-device .joystick { left:max(16px,env(safe-area-inset-left,0px)); bottom:calc(12px + env(safe-area-inset-bottom,0px)); }
.touch-device .drive button { right:max(16px,env(safe-area-inset-right,0px)); bottom:calc(18px + env(safe-area-inset-bottom,0px)); }
.touch-device .dual #hunterStick { left:auto; right:max(16px,env(safe-area-inset-right,0px)); }
.touch-device .dual #runnerBoost { left:max(130px,calc(env(safe-area-inset-left,0px) + 112px)); right:auto; }
.touch-device .dual #hunterBoost { right:max(130px,calc(env(safe-area-inset-right,0px) + 112px)); }
.phone-portrait .hud { grid-template-columns:auto minmax(0,1fr); gap:4px 8px; }
.phone-portrait .identity { display:flex; }
.phone-portrait .score { justify-content:flex-end; }
.phone-portrait .actions { grid-column:1/-1; justify-content:space-between; }
.phone-portrait .actions button { flex:1; }
.phone-portrait.match-active .arena,
.phone-portrait.match-result .arena { grid-template-rows:auto minmax(0,1fr) auto; }
.phone-portrait .drive-controls {
  position:relative;
  inset:auto;
  height:calc(121px + env(safe-area-inset-bottom,0px));
  background:#eef3e9;
  border-top:1px solid var(--line);
}
.phone-portrait .drive-controls.dual { height:calc(167px + env(safe-area-inset-bottom,0px)); }
.phone-portrait.match-result .drive-controls { display:block; background:#fff0d4; border-top-color:transparent; }
.phone-portrait.match-result .drive { visibility:hidden; }
.phone-portrait .dual #runnerBoost { left:41px; bottom:calc(116px + env(safe-area-inset-bottom,0px)); }
.phone-portrait .dual #hunterBoost { right:41px; bottom:calc(116px + env(safe-area-inset-bottom,0px)); }
dialog {
  max-height:calc(var(--screen-height, 100vh) - 20px);
  overflow:auto;
  overscroll-behavior:contain;
}
dialog.fallback-dialog[open] { position:fixed; inset:10px 0 auto; z-index:9; margin:auto; box-shadow:0 0 0 100vmax #071e4a45; }
#displayNotice {
  position:absolute; z-index:5; bottom:calc(12px + env(safe-area-inset-bottom,0px));
  left:50%; transform:translateX(-50%); width:max-content; max-width:calc(100% - 28px);
  padding:8px 12px; background:#18332d; color:white; border-radius:8px; text-align:center;
  pointer-events:none;
}
@media (max-height:380px) and (orientation:landscape) {
  .touch-device .joystick { width:96px; height:96px; }
  .touch-device .drive button { width:60px; height:60px; }
}
.touch-device dialog[open] {
  position:fixed;
  inset:auto;
  left:calc(var(--screen-x,0px) + var(--screen-width,100vw)/2);
  top:calc(var(--screen-y,0px) + max(8px,env(safe-area-inset-top,0px)));
  margin:0;
  width:min(460px,calc(var(--screen-width,100vw) - 24px));
  transform:translateX(-50%);
  max-height:calc(var(--screen-height,100vh) - 16px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
}
.phone-portrait dialog[open] {
  top:calc(var(--screen-y,0px) + var(--screen-height,100vh) - max(6px,env(safe-area-inset-bottom,0px)));
  transform:translate(-50%,-100%);
  border-radius:18px;
}

/* Daylight Sprint */
:root {
  --ink:#152c50;
  --muted:#52637d;
  --line:#d8dbea;
  --green:#184bce;
  --paper:#fffbf0;
}
body { background:#f5e9d4; }
.hud {
  color:#153464;
  background:#fff9ed;
  border-bottom:2px solid #ee7437;
}
.hud .brandmark {
  color:#184bce;
  background:#e9efff;
  border-color:#c6d5f2;
}
.identity .daylight-wordmark {
  display:block;
  flex:none;
  width:62px;
  height:33px;
  font-size:0;
  background:url('art/wordmark.svg') center/66px no-repeat;
}
.phone-portrait .identity .daylight-wordmark { width:56px; }
.hud .identity small,.score .label { color:#52637d; }
.hud button { background:#edf2ff; color:#173970; border-color:#c9d7ef; }
.hud button:hover { background:#dce8ff; }
.score strong { color:#173d95; }
#timer { font-style:italic; font-weight:850; letter-spacing:.02em; }
#timer.urgent { color:#c74020; background:#ffe5cf; border-radius:6px; padding-inline:5px; }
.board .overlay { background:transparent; }
.overlay-card {
  background:#fffbf0f7;
  border:1px solid #fff;
  border-top:4px solid #ef7136;
  box-shadow:0 14px 38px #29406b32;
}
.eyebrow { color:#a24421; font-weight:750; }
.primary { background:linear-gradient(#126bff,#0646ec); border-color:#0342ce; }
.primary:hover { background:#123cae; }
.growth-hero { background:#eaf1ff; }
.growth-stages [aria-current] { background:#174bd8; border-color:#174bd8; }
#growthFeedback,.runner-text { color:#174bd8; }
.hunter-text { color:#c14527; }
.phone-portrait .drive-controls { background:#fff4df; }
.joystick {
  background:#c4e4fc url('art/joystick-base.svg') center/100% 100% no-repeat;
  border:0;
  box-shadow:inset 0 0 0 3px #507dff;
}
.stick-cross { visibility:hidden; }
.stick-knob,.hunter-stick .stick-knob {
  background:#0874ff url('art/joystick-thumb.svg') center/100% 100% no-repeat;
  border:0;
}
.hunter-stick .stick-knob { filter:hue-rotate(142deg); }
.drive button {
  background:linear-gradient(145deg,#1788ff,#0647ee 65%,#1632c3);
  border-color:#fff5df;
  text-shadow:0 1px 3px #12255d;
  display:block;
  padding:0;
  font-size:11px;
}
.boost-icon { position:absolute; width:66%; height:62%; top:7%; left:17%; pointer-events:none; }
.boost-label { position:absolute; left:0; right:0; bottom:10%; display:block; font-size:12px; line-height:1; text-align:center; white-space:nowrap; pointer-events:none; }
.drive button[data-boost=active] { opacity:1; background:linear-gradient(135deg,#fff087,#ff831d 50%,#f34412); color:white; box-shadow:0 0 0 4px #ffca7070,0 0 24px #ff9b24; }
.drive button[data-boost=cooldown] { background:linear-gradient(145deg,#5376b2,#304e8c); opacity:.9; }
.dual .boost-label { font-size:10px; bottom:9%; }
@media(max-width:760px) and (orientation:landscape) {
  .identity .daylight-wordmark { display:none; }
}

/* Race broadcast treatment for the playable Daylight art direction. */
.hud {
  background:#fffaf0;
  border-bottom:3px solid #f59a58;
  box-shadow:0 2px 0 #fff8ee;
}
.identity .daylight-wordmark { width:90px; height:43px; background-size:92px; }
.score { gap:12px; }
.race-clock {
  display:flex;
  flex-direction:column;
  min-width:clamp(85px,12vw,190px);
  text-align:center;
  padding:0 10px;
  border-inline:1px solid #b5c3df;
}
.score #timer {
  color:#1744c9;
  font-size:clamp(23px,4vw,46px);
  font-weight:950;
  line-height:1;
  letter-spacing:-.055em;
  padding:0;
}
.score #timer.urgent {
  color:#d63813;
  background:transparent;
}
.clock-track {
  height:5px;
  width:100%;
  border-radius:8px;
  background:#e0e8f8;
  overflow:hidden;
  margin:5px auto 0;
}
#clockFill {
  display:block;
  height:100%;
  background:#2b59dc;
  transform-origin:left center;
}
#clockFill.urgent { background:#f05424; }
.beacon-label { font-weight:750; }
.hud #taskCount { font-size:clamp(17px,2.4vw,26px); font-weight:850; }
.overlay-card {
  border-top:0;
  border-left:5px solid #f17a37;
  background:#fffdf6;
  box-shadow:0 16px 36px #2f416d30,0 1px 0 #fff inset;
}
.overlay-card h2 { color:#183e98; font-weight:900; }
.overlay-card .primary {
  box-shadow:0 4px 0 #102f92;
  font-weight:800;
}
@media(max-width:900px) {
  .identity .daylight-wordmark { width:62px; height:36px; background-size:66px; }
  .score { gap:7px; }
}
@media(max-width:760px) and (orientation:landscape) {
  .identity .daylight-wordmark { display:none; }
}
@media(max-height:380px) and (orientation:landscape) {
  .score #timer { font-size:24px; }
  .clock-track { height:3px; margin-top:3px; }
}


/* Embedded WebViews can report different layout and visible widths during rotation. */
html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
.touch-device .hud {
  grid-template-columns:minmax(0,1fr) max-content max-content;
  gap:5px 8px;
}
.touch-device .identity { overflow:hidden; }
.touch-device .score { gap:6px; }
.touch-device .race-clock { min-width:0; padding-inline:7px; }
.touch-device .score #timer { font-size:clamp(20px,calc(var(--screen-width,390px)*.05),33px); }
.touch-device .score #taskCount { font-size:18px; }
.touch-device .actions { gap:4px; min-width:0; }
.touch-device .actions button { padding-inline:7px; }
.compact-hud .hud { grid-template-columns:minmax(0,1fr) max-content; }
.compact-hud .actions { grid-column:1/-1; justify-content:space-between; }
.compact-hud .actions button { flex:1 1 0; min-width:0; padding-inline:3px; }
.compact-hud .identity .daylight-wordmark { width:55px; background-size:59px; }
.compact-hud #view { font-size:0; }
.compact-hud #view::after { content:'视角'; font-size:12px; }
.narrow-viewport .identity .daylight-wordmark,.narrow-viewport .score .label { display:none; }
.narrow-viewport .actions button { font-size:11px; }

.board .overlay { min-width:0; min-height:0; }
.touch-device .overlay { padding:8px; }
.touch-device .overlay-card {
  display:flex;
  flex-direction:column;
  width:min(100%,350px);
  max-width:100%;
  max-height:100%;
  min-height:0;
  padding:12px 14px;
}
.touch-device .overlay h2 { font-size:clamp(16px,calc(var(--screen-width,390px)*.05),23px); }
.touch-device #resultText { overflow:auto; min-height:0; }
.overlay-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:6px; flex:none; }
.overlay-actions .display-prompt { margin-left:0; }
.overlay-actions button { min-width:0; white-space:normal; }
.short-viewport .overlay-card { padding:8px 10px; }
.short-viewport .overlay h2 { margin:2px 0 4px; font-size:18px; line-height:1.2; }
.short-viewport #resultText { margin-bottom:6px; font-size:12px; }
.short-viewport .overlay-actions button { min-height:34px; padding:5px 10px; font-size:12px; }
.very-short-viewport .hud .brandmark,.very-short-viewport .hud button { min-height:30px; }
.very-short-viewport .overlay-card .eyebrow { display:none; }
.very-short-viewport .overlay h2 { font-size:16px; }
.touch-device .overlay { grid-template-rows:minmax(0,1fr); }

/* Keep the thumb travel inside the screen, including on short landscape displays. */
.touch-device {
  --stick-size:128px;
  --boost-size:84px;
  --stick-thumb:54px;
  --control-inset:clamp(30px,calc(var(--screen-width, 390px)*.065),70px);
  --control-bottom:27px;
  --control-left:max(var(--control-inset),calc(env(safe-area-inset-left,0px) + 14px));
  --control-right:max(var(--control-inset),calc(env(safe-area-inset-right,0px) + 14px));
}
.touch-device.short-viewport { --stick-size:112px; --boost-size:74px; --control-bottom:23px; }
.phone-portrait { --stick-size:118px; --boost-size:76px; --control-bottom:24px; }
.touch-device.narrow-viewport { --stick-size:104px; --boost-size:64px; --control-inset:18px; }
.touch-device .drive-controls:not(.dual) .joystick {
  width:var(--stick-size);
  height:var(--stick-size);
  left:var(--control-left);
  bottom:calc(var(--control-bottom) + env(safe-area-inset-bottom,0px));
}
.touch-device .drive-controls:not(.dual) .stick-knob {
  width:var(--stick-thumb);
  height:var(--stick-thumb);
  left:calc(50% - var(--stick-thumb)/2);
  top:calc(50% - var(--stick-thumb)/2);
}
.touch-device .drive-controls:not(.dual) .drive button {
  width:var(--boost-size);
  height:var(--boost-size);
  right:var(--control-right);
  bottom:calc(var(--control-bottom) + (var(--stick-size) - var(--boost-size))/2 + env(safe-area-inset-bottom,0px));
}
.right-stick.touch-device .drive-controls:not(.dual) .joystick { left:auto; right:var(--control-right); }
.right-stick.touch-device .drive-controls:not(.dual) .drive button { right:auto; left:var(--control-left); }
.phone-portrait .drive-controls:not(.dual) {
  height:calc(var(--stick-size) + var(--control-bottom) + 12px + env(safe-area-inset-bottom,0px));
}

/* Leave vertical scrolling available in text panels, without granting pinch zoom. */
.hud, .drive-controls, button { touch-action:none; }
.board, dialog, #resultText { touch-action:pan-y; }
.arena { -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
.touch-device input,.touch-device select,.touch-device textarea { font-size:16px; }

.versus-stage {
  position:relative;
  isolation:isolate;
  overflow:hidden;
  display:grid;
  grid-template-columns:minmax(0,1fr) 70px minmax(0,1fr);
  align-items:center;
  gap:10px;
  padding:12px 8px;
  margin-top:12px;
  border:1px solid #fff;
  border-radius:14px;
  background:linear-gradient(115deg,#00bfff 0 46%,#ffffff 46% 54%,#ff6435 54%);
  box-shadow:0 4px 0 #153f8f25,inset 0 0 0 2px #fff;
}
.duel-art { position:absolute; inset:0; z-index:0; width:100%; height:100%; opacity:0; pointer-events:none; }
.has-art .duel-art { opacity:1; }
.versus-seat { position:relative; z-index:1; display:grid; justify-items:center; gap:3px; min-width:0; color:#1646bd; font-weight:800; }
.versus-seat.hunter-seat { color:#ac2d21; }
.versus-seat img { display:block; width:min(100%,94px); aspect-ratio:1; }
.has-art .versus-seat img,.has-art .versus-mark { opacity:0; }
.versus-seat strong { padding:1px 7px; border-radius:4px; background:#f9fdffed; }
.versus-seat.hunter-seat strong { background:#fff6ebed; }
.versus-seat span {
  padding:2px 6px;
  border-radius:5px;
  background:#fff9;
  font-size:12px;
  white-space:nowrap;
}
.versus-seat.is-ready span { background:#d8f9e5; color:#166845; }
.versus-mark {
  position:relative;
  z-index:1;
  font-weight:950;
  font-style:italic;
  font-size:clamp(24px,7vw,48px);
  letter-spacing:-.1em;
  color:#1f43d6;
  text-shadow:2px 2px #fff,-2px -2px #fff,0 4px #ffc36e;
  transform:skew(-8deg);
}
#roomRole,#roomPlayers { margin:6px 0; font-size:13px; }
.countdown-matchup:not([hidden]) {
  display:flex;
  flex:none;
  justify-content:center;
  align-items:center;
  gap:12px;
}
.countdown-matchup img { width:52px; height:52px; }
.countdown-matchup strong { color:#174bd8; font-weight:950; font-size:26px; font-style:italic; }
.short-viewport .versus-seat img { width:min(100%,55px); }
.short-viewport .versus-stage { margin-top:7px; padding:5px; gap:5px; }
.short-viewport .countdown-matchup img { width:35px; height:35px; }

/* Single-purpose panels keep the decision and its action together. */
.task-dialog { width:min(540px,calc(100vw - 24px)); background:#fffdf7; border:2px solid #fff; }
.task-dialog .dialog-head { margin-bottom:12px; }
.task-dialog .dialog-head h2 { color:#113bc2; font-weight:900; }
.task-dialog p { margin:6px 0; }
.task-dialog button { min-height:40px; }
.task-dialog .primary { font-weight:800; box-shadow:0 3px 0 #102f92; }
.task-dialog .muted { color:#4d6082; }
.touch-device .task-dialog[open] {
  left:calc(var(--screen-x,0px) + env(safe-area-inset-left,0px) + (var(--screen-width,100vw) - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px))/2);
  top:calc(var(--screen-y,0px) + env(safe-area-inset-top,0px) + (var(--screen-height,100vh) - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))/2);
  transform:translate(-50%,-50%);
  width:min(560px,calc(var(--screen-width,100vw) - 24px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)));
  max-height:calc(var(--screen-height,100vh) - 16px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
  padding:12px 16px;
  border-radius:20px;
}
.phone-portrait .task-dialog[open] { width:min(440px,calc(var(--screen-width,100vw) - 24px)); }
#roomDialog { --duel-height:164px; width:min(520px,calc(100vw - 24px)); }
.touch-device #roomDialog[open] { width:min(520px,calc(var(--screen-width,100vw) - 24px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px))); }
.room-header { gap:8px; }
.room-header h2 { flex:none; }
.room-header form { flex:none; }
#roomDialog .room-invite { display:none; margin-left:auto; gap:7px; }
.online-match #roomDialog .room-invite { display:flex; }
.room-header #roomNumber { font-size:22px; letter-spacing:.06em; }
.room-header #copyRoom { min-height:32px; padding:3px 8px; }
#roomDialog .versus-stage {
  height:var(--duel-height);
  padding:6px;
  border:2px solid white;
  border-radius:17px;
}
#roomDialog .versus-seat img { width:clamp(42px,calc(var(--duel-height) - 45px),120px); }
#roomDialog .versus-seat { height:100%; min-height:0; align-self:stretch; grid-template-rows:auto minmax(0,1fr) auto; gap:0; }
#roomDialog .versus-seat img { height:100%; max-height:100%; min-height:0; object-fit:contain; align-self:center; }
#roomDialog .room-status { display:flex; flex-wrap:wrap; justify-content:space-between; gap:0 8px; }
#roomDialog .room-status p { font-size:12px; margin:0; }
.growth-layout { display:grid; gap:12px; }
.growth-hero {
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:6px 12px;
  background:linear-gradient(135deg,#dcf5ff,#bfe3ff);
  border:1px solid #9fceff;
  color:#0647d9;
}
.growth-hero strong { font-weight:900; }
.growth-details { min-width:0; }
.growth-stages { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:4px; margin:0 0 8px; }
.growth-stages li { padding:6px 2px; text-align:center; font-size:11px; white-space:nowrap; }
.growth-stages [aria-current] { color:white; }
#speedEffect { color:#133fb6; font-weight:750; }
#growthRequirement { margin-bottom:0; }
.growth-actions { display:grid; align-content:start; gap:6px; min-width:0; }
#upgrade { width:100%; }
#rewardHelp { margin:0; font-size:11px; }
#growthFeedback { grid-column:1/-1; margin:0; font-size:12px; }
#roomEntry:not([hidden]) { display:grid; gap:14px; }
.room-intro p:first-child { margin-top:0; font-weight:800; color:#1649bd; }
.room-entry-actions { display:grid; gap:12px; }
#joinRoom { flex-wrap:nowrap; margin:0; }
#roomCode { flex:1; min-width:0; width:0; }
#joinRoom button { flex:none; }
#roomLobby:not([hidden]) { display:grid; gap:10px; }
.room-invite { justify-content:space-between; flex-wrap:nowrap; margin:0; }
#roomNumber { color:#103bbf; font-size:30px; line-height:1.1; letter-spacing:.12em; }
#copyRoom { font-size:12px; padding:6px 10px; }
#roomLobby .versus-stage { margin:0; }
.room-status { padding:0 2px; }
.room-status p { margin:2px 0; line-height:1.4; }
.room-actions { margin:0; gap:8px; }
.room-actions button { flex:1; padding-inline:8px; }
#roomMessage { margin:8px 0 0; font-size:12px; line-height:1.4; }
#roomMessage:empty { display:none; }
#displayDialog p { line-height:1.5; }
#displayDialog .room-row { justify-content:flex-end; margin-top:12px; }

@media (orientation:landscape) and (min-width:480px) {
  .touch-device #roomEntry:not([hidden]) { grid-template-columns:minmax(0,1fr) minmax(0,1fr); align-items:center; gap:24px; }
  .touch-device .room-intro p:first-child { font-size:20px; line-height:1.3; }
  .touch-device #roomDialog { --duel-height:clamp(90px,calc(var(--screen-height,390px) - 180px),174px); }
  .touch-device #roomLobby:not([hidden]) { grid-template-columns:minmax(0,1fr); gap:7px; }
  .touch-device .growth-layout { grid-template-columns:minmax(0,.85fr) minmax(0,1.5fr); gap:10px 18px; }
  .touch-device .growth-hero { display:flex; grid-row:1/3; flex-direction:column; gap:8px; padding:12px 16px; }
  .touch-device #growthSpeed { font-size:52px; }
  .touch-device .growth-wallet { display:flex; align-items:baseline; gap:10px; text-align:left; }
  .touch-device .growth-wallet strong { font-size:26px; }
  .touch-device .growth-details,.touch-device .growth-actions { grid-column:2; }
}
@media (orientation:landscape) and (max-height:340px) {
  .touch-device .task-dialog[open] { padding:8px 12px; border-radius:16px; }
  .touch-device .task-dialog .dialog-head { margin-bottom:5px; }
  .touch-device .task-dialog .dialog-head h2 { font-size:18px; }
  .touch-device .task-dialog .dialog-head button { min-height:34px; padding:4px 12px; }
  .touch-device #roomLobby:not([hidden]) { gap:5px; }
  .touch-device .versus-seat strong { font-size:13px; }
  .touch-device .versus-seat span { font-size:11px; }
  .touch-device .versus-mark { font-size:32px; }
  .touch-device #roomNumber { font-size:22px; }
  .touch-device #copyRoom { padding-inline:7px; min-height:36px; }
  .touch-device #roomRole,.touch-device #roomPlayers { font-size:12px; }
  .touch-device #roomMessage { font-size:11px; margin-top:6px; }
  .touch-device .growth-layout { gap:5px 14px; }
  .touch-device .growth-stages { margin-bottom:4px; }
  .touch-device .growth-stages li { padding:4px 0; }
  .touch-device #speedEffect { margin:3px 0; font-size:13px; }
  .touch-device #growthRequirement { margin-top:2px; font-size:11px; }
  .touch-device #growthProgress { display:block; height:8px; margin:4px 0; }
  .touch-device .growth-actions { gap:4px; }
  .touch-device .growth-hero { padding:10px 14px; }
  .touch-device #growthSpeed { font-size:40px; }
  .touch-device .growth-kicker,.touch-device .growth-hero small { font-size:12px; }
  .touch-device .growth-wallet strong { font-size:22px; }
  .touch-device #growthFeedback,.touch-device #rewardHelp { margin-top:0; font-size:11px; }
}
@media (orientation:portrait) and (max-height:560px) {
  .phone-portrait .task-dialog[open] { padding:10px 12px; }
  .phone-portrait .task-dialog .dialog-head { margin-bottom:8px; }
  .phone-portrait #roomLobby:not([hidden]) { gap:5px; }
  .phone-portrait #roomDialog { --duel-height:130px; }
  .phone-portrait #roomMessage { font-size:11px; margin-top:6px; }
  .phone-portrait .growth-layout { gap:8px; }
  .phone-portrait .growth-hero { padding:8px 12px; gap:4px 8px; }
  .phone-portrait #growthSpeed { font-size:32px; }
  .phone-portrait .growth-stages li { padding:4px 0; }
  .phone-portrait .growth-stages { margin-bottom:4px; }
}

/* Pursuit feedback stays above the players and never captures input. */
.pursuit-vignette {
  position:absolute; inset:0; z-index:1; pointer-events:none;
  border:3px solid #ff552c;
  background:radial-gradient(ellipse at center,transparent 46%,#ff532d38 74%,#fa300bab);
  box-shadow:inset 0 0 28px #ff4b2440;
  opacity:var(--pressure-opacity,0);
  will-change:opacity;
}
.pursuit-vignette[data-level="near"] { border-color:#ff9c40; }
.pursuit-alert {
  position:absolute; z-index:1; top:12px; left:50%; transform:translateX(-50%);
  display:flex; align-items:center; gap:7px; pointer-events:none;
  padding:5px 12px; border:2px solid #fff6da; border-radius:8px;
  color:#fff; background:#b53615; box-shadow:0 3px 10px #53200f30; white-space:nowrap;
  font-size:12px; transition:background-color .35s ease,box-shadow .35s ease;
}
.pursuit-alert>img { width:23px; height:23px; flex:none; }
.pursuit-alert[data-level="urgent"] { background:#d23210; box-shadow:0 2px 12px #ff481a60; }
.pursuit-alert[data-level="near"] { background:#bd6413; }
.pursuit-alert.is-hunting { background:#0756b9; }

/* Round endings use a full-arena mask and a winner-specific presentation. */
.result-hero[hidden],.result-stats[hidden],.pursuit-alert[hidden],.pursuit-vignette[hidden],
#resultExit[hidden],#resultGrowth[hidden],#exitMatch[hidden] { display:none; }
.match-result .overlay {
  inset:0; z-index:6; padding:12px;
  background:radial-gradient(ellipse at center,#173f7640,#071830c4);
}
.match-result .overlay-card {
  position:relative; overflow:hidden;
  width:min(510px,100%); max-width:100%; max-height:100%;
  padding:16px 20px; border:2px solid #fff; border-radius:23px;
  background:radial-gradient(circle at 8% 5%,#fff09c,#fffdf4 56%);
  box-shadow:0 18px 70px #020c2b80,0 0 0 5px #ffdb7140;
  animation:result-arrive .35s ease-out;
}
.match-result .overlay[data-outcome="lose"] { background:radial-gradient(ellipse at center,#4b264e55,#08112bd4); }
.match-result [data-outcome="lose"] .overlay-card {
  background:radial-gradient(circle at 8% 5%,#ffd3ba,#fff8f2 60%);
  box-shadow:0 18px 70px #020c2b80,0 0 0 5px #ff5b5340;
}
.result-hero { display:grid; grid-template-columns:108px minmax(0,1fr); align-items:center; gap:12px; text-align:left; }
.result-emblem { position:relative; display:grid; place-items:center; height:104px; isolation:isolate; }
.result-emblem::before {
  content:""; position:absolute; z-index:-1; inset:0; border-radius:50%;
  background:repeating-conic-gradient(from 10deg,#ffdb4e 0deg 12deg,#ffedaa 12deg 24deg);
  transform:rotate(-8deg);
}
.result-emblem img { width:95px; height:95px; filter:drop-shadow(0 5px 3px #af6e2860); }
#resultStamp { position:absolute; bottom:0; left:50%; transform:translateX(-50%) rotate(-6deg); border:2px solid #fff; padding:1px 7px; color:#1437b4; background:#ffe45a; border-radius:4px; font-size:10px; font-weight:950; letter-spacing:.08em; }
.result-heading { display:grid; gap:3px; }
#resultVerdict { color:#1642d5; font-size:52px; font-weight:950; font-style:italic; line-height:1.12; text-shadow:2px 3px #ffda61; }
#resultSummary { color:#6b4c2c; font-size:12px; font-weight:750; }
[data-outcome="lose"] #resultVerdict { color:#cd351f; text-shadow:2px 3px #ffb18a; }
[data-outcome="lose"] .result-emblem::before { background:repeating-conic-gradient(#ff845e 0deg 12deg,#ffd4b4 12deg 24deg); }
[data-outcome="lose"] #resultStamp { background:#d83628; color:white; }
.match-result .overlay-card .eyebrow { margin-bottom:6px; color:#8b4d11; }
.match-result .overlay-card h2 { margin:7px 0 2px; font-size:15px; }
.match-result #resultText { margin:0 0 8px; font-size:12px; line-height:1.4; }
.result-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; margin:0 0 12px; }
.result-stats>div { padding:6px; border-radius:9px; background:#fff9; border:1px solid #f5d9a5; }
.result-stats span { display:block; color:#6b6280; font-size:10px; }
.result-stats strong { display:block; color:#173b9b; font-size:20px; font-weight:900; line-height:1.25; }
.match-result .overlay-actions { flex-wrap:nowrap; gap:9px; }
.match-result .overlay-actions button { flex:1; min-height:42px; font-weight:800; }
.match-result #resultExit { background:#fffaf1; color:#193778; border:1px solid #c5cfe8; }
.match-result #resultGrowth { background:#ffe88b; color:#74410a; border:1px solid #e7b247; }
.exit-actions { display:flex; gap:10px; margin-top:16px; }
.exit-actions button { flex:1; }
.touch-device .exit-dialog[open] { width:min(420px,calc(var(--screen-width,100vw) - 28px)); }
.exit-dialog p { color:#52637d; line-height:1.6; }
@keyframes result-arrive { from { opacity:0; transform:translateY(12px) scale(.96); } to { opacity:1; transform:none; } }
@media (max-width:400px) {
  .room-header { gap:5px; }
  .room-header h2 { font-size:16px; }
  .room-header #roomNumber { font-size:19px; }
  .room-header #copyRoom { padding-inline:6px; }
  .room-header form button { padding-inline:8px; }
  .match-result .overlay-card { padding:13px; }
  .result-hero { grid-template-columns:88px minmax(0,1fr); gap:10px; }
  .result-emblem { height:88px; }
  .result-emblem img { width:80px; height:80px; }
  #resultVerdict { font-size:40px; }
}
@media (orientation:landscape) and (max-height:340px) {
  .match-result .overlay { padding:8px; }
  .match-result .overlay-card { width:min(470px,100%); padding:9px 14px; border-radius:18px; }
  .match-result .overlay-card .eyebrow { display:block; margin:0 0 2px; font-size:10px; }
  .result-hero { grid-template-columns:78px minmax(0,1fr); gap:10px; }
  .result-emblem { height:71px; }
  .result-emblem img { width:68px; height:68px; }
  #resultStamp { font-size:8px; }
  #resultVerdict { font-size:36px; }
  #resultSummary { font-size:11px; }
  .match-result .overlay-card h2 { margin:3px 0 1px; font-size:12px; }
  .match-result #resultText { margin-bottom:5px; font-size:11px; }
  .result-stats { margin-bottom:7px; gap:6px; }
  .result-stats>div { padding:3px 5px; }
  .result-stats strong { font-size:17px; }
  .match-result .overlay-actions button { min-height:35px; padding:4px 10px; font-size:12px; }
  .pursuit-alert { top:7px; padding:3px 9px; font-size:11px; }
}
@media (prefers-reduced-motion:reduce) {
  .pursuit-vignette,.match-result .overlay-card { animation:none; }
  .pursuit-vignette { opacity:var(--risk,.5); }
}

/* Immersive landscape: world fills the frame and thumb controls float above it. */
@media (orientation:landscape) {
  .touch-device.match-active .arena,.touch-device.match-result .arena { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); }
  .touch-device.match-active .board,.touch-device.match-result .board { grid-column:1; grid-row:2; border:0; }
  .touch-device .drive-controls { height:calc(100% - var(--hud-height,54px)); }
  .touch-device .drive-controls.dual {
    --duo-stick:min(104px,max(64px,calc((var(--screen-height,390px) - 100px)*.5)));
    --duo-boost:min(60px,max(40px,calc((var(--screen-height,390px) - 100px)*.28)));
  }
  .touch-device .dual .joystick { width:var(--duo-stick); height:var(--duo-stick); bottom:calc(16px + env(safe-area-inset-bottom,0px)); }
  .touch-device .dual #runnerStick { left:var(--control-left); }
  .touch-device .dual #hunterStick { right:var(--control-right); }
  .touch-device .dual .drive button { width:var(--duo-boost); height:var(--duo-boost); bottom:calc(24px + var(--duo-stick) + env(safe-area-inset-bottom,0px)); }
  .touch-device .dual #runnerBoost { left:calc(var(--control-left) + (var(--duo-stick) - var(--duo-boost))/2); right:auto; }
  .touch-device .dual #hunterBoost { right:calc(var(--control-right) + (var(--duo-stick) - var(--duo-boost))/2); }
  .touch-device.match-result .drive-controls { display:block; visibility:hidden; }
  .touch-device .joystick { opacity:.76; }
  .touch-device .drive button { opacity:.9; }
  .touch-device .joystick,.touch-device .drive button { transition:opacity .16s ease; }
  .touch-device .action-under-control,.touch-device .drive button.action-under-control { opacity:.18; transition-duration:.06s; }
}

/* Every action keeps its label on one line, with layout changes instead of text wrapping. */
.overlay-actions button,dialog button { white-space:nowrap; flex-shrink:0; }
.match-result .overlay-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
.match-result .overlay-actions button { padding-inline:8px; min-width:0; }
.task-dialog .room-row:not(.room-invite) { flex-wrap:nowrap; }
#installGame[hidden] { display:none; }
#displayDialog .display-actions { flex-wrap:wrap; }
#displayDialog .display-actions button { flex:1 0 auto; }
@media (orientation:portrait) {
  .touch-device .overlay-actions { display:grid; grid-template-columns:1fr; width:100%; }
  .touch-device .overlay-actions button { width:100%; min-height:40px; margin:0; padding:7px 10px; }
  .touch-device.match-result .overlay-actions { grid-template-columns:1fr 1fr; gap:8px; }
  .touch-device.match-result #start { grid-column:1/-1; }
  .touch-device.match-result .overlay-actions button { font-size:14px; }
  .phone-portrait #displayDialog .display-actions { display:grid; grid-template-columns:1fr 1fr; }
  .phone-portrait #installGame:not([hidden]) { grid-column:1/-1; grid-row:1; }
  .phone-portrait #displayDialog .display-actions button { min-width:0; padding-inline:8px; }
}

/* Campaign choices and audio controls share the existing mobile-safe modal rules. */
.audio-settings input[type=range] { width:100%; accent-color:#1458ee; touch-action:pan-x; }
.audio-settings .audio-check { display:flex; align-items:center; gap:8px; }
.audio-settings input[type=checkbox] { width:20px; height:20px; accent-color:#1458ee; }
#campaignDialog { width:min(680px,calc(100vw - 24px)); }
.touch-device #campaignDialog[open] { width:min(680px,calc(var(--screen-width,100vw) - 24px)); }
#campaignProgress { margin-left:auto; color:#47608e; font-size:12px; white-space:nowrap; }
#chapterTabs { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:6px; }
#chapterTabs button { min-height:32px; padding:4px; background:#e9efff; color:#1c4bc8; font-weight:850; }
#chapterTabs [aria-pressed=true] { color:white; background:#1554f1; }
#campaignChapter { margin:8px 0 6px; color:#1741bc; font-size:15px; }
#campaignLevels { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; }
#campaignLevels button { min-width:0; min-height:40px; padding:5px; font-size:13px; font-variant-numeric:tabular-nums; }
#campaignLevels .is-selected { background:#fff0b8; border-color:#eda325; box-shadow:inset 0 0 0 1px #eda325; }
#campaignLevels .is-locked { color:#939bac; background:#f2f3f6; }
.campaign-detail { display:grid; grid-template-columns:1.15fr 1fr; gap:12px; margin:10px 0; padding:10px; background:linear-gradient(120deg,#e9f4ff,#fff3d6); border-radius:12px; }
.campaign-detail h3 { margin:0 0 4px; color:#1138ab; font-size:15px; }
.campaign-detail p { font-size:12px; margin:4px 0; line-height:1.4; }
#campaignObjective { font-weight:800; }
#campaignStars,#campaignNumbers,#campaignBonus { color:#526586; }
.campaign-footer { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px 10px; align-items:center; }
.campaign-footer small { grid-column:1/-1; font-size:11px; color:#526586; }
@media (orientation:landscape) and (max-height:340px) {
 #campaignLevels { grid-template-columns:repeat(8,minmax(0,1fr)); gap:4px; }
 #campaignLevels button { min-height:30px; font-size:10px; padding:3px; }
 #chapterTabs button { min-height:27px; }
 #campaignChapter { margin:4px 0; font-size:12px; }
 .campaign-detail { gap:8px; padding:5px 8px; margin:5px 0; }
 .campaign-detail h3 { font-size:12px; }
 .campaign-detail p { font-size:10px; margin:2px 0; }
 .campaign-footer button { min-height:32px; padding:4px 10px; }
 .campaign-footer small { font-size:10px; }
}
@media (orientation:portrait) {
 .campaign-detail { grid-template-columns:1fr; gap:3px; padding:8px; }
 #campaignProgress { font-size:10px; }
 #campaignDialog .dialog-head h2 { font-size:18px; }
 #campaignLevels button { font-size:11px; }
}
@media (max-height:480px) and (orientation:portrait) {
 #campaignLevels button { min-height:32px; }
 .campaign-detail p { font-size:11px; margin:2px 0; }
 #campaignChapter { margin:5px 0; }
}
@media (orientation:landscape) {
 .touch-device #campaignDialog[open] { padding:10px 12px; }
 #campaignDialog .dialog-head { margin-bottom:6px; }
 #campaignLevels { grid-template-columns:repeat(8,minmax(0,1fr)); gap:4px; }
 #campaignLevels button { min-height:34px; font-size:11px; }
 .campaign-detail { margin:6px 0; padding:7px 9px; }
 .campaign-detail p { font-size:11px; }
 .campaign-footer small { display:none; }
 .campaign-footer button { min-height:36px; }
}
@media (orientation:landscape) and (max-height:340px) {
 .touch-device #campaignDialog[open] { padding:7px 10px; }
 #campaignDialog .dialog-head { margin-bottom:4px; }
 #campaignDialog .dialog-head button { min-height:30px; }
 #campaignChapter { display:none; }
 #campaignLevels { margin-top:5px; }
 #campaignLevels button { min-height:27px; font-size:10px; }
 .campaign-detail { padding:4px 7px; margin:5px 0; }
 .campaign-detail h3 { margin-bottom:1px; font-size:12px; }
 .campaign-detail p { margin:1px 0; font-size:10px; line-height:1.3; }
 .campaign-footer button { min-height:32px; }
}
/* One 20:9 world, uniform scaling. The compact HUD floats above the landscape arena. */
@media (orientation:landscape) {
 .touch-device.match-active .arena,.touch-device.match-result .arena { grid-template-rows:minmax(0,1fr); }
 .touch-device.match-active .board,.touch-device.match-result .board { grid-row:1; }
 .touch-device.match-active .hud,.touch-device.match-result .hud { position:absolute; inset:0 0 auto; background:linear-gradient(#fffaf0f5,#fffaf0de); border-bottom:0; box-shadow:0 1px 8px #24446a12; }
 .touch-device .drive-controls { height:100%; }
 .touch-device.compact-hud .hud { grid-template-columns:minmax(0,1fr) max-content max-content; }
 .touch-device.compact-hud .actions { grid-column:auto; justify-content:flex-end; }
 .touch-device.compact-hud .actions button { flex:initial; padding-inline:5px; }
 .touch-device.compact-hud .identity .daylight-wordmark { display:none; }
}
@media (max-height:480px) and (orientation:portrait) {
 #campaignDialog .dialog-head { margin-bottom:6px; }
 #campaignDialog .dialog-head button { min-height:32px; }
 #chapterTabs button { min-height:27px; }
 #campaignChapter { margin:4px 0; font-size:13px; }
 .campaign-detail { gap:1px; margin:6px 0; padding:6px; }
 .campaign-detail h3 { font-size:13px; margin:0 0 2px; }
 .campaign-detail p { font-size:10px; line-height:1.3; margin:1px 0; }
 .campaign-footer button { min-height:34px; }
}
.stage-label { color:#174ad1; font-size:12px; font-weight:850; white-space:nowrap; padding:3px 6px; border-radius:6px; background:#e9efff; }
.stage-label[hidden] { display:none; }
.campaign-mode .daylight-wordmark { display:none; }
/* Reuse the online matchup presentation with only the mission and a five-second clock. */
.mission-dialog[open] { width:min(430px,calc(var(--screen-width,100vw) - 24px)); }
.touch-device .mission-dialog[open] { width:min(430px,calc(var(--screen-width,100vw) - 24px)); padding:16px 20px; }
.mission-dialog .dialog-head { align-items:center; margin-bottom:8px; }
.mission-dialog .dialog-head h2 { color:#47669a; font-size:13px; letter-spacing:.08em; }
.mission-dialog .mission-close { width:30px; min-height:30px; padding:0; font-size:22px; line-height:1; border:0; color:#6a7d9d; background:transparent; box-shadow:none; }
#missionGoal { margin:2px auto 12px; color:#1543c1; font-size:22px; line-height:1.4; text-align:center; max-width:22em; }
.mission-dialog[data-role=hunter] #missionGoal { color:#c24625; }
.mission-start-line { gap:24px; margin:0 auto 5px; }
.mission-start-line img { width:66px; height:66px; }
.mission-dialog[data-role=runner] .mission-hunter,.mission-dialog[data-role=hunter] .mission-runner { opacity:.6; }
.mission-clock { display:grid; justify-items:center; width:80px; flex:none; }
#missionCountdown { color:#f26020; font-size:72px; line-height:1; font-style:italic; font-weight:950; text-shadow:1px 3px #ffdb65; font-variant-numeric:tabular-nums; }
#missionCountdownHelp { font-size:10px; color:#6b7290; }
.mission-dialog::backdrop { background:#0a1b4870; }
@media (orientation:landscape) and (max-height:300px) {
 .touch-device .mission-dialog[open] { padding:9px 16px; }
 .mission-dialog .dialog-head { margin-bottom:2px; }
 #missionGoal { font-size:18px; margin-bottom:5px; }
 .mission-start-line img { width:48px; height:48px; }
 #missionCountdown { font-size:52px; }
}
/* Native modal dialogs live above transformed main, so recover their zoom separately. */
.touch-device dialog[open]:not(.fallback-dialog) {
 left:calc(var(--screen-x,0px) + var(--visible-screen-width,100vw)/2);
 top:calc(var(--screen-y,0px) + 8px*var(--viewport-inverse,1));
 transform:scale(var(--viewport-inverse,1)) translateX(-50%);
 transform-origin:top left;
}
.touch-device .task-dialog[open]:not(.fallback-dialog) {
 top:calc(var(--screen-y,0px) + var(--visible-screen-height,100dvh)/2);
 transform:scale(var(--viewport-inverse,1)) translate(-50%,-50%);
}
.phone-portrait dialog[open]:not(.task-dialog):not(.fallback-dialog) {
 top:calc(var(--screen-y,0px) + var(--visible-screen-height,100dvh) - 8px*var(--viewport-inverse,1));
 transform:scale(var(--viewport-inverse,1)) translate(-50%,-100%);
}
.touch-device dialog.fallback-dialog[open] { left:calc(var(--screen-width,100vw)/2); top:8px; transform:translateX(-50%); transform-origin:center; }
.touch-device .task-dialog.fallback-dialog[open] { top:calc(var(--screen-height,100dvh)/2); transform:translate(-50%,-50%); }
.phone-portrait dialog.fallback-dialog[open]:not(.task-dialog) { top:calc(var(--screen-height,100dvh) - 8px); transform:translate(-50%,-100%); }

#missionGoal:focus { outline:none; }

/* Persistent navigation and compact result layout. Home art is isolated in home.css. */
.home-active .workspace { visibility:hidden; pointer-events:none; }
#settings .dialog-head { position:sticky; top:-16px; z-index:2; background:#fffaf0; padding-block:5px 10px; border-bottom:1px solid #dbe3f4; }
#settings .dialog-head form { margin:0; }
.match-result .overlay-actions { grid-template-columns:repeat(2,minmax(0,1fr)); }
#overlayHome,#practiceSettings,#restart,#resultExit { background:#fffdf6; border:1px solid #bdccec; color:#214581; box-shadow:none; }
@media (orientation:landscape) and (max-height:340px) {
 .match-result .overlay-actions { grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; }
 .match-result .overlay-actions button { font-size:12px; padding-inline:5px; }
}
@media (orientation:portrait) and (max-height:500px) { .touch-device.match-result #start { grid-column:auto; } }

#displayMode[hidden] { display:none; }
