/* Territory arcade — Racing-style, scoped to .territory-stage */
/* Original 3-column lobby + GTALAB DS tokens
   (Gmarket/Pretendard, --accent #ff4d00, hairline panels, square CTAs).
   Tone: site editorial labels (muted mono) + accent on brand/CTA/selected only.
   Not flattened hub chrome; not racing garage; not unmanaged neon pink.
   Soft-rec Hold (#87) SEED tokens are intentionally not used here. */

/* Fonts come from the site CSS: Gmarket Sans (globals.css @import) and Pretendard
   (app/fonts-pretendard.css, self-hosted dynamic subset). A second @import here only
   chained one more render-blocking request; the standalone index.html links both. */

.territory-stage {
  --canvas: #000;
  --surface: #0d0d0d;
  --surface-card: #141414;
  --white: #fff;
  --body: #ccc;
  --muted: #999;
  --muted-soft: #666;
  --hairline: #262626;
  --hairline-strong: #3a3a3a;
  --accent: #ff4d00;
  --ink: #070707;
  /* Legacy alias kept so older JS/tests that reference --pink still resolve to site orange */
  --pink: var(--accent);
  --cyan: var(--white);
  --display: "Gmarket Sans", "Noto Sans KR", "Noto Sans JP", sans-serif;
  --heading: "Gmarket Sans", "Noto Sans KR", "Noto Sans JP", sans-serif;
  --body-font: "Pretendard Variable", Pretendard, "Noto Sans KR", "Noto Sans JP", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --condensed: var(--heading);
  font-family: var(--body-font);
  color: var(--white);
  background: var(--canvas);
  font-synthesis: none;
  font-weight: 400;
}

.territory-stage,
.territory-stage *,
.territory-stage *::before,
.territory-stage *::after {
  box-sizing: border-box;
}

.territory-stage {
  min-height: 0;
  background: var(--canvas);
  color: var(--white);
}

.territory-stage button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.territory-stage button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.territory-stage button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.territory-stage button:active:not(:disabled) {
  transform: none;
}

/* ── Shell ─────────────────────────────────────────────── */

.arcade {
  min-height: 100svh;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 4.4% 40px;
  background: var(--canvas);
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--hairline-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--white);
}

.brand > svg {
  color: var(--accent);
}

.brand strong {
  font: 600 15px/1 var(--heading);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.brand strong span {
  font-weight: 400;
  color: var(--muted);
}

.brand-divider {
  height: 14px;
  width: 1px;
  background: var(--hairline-strong);
  margin: 0 6px;
}

.arcade-label {
  font: 700 10px/1 var(--mono);
  letter-spacing: 1.8px;
  color: var(--muted);
  text-transform: uppercase;
}

.edition {
  font: 400 10px/1 var(--mono);
  letter-spacing: 1.2px;
  color: var(--muted-soft);
  text-transform: uppercase;
}

.edition span {
  color: var(--accent);
  margin: 0 6px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.how-button {
  font: 600 16px/1 var(--mono);
  letter-spacing: 0;
  text-transform: none;
  margin-right: 0;
}

.how-button:hover {
  color: var(--white);
}

.icon-button {
  background: transparent;
  border: 1px solid var(--hairline-strong);
  width: 36px;
  height: 36px;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--body);
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--white);
  background: rgba(255, 77, 0, 0.08);
}

.icon-button svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.icon-button.sound-button .icon-off {
  display: none;
}

.icon-button.sound-button[aria-pressed="false"] .icon-on {
  display: none;
}

.icon-button.sound-button[aria-pressed="false"] .icon-off {
  display: block;
}

/* ── Lobby layout: original 3-column composition + DS visual language ── */

.game-layout {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 400px) minmax(220px, 1fr);
  gap: clamp(20px, 3.5vw, 64px);
  max-width: 1220px;
  margin: 28px auto 28px;
  align-items: start;
}

/* Left column: brand + stage sidebar + how-to */
.intro-panel {
  grid-column: auto;
  display: block;
  padding-top: 18px;
  border-bottom: 0;
  margin-bottom: 0;
}

/* Labels follow site `.label` — muted mono. Accent only on eyebrow /
   interactive selected/active, primary CTA, and overlay kickers. */
.eyebrow,
.section-label,
.mini-label {
  font: 500 11px/1.2 var(--mono);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  margin: 0 0 8px;
}

.status-dot {
  display: inline-block;
  height: 6px;
  width: 6px;
  border-radius: 0;
  background: var(--accent);
  flex-shrink: 0;
}

.intro-panel h1 {
  font-family: var(--display);
  font-size: clamp(52px, 6.2vw, 88px);
  line-height: 0.86;
  letter-spacing: -0.02em;
  font-weight: 400;
  margin: 22px 0 18px;
  text-transform: uppercase;
  color: var(--white);
}

.intro-panel h1 > span {
  color: var(--accent);
}

.intro-panel h1 .title-period {
  color: var(--white);
}

.intro-panel h1 br {
  display: block;
}

.tagline {
  font-size: 13px;
  line-height: 1.85;
  color: var(--muted);
  margin: 0 0 32px;
  max-width: 36ch;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}

.section-label > span {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted-soft);
}

.run-path {
  border-top: 1px solid var(--hairline);
  padding-top: 18px;
  max-width: 270px;
}

.run-path > .section-label {
  margin-bottom: 16px;
}

.stage-step {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  opacity: 0.45;
  position: relative;
}

.stage-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 32px;
  left: 14px;
  width: 1px;
  height: 16px;
  background: var(--hairline);
}

.stage-step.active,
.stage-step.done {
  opacity: 1;
}

.step-number {
  border: 1px solid var(--hairline-strong);
  color: var(--muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 12px/1 var(--mono);
  background: transparent;
  flex-shrink: 0;
}

.active .step-number {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 77, 0, 0.1);
}

.done .step-number {
  border-color: var(--white);
  color: var(--white);
}

.stage-step strong {
  display: block;
  font: 600 13px/1.2 var(--heading);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--white);
}

.stage-step span:not(.step-current) {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-top: 2px;
  text-transform: none;
  letter-spacing: 0;
}

.step-current {
  height: 6px;
  width: 6px;
  border-radius: 0;
  background: var(--accent);
  margin-left: auto;
}

/* How-to lives on the parent page for GamesShell embeds; keep compact on standalone */
.quick-guide {
  border-top: 1px solid var(--hairline);
  margin-top: 0;
  padding-top: 16px;
  max-width: none;
  grid-column: 1 / -1;
}

.quick-guide > .section-label {
  margin-bottom: 14px;
}

.guide-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.guide-row p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--body);
}

.guide-row strong,
.guide-row p span {
  display: block;
}

.guide-row strong {
  font-weight: 600;
  color: var(--white);
  margin-bottom: 2px;
}

.guide-row p span {
  color: var(--muted);
  font-size: 12px;
}

kbd {
  font-family: var(--mono);
  border: 1px solid var(--hairline-strong);
  border-bottom-width: 1px;
  background: var(--surface);
  border-radius: 0;
  padding: 3px 7px;
  font-size: 10px;
  color: var(--body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
}

.key-cluster {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 2px;
  width: 74px;
}

.key-cluster span {
  display: flex;
  gap: 2px;
}

.key-cluster kbd {
  padding: 0;
  width: 22px;
  height: 20px;
}

.space-key {
  width: 74px;
  height: 26px;
  letter-spacing: 1px;
  font-size: 9px;
}

.danger-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 12px;
}

.danger-note svg {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.art-note {
  display: none;
}

.tiny-rule {
  display: none;
}

/* ── Board / canvas ────────────────────────────────────── */

.play-column {
  width: 100%;
  max-width: none;
  margin: 0;
  min-width: 0;
}

.board-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  min-height: 44px;
  padding: 0 0 12px;
  gap: 12px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 12px;
}

.board-top > div:first-child {
  flex: 0 0 auto;
}

.board-top [data-bind="scene-title"] {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font: 600 13px/1.2 var(--heading);
  color: var(--body);
}

.board-top > div:last-child {
  flex: 0 0 auto;
  text-align: right;
}

.board-top > div:first-child,
.clock {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.board-top strong {
  font: 600 22px/1 var(--heading);
  letter-spacing: 0.02em;
  color: var(--white);
}

.board-top small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.mini-label {
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--muted);
}

.clock {
  text-align: right;
}

.clock strong {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
}

.clock.urgent strong {
  color: var(--accent);
}

.board-stage-name {
  font: 600 12px/1.2 var(--mono);
  letter-spacing: 1.2px;
  color: var(--body);
  text-align: center;
  text-transform: uppercase;
}

.canvas-frame {
  position: relative;
  border: 1px solid var(--hairline-strong);
  box-shadow: none;
  border-radius: 0;
  overflow: hidden;
  background: #0a0a0a;
  aspect-ratio: 64 / 104;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  transition: border-color 0.2s;
  display: grid;
  place-items: center;
}

.canvas-frame.is-drawing {
  border-color: var(--accent);
  box-shadow: none;
}

.territory-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
  image-rendering: auto;
}

.preview-stamp {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  gap: 8px;
  align-items: center;
  font: 700 10px/1 var(--mono);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--body);
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid var(--hairline-strong);
  padding: 8px 10px;
  border-radius: 0;
  white-space: nowrap;
}

.preview-stamp .status-dot {
  width: 6px;
  height: 6px;
}

/* Qix-style win metric — lives in the above-board play HUD, not on the map. */
.claim-hud {
  position: static;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  max-width: none;
  pointer-events: none;
}
.claim-hud-kicker {
  display: block;
  font: 500 10px/1 var(--mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
  text-shadow: 0 1px 8px #000;
}
.claim-hud-score strong {
  display: block;
  font: 600 clamp(22px, 4vw, 34px)/1 var(--heading);
  letter-spacing: -0.02em;
  color: var(--white);
  text-shadow: 0 1px 10px #000, 0 0 18px rgba(0, 0, 0, 0.6);
}
.claim-hud-target {
  font-size: 0.58em;
  font-weight: 500;
  color: color-mix(in srgb, var(--white) 72%, var(--muted));
  letter-spacing: 0.02em;
}
.claim-hud-meter {
  width: min(148px, 42vw);
  height: 3px;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.claim-hud-meter > i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease-out;
}
.claim-hud.is-flash strong {
  color: var(--accent);
  animation: claim-pop 0.55s ease-out;
}
.claim-hud.is-flash .claim-hud-meter > i {
  box-shadow: 0 0 10px rgba(255, 77, 0, 0.85);
}
.canvas-frame.is-claim-flash {
  box-shadow:
    inset 0 0 0 3px var(--accent),
    0 0 28px rgba(255, 77, 0, 0.42);
}
.canvas-frame.is-claim-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 48px rgba(255, 77, 0, 0.28);
  animation: claim-edge 0.9s ease-out;
}
@keyframes claim-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes claim-edge {
  0% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}
.play-coach {
  position: static;
  margin: 0;
  text-align: left;
  font: 500 12px/1.45 var(--body-font);
  color: var(--white);
  background: transparent;
  border: 0;
  padding: 0;
  pointer-events: none;
  word-break: keep-all;
  width: auto;
  max-width: none;
}
.overlay-stat {
  font: 600 13px/1.2 var(--mono) !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent) !important;
  margin: 0 0 8px !important;
  max-width: none !important;
}
.claim-hud-lives {
  display: flex;
  gap: 5px;
  padding-top: 4px;
}
.claim-hud-lives i {
  display: block;
  width: 8px;
  height: 8px;
  background: var(--hairline-strong);
}
.claim-hud-lives i.alive {
  background: var(--accent);
}
.claim-hud-lives i.lost {
  background: transparent;
  outline: 1px solid var(--hairline-strong);
  outline-offset: -1px;
}

.play-hud {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "row actions"
    "msg actions";
  column-gap: 8px;
  row-gap: 6px;
  padding: 4px 8px 8px;
  pointer-events: none;
  z-index: 2;
}
.play-hud-row {
  grid-area: row;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.play-hud-stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  flex: 0 1 132px;
}
.play-hud-stage .mini-label {
  color: color-mix(in srgb, var(--white) 70%, var(--muted));
}
.play-hud-stage strong {
  font: 600 16px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--white);
}
.play-hud-stage [data-bind="hud-scene"] {
  font: 600 11px/1.2 var(--body-font);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18ch;
}
.play-hud-actions {
  /* Pause square sits above the ? at top-right of the play HUD. */
  grid-area: actions;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-left: 0;
  pointer-events: auto;
  flex: 0 0 auto;
  align-self: start;
}
.play-hud-msg {
  /* Reserved play-hud-msg line — LAND SECURED / ENEMY CAUGHT never shift the board. */
  grid-area: msg;
  position: relative;
  height: 1.4em;
  min-height: 1.4em;
  max-height: 1.4em;
  overflow: hidden;
  flex: 0 0 1.4em;
}
.play-hud-msg .play-coach,
.play-hud-msg .game-toast,
.play-hud-msg .play-keys {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.field-vitals {
  position: static;
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  pointer-events: none;
}
.fuse-timer {
  flex: 1 1 160px;
  min-width: 132px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.fuse-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.fuse-head .mini-label {
  color: color-mix(in srgb, var(--white) 70%, var(--muted));
}
.fuse-timer strong {
  font: 600 18px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--white);
}
.fuse-timer.is-warn strong {
  color: #ffd166;
}
.fuse-timer.is-critical strong {
  color: var(--accent);
}
.fuse-track {
  position: relative;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  overflow: visible;
}
.fuse-track > i {
  position: relative;
  display: block;
  height: 100%;
  width: 100%;
  max-width: 100%;
  background: linear-gradient(90deg, #5a1c00, var(--accent) 70%, #ffd166);
  box-shadow: 0 0 8px rgba(255, 77, 0, 0.55);
  transform-origin: left center;
  pointer-events: none;
}
.fuse-track > i::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -3px;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: #ffe7a3;
  box-shadow: 0 0 8px 3px rgba(255, 77, 0, 0.85);
}
.fuse-timer.is-warn .fuse-track > i {
  background: linear-gradient(90deg, #7a2a00, #ffd166);
}
.fuse-timer.is-critical .fuse-track > i {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(255, 77, 0, 0.9);
}
.fuse-timer.is-critical .fuse-track > i::after {
  background: #fff;
}
.field-lives-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
}
.field-caught-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 3.2em;
}
.field-caught-block .mini-label {
  color: color-mix(in srgb, var(--white) 70%, var(--muted));
}
.field-caught-block strong {
  font: 600 16px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--white);
  min-width: 2ch;
  text-align: right;
}
.field-lives-block .mini-label {
  color: color-mix(in srgb, var(--white) 70%, var(--muted));
}
.field-lives {
  display: flex;
  gap: 5px;
}
.field-lives i {
  display: block;
  width: 12px;
  height: 12px;
  background: var(--hairline-strong);
}
.field-lives i.alive {
  background: var(--accent);
}
.field-lives i.lost {
  background: transparent;
  outline: 1px solid var(--hairline-strong);
  outline-offset: -1px;
}
.field-lives-block.is-last-life .mini-label {
  color: var(--accent);
}
.field-lives-block.is-last-life .field-lives i.alive {
  box-shadow: 0 0 8px rgba(255, 77, 0, 0.85);
}
@keyframes territory-last-life {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.field-lives-block.is-last-life .field-lives i.alive {
  animation: territory-last-life 0.9s ease-in-out infinite;
}
.fuse-timer.is-critical strong {
  animation: territory-last-life 0.8s ease-in-out infinite;
}

.ad-slot:empty,
.ad-slot[hidden] {
  display: none !important;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  pointer-events: none;
}
.ad-slot:not(:empty):not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-area: auto;
  background: transparent;
  color: var(--muted);
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: auto;
}
.ad-slot--left { grid-area: ad-left; min-width: 160px; min-height: 600px; }
.ad-slot--right { grid-area: ad-right; min-width: 300px; min-height: 250px; }
.ad-slot--below { grid-area: ad-below; min-height: 90px; width: 100%; max-width: 728px; margin: 8px auto 0; }
.ad-slot--mobile { grid-area: ad-mobile; min-height: 50px; width: 100%; max-width: 320px; margin: 8px auto 0; }

/* No ads on the board: leaderboard + phone banner stay lobby-only even if filled later. */
.territory-stage:has(.mode-playing) .ad-slot--below,
.territory-stage:has(.mode-paused) .ad-slot--below,
.territory-stage:has(.mode-cleared) .ad-slot--below,
.territory-stage:has(.mode-finished) .ad-slot--below,
.territory-stage:has(.mode-gameover) .ad-slot--below,
.territory-stage:has(.mode-playing) .ad-slot--mobile,
.territory-stage:has(.mode-paused) .ad-slot--mobile,
.territory-stage:has(.mode-cleared) .ad-slot--mobile,
.territory-stage:has(.mode-finished) .ad-slot--mobile,
.territory-stage:has(.mode-gameover) .ad-slot--mobile {
  display: none !important;
  width: 0;
  height: 0;
  margin: 0;
  min-height: 0;
  min-width: 0;
}

.board-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font: 400 10px/1.3 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 28px;
}

.board-bottom > span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
}

.board-bottom .status-dot {
  width: 6px;
  height: 6px;
}

.board-bottom .drawing-status {
  color: var(--accent);
}

/* ── Difficulty / controls (heat cards — original stack + DS hairlines) ── */

.control-panel {
  padding: 0;
  max-width: none;
  width: 100%;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.018);
  padding: 18px;
}

.control-panel > .section-label {
  margin-bottom: 14px;
}

.difficulty-list {
  display: grid;
  gap: 8px;
}

.difficulty-card {
  text-align: left;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 0;
  padding: 14px 14px 12px;
  width: 100%;
  position: relative;
  color: var(--body);
}

.difficulty-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--hairline-strong);
}

.difficulty-card.selected {
  border-color: var(--accent);
  background: rgba(255, 77, 0, 0.1);
  box-shadow: inset 3px 0 var(--accent);
}

.difficulty-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.difficulty-top strong {
  font: 600 18px/1 var(--heading);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--white);
}

.difficulty-card.selected strong {
  color: var(--accent);
}

.difficulty-card > span {
  font-size: 12px;
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.heat-bars {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 14px;
}

.heat-bars i {
  display: block;
  width: 4px;
  background: var(--hairline-strong);
  height: 6px;
  transform: none;
  border-radius: 0;
}

.heat-bars i:nth-child(2) {
  height: 10px;
}

.heat-bars i:nth-child(3) {
  height: 14px;
}

.heat-bars .lit {
  background: var(--muted);
}

.selected .heat-bars .lit {
  background: var(--accent);
}

.difficulty-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--hairline);
  margin-top: 12px;
  padding-top: 10px;
  font: 400 10px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  height: auto;
  min-height: 20px;
}

.selected .difficulty-meta {
  border-color: rgba(255, 77, 0, 0.28);
}

.difficulty-meta svg {
  color: var(--accent);
  margin-left: auto;
}

.heat-rating {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font: 400 10px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.heat-rating strong {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--white);
}

.heat-rating > span:last-child {
  margin-left: auto;
  letter-spacing: 0;
  font-size: 11px;
  text-transform: none;
}

.selected .heat-rating strong {
  color: var(--accent);
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: var(--ink);
  border: 1px solid var(--accent);
  padding: 0 16px;
  border-radius: 0;
  font: 700 11px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.primary-button:hover {
  background: transparent;
  color: var(--accent);
}

.start-button {
  margin-top: 16px;
}

.start-note {
  font-size: 12px;
  text-align: center;
  color: var(--muted);
  margin: 12px 0 0;
  line-height: 1.5;
}

.mission-note {
  border-top: 1px solid var(--hairline);
  margin-top: 20px;
  padding-top: 16px;
}

.mission-note p {
  font: 600 13px/1.3 var(--heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 10px 0 8px;
  color: var(--white);
}

.mission-note > span {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  display: block;
  word-break: keep-all;
}

/* ── In-run chrome ─────────────────────────────────────── */

.score-value {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  order: 8;
}

.score-caption {
  font: 400 10px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}

.level-chip {
  color: var(--accent) !important;
  border: 1px solid rgba(255, 77, 0, 0.4);
  padding: 4px 8px;
  letter-spacing: 1px !important;
  font: 700 10px/1 var(--mono) !important;
  text-transform: uppercase;
  border-radius: 0;
}

.capture-stat {
  padding: 18px 0;
  margin-top: 16px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.capture-stat svg {
  color: var(--accent);
}

.percent-value {
  font-family: var(--heading);
  font-size: 22px;
  color: var(--white);
  font-weight: 500;
  line-height: 1.15;
  margin: 8px 0 12px;
}

.percent-value span {
  font-size: 22px;
  margin-left: 4px;
  color: var(--muted);
}

.progress-track {
  height: 4px;
  background: var(--hairline);
  overflow: hidden;
  border-radius: 0;
}

.progress-track > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font: 400 10px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
}

.progress-meta strong {
  color: var(--body);
  font-weight: 600;
}

.lives-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}

.lives-block > div {
  display: flex;
  gap: 6px;
}

.lives-block i {
  display: block;
  width: 10px;
  height: 10px;
  background: var(--hairline-strong);
}

.alive {
  color: var(--accent);
}

.lives-block i.alive {
  background: var(--accent);
}

.lost {
  opacity: 0.35;
}

.lives-block i.lost {
  background: transparent;
  border: 1px solid var(--hairline-strong);
  opacity: 1;
}

.run-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-top: 1px solid var(--hairline);
  padding: 16px 0;
  font-size: 12px;
}

.run-details > span {
  color: var(--muted);
  font: 400 10px/1.4 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.run-details strong {
  font-weight: 500;
  text-align: right;
  color: var(--body);
}

.secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 0 14px;
  min-height: 40px;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  border-radius: 0;
  font: 700 11px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--white);
}

.secondary-button:hover {
  border-color: var(--accent);
  background: rgba(255, 77, 0, 0.08);
}

.pause-button kbd {
  margin-left: auto;
  font-size: 8px;
}

.pause-button {
  justify-content: start;
}

.text-button {
  font: 400 11px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 0;
  background: none;
  color: var(--muted);
  padding: 12px 4px;
}

.text-button:hover {
  color: var(--accent);
}

.menu-button {
  width: 100%;
  margin-top: 4px;
  font-size: 10px;
}

/* ── Overlays ────────────────────────────────────────────
   Author `display:flex` beats UA `[hidden]{display:none}`. React used to
   unmount these nodes; vanilla keeps them in the DOM, so hidden must win. */

.territory-stage [hidden] {
  display: none !important;
}

.board-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(0, 0, 0, 0.88);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
}

.canvas-frame:has(.board-overlay:not([hidden])) .claim-hud,
.canvas-frame:has(.clear-banner:not([hidden])) .claim-hud {
  opacity: 0;
}

/* Pause: keep board faintly visible for planning (P2). */
.mode-paused .board-overlay {
  background: rgba(0, 0, 0, 0.42);
}

.overlay-kicker {
  font: 700 10px/1 var(--mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
}

.board-overlay h2,
.clear-banner h2 {
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  margin: 12px 0;
  color: var(--white);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

.board-overlay p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
  margin: 0 0 20px;
  word-break: keep-all;
  max-width: 28ch;
}

.board-overlay .primary-button {
  max-width: 260px;
  margin-top: 4px;
}

.mode-gameover .board-overlay h2 {
  color: var(--accent);
}

.clear-banner,
.clear-banner.end-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(7, 7, 7, 0.72);
  border: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-radius: 0;
}

.end-card {
  width: min(100%, 420px);
  max-height: 100%;
  overflow: auto;
  background: rgba(13, 13, 13, 0.96);
  border: 1px solid var(--hairline-strong);
  padding: 20px 18px 16px;
  text-align: center;
}

.end-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
}

.play-keys {
  margin: 0 0 4px;
  font: 600 11px/1.4 var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
}

.play-keys kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--hairline-strong);
  background: rgba(255, 255, 255, 0.06);
  font: 600 10px/1.4 var(--mono);
  color: var(--white);
}

.difficulty-meta-line {
  margin: 8px 0 12px;
  font: 600 11px/1.45 var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
}

.territory-stage .mode-menu .seg.difficulty {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--hairline-strong);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 10px 6px 8px;
  width: auto;
  border: 0;
  border-right: 1px solid var(--hairline);
  background: transparent;
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--difficulty-color, var(--accent)) 45%, transparent);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card:last-child {
  border-right: 0;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card strong {
  font: 700 13px/1 var(--heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card small {
  font: 600 10px/1 var(--mono);
  color: var(--muted);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card.on,
.territory-stage .mode-menu .seg.difficulty .difficulty-card.selected {
  background: color-mix(in srgb, var(--difficulty-color, var(--accent)) 22%, transparent);
  box-shadow: inset 0 -3px 0 var(--difficulty-color, var(--accent));
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card.on small,
.territory-stage .mode-menu .seg.difficulty .difficulty-card.selected small {
  color: var(--white);
}

.clear-banner h2 {
  font-size: 28px;
  margin: 6px 0;
}

.clear-banner p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.55;
}

.finish-banner {
  inset: 12px;
  top: 12px;
  text-align: center;
  border-color: var(--accent);
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 24px);
  overflow: auto;
}

.finish-banner > svg {
  color: var(--accent);
  display: block;
  margin: 0 auto 12px;
}

.finish-banner h2 {
  font-size: 32px;
}

.finish-banner .primary-button {
  margin-top: 12px;
}

.finish-banner .text-button {
  padding-bottom: 0;
}

.souvenir-still {
  position: relative;
  width: min(100%, 320px);
  aspect-ratio: 16 / 9;
  margin: 0 0 12px;
  overflow: hidden;
  border: 1px solid var(--accent);
  background: var(--surface);
}
.souvenir-still img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.souvenir-still span {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.82);
  color: var(--accent);
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.06em;
}
.board-portrait .souvenir-still {
  aspect-ratio: 64 / 104;
  width: min(52%, 168px);
}
.finish-banner .collected-scenes {
  margin: 0 0 14px;
  max-height: 46%;
  min-height: 0;
}
.board-landscape .collected-scenes > div {
  aspect-ratio: 16 / 9;
}
.collected-scenes {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.collected-scenes > div {
  position: relative;
  width: 33.33%;
  aspect-ratio: 9 / 13;
  background: var(--surface);
  overflow: hidden;
  border: 1px solid var(--hairline);
}

.collected-scenes img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.collected-scenes span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  justify-content: space-between;
  padding: 5px;
  color: var(--accent);
  font: 400 9px/1 var(--mono);
}
.collected-scenes span em {
  font-style: normal;
  color: var(--white);
}

.game-toast {
  position: static;
  margin: 0;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--body);
  pointer-events: none;
  width: auto;
  max-width: none;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 28px;
  font-size: 13px;
  color: var(--muted);
}

.help-overlay {
  padding: 24px;
  text-align: left;
  align-items: stretch;
  overflow-y: auto;
  justify-content: safe center;
  z-index: 9;
}

.help-overlay[hidden] {
  display: none !important;
}

.help-overlay > * {
  flex-shrink: 0;
}

.help-overlay h2 {
  font-size: 32px;
}

.close-help {
  position: absolute;
  right: 12px;
  top: 12px;
}

.help-overlay ol {
  list-style: none;
  counter-reset: help;
  padding: 0;
  margin: 12px 0 10px;
}

.help-overlay li {
  counter-increment: help;
  position: relative;
  padding-left: 28px;
  margin-bottom: 16px;
}

.help-overlay li::before {
  content: counter(help, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  color: var(--accent);
  font: 700 11px/1 var(--mono);
}

.help-overlay li strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--white);
}

.help-overlay li span {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  display: block;
  word-break: keep-all;
}

.help-overlay .help-touch {
  font-size: 11px;
  margin: 4px 0 12px;
  color: var(--muted);
}

.help-overlay .primary-button {
  max-width: none;
}

.image-view-toggle {
  position: absolute;
  right: 12px;
  top: 12px;
  border: 1px solid var(--hairline-strong);
  background: rgba(0, 0, 0, 0.78);
  border-radius: 0;
  padding: 8px 10px;
  font: 700 10px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--body);
}

.loading-overlay {
  z-index: 4;
}

/* ── Hazard panel ──────────────────────────────────────── */

.hazard-panel {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.hazard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--hairline);
  background: transparent;
  padding: 10px 12px;
  color: var(--muted);
  border-radius: 0;
  min-width: 0;
}

.hazard-row > svg {
  flex-shrink: 0;
  color: var(--accent);
}

.hazard-row strong {
  display: block;
  font: 600 11px/1.2 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: var(--white);
}

.hazard-row span:not(.laser-symbol) {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  word-break: keep-all;
}

.hazard-row.warning {
  border-color: rgba(255, 77, 0, 0.45);
  color: var(--accent);
  background: rgba(255, 77, 0, 0.08);
}

.hazard-row.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 77, 0, 0.14);
}

.hazard-row.warning span:not(.laser-symbol),
.hazard-row.active span:not(.laser-symbol) {
  color: var(--body);
}

.laser-symbol {
  display: block;
  width: 16px;
  height: 12px;
  flex-shrink: 0;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
  position: relative;
}

.laser-symbol::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
}

.clear-banner .next-hazard {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  line-height: 1.55;
  color: var(--body);
  word-break: keep-all;
}

.next-hazard > svg {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.next-hazard strong {
  display: block;
  font: 600 11px/1.2 var(--mono);
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

/* ── Touch controls ────────────────────────────────────── */

.touch-controls {
  display: none;
}

/* DRAW/d-pad is mobile/portrait (≤900) only. Desktop 16:9 is keyboard.
   Pause is not in this row — it sits above the play HUD `?`. */
.touch-controls.active {
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 16px;
}

@media (max-width: 900.98px) {
  .touch-controls.active {
    display: flex;
  }
}

@media (min-width: 901px) {
  .touch-controls,
  .touch-controls.active,
  .mode-playing .touch-controls.active,
  .mode-paused .touch-controls.active,
  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    display: none !important;
  }
}

.touch-lobby-guide {
  display: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 40px);
  gap: 4px;
}

.dpad button {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  border-radius: 0;
  font-size: 18px;
  color: var(--white);
}

.dpad button:active {
  background: rgba(255, 77, 0, 0.16);
  border-color: var(--accent);
}

.pad-up {
  grid-column: 2;
}
.pad-up::before { content: "▲"; font-size: 12px; }
.pad-left::before { content: "◀"; font-size: 12px; }
.pad-down::before { content: "▼"; font-size: 12px; }
.pad-right::before { content: "▶"; font-size: 12px; }

.pad-left {
  grid-row: 2;
  grid-column: 1;
}

.pad-down {
  grid-row: 2;
  grid-column: 2;
}

.pad-right {
  grid-row: 2;
  grid-column: 3;
}

.draw-toggle {
  touch-action: manipulation;
  width: 110px;
  height: 84px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 0;
  color: var(--body);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  align-content: center;
  font: 700 12px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.draw-toggle strong {
  width: 100%;
  font: 700 13px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.draw-toggle span {
  width: 100%;
  font-family: var(--body-font);
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.draw-toggle.selected {
  background: rgba(255, 77, 0, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.is-learning .draw-toggle:not(.selected) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* touch-pause lives in the play HUD, never in .touch-controls. */
.touch-controls .touch-pause,
.touch-controls.active .touch-pause {
  display: none !important;
}
.play-hud-actions .touch-pause {
  display: inline-flex;
}

/* ── Footer ────────────────────────────────────────────── */

footer {
  max-width: 1180px;
  margin: auto;
  border-top: 1px solid var(--hairline);
  padding: 18px 0 8px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: var(--muted-soft);
  font: 400 10px/1.4 var(--mono);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

footer > span:first-child {
  font-weight: 600;
  color: var(--muted);
}

footer b {
  font-weight: 400;
  color: var(--muted-soft);
  margin-left: 10px;
  font-size: 10px;
}

footer > span:last-child {
  color: var(--muted-soft);
}

/* ── Playing: restore useful left stage column ─────────── */

.mode-playing .game-layout,
.mode-paused .game-layout,
.mode-cleared .game-layout,
.mode-gameover .game-layout,
.mode-finished .game-layout {
  grid-template-columns: minmax(132px, 168px) minmax(0, 1fr) minmax(148px, 188px);
}

.mode-playing .intro-panel,
.mode-paused .intro-panel,
.mode-cleared .intro-panel,
.mode-gameover .intro-panel,
.mode-finished .intro-panel {
  grid-column: auto;
  display: block;
  padding: 0;
  border-bottom: 0;
  margin: 0;
}

.mode-playing .intro-panel h1,
.mode-paused .intro-panel h1,
.mode-cleared .intro-panel h1,
.mode-gameover .intro-panel h1,
.mode-finished .intro-panel h1,
.mode-playing .tagline,
.mode-paused .tagline,
.mode-cleared .tagline,
.mode-gameover .tagline,
.mode-finished .tagline,
.mode-playing .quick-guide,
.mode-paused .quick-guide,
.mode-cleared .quick-guide,
.mode-gameover .quick-guide,
.mode-finished .quick-guide,
.mode-playing .eyebrow,
.mode-paused .eyebrow,
.mode-cleared .eyebrow,
.mode-gameover .eyebrow,
.mode-finished .eyebrow {
  display: none;
}

.mode-playing .run-path,
.mode-paused .run-path,
.mode-cleared .run-path,
.mode-gameover .run-path,
.mode-finished .run-path {
  padding: 0;
}

.mode-menu .play-column {
  grid-column: 1;
  grid-row: 2;
}

.mode-menu .control-panel {
  grid-column: 2;
  grid-row: 2;
}

.mode-menu .intro-panel {
  grid-row: 1;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 1100px) {
  .arcade {
    padding: 0 16px 40px;
  }

  .edition {
    display: none;
  }

  .intro-panel {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 900.98px) {
  .arcade {
    padding: 0 16px 32px;
  }

  .topbar {
    height: 52px;
  }

  .game-layout {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 10px auto 14px;
  }

  .mode-menu .play-column,
  .mode-menu .control-panel,
  .mode-menu .intro-panel {
    grid-column: auto;
    grid-row: auto;
  }

  /* Lobby: compact brand → heat+Start → board in one viewport (P0-2). */
  .mode-menu .intro-panel {
    order: 0;
    padding-bottom: 0;
    margin: 0;
  }

  .mode-menu .control-panel {
    order: 1;
    padding: 10px;
  }

  .mode-menu .play-column {
    order: 2;
  }

  .mode-menu .intro-panel h1 {
    font-size: clamp(28px, 8vw, 36px);
    margin: 6px 0 4px;
    line-height: 0.95;
  }

  .mode-menu .tagline,
  .mode-menu .run-path,
  .mode-menu .art-note,
  .mode-menu .eyebrow {
    display: none;
  }

  .intro-panel {
    grid-template-columns: 1fr;
    padding-bottom: 8px;
  }

  .quick-guide {
    display: none;
  }

  .touch-lobby-guide {
    display: block;
    margin: 10px 0 0;
    padding: 8px 10px;
    border: 1px solid var(--hairline-strong);
    background: var(--surface);
    color: var(--body);
    font: 500 12px/1.45 var(--body-font);
    text-align: center;
  }

  .mode-menu .start-button {
    margin-top: 10px;
  }

  .mode-menu .start-note {
    margin-top: 6px;
    font-size: 10px;
  }

  .mode-playing .game-layout,
  .mode-paused .game-layout,
  .mode-cleared .game-layout,
  .mode-gameover .game-layout,
  .mode-finished .game-layout {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 8px auto 10px;
  }

  .mode-playing .intro-panel,
  .mode-paused .intro-panel,
  .mode-cleared .intro-panel,
  .mode-gameover .intro-panel,
  .mode-finished .intro-panel {
    display: none;
  }

  .difficulty-list {
    /* minmax(0,1fr): EN "3 LIVES 120 SEC" must not blow past the iframe. */
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    min-width: 0;
  }

  .difficulty-card {
    padding: 10px 8px;
    min-width: 0;
    overflow: hidden;
  }

  .difficulty-top strong {
    font-size: 13px;
  }

  .difficulty-card > span {
    display: none;
  }

  .difficulty-meta {
    margin-top: 6px;
    padding-top: 6px;
    gap: 4px;
    font-size: 8px;
    letter-spacing: 0.4px;
    /* was nowrap — HARD meta clipped / iframe horizontal overflow ≤390. */
    white-space: normal;
    flex-wrap: wrap;
    min-width: 0;
  }

  .difficulty-meta svg {
    display: none;
  }

  .heat-rating {
    margin-top: 6px;
    gap: 4px;
    font-size: 8px;
    min-width: 0;
    flex-wrap: wrap;
  }

  .heat-rating strong {
    font-size: 13px;
  }

  .heat-rating > span:last-child {
    font-size: 9px;
  }

  .mission-note {
    display: none;
  }

  .canvas-frame {
    max-width: min(100%, 300px);
  }

  .mode-menu .canvas-frame {
    max-width: min(100%, 260px);
    max-height: min(36svh, 280px);
  }

  .mode-menu .board-top,
  .mode-menu .board-bottom {
    display: none;
  }

  /* P1-3: compress playing HUD to one slim strip. */
  .mode-playing .control-panel,
  .mode-paused .control-panel,
  .mode-cleared .control-panel,
  .mode-gameover .control-panel,
  .mode-finished .control-panel {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
  }

  .mode-playing .control-panel > .section-label:has(.level-chip),
  .mode-paused .control-panel > .section-label:has(.level-chip),
  .mode-playing .score-caption,
  .mode-paused .score-caption,
  .mode-playing .progress-track,
  .mode-paused .progress-track,
  .mode-playing .progress-meta,
  .mode-paused .progress-meta,
  .mode-playing .capture-stat .section-label,
  .mode-paused .capture-stat .section-label,
  .mode-playing .lives-block .section-label,
  .mode-paused .lives-block .section-label,
  .mode-playing .hazard-panel,
  .mode-paused .hazard-panel,
  .mode-playing .run-details,
  .mode-paused .run-details,
  .mode-playing .pause-button,
  .mode-paused .pause-button,
  .mode-playing .menu-button,
  .mode-paused .menu-button {
    display: none;
  }

  .mode-playing .score-value,
  .mode-paused .score-value,
  .mode-playing .percent-value,
  .mode-paused .percent-value {
    font-size: 18px;
    margin: 0;
    grid-row: unset;
  }

  .mode-playing .percent-value span,
  .mode-paused .percent-value span {
    font-size: 12px;
  }

  .mode-playing .capture-stat,
  .mode-paused .capture-stat,
  .mode-playing .lives-block,
  .mode-paused .lives-block {
    margin: 0;
    padding: 0;
    border: 0;
    grid-column: unset;
    grid-row: unset;
  }

  .mode-playing .lives-block svg,
  .mode-paused .lives-block svg {
    width: 16px;
    height: 16px;
  }

  .control-panel > .section-label:has(.level-chip) {
    margin: 0;
    font-size: 10px;
  }

  .score-value {
    font-size: 26px;
    grid-row: 2;
  }

  .score-caption {
    display: none;
  }

  .capture-stat {
    margin: 0;
    padding: 0;
    border: 0;
    grid-column: 2;
    grid-row: 1 / 3;
  }

  .capture-stat .section-label {
    font-size: 10px;
  }

  .capture-stat .section-label svg {
    display: none;
  }

  .percent-value {
    font-size: 26px;
    display: inline-block;
    margin: 0 0 4px;
  }

  .percent-value span {
    font-size: 14px;
  }

  .progress-track {
    height: 3px;
  }

  .progress-meta {
    font-size: 9px;
    margin-top: 5px;
  }

  .lives-block {
    padding: 4px 0;
    grid-column: 1;
    grid-row: 3;
  }

  .run-details,
  .pause-button,
  .menu-button {
    display: none;
  }

  .hazard-panel {
    grid-column: 1 / -1;
    grid-row: 4;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
    margin: 4px 0 0;
  }

  .hazard-row {
    padding: 8px;
  }

  /* P0-1: board + touch bar must fit inside the iframe viewport. */
  .mode-playing .canvas-frame,
  .mode-paused .canvas-frame,
  .mode-gameover .canvas-frame,
  .mode-cleared .canvas-frame,
  .mode-finished .canvas-frame {
    height: min(42svh, 400px);
    width: auto;
    max-width: 100%;
    margin: 0 auto;
    flex: 0 1 auto;
  }

  .mode-playing .touch-controls.active,
  .mode-paused .touch-controls.active {
    display: flex;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 6;
    margin-top: 6px;
    padding: 6px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--canvas);
    gap: 12px;
  }

  .mode-playing .draw-toggle,
  .mode-paused .draw-toggle {
    width: 96px;
    height: 72px;
  }

  .mode-playing .dpad,
  .mode-paused .dpad {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 36px);
  }

  .touch-controls .touch-pause,
  .touch-controls.active .touch-pause {
    display: none !important;
  }

  footer {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    font-size: 9px;
  }

  footer > span:last-child {
    display: none;
  }
}

@media (max-width: 650px) {
  .arcade {
    padding: 0 12px 28px;
  }

  .topbar {
    height: 48px;
    gap: 8px;
  }

  .brand strong {
    font-size: 13px;
  }

  .arcade-label {
    font-size: 9px;
  }

  .how-button {
    font-size: 10px;
    margin-right: 0;
  }

  .icon-button {
    width: 32px;
    height: 32px;
  }

  .fullscreen {
    display: none;
  }

  .start-button {
    margin-top: 12px;
    min-height: 44px;
  }

  .board-overlay h2 {
    font-size: 32px;
  }

  .board-overlay {
    padding: 18px;
  }

  .clear-banner {
    padding: 14px;
    bottom: 10px;
    left: 10px;
    right: 10px;
  }

  .clear-banner h2 {
    font-size: 24px;
  }

  .help-overlay h2 {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
    animation: none !important;
  }
  /* Keep a non-motion claim cue (accent + edge) when animations are off. */
  .claim-hud.is-flash strong {
    color: var(--accent);
  }
  .canvas-frame.is-claim-flash {
    box-shadow: inset 0 0 0 3px var(--accent);
  }
  .canvas-frame.is-claim-flash::after {
    content: none;
  }
  .is-learning .draw-toggle:not(.selected) {
    box-shadow: none;
  }
}

/* ── GamesShell embed: drop competing brand; keep original 3-col lobby ── */

.territory-stage,
.territory-stage body {
  height: 100%;
  min-height: 0;
  background: var(--canvas);
}

.territory-stage body {
  margin: 0;
  overflow: auto;
}

.territory-stage .arcade {
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0 8px 16px;
}

.territory-stage .topbar {
  height: 48px;
  gap: 12px;
  border-bottom: 1px solid var(--hairline);
  justify-content: flex-end;
}

.territory-stage .topbar .brand,
.territory-stage .topbar .edition {
  display: none;
}

/* Keep Seokjun left-column brand + stages + how-to. Only art-note is trimmed in embed. */
.territory-stage .mode-menu .art-note {
  display: none;
}

.territory-stage .mode-menu .game-layout {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 400px) minmax(220px, 1fr);
  gap: clamp(16px, 2.8vw, 48px);
  max-width: none;
  margin-top: 8px;
  align-items: start;
}

.territory-stage .mode-menu .intro-panel {
  grid-column: auto;
  grid-row: auto;
  display: block;
  padding-top: 8px;
  border-bottom: 0;
  margin: 0;
}

.territory-stage .mode-menu .intro-panel h1 {
  font-size: clamp(40px, 4.8vw, 72px);
  margin: 14px 0 12px;
}

.territory-stage .mode-menu .tagline {
  margin: 0 0 22px;
  font-size: 12px;
}

.territory-stage .mode-menu .run-path {
  max-width: 270px;
  display: block;
  border-top: 1px solid var(--hairline);
  padding-top: 16px;
}

.territory-stage .mode-menu .run-path > .section-label {
  width: auto;
  margin-bottom: 14px;
}

.territory-stage .mode-menu .stage-step {
  display: flex;
  margin: 0 0 18px;
  opacity: 0.45;
}

.territory-stage .mode-menu .stage-step:not(:last-child)::after {
  display: block;
}

.territory-stage .mode-menu .stage-step.active,
.territory-stage .mode-menu .stage-step.done {
  opacity: 1;
}

.territory-stage .mode-menu .stage-step span:not(.step-current) {
  display: block;
}

.territory-stage .mode-menu .play-column,
.territory-stage .mode-menu .control-panel {
  grid-column: auto;
  grid-row: auto;
}

.territory-stage .mode-menu .control-panel {
  background: transparent;
  border: 0;
  padding: 12px 0 0;
  position: sticky;
  top: 0;
  max-width: 280px;
}

.territory-stage .mode-menu .canvas-frame {
  max-width: min(100%, 400px);
  /* R3: slightly shorter board so lobby columns sit closer without clipping */
  max-height: min(48vh, 400px);
  width: 100%;
  margin: 0 auto;
}

/* Lobby objective stack duplicates tagline + quick-guide + start-note. */
.territory-stage .mode-menu .mission-note,
.territory-stage .mode-menu .eyebrow,
.territory-stage .mode-menu .board-bottom,
.territory-stage .mode-menu .quick-guide .danger-note {
  display: none;
}

/* Playing score caption is noise next to the big number. */
.territory-stage .mode-playing .score-caption,
.territory-stage .mode-paused .score-caption {
  display: none;
}

.territory-stage .mode-menu .start-button {
  /* S3: Start closer to heat cards — less dead air under the right rail */
  margin-top: 10px;
}

.territory-stage .mode-menu .control-panel .difficulty-list {
  margin-bottom: 0;
}

.territory-stage footer {
  display: none;
}

/* Playing/paused in embed: fit board without iframe scroll.
   P0 S1: desktop keeps Seokjun 3-col grid; column flex is mobile-only (≤900). */
.territory-stage:has(.mode-playing) body,
.territory-stage:has(.mode-paused) body {
  overflow: hidden;
  height: 100%;
}

.territory-stage:has(.mode-playing) .arcade,
.territory-stage:has(.mode-paused) .arcade {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
  overflow: hidden;
}

/* Desktop embed play: restore 3-col (stage / board / HUD) so CURRENT RUN rail
   stays in the first viewport — never stack into a tall scroll column. */
@media (min-width: 901px) {
  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(128px, 156px) minmax(0, 1fr) minmax(140px, 176px);
    gap: clamp(16px, 2.8vw, 48px);
    overflow: hidden;
    margin-top: 4px;
    margin-bottom: 0;
    align-items: stretch;
  }

  .territory-stage:has(.mode-playing) .intro-panel,
  .territory-stage:has(.mode-paused) .intro-panel,
  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column,
  .territory-stage:has(.mode-playing) .control-panel,
  .territory-stage:has(.mode-paused) .control-panel {
    grid-column: auto;
    grid-row: auto;
    min-height: 0;
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .territory-stage:has(.mode-playing) .control-panel,
  .territory-stage:has(.mode-paused) .control-panel {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100%;
    overflow: auto;
    padding-top: 8px;
    background: transparent;
    border: 0;
  }

  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame {
    flex: 1 1 auto;
    max-width: min(100%, 720px);
    max-height: min(86vh, calc(100% - 48px));
    width: 100%;
    margin: 0 auto;
    height: auto;
    aspect-ratio: 64 / 104;
  }

  /* Playing objective note duplicates stage copy + board HUD — drop in embed. */
  .territory-stage .mode-playing .mission-note,
  .territory-stage .mode-paused .mission-note {
    display: none;
  }

  /* R1: collapse dense desktop playing rail — stage is already on board-top;
     run-details duplicates CURRENT RUN; menu-button doubles pause while playing. */
  .territory-stage .mode-playing .run-details,
  .territory-stage .mode-paused .run-details,
  .territory-stage .mode-playing .menu-button {
    display: none;
  }
}

/* Mobile embed: lobby stack + playing column flex + touch bar. */
@media (max-width: 900.98px) {
  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 4px;
    margin-bottom: 0;
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .territory-stage .arcade {
    padding: 0 4px 8px;
    max-width: 100%;
    overflow-x: clip;
  }

  .territory-stage body {
    overflow-x: hidden;
  }

  .territory-stage .topbar {
    height: 40px;
  }

  .territory-stage .mode-menu .game-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-top: 4px;
    min-width: 0;
    max-width: 100%;
  }

  .territory-stage .mode-menu .intro-panel {
    display: block;
    order: 0;
    padding-top: 0;
  }

  .territory-stage .mode-menu .intro-panel h1 {
    font-size: clamp(26px, 7vw, 34px);
    margin: 4px 0 2px;
  }

  .territory-stage .mode-menu .tagline,
  .territory-stage .mode-menu .run-path {
    display: none;
  }

  .territory-stage .mode-menu .control-panel {
    order: 1;
    position: static;
    max-width: none;
    padding: 4px 0 0;
  }

  .territory-stage .mode-menu .play-column {
    order: 2;
    position: static;
    max-width: none;
  }

  /* Keep Start + claim canvas adjacent — hide verbose objective on mobile embed. */
  .territory-stage .mode-menu .mission-note {
    display: none;
  }

  .territory-stage .mode-menu .canvas-frame {
    max-width: min(100%, 240px);
    max-height: min(32svh, 240px);
    margin: 0 auto;
  }

  .territory-stage .mode-menu .quick-guide {
    display: none;
  }

  .territory-stage .mode-menu .start-button {
    margin-top: 8px;
    min-height: 44px;
  }

  .territory-stage:has(.mode-playing) .mode-playing .canvas-frame,
  .territory-stage:has(.mode-paused) .mode-paused .canvas-frame {
    height: min(40svh, 360px);
  }
}

/* Narrow phones: stack lives/time so 3 heat cards stay inside iframe. */
@media (max-width: 360px) {
  .difficulty-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .difficulty-card {
    padding: 8px 6px;
  }

  .difficulty-top strong {
    font-size: 12px;
  }

  .mode-menu .intro-panel h1 {
    font-size: clamp(22px, 7vw, 28px);
    margin: 2px 0;
  }

  .mode-menu .canvas-frame {
    max-width: min(100%, 200px);
    max-height: min(28svh, 180px);
  }

  .territory-stage .mode-menu .canvas-frame {
    max-width: min(100%, 200px);
    max-height: min(26svh, 170px);
  }

  .touch-lobby-guide {
    margin-top: 6px;
    padding: 6px 8px;
    font-size: 11px;
  }
}

/* ── V2 Instrument Deck (GamesShell embed) ─────────────────
   One horizontal “deck”: stage rail | sealed canvas | run controls.
   Matches GTALAB L3 instrument pattern (home hub #96, games shell) —
   not a nested mini-site hero. Standalone /arcade keeps Seokjun 3-col. */

.territory-stage .mode-menu .game-layout {
  grid-template-columns: minmax(168px, 220px) minmax(260px, 1fr) minmax(200px, 280px);
  grid-template-areas: "stages canvas controls";
  gap: clamp(12px, 2vw, 32px);
  align-items: stretch;
  margin: 0 auto;
  padding: 4px 0 8px;
}

.territory-stage .mode-menu .intro-panel {
  grid-area: stages;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 4px 0 0;
  border-right: 1px solid var(--hairline);
  padding-right: clamp(12px, 2vw, 20px);
}

.territory-stage .mode-menu .play-column {
  grid-area: canvas;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.territory-stage .mode-menu .control-panel {
  grid-area: controls;
  align-self: start;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: fit-content;
  max-width: none;
  border-left: 1px solid var(--hairline);
  padding: 4px 0 0 clamp(12px, 2vw, 20px);
  position: static;
}

.territory-stage .mode-menu .intro-panel h1 {
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1;
  margin: 6px 0 10px;
  letter-spacing: -0.01em;
}

.territory-stage .mode-menu .intro-panel h1 br {
  display: none;
}

.territory-stage .mode-menu .intro-panel h1 > span.title-period {
  margin-left: 2px;
}

.territory-stage .mode-menu .tagline,
.territory-stage .mode-menu .quick-guide {
  display: none;
}

.territory-stage .mode-menu .run-path {
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  border-top: 0;
  padding-top: 0;
  overflow: auto;
}

.territory-stage .mode-menu .canvas-frame {
  max-width: min(100%, 440px);
  max-height: min(52vh, 420px);
  border: 1px solid var(--hairline-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}

.territory-stage .mode-menu .control-panel .section-label {
  margin-bottom: 10px;
}

.territory-stage .mode-menu .difficulty-list {
  gap: 8px;
}

.territory-stage .mode-menu .difficulty-card {
  border: 1px solid var(--hairline);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.territory-stage .mode-menu .difficulty-card.is-selected,
.territory-stage .mode-menu .difficulty-card.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.territory-stage .mode-menu .start-button {
  width: 100%;
  margin-top: 12px;
}

.territory-stage .topbar {
  height: 44px;
  margin-bottom: 4px;
  background: color-mix(in srgb, var(--canvas) 92%, var(--surface));
}

@media (max-width: 900.98px) {
  .territory-stage .mode-menu .game-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
  }

  .territory-stage .mode-menu .intro-panel {
    order: 2;
    border-right: 0;
    padding-right: 0;
    border-bottom: 1px solid var(--hairline);
    padding-bottom: 8px;
  }

  .territory-stage .mode-menu .intro-panel h1,
  .territory-stage .mode-menu .tagline {
    display: none;
  }

  .territory-stage .mode-menu .run-path {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .territory-stage .mode-menu .run-path > .section-label {
    display: none;
  }

  .territory-stage .mode-menu .stage-step {
    flex: 0 0 auto;
    margin: 0;
    min-width: 72px;
    padding: 8px;
    border: 1px solid var(--hairline);
    background: var(--surface);
  }

  .territory-stage .mode-menu .stage-step:not(:last-child)::after {
    display: none;
  }

  .territory-stage .mode-menu .stage-step span:not(.step-current) {
    display: none;
  }

  .territory-stage .mode-menu .control-panel {
    order: 0;
    position: sticky;
    top: 0;
    z-index: 3;
    border-left: 0;
    padding: 8px 0;
    background: var(--canvas);
    border-bottom: 1px solid var(--hairline);
  }

  .territory-stage .mode-menu .play-column {
    order: 1;
  }

  .territory-stage .mode-menu .canvas-frame {
    max-width: min(100%, 280px);
    max-height: min(32svh, 220px);
  }
}

@media (min-width: 901px) {
  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout {
    grid-template-areas: "stages canvas controls";
  }
}

/* ── P0/P1: map-as-product playfield (claim HUD + thinner rails) ── */

.territory-stage .heat-bars {
  opacity: 0.28;
}

.territory-stage .mode-playing .control-panel,
.territory-stage .mode-paused .control-panel {
  display: flex;
  flex-direction: column;
}

.territory-stage .mode-playing .capture-stat,
.territory-stage .mode-paused .capture-stat {
  order: 0;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.territory-stage .mode-playing .percent-value,
.territory-stage .mode-paused .percent-value,
.territory-stage .mode-playing .capture-stat .section-label,
.territory-stage .mode-paused .capture-stat .section-label {
  display: none;
}

.territory-stage .mode-playing .progress-track,
.territory-stage .mode-paused .progress-track {
  height: 6px;
}

.territory-stage .mode-playing .score-value,
.territory-stage .mode-paused .score-value,
.territory-stage .mode-cleared .score-value,
.territory-stage .mode-finished .score-value,
.territory-stage .mode-gameover .score-value {
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.12em;
  color: var(--muted-soft);
  margin-top: auto;
}

.territory-stage .mode-playing .intro-panel .stage-step span:not(.step-current),
.territory-stage .mode-paused .intro-panel .stage-step span:not(.step-current) {
  display: none;
}

.territory-stage .mode-playing .intro-panel .stage-step,
.territory-stage .mode-paused .intro-panel .stage-step {
  margin-bottom: 10px;
}

@media (min-width: 901px) {
  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout {
    grid-template-columns: minmax(128px, 156px) minmax(0, 1fr) minmax(140px, 176px);
    gap: 12px;
  }

  .territory-stage:has(.mode-playing) .intro-panel,
  .territory-stage:has(.mode-paused) .intro-panel {
    border-right: 1px solid var(--hairline);
    padding-right: 10px;
  }

  .territory-stage:has(.mode-playing) .control-panel,
  .territory-stage:has(.mode-paused) .control-panel {
    border-left: 1px solid var(--hairline);
    padding-left: 10px;
    max-width: none;
  }

  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame {
    flex: 1 1 auto;
    max-width: min(100%, 720px);
    max-height: min(86vh, calc(100% - 48px));
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    justify-content: center;
  }
}

@media (max-width: 900.98px) {
  .territory-stage .mode-menu .canvas-frame {
    max-width: min(100%, 340px);
    max-height: min(46svh, 360px);
  }

  .territory-stage .mode-menu .run-path {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    width: 100%;
  }

  .territory-stage .mode-menu .stage-step {
    flex: 1 1 0;
    min-width: 0;
    overflow: visible;
    padding: 8px 8px;
  }

  .territory-stage .mode-menu .stage-step strong {
    white-space: normal;
    overflow: visible;
  }

  .territory-stage .mode-menu .difficulty-card > span {
    display: none;
  }

  .territory-stage .mode-menu .difficulty-card {
    padding: 8px 8px 7px;
  }

  .territory-stage .mode-menu .difficulty-meta {
    margin-top: 6px;
    padding-top: 6px;
  }

  .territory-stage .mode-playing .score-value,
  .territory-stage .mode-paused .score-value {
    display: none;
  }

  .territory-stage .mode-playing .control-panel,
  .territory-stage .mode-paused .control-panel {
    display: none;
  }

  .territory-stage:has(.mode-playing) .mode-playing .canvas-frame,
  .territory-stage:has(.mode-paused) .mode-paused .canvas-frame {
    height: min(58svh, 520px);
    max-width: min(100%, 420px);
    max-height: min(58svh, 520px);
    flex: 1 1 auto;
  }

  .territory-stage .fullscreen {
    display: inline-flex;
  }

  .mode-playing .canvas-frame,
  .mode-paused .canvas-frame,
  .mode-gameover .canvas-frame,
  .mode-cleared .canvas-frame,
  .mode-finished .canvas-frame {
    height: min(52svh, 480px);
    max-width: 100%;
  }
}

/* ── Side chrome: hug-the-board Instrument Deck ───────────
   Keep stages | canvas | controls. Size the deck to the portrait
   board (`auto` center + `width: fit-content`) so rails sit flush
   instead of stretching to iframe edges with a postage board in a
   1fr gutter. Left rail is wide enough for nowrap stage titles.
   Play right is lives + progress fill + pause — not a second % HUD. */

@media (min-width: 901px) {
  .territory-stage .mode-menu .game-layout {
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    justify-content: center;
    grid-template-columns: auto 248px;
    grid-template-areas: "canvas controls";
    gap: 16px;
    align-items: stretch;
  }

  .territory-stage .mode-menu .intro-panel {
    display: none;
  }

  .territory-stage .mode-menu .control-panel {
    width: 248px;
    max-width: 248px;
    padding-left: 14px;
  }

  .territory-stage .mode-menu .canvas-frame {
    height: min(72vh, 560px);
    max-height: min(72vh, 560px);
    width: auto;
    max-width: none;
    aspect-ratio: 64 / 104;
  }

  .territory-stage .mode-menu .stage-step strong {
    white-space: nowrap;
  }

  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout {
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    justify-content: center;
    grid-template-columns: 188px auto 176px;
    gap: 12px;
  }

  .territory-stage:has(.mode-playing) .intro-panel,
  .territory-stage:has(.mode-paused) .intro-panel {
    width: 188px;
    max-width: 188px;
    align-self: start;
  }

  .territory-stage:has(.mode-playing) .control-panel,
  .territory-stage:has(.mode-paused) .control-panel {
    width: 176px;
    max-width: 176px;
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    width: auto;
    align-items: center;
    justify-content: center;
  }

  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame {
    flex: 0 0 auto;
    height: min(86vh, calc(100% - 40px));
    max-height: min(86vh, calc(100% - 40px));
    width: auto;
    max-width: none;
    aspect-ratio: 64 / 104;
  }

  .territory-stage .mode-playing .intro-panel .stage-step strong,
  .territory-stage .mode-paused .intro-panel .stage-step strong {
    white-space: nowrap;
    font-size: 12px;
  }
}

/* Lobby: left rail owns stages; drop duplicate STAGE/TIME chrome above the board. */
.territory-stage .mode-menu .board-top {
  display: none;
}

/* Lobby stage rail: titles only — body copy fights the board. */
.territory-stage .mode-menu .stage-step span:not(.step-current) {
  display: none;
}

.territory-stage .mode-menu .run-path > .section-label span,
.territory-stage .mode-playing .run-path > .section-label span,
.territory-stage .mode-paused .run-path > .section-label span {
  display: none;
}

/* Compact heat cards: threat counts stay, flavor copy drops. */
.territory-stage .mode-menu .difficulty-card > span {
  display: none;
}

@media (min-width: 901px) {
  .territory-stage .mode-menu .difficulty-card.selected > span {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
  }
}

.territory-stage .mode-menu .difficulty-card {
  padding: 10px 12px 8px;
}

.territory-stage .mode-menu .difficulty-top strong {
  font-size: 15px;
}

.territory-stage .mode-menu .heat-rating {
  margin-top: 6px;
}

.territory-stage .mode-menu .difficulty-meta {
  margin-top: 8px;
  padding-top: 8px;
}

/* Play right: on-canvas CLAIMED % owns the metric. Keep fill + lives + pause. */
.territory-stage .mode-playing .score-value,
.territory-stage .mode-paused .score-value,
.territory-stage .mode-playing .progress-meta,
.territory-stage .mode-paused .progress-meta {
  display: none;
}

.territory-stage .mode-playing .lives-block,
.territory-stage .mode-paused .lives-block {
  order: 1;
  padding: 12px 0 8px;
}

.territory-stage .mode-playing .capture-stat,
.territory-stage .mode-paused .capture-stat {
  order: 2;
  margin-top: 0;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--hairline);
}

.territory-stage .mode-playing .pause-button,
.territory-stage .mode-paused .pause-button {
  order: 4;
  margin-top: auto;
}

.territory-stage .mode-playing .hazard-panel,
.territory-stage .mode-paused .hazard-panel {
  order: 3;
}

/* Mobile lobby chips: number squares + current title on one nowrap line. */
@media (max-width: 900.98px) {
  .territory-stage .mode-menu .run-path {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 6px;
    overflow-x: hidden;
    width: 100%;
    padding-bottom: 4px;
  }

  .territory-stage .mode-menu .stage-step {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
    padding: 6px 8px;
  }

  .territory-stage .mode-menu .stage-step:not(.active) strong {
    display: none;
  }

  .territory-stage .mode-menu .stage-step.active {
    flex: 1 1 auto;
    min-width: 0;
  }

  .territory-stage .mode-menu .stage-step.active strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0.04em;
  }

  .territory-stage .mode-menu .stage-step .step-current {
    display: none;
  }
}

/* ── Lobby 2-zone: canvas | heat+Start. YOUR RUN legend is unused. ──
   Play stays board + ~120px flange. Mobile stacked heat → board, no chips. */

@media (min-width: 901px) {
  .territory-stage .mode-menu .game-layout {
    grid-template-columns: auto 248px;
    grid-template-areas: "canvas controls";
    gap: 16px;
  }

  .territory-stage .mode-menu .intro-panel {
    display: none;
  }

  .territory-stage .mode-menu .intro-panel h1 {
    display: none;
  }

  .territory-stage .mode-menu .play-column {
    grid-area: canvas;
  }

  .territory-stage .mode-menu .control-panel {
    grid-area: controls;
    width: 248px;
    max-width: 248px;
    padding-left: 14px;
    z-index: 2;
  }

  .territory-stage .mode-menu .canvas-frame {
    height: min(calc(100svh - 48px), 680px);
    max-height: min(calc(100svh - 48px), 680px);
    width: auto;
    max-width: none;
    aspect-ratio: 64 / 104;
  }

  /* Play: drop left stage column. 2-col board + 120px flange. */
  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout,
  .territory-stage:has(.mode-cleared) .game-layout,
  .territory-stage:has(.mode-gameover) .game-layout,
  .territory-stage:has(.mode-finished) .game-layout {
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    justify-content: center;
    grid-template-columns: auto 120px;
    grid-template-areas: none;
    gap: 12px;
  }

  .territory-stage:has(.mode-playing) .intro-panel,
  .territory-stage:has(.mode-paused) .intro-panel,
  .territory-stage:has(.mode-cleared) .intro-panel,
  .territory-stage:has(.mode-gameover) .intro-panel,
  .territory-stage:has(.mode-finished) .intro-panel {
    display: none;
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    grid-area: auto;
    width: auto;
    align-items: center;
    justify-content: center;
  }

  .territory-stage:has(.mode-playing) .control-panel,
  .territory-stage:has(.mode-paused) .control-panel {
    grid-area: auto;
    width: 120px;
    max-width: 120px;
    padding-left: 8px;
    align-self: start;
  }

  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame {
    flex: 0 0 auto;
    height: min(88vh, calc(100% - 36px));
    max-height: min(88vh, calc(100% - 36px));
    width: auto;
    max-width: none;
    aspect-ratio: 64 / 104;
  }

  .territory-stage .mode-playing .board-top,
  .territory-stage .mode-paused .board-top {
    min-height: 32px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    width: 100%;
  }

  .territory-stage .mode-playing .board-top strong,
  .territory-stage .mode-paused .board-top strong {
    font-size: 18px;
  }

  .territory-stage .mode-playing .control-panel > .section-label,
  .territory-stage .mode-paused .control-panel > .section-label,
  .territory-stage .mode-playing .capture-stat,
  .territory-stage .mode-paused .capture-stat,
  .territory-stage .mode-playing .hazard-panel,
  .territory-stage .mode-paused .hazard-panel {
    display: none;
  }

  .territory-stage .mode-playing .lives-block,
  .territory-stage .mode-paused .lives-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 0 0 12px;
  }

  .territory-stage .mode-playing .pause-button,
  .territory-stage .mode-paused .pause-button {
    margin-top: 0;
    min-height: 36px;
    padding: 0 8px;
    justify-content: center;
  }

  .territory-stage .mode-playing .pause-button kbd,
  .territory-stage .mode-paused .pause-button kbd {
    display: none;
  }
}

@media (max-width: 900.98px) {
  .territory-stage .mode-menu .intro-panel {
    display: none;
  }

  .territory-stage .mode-menu .canvas-frame {
    max-width: min(100%, 360px);
    max-height: min(52svh, 400px);
  }
}

/* ── Restructure: desktop 16:9 field + chrome HUD above the board; mobile 64:104 ──
   R1: desktop abandons tall pillar — square cells on 144×81 (16:9) grid.
   R2: play is field-first; CLAIMED / TIME / LIVES / coach sit in .play-hud above
       the map (never overlay). Lobby is 2-zone board | heat+Start; full how-to is `?`.
   Mobile keeps portrait honesty. */

.territory-stage {
  --territory-lobby-chrome: 120px;
  --territory-play-hud: 110px;
  --territory-play-chrome: calc(var(--territory-play-hud) + 8px);
  --territory-flange: 248px;
}

.territory-stage .arcade {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.territory-stage .game-layout {
  flex: 1 1 auto;
  min-height: 0;
}

/* Single chrome band: utility icons sit on the breadcrumbs row
   (.territory-stage is the positioned ancestor — arcade stays static). */
.territory-stage .mode-menu .topbar {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
  height: 40px;
  width: auto;
  border: 0;
  background: transparent;
  padding: 0 4px;
  justify-content: flex-end;
}

.territory-stage .mode-playing .topbar,
.territory-stage .mode-paused .topbar,
.territory-stage .mode-cleared .topbar,
.territory-stage .mode-gameover .topbar,
.territory-stage .mode-finished .topbar {
  display: none;
}

.territory-stage .field-pause {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.72);
  border-color: var(--hairline-strong);
}

.territory-stage .mode-playing .board-bottom,
.territory-stage .mode-paused .board-bottom,
.territory-stage .mode-cleared .board-bottom,
.territory-stage .mode-gameover .board-bottom,
.territory-stage .mode-finished .board-bottom {
  display: none;
}

.territory-stage .mode-playing .board-top,
.territory-stage .mode-paused .board-top,
.territory-stage .mode-cleared .board-top,
.territory-stage .mode-finished .board-top,
.territory-stage .mode-gameover .board-top {
  display: none;
}

.territory-stage .field-pause svg {
  width: 16px;
  height: 16px;
}

.territory-stage .play-coach {
  font: 600 11px/1.35 var(--body-font);
  padding: 0;
  border: 0;
  background: transparent;
  max-height: 2.7em;
  overflow: hidden;
}

.territory-stage .draw-toggle {
  min-width: 118px;
}

.territory-stage .draw-toggle.selected {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}

.territory-stage .draw-toggle.selected span {
  color: var(--ink);
}

.territory-stage .is-learning .draw-toggle:not(.selected) {
  animation: territory-draw-pulse 1.4s ease-in-out infinite;
}

@keyframes territory-draw-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--accent); }
  50% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 3px rgba(255, 77, 0, 0.28); }
}

.territory-stage .board-overlay {
  padding: 22px 20px;
  gap: 4px;
}

.territory-stage .board-overlay .primary-button,
.territory-stage .board-overlay .text-button {
  min-height: 44px;
}

@media (prefers-reduced-motion: reduce) {
  .territory-stage .is-learning .draw-toggle:not(.selected) {
    animation: none;
  }
}

@media (min-width: 901px) {
  .territory-stage .mode-menu .game-layout {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 8px 12px 12px;
    justify-content: stretch;
    grid-template-columns: auto minmax(0, 1fr) var(--territory-flange) auto;
    grid-template-areas: "ad-left canvas controls ad-right";
    gap: 16px;
    align-items: stretch;
  }

  .territory-stage .mode-menu .play-column {
    width: 100%;
    min-width: 0;
    align-items: stretch;
    justify-content: center;
    grid-area: canvas;
  }

  .territory-stage .mode-menu .control-panel {
    width: var(--territory-flange);
    max-width: var(--territory-flange);
    align-self: center;
    grid-area: controls;
  }

  /* Desktop lobby: 16:9 field fills leftover width × height (square cells). */
  .territory-stage .mode-menu .canvas-frame {
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome)),
      calc((100vw - var(--territory-flange) - 48px) * 9 / 16)
    );
    height: auto;
    width: min(100%, calc(var(--territory-board-h) * 16 / 9));
    max-width: min(100%, calc(var(--territory-board-h) * 16 / 9));
    max-height: var(--territory-board-h);
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
    margin: 0 auto;
  }

  /* Play: full-bleed field, no peer flange (R2). HUD overlays only. */
  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout,
  .territory-stage:has(.mode-cleared) .game-layout,
  .territory-stage:has(.mode-gameover) .game-layout,
  .territory-stage:has(.mode-finished) .game-layout {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: block;
    grid-template-columns: none;
    gap: 0;
  }

  .territory-stage:has(.mode-playing) .control-panel,
  .territory-stage:has(.mode-paused) .control-panel,
  .territory-stage:has(.mode-cleared) .control-panel,
  .territory-stage:has(.mode-gameover) .control-panel,
  .territory-stage:has(.mode-finished) .control-panel {
    display: none;
  }

  .territory-stage:has(.mode-playing) .arcade,
  .territory-stage:has(.mode-paused) .arcade {
    position: relative;
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    position: relative;
  }

  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame,
  .territory-stage:has(.mode-cleared) .canvas-frame,
  .territory-stage:has(.mode-gameover) .canvas-frame,
  .territory-stage:has(.mode-finished) .canvas-frame {
    --territory-board-h: min(
      calc(100dvh - var(--territory-play-chrome)),
      calc(100vw * 9 / 16)
    );
    flex: 0 0 auto;
    height: auto;
    width: min(100%, calc(var(--territory-board-h) * 16 / 9));
    max-width: min(100%, calc(var(--territory-board-h) * 16 / 9));
    max-height: var(--territory-board-h);
    aspect-ratio: 16 / 9;
    margin: 0 auto;
    /* Prefer height from aspect; never let width:100% + max-height stretch. */
    box-sizing: border-box;
  }

  /* Stage / time live in .play-hud above the board — never overlay the map. */
  .territory-stage .mode-playing .board-top,
  .territory-stage .mode-paused .board-top,
  .territory-stage .mode-cleared .board-top,
  .territory-stage .mode-finished .board-top,
  .territory-stage .mode-gameover .board-top {
    display: none;
  }

  .territory-stage .mode-playing .topbar .how-button,
  .territory-stage .mode-paused .topbar .how-button {
    display: none;
  }
}

@media (max-width: 900.98px) {
  .territory-stage .play-hud-stage {
    flex: 0 0 auto;
  }
  .territory-stage .play-hud-stage [data-bind="hud-scene"] {
    display: none;
  }
  .territory-stage .play-hud-row {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
  }
  .territory-stage .field-vitals {
    flex: 1 1 100%;
    order: 3;
    max-width: none;
  }
  .territory-stage .fuse-timer {
    max-width: none;
    min-width: 0;
  }
  .territory-stage .play-hud-actions {
    order: 0;
    align-self: start;
  }

  .territory-stage {
    --territory-lobby-chrome: 132px;
    --territory-play-hud: 130px;
    --territory-play-chrome: calc(var(--territory-play-hud) + 108px);
  }

  .territory-stage .arcade {
    padding: 0 2px 4px;
    width: 100%;
  }

  .territory-stage .mode-menu .topbar {
    position: absolute;
    top: 0;
    right: 0;
  }

  .territory-stage .mode-menu .game-layout {
    gap: 4px;
    padding: 0;
  }

  .territory-stage .mode-menu .control-panel {
    padding: 2px 0 0;
  }

  .territory-stage .mode-menu .control-panel .section-label {
    margin-bottom: 2px;
    font-size: 9px;
  }

  .territory-stage .mode-menu .difficulty-list {
    gap: 4px;
  }

  .territory-stage .mode-menu .difficulty-card {
    padding: 5px 4px 4px;
  }

  .territory-stage .mode-menu .difficulty-top strong {
    font-size: 12px;
  }

  /* P1.2: 2-line heat cards — hide enemy row, keep lives/time meta. */
  .territory-stage .mode-menu .heat-rating {
    display: none;
  }

  .territory-stage .mode-menu .difficulty-meta {
    margin-top: 3px;
    padding-top: 3px;
    font-size: 8px;
    letter-spacing: 0.6px;
    min-height: 0;
  }

  .territory-stage .mode-menu .start-button {
    margin-top: 4px;
    min-height: 44px;
  }

  .territory-stage .mode-menu .touch-lobby-guide {
    display: block;
    margin: 4px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 10px;
    line-height: 1.3;
    color: var(--muted);
    text-align: center;
  }

  .territory-stage .mode-menu .art-note {
    display: none;
  }

  /* Mobile keeps 64:104 honesty. */
  .territory-stage .mode-menu .canvas-frame {
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome)),
      calc((100vw - 12px) * 104 / 64)
    );
    width: min(100%, calc(var(--territory-board-h) * 64 / 104));
    max-width: min(100%, calc(var(--territory-board-h) * 64 / 104));
    max-height: var(--territory-board-h);
    height: auto;
    aspect-ratio: 64 / 104;
    margin: 0 auto;
  }

  .territory-stage:has(.mode-playing) .control-panel,
  .territory-stage:has(.mode-paused) .control-panel {
    display: none;
  }

  .territory-stage:has(.mode-playing) .mode-playing .canvas-frame,
  .territory-stage:has(.mode-paused) .mode-paused .canvas-frame,
  .territory-stage .mode-playing .canvas-frame,
  .territory-stage .mode-paused .canvas-frame,
  .territory-stage .mode-gameover .canvas-frame,
  .territory-stage .mode-cleared .canvas-frame,
  .territory-stage .mode-finished .canvas-frame {
    --territory-board-h: min(
      calc(100dvh - var(--territory-play-chrome)),
      calc((100vw - 8px) * 104 / 64)
    );
    height: auto;
    width: min(100%, calc(var(--territory-board-h) * 64 / 104));
    max-width: min(100%, calc(var(--territory-board-h) * 64 / 104));
    max-height: var(--territory-board-h);
    aspect-ratio: 64 / 104;
    flex: 0 0 auto;
  }

  .territory-stage .mode-playing .field-pause,
  .territory-stage .mode-paused .field-pause {
    display: inline-flex;
  }

  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    gap: 10px;
    padding: 6px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .territory-stage .mode-playing .draw-toggle,
  .territory-stage .mode-paused .draw-toggle {
    width: 100px;
    height: 72px;
  }

  .territory-stage:not(.is-learning) .mode-playing .draw-toggle,
  .territory-stage:not(.is-learning) .mode-paused .draw-toggle {
    width: 92px;
    height: 64px;
  }
}

/* ── Play HUD chips, lobby how-to, reserved ad rails (empty = collapsed) ── */

@media (min-width: 901px) {
  .territory-stage .mode-menu .touch-lobby-guide {
    display: none;
  }
}

.territory-stage .mode-playing .board-top-clock,
.territory-stage .mode-paused .board-top-clock {
  display: none;
}

.territory-stage .mode-playing .field-vitals,
.territory-stage .mode-paused .field-vitals,
.territory-stage .mode-playing .claim-hud,
.territory-stage .mode-paused .claim-hud,
.territory-stage .mode-playing .play-coach,
.territory-stage .mode-paused .play-coach,
.territory-stage .mode-playing .game-toast,
.territory-stage .mode-paused .game-toast {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  max-width: none;
}

@media (max-width: 900.98px) {
  .territory-stage .mode-menu .control-panel {
    position: relative;
    max-width: none;
    overflow: visible;
  }

  .territory-stage .mode-playing .board-top,
  .territory-stage .mode-paused .board-top,
  .territory-stage .mode-cleared .board-top,
  .territory-stage .mode-finished .board-top,
  .territory-stage .mode-gameover .board-top {
    display: none;
  }

  .ad-slot--left:not(:empty):not([hidden]),
  .ad-slot--right:not(:empty):not([hidden]),
  .ad-slot--below:not(:empty):not([hidden]) {
    display: none !important;
  }
}

@media (min-width: 901px) {
  .ad-slot--mobile:not(:empty):not([hidden]) {
    display: none !important;
  }

  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout,
  .territory-stage:has(.mode-cleared) .game-layout,
  .territory-stage:has(.mode-gameover) .game-layout,
  .territory-stage:has(.mode-finished) .game-layout {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "ad-left canvas ad-right";
    align-items: center;
    justify-items: center;
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    grid-area: canvas;
  }
}

@media (prefers-reduced-motion: reduce) {
  .field-clock.is-critical strong,
  .field-clock.is-warn strong,
  .field-lives-block.is-last-life .field-lives i.alive,
  .fuse-timer.is-critical strong {
    animation: none;
  }
}

/* ── Compose: pack board + rail, match HUD to field, drop leftover chrome ──
   Empty ad tracks collapse (no 1fr black gutters). HUD and canvas share width.
   How-to is `?` only; sound/fullscreen chrome is gone. */

.territory-stage .arcade-offline {
  min-height: min(52svh, 360px);
  margin: 24px auto;
  max-width: 520px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 40px 24px;
  text-align: center;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--muted);
}
.territory-stage .arcade-offline h2 {
  margin: 0;
  font: 400 28px/1.1 var(--display);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--white);
}
.territory-stage .arcade-offline p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  max-width: 36ch;
}
.territory-stage .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Racing-like hall of fame on the lobby heat rail */
.territory-hof {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.territory-hof .section-label {
  margin-bottom: 4px;
}
.hof-scope {
  margin: 0 0 8px;
  font: 600 11px/1.2 var(--mono);
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}
.hof-body {
  min-height: 72px;
}
.hof-state {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.hof-retry {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 8px;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--white);
  font: 600 11px/1 var(--mono);
  cursor: pointer;
}
.hof-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: min(28vh, 220px);
  overflow: auto;
}
.hof-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--hairline) 70%, transparent);
  font-size: 12px;
}
.hof-rank {
  font: 600 11px/1 var(--mono);
  color: var(--muted);
}
.hof-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--white);
}
.hof-score {
  font: 600 12px/1 var(--mono);
  color: color-mix(in srgb, var(--white) 82%, var(--muted));
  font-variant-numeric: tabular-nums;
}
.record-submit {
  width: min(100%, 280px);
  margin: 0 auto 12px;
  text-align: left;
}
.hof-submit-label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.hof-submit-label input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--hairline-strong);
  background: #0c1018;
  color: var(--white);
  font: 600 14px/1.2 var(--mono);
}
.hof-submit-score {
  margin: 8px 0;
  font: 600 12px/1 var(--mono);
  color: var(--body);
}
.record-submit .secondary-button {
  width: 100%;
  margin-top: 4px;
}

.territory-stage .arcade {
  padding: 0;
}

.territory-stage .mode-menu .board-bottom,
.territory-stage .mode-menu .board-top {
  display: none;
}

.territory-stage .play-hud .claim-hud-score strong,
.territory-stage .play-hud .claim-hud-kicker {
  text-shadow: none;
}

.territory-stage .mode-playing .play-hud,
.territory-stage .mode-paused .play-hud {
  display: grid;
  width: 100%;
  padding: 4px 12px 8px;
  box-sizing: border-box;
  overflow: visible;
}

@media (min-width: 901px) {
  .territory-stage .mode-menu .game-layout {
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome)),
      calc((100vw - var(--territory-flange) - 40px) * 9 / 16)
    );
    display: grid;
    grid-template-columns: minmax(0, calc(var(--territory-board-h) * 16 / 9)) var(--territory-flange);
    grid-template-areas: "canvas controls";
    justify-content: center;
    align-items: start;
    gap: 20px;
    padding: 8px 16px 12px;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .territory-stage .mode-menu .game-layout:has(.ad-slot--left:not(:empty):not([hidden])),
  .territory-stage .mode-menu .game-layout:has(.ad-slot--right:not(:empty):not([hidden])) {
    grid-template-columns: auto minmax(0, 1fr) var(--territory-flange) auto;
    grid-template-areas: "ad-left canvas controls ad-right";
  }

  .territory-stage .mode-menu .play-column {
    grid-area: canvas;
    width: 100%;
    align-items: stretch;
    justify-content: flex-start;
  }

  .territory-stage .mode-menu .control-panel {
    grid-area: controls;
    align-self: start;
    position: static;
    width: var(--territory-flange);
    max-width: var(--territory-flange);
    padding: 0;
    margin: 0;
  }

  .territory-stage .mode-menu .canvas-frame {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: var(--territory-board-h);
    aspect-ratio: 16 / 9;
    margin: 0;
  }

  .territory-stage:has(.mode-playing),
  .territory-stage:has(.mode-paused),
  .territory-stage:has(.mode-cleared),
  .territory-stage:has(.mode-gameover),
  .territory-stage:has(.mode-finished) {
    --territory-board-h: min(
      calc(100dvh - var(--territory-play-chrome)),
      calc(100vw * 9 / 16)
    );
  }

  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout,
  .territory-stage:has(.mode-cleared) .game-layout,
  .territory-stage:has(.mode-gameover) .game-layout,
  .territory-stage:has(.mode-finished) .game-layout {
    display: grid;
    grid-template-columns: minmax(0, calc(var(--territory-board-h) * 16 / 9));
    grid-template-areas: "canvas";
    justify-content: center;
    align-items: start;
    justify-items: stretch;
    gap: 0;
    padding: 4px 12px 8px;
    margin: 0;
    width: 100%;
  }

  .territory-stage:has(.mode-playing) .game-layout:has(.ad-slot--left:not(:empty):not([hidden])),
  .territory-stage:has(.mode-playing) .game-layout:has(.ad-slot--right:not(:empty):not([hidden])),
  .territory-stage:has(.mode-paused) .game-layout:has(.ad-slot--left:not(:empty):not([hidden])),
  .territory-stage:has(.mode-paused) .game-layout:has(.ad-slot--right:not(:empty):not([hidden])) {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "ad-left canvas ad-right";
  }

  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    grid-area: canvas;
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame,
  .territory-stage:has(.mode-cleared) .canvas-frame,
  .territory-stage:has(.mode-gameover) .canvas-frame,
  .territory-stage:has(.mode-finished) .canvas-frame {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: var(--territory-board-h);
    aspect-ratio: 16 / 9;
    margin: 0;
  }
}

@media (max-width: 900.98px) {
  .territory-stage .mode-menu .game-layout {
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome)),
      calc((100vw - 16px) * 104 / 64)
    );
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 8px 8px;
  }

  .territory-stage .mode-menu .play-column,
  .territory-stage .mode-menu .control-panel {
    width: min(100%, calc(var(--territory-board-h) * 64 / 104));
    max-width: 100%;
  }

  .territory-stage .mode-menu .control-panel {
    position: static;
    padding: 0;
    align-self: center;
  }

  .territory-stage .mode-menu .canvas-frame {
    width: 100%;
    max-width: 100%;
    max-height: var(--territory-board-h);
    aspect-ratio: 64 / 104;
    margin: 0 auto;
  }

  .territory-stage .mode-playing .play-column,
  .territory-stage .mode-paused .play-column {
    width: min(100%, calc(var(--territory-board-h) * 64 / 104));
    margin: 0 auto;
    align-items: stretch;
  }
}

/* CJK tracking: 1–1.5px letter-spacing on Hangul/Kana/Han reads as syllable
   gaps (난이 도 선택 / 스테이지 / 차지해야 공개 / 명예의 전당).
   Zero tracking on the whole arcade tree; Latin chrome keeps tracking
   when lang is en/es. */
#territory-root:is(:lang(ko), :lang(ja), :lang(zh)),
#territory-root:is(:lang(ko), :lang(ja), :lang(zh)) * {
  letter-spacing: 0;
}

#territory-root:is(:lang(ko), :lang(ja), :lang(zh))
  :is(
    .section-label,
    .mini-label,
    .preview-stamp,
    .hof-scope,
    .arcade-label,
    .difficulty-meta-line,
    .art-note,
    .touch-lobby-guide,
    .play-coach,
    .play-keys,
    .difficulty-card strong,
    .primary-button,
    .pause-button,
    .draw-toggle strong,
    .overlay-kicker,
    .end-title,
    .result-kicker,
    .souvenir-cta,
    .record-submit-title,
    .hof-state,
    .next-hazard
  ) {
  text-transform: none;
}

/* ── UX UI enough: Racing-aligned finish, denser lobby/HUD, mobile taps ── */

.lobby-controls {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.lobby-start-cluster {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 4px;
}

.territory-stage .mode-menu .lobby-start-cluster .section-label {
  margin-bottom: 8px;
}

.territory-stage .mode-menu .difficulty-meta-line {
  margin: 10px 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.03);
  color: color-mix(in srgb, var(--white) 78%, var(--muted));
  font: 600 11px/1.4 var(--mono);
}

.territory-stage .mode-menu .start-button {
  margin-top: 0;
  min-height: 48px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.28);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card {
  padding: 12px 6px 10px;
  min-height: 56px;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card strong {
  font-size: 14px;
}

.territory-stage .mode-menu .preview-stamp {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--hairline-strong));
  background: rgba(0, 0, 0, 0.82);
}

.territory-hof {
  margin-top: 12px;
  padding: 12px 10px 10px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.02);
}

.territory-hof .section-label {
  margin-bottom: 2px;
}

.hof-body {
  min-height: 64px;
}

.hof-state {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.hof-state--error,
.hof-state--empty,
.hof-state--offline {
  display: grid;
  gap: 8px;
  justify-items: stretch;
  padding: 2px 0 0;
  min-height: 0;
}

.hof-soft-copy {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.hof-state--error strong,
.hof-state--empty strong,
.hof-state--offline strong {
  font: 600 12px/1.35 var(--body-font);
  color: color-mix(in srgb, var(--white) 88%, var(--muted));
}

.hof-state--error span,
.hof-state--empty span,
.hof-state--offline span {
  font-size: 11px;
  color: var(--muted-soft);
}

.hof-list--soft {
  opacity: 0.38;
  pointer-events: none;
  max-height: none;
}

.hof-list--soft .hof-ghost {
  border-bottom-color: color-mix(in srgb, var(--hairline) 55%, transparent);
}

.hof-list--soft .hof-name,
.hof-list--soft .hof-score {
  color: var(--muted);
  letter-spacing: 0.12em;
}

.hof-retry {
  margin-top: 2px;
  min-height: 32px;
  padding: 0 12px;
  border-color: var(--hairline-strong);
  background: rgba(255, 255, 255, 0.04);
}

.hof-retry:hover {
  border-color: var(--accent);
  color: var(--white);
}

/* Play HUD: denser instrument strip above the board */
.territory-stage .play-hud {
  gap: 4px;
  padding: 2px 10px 6px;
}

.territory-stage .play-hud-row {
  gap: 10px;
  align-items: center;
}

.territory-stage .play-hud-stage {
  flex: 0 1 120px;
  gap: 1px;
}

.territory-stage .play-hud-stage strong {
  font-size: 15px;
}

.territory-stage .claim-hud-score strong {
  font-size: clamp(20px, 3.2vw, 28px);
}

.territory-stage .claim-hud-meter {
  margin-top: 5px;
  height: 4px;
  width: min(160px, 36vw);
}

.territory-stage .fuse-timer {
  flex: 1 1 180px;
  max-width: 320px;
  gap: 4px;
}

.territory-stage .fuse-timer strong {
  font-size: 16px;
}

.territory-stage .fuse-track {
  height: 7px;
}

.territory-stage .play-hud-msg {
  min-height: 1.4em;
  height: 1.4em;
  max-height: 1.4em;
}

.territory-stage .play-hud-msg:not(:has(:not([hidden]))) {
  display: block;
}

.territory-stage .play-keys,
.territory-stage .play-coach,
.territory-stage .game-toast {
  font-size: 11px;
  line-height: 1.35;
}

.territory-stage .play-keys kbd {
  padding: 1px 4px;
  font-size: 10px;
}

.territory-stage .claim-hud.is-flash strong {
  animation: claim-pop 0.45s ease-out;
}

.territory-stage .canvas-frame.is-claim-flash {
  box-shadow:
    inset 0 0 0 4px var(--accent),
    0 0 36px rgba(255, 77, 0, 0.5);
}

.territory-stage .canvas-frame.is-claim-flash::after {
  box-shadow: inset 0 0 64px rgba(255, 77, 0, 0.34);
}

/* Overlays: Racing-like result cards */
.territory-stage .board-overlay,
.territory-stage .clear-banner.end-overlay {
  background: rgba(0, 0, 0, 0.78);
  padding: 16px;
  align-items: center;
  justify-content: center;
}

.territory-stage .mode-paused .board-overlay {
  background: rgba(0, 0, 0, 0.48);
}

.territory-stage .end-card {
  width: min(100%, 460px);
  max-height: min(92dvh, 720px);
  overflow: auto;
  background: #101010;
  border: 1px solid var(--hairline-strong);
  padding: 0;
  text-align: left;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.5);
}

.territory-stage .end-card.finish-result,
.territory-stage .end-card.clear-result {
  border-color: var(--accent);
  box-shadow:
    0 18px 70px rgba(0, 0, 0, 0.5),
    0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent);
}

.territory-stage .end-card.failed-result {
  border-color: #76363d;
}

.territory-stage .end-title {
  margin: 0;
  padding: 16px 18px;
  font: 800 22px/1.15 var(--heading);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  background: var(--surface-card);
  border-bottom: 1px solid var(--hairline);
  color: var(--white);
}

.territory-stage .finish-result .end-title,
.territory-stage .clear-result .end-title {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  font-size: 24px;
}

.territory-stage .failed-result .end-title {
  background: #3b1e24;
  border-color: #673039;
  color: #ffb0b0;
  letter-spacing: 0;
}

.territory-stage .pause-result .end-title {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  font-size: 24px;
}

.territory-stage .result-hero {
  margin: 0;
  padding: 16px 18px 14px;
  text-align: center;
  border-bottom: 1px solid var(--hairline);
}

.territory-stage .clear-hero {
  background: #0a0a0a;
  padding-top: 0;
}

.territory-stage .pause-hero,
.territory-stage .failed-hero {
  background: #141014;
}

.territory-stage .checker-strip {
  height: 10px;
  margin: 0 -18px 14px;
  background-color: #f2f2ed;
  background-image: conic-gradient(#11161c 25%, transparent 0 50%, #11161c 0 75%, transparent 0);
  background-size: 14px 14px;
}

.territory-stage .checker-strip:last-child {
  margin: 14px -18px 0;
}

.territory-stage .result-kicker,
.territory-stage .result-hero .overlay-kicker {
  display: block;
  margin: 0 0 8px;
  color: var(--accent);
  font: 800 10px/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.territory-stage .result-copy,
.territory-stage .result-hero > p:not(.overlay-stat) {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  max-width: none;
}

.territory-stage .result-hero .overlay-stat {
  margin: 0 0 8px !important;
  color: color-mix(in srgb, var(--white) 88%, var(--accent));
}

.territory-stage .end-body {
  padding: 14px 18px 8px;
}

.territory-stage .end-actions-bar {
  display: grid;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}

.territory-stage .end-actions-bar .primary-button,
.territory-stage .end-actions-bar .text-button {
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 48px;
}

.territory-stage .end-actions-bar .text-button {
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--white);
}

.territory-stage .end-actions-bar .text-button:hover {
  border-color: var(--white);
}

.territory-stage .souvenir-cta {
  display: grid;
  gap: 3px;
  width: 100%;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--white);
  text-align: left;
}

.territory-stage .souvenir-cta strong {
  font: 800 12px/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.territory-stage .souvenir-cta span {
  font-size: 11px;
  color: var(--muted);
}

.territory-stage .souvenir-cta:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.territory-stage .souvenir-still {
  width: min(100%, 360px);
  margin: 0 auto 4px;
  border-width: 2px;
  box-shadow: 0 0 0 1px rgba(255, 77, 0, 0.2);
}

.territory-stage .finish-banner .collected-scenes,
.territory-stage .collected-scenes {
  margin: 0 0 4px;
  gap: 6px;
  max-height: none;
}

.territory-stage .board-landscape .collected-scenes > div {
  aspect-ratio: 16 / 9;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--hairline));
}

.territory-stage .collected-scenes span {
  font-size: 10px;
  padding: 4px 6px;
}

.territory-stage .record-submit {
  width: 100%;
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 18px 8px;
  border-top: 1px solid var(--hairline);
  border-bottom: 0;
}

.territory-stage .end-body .record-submit {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--hairline));
  background: rgba(0, 0, 0, 0.35);
  margin: 0 0 10px;
}

.territory-stage .record-submit-title {
  color: var(--accent);
  font: 800 10px/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.territory-stage .record-lock {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 10px;
  font: 600 11px/1 var(--mono);
  color: var(--muted);
}

.territory-stage .record-lock b {
  color: var(--white);
  font: 800 18px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.territory-stage .record-submit-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--ink);
  font: 800 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.territory-stage .record-submit-button:hover {
  background: transparent;
  color: var(--accent);
}

.territory-stage .next-hazard {
  margin: 0 0 4px;
  text-align: center;
  font: 700 11px/1.3 var(--mono);
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: uppercase;
}

.territory-stage .help-overlay {
  background: rgba(0, 0, 0, 0.9);
}

.territory-stage .help-overlay h2 {
  margin-top: 8px;
}

/* Mobile touch row: larger targets, clearer DRAW, HUD stack */
@media (max-width: 900.98px) {
  .territory-stage .mode-menu .lobby-start-cluster {
    gap: 0;
  }

  .territory-stage .mode-menu .difficulty-meta-line {
    margin: 6px 0 8px;
    padding: 6px 8px;
    font-size: 10px;
    letter-spacing: 0;
  }

  .territory-stage .mode-menu .start-button {
    min-height: 48px;
  }

  .territory-hof {
    margin-top: 8px;
    padding: 10px 8px 8px;
  }

  .territory-stage .play-hud {
    padding: 2px 6px 6px;
  }

  .territory-stage .play-hud-stage strong {
    font-size: 14px;
  }

  .territory-stage .claim-hud-score strong {
    font-size: 22px;
  }

  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    gap: 10px;
    padding: 8px 4px calc(10px + env(safe-area-inset-bottom, 0px));
    align-items: center;
  }

  .territory-stage .mode-playing .dpad,
  .territory-stage .mode-paused .dpad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(2, 44px);
    gap: 4px;
  }

  .territory-stage .dpad button {
    min-width: 44px;
    min-height: 44px;
  }

  .territory-stage .mode-playing .draw-toggle,
  .territory-stage .mode-paused .draw-toggle {
    width: min(112px, 30vw);
    height: 76px;
    min-height: 72px;
  }

  .territory-stage .draw-toggle strong {
    font-size: 16px;
  }

  .territory-stage .touch-controls .touch-pause,
  .territory-stage .touch-controls.active .touch-pause {
    display: none !important;
  }
  .territory-stage .play-hud-actions .touch-pause {
    display: inline-flex;
  }

  .territory-stage .end-card {
    width: min(100%, 100%);
    max-height: min(88dvh, 680px);
  }

  .territory-stage .end-title {
    padding: 14px 14px;
    font-size: 18px;
  }

  .territory-stage .finish-result .end-title,
  .territory-stage .clear-result .end-title {
    font-size: 20px;
  }

  .territory-stage .result-hero,
  .territory-stage .end-body,
  .territory-stage .end-actions-bar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .territory-stage .checker-strip {
    margin-left: -14px;
    margin-right: -14px;
  }

  .territory-stage .checker-strip:last-child {
    margin-left: -14px;
    margin-right: -14px;
  }

  .territory-stage .finish-result .collected-scenes > div {
    max-height: 64px;
  }

  .territory-stage .finish-result .souvenir-cta {
    padding: 8px 10px;
    gap: 8px;
  }

  .territory-stage .finish-result .record-submit {
    padding: 8px 0 6px;
  }

  .territory-stage .finish-result .record-lock {
    margin: 6px 0 8px;
  }

  .territory-stage .finish-result .record-lock b {
    font-size: 16px;
  }

  .territory-stage .hof-submit-label input {
    min-height: 44px;
    padding: 10px 12px;
  }
}

/* CJK: win over later letter-spacing rules (mobile meta, kickers, etc.) */
#territory-root:is(:lang(ko), :lang(ja), :lang(zh)),
#territory-root:is(:lang(ko), :lang(ja), :lang(zh)) * {
  letter-spacing: 0 !important;
}

html:has(.territory-stage),
body:has(.territory-stage) {
  background: #000;
  margin: 0;
}

.territory-stage {
  min-height: 100dvh;
  background: #000;
}

@media (min-width: 901px) {
  .territory-stage .mode-menu .game-layout {
    align-items: start;
  }
  .territory-stage .mode-menu .control-panel {
    display: flex;
    flex-direction: column;
    align-self: start;
    height: fit-content;
  }
  .lobby-controls {
    flex: 0 1 auto;
    min-height: 0;
    height: auto;
  }
  .territory-hof {
    flex: 0 1 auto;
  }
}

.territory-stage .end-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.territory-stage .finish-result .finish-layout,
.territory-stage .clear-result .finish-layout {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  grid-auto-rows: max-content;
}

.territory-stage .result-hero,
.territory-stage .end-body {
  min-height: 0;
}

.territory-stage .finish-result .result-hero,
.territory-stage .finish-result .end-body,
.territory-stage .clear-result .result-hero,
.territory-stage .clear-result .end-body {
  overflow: visible;
  min-height: max-content;
}

.territory-stage .end-actions-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex: 0 0 auto;
}

.territory-stage .finish-result .collected-scenes > div {
  max-height: 92px;
}

.territory-stage .finish-result .collected-scenes {
  align-items: stretch;
}

.territory-stage .mode-menu .difficulty-meta-line {
  word-break: keep-all;
}

/* Deepen: Racing-width finish, heat chips, HUD scene room, teaser vignette */

.territory-stage .mode-menu .canvas-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 0 80px rgba(0, 0, 0, 0.45),
    inset 0 -56px 72px rgba(0, 0, 0, 0.4);
}

.territory-stage .heat-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
}

.territory-stage .heat-chips > span {
  display: grid;
  gap: 2px;
  padding: 8px 8px 7px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.03);
  font: 600 10px/1.2 var(--mono);
  color: var(--muted);
  text-transform: uppercase;
}

.territory-stage .heat-chips > span b {
  color: var(--white);
  font: 700 13px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.territory-stage .play-hud-stage {
  flex: 0 1 168px;
}

.territory-stage .play-hud-stage [data-bind="hud-scene"] {
  max-width: 22ch;
}

.territory-stage .end-card.finish-result,
.territory-stage .end-card.clear-result {
  width: min(100%, 620px);
  max-height: min(92dvh, 740px);
}

.territory-stage .finish-layout {
  display: grid;
  min-height: 0;
  overflow: auto;
}

@media (min-width: 901px) {
  .territory-stage .finish-result .finish-layout,
  .territory-stage .clear-result .finish-layout {
    align-items: start;
  }
  .territory-stage .finish-result .finish-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.95fr);
  }
  .territory-stage .finish-result .result-hero {
    border-bottom: 0;
    border-right: 1px solid var(--hairline);
  }
  .territory-stage .finish-result .end-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .territory-stage .finish-result .collected-scenes > div {
    max-height: 110px;
  }
}

.territory-stage .rsum {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 0 14px;
}

.territory-stage .rsum > div {
  font-size: 11px;
  color: var(--muted);
  min-width: 64px;
}

.territory-stage .rsum b {
  display: block;
  margin-top: 2px;
  font: 700 17px/1.1 var(--mono);
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.territory-stage .souvenir-cta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.territory-stage .souvenir-cta-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--ink);
  font: 800 16px/1 var(--mono);
}

.territory-stage .souvenir-cta-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.territory-stage .souvenir-cta:hover .souvenir-cta-mark {
  background: transparent;
  color: var(--accent);
}

.territory-stage .help-overlay {
  align-items: center;
  justify-content: center;
  text-align: left;
  padding: 16px;
  background: rgba(0, 0, 0, 0.82);
}

.territory-stage .help-result {
  width: min(100%, 520px);
  position: relative;
}

.territory-stage .help-result .close-help {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

.territory-stage .help-body {
  padding-top: 10px;
}

.territory-stage .help-body ol {
  margin: 12px 0;
}

.territory-stage .mode-menu .control-panel {
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 12px 10px;
}

@media (max-width: 900.98px) {
  .territory-stage .heat-chips {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin: 6px 0 8px;
  }
  .territory-stage .heat-chips > span {
    padding: 6px 4px;
    font-size: 8px;
  }
  .territory-stage .heat-chips > span b {
    font-size: 11px;
  }
  .territory-stage .mode-menu .control-panel {
    padding: 8px;
  }
  .territory-stage .finish-result .finish-layout,
  .territory-stage .clear-result .finish-layout {
    grid-template-columns: 1fr;
  }
  .territory-stage .rsum {
    gap: 10px 12px;
  }
  .territory-stage .rsum b {
    font-size: 15px;
  }
}

/* ── Lobby finish: denser stage, soft HOF offline, intentional teaser ── */

.territory-stage {
  --territory-lobby-chrome: 72px;
  background:
    radial-gradient(120% 80% at 50% 18%, rgba(28, 36, 48, 0.55), transparent 62%),
    radial-gradient(90% 60% at 72% 88%, rgba(255, 77, 0, 0.06), transparent 55%),
    #05070b;
}

.territory-stage .mode-menu .preview-stamp {
  top: 14px;
  left: 14px;
  gap: 8px;
  padding: 9px 12px;
  border-color: color-mix(in srgb, var(--accent) 55%, rgba(214, 224, 232, 0.35));
  background: linear-gradient(180deg, rgba(8, 12, 18, 0.88), rgba(0, 0, 0, 0.78));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.territory-stage .mode-menu .preview-stamp .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 77, 0, 0.18);
}

/* Lobby ? lives inside the CLAIM stamp — not a 36px square hanging off the frame. */
.territory-stage .mode-menu .preview-stamp .how-button--stamp,
.territory-stage .mode-menu .icon-button.how-button.how-button--stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-height: 22px;
  min-width: 22px;
  margin: 0 0 0 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--body, #e8e8e8);
  font: 700 13px/1 var(--mono);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.territory-stage .mode-menu .preview-stamp .how-button--stamp:hover {
  color: var(--acc, #ff4d00);
  background: transparent;
  border: 0;
}

.territory-stage .mode-menu .lobby-start-cluster .section-label {
  margin-bottom: 6px;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card {
  padding: 10px 6px 8px;
  min-height: 50px;
}

.territory-stage .mode-menu .difficulty-meta-line.heat-chips {
  margin: 8px 0 10px;
}

.territory-stage .mode-menu .start-button {
  min-height: 46px;
  letter-spacing: 0.04em;
}

.territory-stage .mode-menu .art-note {
  margin: 6px 0 0;
  font-size: 10px;
  opacity: 0.72;
}

.territory-hof {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  padding: 10px 10px 8px;
  min-height: 0;
  flex: 0 1 auto;
}

.territory-hof .hof-body {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.territory-hof .hof-state--offline,
.territory-hof .hof-state--empty {
  flex: 0 1 auto;
  align-content: start;
}

@media (min-width: 901px) {
  .territory-stage .arcade.mode-menu {
    justify-content: center;
  }

  .territory-stage .mode-menu .game-layout {
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome)),
      calc((100vw - var(--territory-flange) - 32px) * 9 / 16)
    );
    align-items: stretch;
    align-content: center;
    justify-content: center;
    min-height: calc(100dvh - var(--territory-lobby-chrome));
    gap: 16px;
    padding: 10px 16px 16px;
  }

  .territory-stage .mode-menu .play-column {
    height: var(--territory-board-h);
    max-height: var(--territory-board-h);
  }

  .territory-stage .mode-menu .control-panel {
    display: flex;
    flex-direction: column;
    align-self: start;
    height: fit-content;
    max-height: var(--territory-board-h);
    overflow-y: auto;
    padding: 12px 12px 10px;
  }

  .territory-stage .mode-menu .lobby-controls {
    flex: 0 1 auto;
    min-height: 0;
    height: auto;
  }

  .territory-stage .mode-menu .canvas-frame {
    height: 100%;
    max-height: 100%;
    width: 100%;
  }
}

@media (max-width: 900.98px) {
  .territory-stage {
    --territory-lobby-chrome: 96px;
  }

  .territory-stage .mode-menu .game-layout {
    gap: 6px;
    padding: 0 8px 10px;
    min-height: calc(100dvh - var(--territory-lobby-chrome));
    justify-content: flex-start;
  }

  .territory-stage .mode-menu .control-panel {
    width: min(100%, calc(var(--territory-board-h) * 64 / 104));
  }

  .territory-hof {
    margin-top: 6px;
    padding: 8px;
    flex: 0 1 auto;
    max-height: min(28vh, 220px);
  }

  .hof-list--soft {
    display: none;
  }

  .territory-stage .mode-menu .touch-lobby-guide {
    margin: 4px 0 0;
    font-size: 10px;
  }

  .territory-stage .mode-menu .art-note {
    display: none;
  }

  .territory-stage .mode-menu .canvas-frame {
    max-height: min(
      calc(100dvh - var(--territory-lobby-chrome) - 168px),
      calc((100vw - 16px) * 104 / 64)
    );
  }
}

/* Stage-clear / finish: keep cards filling the board plane (no cheap void). */
.territory-stage .board-overlay:not([hidden]),
.territory-stage .clear-banner:not([hidden]) {
  align-items: stretch;
  justify-content: stretch;
}

.territory-stage .board-overlay .end-card,
.territory-stage .clear-banner .end-card {
  width: min(100%, 640px);
  max-height: min(92%, 720px);
  margin: auto;
}

/* ── Lobby composition: framed still + solid instrument deck (Racing garage IA).
   Not a floating HUD on the photo — page-chrome siblings like Racing .garage.
   Board-first phone stack kept. ── */

.territory-stage .play-keys,
.territory-stage .play-coach,
.territory-stage .game-toast {
  font-size: 13px;
  line-height: 1.4;
  padding: 0;
}

.territory-stage .play-coach {
  color: color-mix(in srgb, var(--white) 92%, var(--muted));
}

@media (min-width: 901px) {
  /* Reserve room for the solid instrument deck under the framed still so the
     16:9 teaser + deck fill the lobby without a letterbox void under the pair. */
  .territory-stage .arcade.mode-menu {
    --territory-lobby-deck: 292px;
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck)),
      calc((100vw - 48px) * 9 / 16)
    );
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: calc(100dvh - var(--territory-lobby-chrome));
  }

  /* Empty ad slots: framed still above + solid instrument deck below (Racing
     garage instruments as page chrome — never absolute glass on the art). */
  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) {
    --territory-lobby-deck: 292px;
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck)),
      calc((100vw - 48px) * 9 / 16)
    );
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "canvas"
      "controls";
    justify-content: center;
    align-items: stretch;
    align-content: start;
    gap: 0;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 10px 0 16px;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .play-column {
    grid-area: canvas;
    width: 100%;
    height: var(--territory-board-h);
    max-height: var(--territory-board-h);
    margin: 0;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .canvas-frame {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    /* Framed still — page chrome edge, not a floating media card */
    border: 1px solid var(--hairline-strong);
    border-bottom: 0;
    box-shadow: none;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .control-panel {
    /* Solid instrument deck under the still — Racing page chrome, content-hug. */
    grid-area: controls;
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: none;
    height: fit-content;
    max-height: none;
    overflow: visible;
    z-index: auto;
    align-self: stretch;
    background: var(--surface, #0d0d0d);
    border: 1px solid var(--hairline);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 12px 14px 12px;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .lobby-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.9fr);
    gap: 16px 20px;
    align-items: start;
    flex: 0 1 auto;
    min-height: 0;
    height: auto;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .territory-hof {
    margin-top: 0;
    height: fit-content;
  }

  /* Vanilla (no GamesShell crumbs): ? sits on the framed still, not in the
     side gutter. Next embed: ? stays on the breadcrumb band. */
  .territory-stage:not(:has(> .breadcrumbs)) .mode-menu .topbar {
    z-index: 8;
    top: 22px;
    left: max(
      10px,
      calc((100% - min(100%, var(--territory-board-h) * 16 / 9)) / 2 + 10px)
    );
    right: auto;
    width: auto;
  }
  .territory-stage:has(> .breadcrumbs) .mode-menu .topbar {
    z-index: 8;
    top: 0;
    right: 0;
    left: auto;
    height: 40px;
    width: auto;
  }

  .territory-stage .mode-menu .preview-stamp {
    left: 14px;
    top: 14px;
  }
}

@media (max-width: 900.98px) {
  .territory-stage {
    --territory-lobby-chrome: 64px;
  }

  .territory-stage .mode-menu .topbar {
    top: 8px;
    right: 8px;
    z-index: 6;
  }

  .territory-stage .mode-menu .game-layout {
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    gap: 8px;
    padding: 0 0 10px;
  }

  .territory-stage .mode-menu .play-column {
    order: 0;
  }

  .territory-stage .mode-menu .control-panel {
    order: 1;
    position: static;
    width: min(100%, calc(var(--territory-board-h) * 64 / 104));
    border: 1px solid var(--hairline);
    background: rgba(255, 255, 255, 0.03);
    padding: 8px;
  }

  .territory-stage .mode-menu .canvas-frame {
    max-height: min(
      calc(100dvh - var(--territory-lobby-chrome) - 168px),
      calc((100vw - 16px) * 104 / 64)
    );
  }

  .territory-hof {
    margin-top: 8px;
    max-height: none;
  }

  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.88) 28%);
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* Design consistency — Racing CTA pair + GTALAB tokens (filled + outline).
   Wins leftover min-heights / weights so TRY AGAIN and BACK TO DIFFICULTY
   read as one designed pair, not two leftover button skins. */
.territory-stage .primary-button,
.territory-stage .secondary-button,
.territory-stage .record-submit-button,
.territory-stage .end-actions-bar .primary-button,
.territory-stage .end-actions-bar .secondary-button,
.territory-stage .end-actions-bar .text-button,
.territory-stage .mode-menu .start-button,
.territory-stage .board-overlay .primary-button,
.territory-stage .board-overlay .secondary-button,
.territory-stage .board-overlay .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 0;
  gap: 8px;
  box-shadow: none;
  font: 700 11px/1.15 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: normal;
  text-align: center;
}

.territory-stage .primary-button,
.territory-stage .record-submit-button,
.territory-stage .mode-menu .start-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--ink);
}

.territory-stage .primary-button:hover,
.territory-stage .record-submit-button:hover,
.territory-stage .mode-menu .start-button:hover {
  background: transparent;
  color: var(--accent);
}

.territory-stage .secondary-button,
.territory-stage .end-actions-bar .secondary-button,
.territory-stage .end-actions-bar .text-button {
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--white);
}

.territory-stage .secondary-button:hover,
.territory-stage .end-actions-bar .secondary-button:hover,
.territory-stage .end-actions-bar .text-button:hover {
  border-color: var(--white);
  background: transparent;
  color: var(--white);
}

.territory-stage .end-actions-bar.rbtns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* HOF Retry is a compact chip under offline copy — not the Racing 48px CTA. */
.territory-stage .hof-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  min-height: 0;
  height: auto;
  margin-top: 6px;
  padding: 4px 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 0;
  background: transparent;
  color: var(--white);
  box-shadow: none;
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  justify-self: start;
}

.territory-stage .hof-retry:hover {
  border-color: var(--white);
  background: transparent;
  color: var(--white);
}

.territory-stage .souvenir-cta {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--white);
  gap: 10px;
  text-align: left;
}

.territory-stage .souvenir-cta strong {
  font: 700 11px/1.15 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--white);
}

.territory-stage .souvenir-cta span {
  font: 400 11px/1.35 var(--body-font);
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}

.territory-stage .souvenir-cta:hover {
  border-color: var(--white);
  background: transparent;
}

.territory-stage .hof-submit-label input,
.territory-stage .record-name {
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 0;
  background: #090909;
  color: var(--white);
  font: 700 12px/1.2 var(--body-font);
}

.territory-stage .hof-submit-label input:focus {
  outline: 0;
  border-color: var(--accent);
}

.territory-stage .heat-chips > span {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--hairline-strong);
  background: #090909;
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.territory-stage .heat-chips > span b {
  font: 700 13px/1 var(--mono);
  color: var(--white);
  letter-spacing: 0;
}

.territory-stage .icon-button.how-button,
.territory-stage .icon-button.field-pause,
.territory-stage .close-help.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font: 700 14px/1 var(--mono);
  letter-spacing: 0;
  text-transform: none;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--body);
}

.territory-stage .icon-button.how-button:hover,
.territory-stage .icon-button.field-pause:hover,
.territory-stage .close-help.icon-button:hover {
  border-color: var(--accent);
  color: var(--white);
  background: rgba(255, 77, 0, 0.08);
}

.territory-stage .result-kicker,
.territory-stage .result-hero .overlay-kicker,
.territory-stage .overlay-kicker,
.territory-stage .record-submit-title,
.territory-stage .claim-hud-kicker {
  font: 500 10px/1.2 var(--mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
}

.territory-stage .hof-list--soft .hof-name,
.territory-stage .hof-list--soft .hof-score {
  letter-spacing: 0;
}

.territory-stage .hof-list li {
  border-bottom: 1px solid var(--hairline);
  font: 400 11.5px/1.3 var(--body-font);
}

.territory-stage .end-card.pause-result,
.territory-stage .end-card.finish-result,
.territory-stage .end-card.clear-result,
.territory-stage .end-card.failed-result,
.territory-stage .end-card.help-result {
  border-radius: 0;
}

.territory-stage .dpad button {
  border: 1px solid var(--hairline-strong);
  background: #090909;
  border-radius: 0;
}

.territory-stage .draw-toggle {
  border: 1px solid var(--hairline-strong);
  background: #090909;
  border-radius: 0;
  height: 84px;
  min-height: 84px;
}

@media (max-width: 900.98px) {
  .territory-stage .primary-button,
  .territory-stage .secondary-button,
  .territory-stage .record-submit-button,
  .territory-stage .mode-menu .start-button,
  .territory-stage .souvenir-cta {
    min-height: 48px;
  }

  .territory-stage .icon-button.how-button,
  .territory-stage .icon-button.field-pause,
  .territory-stage .close-help.icon-button,
  .territory-stage .touch-pause {
    width: 44px;
    height: 44px;
    min-height: 44px;
    font-size: 16px;
  }

  .territory-stage .mode-menu .preview-stamp .how-button--stamp {
    width: 22px;
    height: 22px;
    min-height: 22px;
    min-width: 22px;
    font-size: 13px;
  }

  .territory-stage .dpad button {
    min-width: 44px;
    min-height: 44px;
  }

  .territory-stage .mode-playing .dpad,
  .territory-stage .mode-paused .dpad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(2, 44px);
  }

  .territory-stage .draw-toggle {
    height: 92px;
    min-height: 92px;
  }
}

#territory-root:is(:lang(ko), :lang(ja), :lang(zh))
  :is(
    .primary-button,
    .secondary-button,
    .record-submit-button,
    .start-button,
    .hof-retry,
    .souvenir-cta strong,
    .heat-chips > span,
    .result-kicker,
    .overlay-kicker,
    .claim-hud-kicker,
    .record-submit-title
  ) {
  letter-spacing: 0 !important;
}

/* ── Racing tone: GTALAB Games chrome language (not a garage-list clone).
   Tokens, module borders, Start bar, compact TOP TIMES widget, heat chips
   vs Racing difficulty strip, finish/HUD result chrome. IA stays framed
   still + solid instrument deck. Soft-rec #87 Hold. */
.territory-stage {
  --panel: var(--surface-card, #141414);
  --panel2: var(--surface, #0d0d0d);
  --well: #0a0a0a;
  --line: var(--hairline, #262626);
  --line-strong: var(--hairline-strong, #3a3a3a);
  --txt: var(--white, #fff);
  --dim: var(--muted, #999);
  --acc: var(--accent, #ff4d00);
  background: var(--canvas, #000);
}

.territory-stage.arcade,
.territory-stage .arcade {
  position: relative;
  background: var(--canvas, #000);
}

.territory-stage .arcade > .help-overlay:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
}

.territory-stage .mode-menu .lobby-start-cluster .section-label,
.territory-stage .mode-menu .olab {
  margin: 0 0 6px;
  color: var(--dim);
  font: 400 10px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.territory-stage .mode-menu .seg.difficulty {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line-strong);
  background: var(--panel2);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 52px;
  padding: 8px 6px;
  border-right: 1px solid var(--line);
  box-shadow: none;
  color: color-mix(in srgb, var(--difficulty-color, var(--acc)) 70%, var(--dim));
  font: 700 11px/1 var(--mono);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card:last-child {
  border-right: 0;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card strong {
  font: 700 12px/1 var(--mono);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: inherit;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card small {
  font: 600 10px/1 var(--mono);
  color: inherit;
  opacity: 0.72;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card .dpips {
  display: flex;
  gap: 3px;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card .dpips i {
  width: 10px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card[data-level="1"] .dpips i:nth-child(-n + 1),
.territory-stage .mode-menu .seg.difficulty .difficulty-card[data-level="2"] .dpips i:nth-child(-n + 2),
.territory-stage .mode-menu .seg.difficulty .difficulty-card[data-level="3"] .dpips i:nth-child(-n + 3),
.territory-stage .mode-menu .seg.difficulty .difficulty-card[data-level="4"] .dpips i {
  background: color-mix(in srgb, var(--difficulty-color, var(--acc)) 55%, transparent);
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card.on,
.territory-stage .mode-menu .seg.difficulty .difficulty-card.selected {
  color: var(--txt);
  background: color-mix(in srgb, var(--difficulty-color, var(--acc)) 20%, var(--panel2));
  box-shadow: inset 0 -3px 0 var(--difficulty-color, var(--acc));
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card.on small,
.territory-stage .mode-menu .seg.difficulty .difficulty-card.selected small {
  color: var(--txt);
  opacity: 1;
}

.territory-stage .mode-menu .seg.difficulty .difficulty-card.on .dpips i,
.territory-stage .mode-menu .seg.difficulty .difficulty-card.selected .dpips i {
  filter: saturate(1.4) brightness(1.2);
}

.territory-stage .heat-chips,
.territory-stage .mode-menu .difficulty-meta-line.heat-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.territory-stage .heat-chips > span {
  display: grid;
  gap: 3px;
  min-height: 40px;
  padding: 7px 8px;
  border: 1px solid var(--line-strong);
  background: #090909;
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--dim);
}

.territory-stage .heat-chips > span b {
  font: 700 13px/1 var(--mono);
  color: var(--txt);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.territory-stage .mode-menu .start-button {
  min-height: 48px;
  height: 48px;
  font: 700 11px/1.15 var(--mono);
  letter-spacing: 1px;
}

.territory-stage .mode-menu .start-hint,
.territory-stage .mode-menu .touch-lobby-guide,
.territory-stage .mode-menu .art-note {
  margin: 6px 0 0;
  color: var(--dim);
  font: 500 10px/1.45 var(--mono);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.territory-hof {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 10px 10px 8px;
  min-height: 0;
  border: 1px solid var(--line-strong);
  background: var(--panel2);
}

.territory-hof .hof-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}

.territory-hof .hof-eyebrow {
  display: block;
  color: var(--txt);
  font: 700 11px/1 var(--mono);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

/* Live Racing TOP TIMES widget is eyebrow + scope + rows — no second 16px title. */
.territory-hof .section-label,
#territory-root[data-lobby-view="garage"] .territory-hof .section-label,
#territory-root[data-lobby-view="garage"] [data-bind="hof-title"] {
  display: none;
}

#territory-root[data-lobby-view="rankings"] .hof-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "eyebrow scope"
    "title scope"
    "challenge challenge";
  align-items: start;
}

#territory-root[data-lobby-view="rankings"] .hof-eyebrow {
  grid-area: eyebrow;
}

#territory-root[data-lobby-view="rankings"] .hof-scope {
  grid-area: scope;
  justify-self: end;
  text-align: right;
}

#territory-root[data-lobby-view="rankings"] .hof-challenge {
  grid-area: challenge;
}

#territory-root[data-lobby-view="rankings"] .territory-hof .section-label,
#territory-root[data-lobby-view="rankings"] [data-bind="hof-title"]:not([hidden]) {
  display: block;
  grid-area: title;
  position: static;
  width: auto;
  height: auto;
  margin: 4px 0 0;
  padding: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  font: 700 16px/1.2 var(--heading);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--txt, #fff);
}

.territory-hof .hof-scope {
  margin: 0;
  color: var(--dim);
  font: 500 10px/1.35 var(--mono);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.territory-hof .hof-body,
.territory-hof .hof-state,
.territory-hof .hof-state--offline,
.territory-hof .hof-state--empty,
.territory-hof .hof-state--error {
  min-height: 0;
  height: auto;
}

.territory-hof .hof-state--offline,
.territory-hof .hof-state--empty,
.territory-hof .hof-state--error {
  display: grid;
  gap: 6px;
  padding: 0;
}

.territory-hof .hof-soft-copy {
  display: grid;
  gap: 3px;
  justify-items: start;
}

.territory-hof .hof-soft-copy strong {
  font: 600 12px/1.35 var(--body-font);
  color: color-mix(in srgb, var(--txt) 88%, var(--dim));
}

.territory-hof .hof-soft-copy span {
  font: 400 11px/1.4 var(--body-font);
  color: var(--dim);
}

/* Racing TOP TIMES is a tight widget — hide empty ghost wells (don't fake scores). */
.territory-hof .hof-list--soft {
  display: none;
}

.territory-stage .hof-retry {
  min-height: 22px;
  height: 22px;
  padding: 0 8px;
  font: 700 10px/1 var(--mono);
}

.territory-stage .mode-playing .play-hud,
.territory-stage .mode-paused .play-hud {
  padding: 8px 12px 8px;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  background: var(--panel2);
}

.territory-stage .play-hud .mini-label,
.territory-stage .play-hud .claim-hud-kicker {
  font: 500 10px/1 var(--mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--acc);
}

.territory-stage .play-hud-stage strong,
.territory-stage .fuse-timer strong {
  font: 700 16px/1 var(--mono);
  letter-spacing: 0;
}

.territory-stage .claim-hud-score strong {
  font: 700 clamp(20px, 3vw, 26px)/1 var(--mono);
}

.territory-stage .claim-hud-meter,
.territory-stage .fuse-track {
  background: #1a1a1a;
}

.territory-stage .end-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
}

.territory-stage .end-title {
  padding: 14px 18px;
  font: 900 20px/1.15 var(--heading);
  letter-spacing: 0.5px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}

  .territory-stage .finish-result .end-title,
  .territory-stage .clear-result .end-title {
    padding: 12px 16px;
    background: var(--acc);
    border-color: var(--acc);
    color: var(--ink);
    font-size: 22px;
    letter-spacing: 0;
    text-transform: none;
  }

  .territory-stage .result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
  }

  .territory-stage .result-head-kicker {
    min-width: 0;
    font: 800 14px/1.25 var(--heading);
    letter-spacing: 0;
    text-transform: none;
  }

  .territory-stage .result-head-num {
    flex: 0 0 auto;
    font: 900 28px/1 var(--mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
  }

  .territory-stage .clear-result .clear-hero {
    padding: 14px 16px 6px;
  }

  .territory-stage .clear-result .result-copy {
    margin-top: 10px;
  }

.territory-stage .result-kicker,
.territory-stage .result-hero .overlay-kicker {
  color: var(--dim);
  font: 800 10px/1.2 var(--mono);
  letter-spacing: 0;
}

.territory-stage .end-actions-bar.rbtns,
.territory-stage .end-actions-bar.rbtns.racing-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  justify-items: stretch;
}

/* Territory pause/finish is a 2-button Racing pair — equal 48px filled + outline.
   Do not copy Racing's 3-button .p { grid-column: 1 / -1 } (huge RESUME, left-short BACK). */
.territory-stage .end-actions-bar.rbtns .primary-button,
.territory-stage .end-actions-bar.rbtns.racing-pair .primary-button,
.territory-stage .end-actions-bar.rbtns .secondary-button,
.territory-stage .end-actions-bar.rbtns.racing-pair .secondary-button {
  grid-column: auto;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  height: 48px;
}

@media (min-width: 901px) {
  .territory-stage .arcade.mode-menu {
    --territory-lobby-deck: 228px;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) {
    --territory-lobby-deck: 228px;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .canvas-frame {
    border: 1px solid var(--line-strong);
    border-bottom: 0;
    background: #0b0b0b;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .control-panel {
    background: var(--panel2);
    border: 1px solid var(--line-strong);
    padding: 12px;
  }

  .territory-stage .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .lobby-controls {
    grid-template-columns: minmax(0, 1.3fr) minmax(220px, 0.75fr);
    gap: 12px 16px;
    align-items: start;
  }

  .territory-stage .mode-menu .lobby-start-cluster {
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .territory-stage .mode-playing .canvas-frame,
  .territory-stage .mode-paused .canvas-frame {
    border: 1px solid var(--line-strong);
    border-top: 0;
  }
}

@media (max-width: 900.98px) {
  .territory-stage .heat-chips,
  .territory-stage .mode-menu .difficulty-meta-line.heat-chips {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin: 6px 0 8px;
  }

  .territory-stage .heat-chips > span {
    min-height: 36px;
    padding: 6px 4px;
    font-size: 8px;
    letter-spacing: 0.4px;
  }

  .territory-stage .heat-chips > span b {
    font-size: 11px;
  }

  .territory-stage .mode-menu .seg.difficulty .difficulty-card {
    min-height: 48px;
    padding: 7px 4px;
  }

  .territory-stage .mode-menu .control-panel {
    border: 1px solid var(--line-strong);
    background: var(--panel2);
    padding: 8px;
  }

  .territory-hof {
    padding: 8px;
  }

  .territory-hof .section-label {
    font-size: 14px;
  }

  .territory-stage .end-actions-bar.rbtns,
  .territory-stage .end-actions-bar.rbtns.racing-pair {
    grid-template-columns: 1fr 1fr;
  }

  .territory-stage .end-actions-bar.rbtns .primary-button,
  .territory-stage .end-actions-bar.rbtns.racing-pair .primary-button {
    grid-column: auto;
  }
}

#territory-root:is(:lang(ko), :lang(ja), :lang(zh))
  :is(
    .hof-eyebrow,
    .hof-scope,
    .olab,
    .mode-menu .section-label,
    .heat-chips > span,
    .difficulty-card strong,
    .start-button,
    .hof-retry,
    .end-actions-bar .primary-button,
    .end-actions-bar .secondary-button,
    .result-head,
    .result-head-kicker,
    .result-head-num,
    .pause-result .end-title
  ) {
  letter-spacing: 0 !important;
}

/* Pause: one plane over HUD + board (no stepped overlay). Racing pair centered. */
.territory-stage .mode-paused .play-column,
.territory-stage .mode-gameover .play-column {
  position: relative;
}

.territory-stage .play-column > .board-overlay:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 12;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.52);
}

.territory-stage .mode-paused .play-hud,
.territory-stage .mode-gameover .play-hud {
  pointer-events: none;
}

.territory-stage .end-card.pause-result {
  width: min(100%, 460px);
  max-height: min(86%, 560px);
  margin: auto;
  overflow: hidden;
}

.territory-stage .pause-hero {
  background: #0a0a0a;
}

/* ── GALLERY | HALL OF FAME tabs (Racing lobby chrome, Territory play setup).
   Gallery = framed 16:9 + 4-up + heat + Start + compact TOP TIMES.
   HOF tab expands the board; difficulty + Start stay. Soft-rec #87 Hold. ── */
.territory-stage .arcade.mode-menu {
  --territory-tab-band: 48px;
}

.territory-stage .mode-menu .topbar,
.territory-stage:not(:has(> .breadcrumbs)) .mode-menu .topbar,
.territory-stage:has(> .breadcrumbs) .mode-menu .topbar {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: var(--territory-tab-band, 48px);
  width: min(100%, calc(var(--territory-board-h) * 16 / 9));
  max-width: min(100%, calc(var(--territory-board-h) * 16 / 9));
  margin: 0 auto;
  padding: 0 0 0 4px;
}

.territory-stage .lobby-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-strong, #3a3a3a);
  background: var(--panel2, #0d0d0d);
}

.territory-stage .lobby-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--dim, #999);
  font: 700 11px/1 var(--mono);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.territory-stage .lobby-tabs__icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.territory-stage .lobby-tabs [data-view="rankings"] .lobby-tabs__icon {
  color: var(--acc, #ff4d00);
}

.territory-stage .lobby-tabs button:hover {
  color: var(--txt, #fff);
  background: rgba(255, 255, 255, 0.04);
}

.territory-stage .lobby-tabs button.on {
  color: var(--txt, #fff);
  background: #1d1d1d;
  box-shadow: inset 0 -2px 0 var(--acc, #ff4d00);
}

.territory-stage .lobby-tabs__lead {
  padding-left: 9px;
  border-left: 1px solid var(--line-strong, #3a3a3a);
  color: var(--acc, #ff4d00);
  font: 700 12px/1 var(--mono);
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}

/* Next chrome row: Racing's segmented tabs, sized to the crumb line.
   not a card on the still. */
.territory-chrome .lobby-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-strong, #3a3a3a);
  background: var(--panel2, #0d0d0d);
  flex: 0 1 auto;
}

.territory-chrome .lobby-tabs button {
  height: 28px;
  min-height: 0;
  padding: 0 12px;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--dim, #999);
  font: 700 11px/1 var(--mono);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  box-shadow: none;
}

.territory-chrome .lobby-tabs button:hover {
  color: var(--txt, #fff);
  background: rgba(255, 255, 255, 0.04);
}

.territory-chrome .lobby-tabs button.on {
  color: var(--txt, #fff);
  background: #1d1d1d;
  box-shadow: inset 0 -2px 0 var(--acc, #ff4d00);
}

.territory-chrome .lobby-tabs__icon {
  width: 14px;
  height: 14px;
}

.territory-chrome .lobby-tabs__lead {
  display: none;
}

.territory-stage .mode-menu .topbar[hidden] {
  display: none !important;
}

.territory-stage .lobby-tabs__lead:empty {
  display: none;
}

.territory-hof .hof-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 16px;
}

.territory-hof .hof-challenge {
  display: none;
  grid-column: 1 / -1;
  margin: 4px 0 0;
  color: var(--acc, #ff4d00);
  font: 700 20px/1.15 var(--heading);
  letter-spacing: 0.01em;
}

#territory-root[data-lobby-view="rankings"] .hof-challenge:not([hidden]) {
  display: block;
}

#territory-root[data-lobby-view="rankings"] .territory-hof .hof-head {
  padding-bottom: 12px;
}

#territory-root[data-lobby-view="rankings"] .territory-hof .hof-eyebrow {
  color: var(--acc, #ff4d00);
  font: 500 10px/1 var(--mono);
  letter-spacing: 1.6px;
}

.territory-hof .hof-hero {
  display: grid;
  gap: 4px;
  margin: 0 0 8px;
  padding: 16px 14px 14px;
  border: 1px solid var(--acc, #ff4d00);
  background: color-mix(in srgb, var(--acc, #ff4d00) 10%, var(--panel2, #0d0d0d));
}

.territory-hof .hof-hero__rank {
  color: var(--acc, #ff4d00);
  font: 700 11px/1 var(--mono);
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.territory-hof .hof-hero__score {
  color: var(--acc, #ff4d00);
  font: 700 32px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.territory-hof .hof-hero__name {
  color: var(--txt, #fff);
  font: 700 15px/1.2 var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 901px) {
  .territory-stage .arcade.mode-menu {
    --territory-lobby-chrome: calc(72px + var(--territory-tab-band, 48px));
  }

  #territory-root[data-lobby-view="rankings"].mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) {
    grid-template-areas:
      "hof"
      "controls";
  }

  #territory-root[data-lobby-view="rankings"] .play-column {
    display: none;
  }

  #territory-root[data-lobby-view="rankings"] .control-panel,
  #territory-root[data-lobby-view="rankings"] .lobby-controls {
    display: contents;
  }

  #territory-root[data-lobby-view="rankings"] .territory-hof {
    grid-area: hof;
    min-height: var(--territory-board-h);
    max-height: var(--territory-board-h);
    overflow: auto;
    padding: 18px 18px 12px;
    border-color: color-mix(in srgb, var(--acc, #ff4d00) 42%, var(--line-strong, #3a3a3a));
    background: linear-gradient(
      180deg,
      color-mix(in srgb, var(--acc, #ff4d00) 9%, var(--panel2, #0d0d0d)) 0,
      var(--panel2, #0d0d0d) 220px
    );
  }

  #territory-root[data-lobby-view="rankings"] .lobby-start-cluster {
    grid-area: controls;
    display: grid;
    align-content: start;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line-strong, #3a3a3a);
    background: var(--panel2, #0d0d0d);
  }

  #territory-root[data-lobby-view="rankings"] .hof-board {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: 20px;
    align-items: start;
    padding-top: 12px;
  }

  #territory-root[data-lobby-view="rankings"] .hof-top {
    position: sticky;
    top: 0;
  }
}

@media (max-width: 900.98px) {
  .territory-stage .arcade.mode-menu,
  .territory-stage {
    --territory-tab-band: 40px;
  }

  .territory-stage .mode-menu .topbar,
  .territory-stage:not(:has(> .breadcrumbs)) .mode-menu .topbar,
  .territory-stage:has(> .breadcrumbs) .mode-menu .topbar {
    width: 100%;
    max-width: 100%;
    padding: 0 8px;
  }

  .territory-stage .lobby-tabs button {
    height: 32px;
    padding: 0 10px;
    font-size: 10px;
    letter-spacing: 0.8px;
    gap: 6px;
  }

  .territory-stage .lobby-tabs__icon {
    display: none;
  }

  .territory-hof .hof-challenge {
    font-size: 16px;
  }

  /* Teaser-first garage. HOF expands the board; Start dock stays at the bottom. */
  #territory-root[data-lobby-view="rankings"] .play-column {
    display: none;
  }

  #territory-root[data-lobby-view="rankings"] .lobby-controls {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--territory-lobby-chrome) - var(--territory-tab-band, 40px));
  }

  #territory-root[data-lobby-view="rankings"] .territory-hof {
    order: 0;
    flex: 1 1 auto;
    min-height: min(52vh, 420px);
    padding: 12px 10px 10px;
    border-color: color-mix(in srgb, var(--acc, #ff4d00) 42%, var(--line-strong, #3a3a3a));
    background: linear-gradient(
      180deg,
      color-mix(in srgb, var(--acc, #ff4d00) 9%, var(--panel2, #0d0d0d)) 0,
      var(--panel2, #0d0d0d) 180px
    );
  }

  #territory-root[data-lobby-view="rankings"] .lobby-start-cluster {
    order: 1;
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin-top: auto;
    padding-top: 8px;
    background: var(--panel2, #0d0d0d);
  }
}

#territory-root:is(:lang(ko), :lang(ja), :lang(zh))
  :is(.lobby-tabs button, .hof-challenge, .hof-hero__rank, .hof-eyebrow) {
  letter-spacing: 0 !important;
}

/* ── One-viewport GALLERY lobby (site header + crumbs counted).
   Next /en/games/territory: leftover height after GamesShell header +
   breadcrumbs + tabs + deck. Still is 16:9 of that box and full width
   of the (shrunk) stage — not a 48px speck, not a full-bleed 16:9 that
   clips START GAME. Vanilla index keeps 100dvh minus tabs + deck. ── */

html:has(> body > .territory-stage),
html:has(> body > .territory-stage) body,
html:has(> body > .territory-stage) .territory-stage {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.territory-stage .arcade.mode-menu {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.territory-stage .arcade.mode-menu:has(.help-overlay:not([hidden])) {
  overflow: visible;
}

/* Next GamesShell: header + page pad + one chrome row (crumbs | tabs). */
.games-page:has(.territory-stage) .territory-stage,
.games-page:has(.territory-stage) .territory-stage .arcade.mode-menu {
  --territory-tab-band: 0px;
  --territory-crumb-band: 40px;
  --territory-page-pad-top: 8px;
  --territory-lobby-chrome: calc(
    var(--site-header-height, 56px) + var(--territory-page-pad-top) +
      var(--territory-crumb-band)
  );
}

@media (min-width: 901px) {
  .games-page:has(.territory-stage) .territory-stage .arcade.mode-menu,
  .games-page:has(.territory-stage) .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) {
    --territory-lobby-deck: 248px;
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck)),
      calc((100vw - 48px) * 9 / 16)
    );
  }

  .territory-stage .arcade.mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .play-column {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
  }

  .territory-stage .arcade.mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .canvas-frame {
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
  }

  .territory-stage .arcade.mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) .control-panel {
    height: fit-content;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 900.98px) {
  .games-page:has(.territory-stage) .territory-stage,
  .games-page:has(.territory-stage) .territory-stage .arcade.mode-menu {
    --territory-tab-band: 0px;
    --territory-page-pad-top: 0px;
    /* One row when the labels fit; wrapped tabs stay content-width. */
    --territory-crumb-band: 80px;
    --territory-lobby-chrome: calc(
      var(--site-header-height, 56px) + var(--territory-crumb-band)
    );
    --territory-lobby-deck: 360px;
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck)),
      calc(100vw * 9 / 16)
    );
  }

  .territory-stage .arcade.mode-menu,
  .games-page:has(.territory-stage) .arcade.mode-menu {
    justify-content: flex-start;
  }

  .territory-stage .arcade.mode-menu .game-layout {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
  }

  .territory-stage .arcade.mode-menu .play-column {
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
  }

  .territory-stage .arcade.mode-menu .canvas-frame,
  #territory-root.mode-menu .canvas-frame {
    aspect-ratio: 16 / 9;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
  }

  .territory-stage .arcade.mode-menu .control-panel {
    flex: 0 0 auto;
  }

  .territory-stage #territory-root[data-lobby-view="rankings"] .lobby-controls {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  .territory-stage #territory-root[data-lobby-view="rankings"] .territory-hof {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
}

/* ── Mid-width stage span + narrow pause pair (901–1366 / 390–760).
   ≤1366: still, instrument deck, and HOF board are the stage width —
   no 64:104 pillar, no 280px floating card, no side void. GALLERY still
   is 16:9 of the stage (canvas fills the frame). TOP TIMES sits in the
   deck. 1440×900 keeps the existing garage stack.
   2-col difficulty | TOP TIMES only when the d-pad is off (≥901).
   ≤760 pause: stack the Racing pair to two 48px rows (RESUME on top)
   so BACK TO DIFFICULTY cannot grow taller. Touch: one aligned row. ── */

@media (max-width: 1366px) {
  .territory-stage .arcade.mode-menu,
  .games-page:has(.territory-stage) .territory-stage .arcade.mode-menu,
  .territory-stage .arcade.mode-menu .game-layout,
  .games-page:has(.territory-stage) .mode-menu .game-layout {
    --territory-lobby-deck: 228px;
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck)),
      1000px
    );
  }

  .territory-stage .arcade.mode-menu .game-layout,
  .territory-stage .arcade.mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))),
  .territory-stage .arcade.mode-menu .play-column,
  .territory-stage .arcade.mode-menu .control-panel,
  .territory-stage .arcade.mode-menu .canvas-frame,
  .territory-stage .arcade.mode-menu .lobby-controls,
  .territory-stage .arcade.mode-menu .lobby-start-cluster,
  .territory-stage .arcade.mode-menu .territory-hof,
  #territory-root[data-lobby-view="rankings"] .game-layout,
  #territory-root[data-lobby-view="rankings"] .control-panel,
  #territory-root[data-lobby-view="rankings"] .lobby-controls,
  #territory-root[data-lobby-view="rankings"] .territory-hof,
  #territory-root[data-lobby-view="rankings"] .lobby-start-cluster {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .territory-stage .arcade.mode-menu .game-layout,
  .territory-stage .arcade.mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    grid-template-columns: none;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    min-height: 0;
    max-height: calc(100dvh - var(--territory-lobby-chrome));
  }

  .territory-stage .arcade.mode-menu .canvas-frame,
  #territory-root.mode-menu .canvas-frame {
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck, 228px)),
      calc(100vw * 9 / 16)
    );
    aspect-ratio: auto;
    width: 100%;
    max-width: 100%;
    height: var(--territory-board-h);
    max-height: var(--territory-board-h);
    min-height: 0;
    margin: 0;
  }

  .territory-stage .arcade.mode-menu .canvas-frame canvas,
  #territory-root.mode-menu .canvas-frame canvas {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
  }

  .territory-stage .arcade.mode-menu .control-panel {
    align-self: stretch;
    position: static;
    max-width: none;
  }

  #territory-root[data-lobby-view="rankings"] .territory-hof {
    align-self: stretch;
  }

  #territory-root[data-lobby-view="rankings"].mode-menu .game-layout {
    height: calc(100dvh - var(--territory-lobby-chrome));
    max-height: calc(100dvh - var(--territory-lobby-chrome));
    overflow: hidden;
  }

  #territory-root[data-lobby-view="rankings"] .control-panel,
  #territory-root[data-lobby-view="rankings"] .lobby-controls {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #territory-root[data-lobby-view="rankings"] .territory-hof {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }

  #territory-root[data-lobby-view="rankings"] .lobby-start-cluster {
    flex: 0 0 auto;
  }

  #territory-root[data-lobby-view="rankings"] .touch-lobby-guide,
  #territory-root[data-lobby-view="rankings"] .art-note {
    display: none;
  }
}

@media (max-width: 700px) {
  .territory-stage .arcade.mode-menu,
  .games-page:has(.territory-stage) .territory-stage .arcade.mode-menu,
  .territory-stage .arcade.mode-menu .game-layout,
  .games-page:has(.territory-stage) .mode-menu .game-layout {
    --territory-lobby-deck: 248px;
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck)),
      calc(100vw * 9 / 16)
    );
  }

  .territory-stage .arcade.mode-menu .canvas-frame,
  #territory-root.mode-menu .canvas-frame {
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck, 248px)),
      calc(100vw * 9 / 16)
    );
    aspect-ratio: 16 / 9;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: var(--territory-board-h);
  }

  .territory-stage .arcade.mode-menu .lobby-controls {
    display: flex;
    flex-direction: column;
  }
}

@media (min-width: 901px) and (max-width: 1366px) {
  .territory-stage .arcade.mode-menu .lobby-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.9fr);
    gap: 12px 16px;
    align-items: start;
    width: 100%;
  }

  #territory-root[data-lobby-view="rankings"] .lobby-controls {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
  }

  #territory-root[data-lobby-view="rankings"] .territory-hof,
  #territory-root[data-lobby-view="rankings"] .lobby-start-cluster {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  /* Narrow pause/finish: stack so BACK TO DIFFICULTY stays one 48px row. */
  .territory-stage .end-actions-bar.rbtns,
  .territory-stage .end-actions-bar.rbtns.racing-pair,
  .territory-stage .pause-result .end-actions-bar.rbtns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .territory-stage .end-actions-bar.rbtns .primary-button,
  .territory-stage .end-actions-bar.rbtns.racing-pair .primary-button,
  .territory-stage .end-actions-bar.rbtns .secondary-button,
  .territory-stage .end-actions-bar.rbtns.racing-pair .secondary-button {
    width: 100%;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .territory-stage .mode-playing .dpad,
  .territory-stage .mode-paused .dpad {
    flex: 0 0 auto;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 4px;
  }

  .territory-stage .mode-playing .draw-toggle,
  .territory-stage .mode-paused .draw-toggle,
  .territory-stage:not(.is-learning) .mode-playing .draw-toggle,
  .territory-stage:not(.is-learning) .mode-paused .draw-toggle {
    flex: 1 1 120px;
    width: auto;
    max-width: 168px;
    height: 84px;
    min-height: 84px;
    max-height: 84px;
  }

  .territory-stage .draw-toggle strong {
    font-size: 13px;
    letter-spacing: 0.6px;
  }

  .territory-stage .draw-toggle span {
    font-size: 10px;
    line-height: 1.2;
  }

  .territory-stage .touch-controls .touch-pause,
  .territory-stage .touch-controls.active .touch-pause {
    display: none !important;
  }
  .territory-stage .play-hud-actions .touch-pause {
    display: inline-flex;
  }
}

@media (min-width: 761px) {
  .territory-stage .end-actions-bar.rbtns,
  .territory-stage .end-actions-bar.rbtns.racing-pair {
    grid-template-columns: 1fr 1fr;
  }

  .territory-stage .end-actions-bar.rbtns .primary-button,
  .territory-stage .end-actions-bar.rbtns .secondary-button {
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    white-space: nowrap;
  }
}

/* ── Width sweep: 412 / 768 / 900 play is the phone width, not a 64:104
   pillar. HUD labels wrap instead of colliding. The mobile DRAW hint
   shows only while the d-pad is on (≤900). Desktop widths get WASD.
   Phone queries use 900.98px so a 900px viewport that lays out a fraction
   past 900 still takes this sheet. min-width 901px is unchanged. ── */
@media (max-width: 900.98px) {
  .territory-stage:has(.mode-playing),
  .territory-stage:has(.mode-paused) {
    overflow: hidden;
  }

  .territory-stage:has(.mode-playing) .arcade,
  .territory-stage:has(.mode-paused) .arcade {
    overflow-x: hidden;
    overflow-y: auto;
    height: 100%;
    max-height: 100%;
  }

  .territory-stage:has(.mode-playing) .game-layout,
  .territory-stage:has(.mode-paused) .game-layout,
  .territory-stage:has(.mode-cleared) .game-layout,
  .territory-stage:has(.mode-gameover) .game-layout,
  .territory-stage:has(.mode-finished) .game-layout {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .territory-stage .mode-playing .play-column,
  .territory-stage .mode-paused .play-column,
  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    /* Play column is the phone width — do not shrink to board-h * 64/104. */
    width: 100%;
    max-width: 100%;
    margin: 0;
    align-items: stretch;
  }

  .territory-stage:has(.mode-playing) .mode-playing .canvas-frame,
  .territory-stage:has(.mode-paused) .mode-paused .canvas-frame,
  .territory-stage .mode-playing .canvas-frame,
  .territory-stage .mode-paused .canvas-frame,
  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame,
  .territory-stage .mode-cleared .canvas-frame,
  .territory-stage .mode-gameover .canvas-frame,
  .territory-stage .mode-finished .canvas-frame {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    aspect-ratio: 64 / 104;
    margin: 0;
    flex: 0 0 auto;
  }

  .territory-stage .arcade.mode-menu .lobby-controls {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .territory-stage .arcade.mode-menu .play-column,
  .territory-stage .arcade.mode-menu .control-panel,
  .territory-stage .arcade.mode-menu .canvas-frame {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .territory-stage .play-hud {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding-left: 10px;
    padding-right: 10px;
  }

  .territory-stage .play-hud-row {
    flex-wrap: wrap;
    min-width: 0;
  }

  .territory-stage .field-vitals {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 8px 16px;
    min-width: 0;
    max-width: none;
  }

  .territory-stage .fuse-timer {
    flex: 1 1 140px;
    min-width: 0;
    max-width: none;
  }

  .territory-stage .field-lives-block,
  .territory-stage .field-caught-block {
    flex: 0 0 auto;
    min-width: 0;
  }

  .territory-stage .play-hud-msg {
    height: auto;
    min-height: 2.8em;
    max-height: none;
    overflow: visible;
  }

  .territory-stage .play-hud-msg .play-coach,
  .territory-stage .play-hud-msg .game-toast,
  .territory-stage .play-hud-msg .play-keys {
    position: static;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .territory-stage .mode-menu .touch-lobby-guide {
    display: block;
  }
}

/* ── 768–900 inclusive: header/crumb/tabs unclipped, START on screen,
   play is stage-width 16:9 (not a 64:104 pillar), pause only above HUD `?`,
   bottom row is d-pad + DRAW, HUD hint wraps in full.
   The cutoff is 900.98px, not 900px: a 900px viewport can lay out at
   ~900.06px, which misses both max-width 900 and min-width 901 and falls
   through to the 64:104 pillar. 901 stays on the desktop rules. ── */
@media (min-width: 768px) and (max-width: 900.98px) {
  .games-page:has(.territory-stage) .territory-stage,
  .games-page:has(.territory-stage) .territory-stage .arcade.mode-menu,
  .territory-stage .arcade.mode-menu,
  .territory-stage .arcade.mode-menu .game-layout {
    --territory-crumb-band: 80px;
    --territory-lobby-deck: 360px;
    --territory-board-h: min(
      calc(100dvh - var(--territory-lobby-chrome) - var(--territory-lobby-deck)),
      calc(100vw * 9 / 16)
    );
    --territory-play-hud: 148px;
    /* +116: d-pad row (108) + the HUD's real overshoot past 148px, so the
       sticky d-pad never covers the board's bottom rows on short tablets. */
    --territory-play-chrome: calc(var(--territory-play-hud) + 116px);
  }

  .territory-stage .arcade.mode-menu .game-layout,
  .territory-stage .arcade.mode-menu .lobby-controls,
  .territory-stage .arcade.mode-menu .lobby-start-cluster,
  .territory-stage .arcade.mode-menu .territory-hof,
  .territory-stage .arcade.mode-menu .hof-head,
  .territory-stage .arcade.mode-menu .hof-scope,
  .territory-stage .mode-menu .topbar,
  .territory-chrome,
  .territory-chrome .lobby-tabs,
  .territory-chrome .lobby-tabs button {
    overflow: visible;
    max-width: 100%;
  }

  .territory-stage .arcade.mode-menu .lobby-controls,
  .territory-stage .arcade.mode-menu .game-layout .lobby-controls,
  #territory-root[data-lobby-view="garage"] .lobby-controls,
  #territory-root[data-lobby-view="rankings"] .lobby-controls {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .territory-stage .arcade.mode-menu .play-column,
  .territory-stage .arcade.mode-menu .control-panel,
  .territory-stage .arcade.mode-menu .canvas-frame,
  .territory-stage .mode-menu .control-panel {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0;
    margin-right: 0;
    align-self: stretch;
  }

  .territory-stage .arcade.mode-menu .canvas-frame,
  #territory-root.mode-menu .canvas-frame {
    aspect-ratio: 16 / 9 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: var(--territory-board-h) !important;
  }

  .territory-hof .hof-head,
  #territory-root[data-lobby-view="garage"] .hof-head,
  #territory-root[data-lobby-view="rankings"] .hof-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    grid-template-columns: none;
  }

  .territory-hof .hof-eyebrow,
  .territory-hof .hof-scope,
  #territory-root[data-lobby-view="rankings"] .hof-scope {
    overflow: visible;
    white-space: nowrap;
    text-overflow: unset;
    justify-self: start;
    text-align: left;
    min-width: 0;
  }

  .territory-stage .mode-menu .start-button {
    display: inline-flex;
    width: 100%;
    min-height: 48px;
    height: auto;
  }

  .territory-stage .mode-playing .play-column,
  .territory-stage .mode-paused .play-column,
  .territory-stage:has(.mode-playing) .play-column,
  .territory-stage:has(.mode-paused) .play-column {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    align-items: stretch;
  }

  .territory-stage:has(.mode-playing) .mode-playing .canvas-frame,
  .territory-stage:has(.mode-paused) .mode-paused .canvas-frame,
  .territory-stage .mode-playing .canvas-frame,
  .territory-stage .mode-paused .canvas-frame,
  .territory-stage:has(.mode-playing) .canvas-frame,
  .territory-stage:has(.mode-paused) .canvas-frame {
    /* 768–900 play is 16:9 of the page — do not shrink to board-h * 64/104. */
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: auto !important;
    height: min(
      calc(100vw * 9 / 16),
      calc(100dvh - var(--territory-play-chrome))
    ) !important;
    max-height: min(
      calc(100vw * 9 / 16),
      calc(100dvh - var(--territory-play-chrome))
    ) !important;
    margin: 0;
    flex: 0 0 auto;
  }

  .territory-stage .mode-playing .canvas-frame canvas,
  .territory-stage .mode-paused .canvas-frame canvas {
    max-width: 100%;
    margin: 0 auto;
  }

  .territory-stage .play-hud {
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  .territory-stage .play-hud-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .territory-stage .touch-controls .touch-pause,
  .territory-stage .touch-controls.active .touch-pause {
    display: none !important;
  }

  .territory-stage .play-hud-actions .touch-pause {
    display: inline-flex;
  }

  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    display: flex;
    flex-direction: row;
    justify-content: center;
    width: 100%;
  }

  .territory-stage .play-hud-msg,
  .territory-stage .play-coach,
  .territory-stage .play-keys,
  .territory-stage .game-toast {
    height: auto;
    max-height: none;
    overflow: visible;
    white-space: normal;
    text-overflow: unset;
  }
}

@media (min-width: 901px) {
  /* Desktop hint under START — not the mobile DRAW/d-pad line. */
  .territory-stage .mode-menu .touch-lobby-guide {
    display: block;
  }
}



/* ── Rules on the page, not a pop-up ─────────────────────────────────────
   Playtest: HOW TO PLAY opened on every start. Rules sit under START,
   before the records, and wrap in the play HUD. The ? help stays optional. */
  .territory-stage .territory-rules {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line-strong);
    background: var(--panel2);
  }

  .territory-stage .territory-rules-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px 20px;
  }

  .territory-stage .territory-rules-list li {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    column-gap: 8px;
    row-gap: 2px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .territory-stage .territory-rules-list .rules-index {
    grid-row: 1 / span 2;
    font: 700 11px/1.2 var(--mono);
    letter-spacing: 0.04em;
    color: var(--dim, var(--muted));
  }

  .territory-stage .territory-rules-list strong {
    font: 700 13px/1.25 var(--heading);
    color: var(--txt, var(--white));
  }

  .territory-stage .territory-rules-list li > span:last-child {
    font: 400 13px/1.45 var(--body-font);
    color: var(--body);
  }

  .territory-stage .territory-rules-controls {
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid var(--line, var(--hairline));
    font: 500 10px/1.45 var(--mono);
    letter-spacing: 0.2px;
    color: var(--dim, var(--muted));
  }

  .territory-stage .territory-rules-controls kbd {
    display: inline-block;
    margin: 0 1px;
    padding: 0 4px;
    background: var(--well, #0a0a0a);
    border: 1px solid var(--line, var(--hairline));
    border-bottom-width: 2px;
    font: 700 9px/1.6 var(--mono);
    color: var(--txt, var(--white));
    text-transform: none;
  }

  .territory-stage .mode-menu .lobby-start-cluster .touch-lobby-guide {
    display: none;
  }

  @media (min-width: 901px) {
    .territory-stage .territory-rules-list {
      grid-template-columns: 1fr 1fr;
    }
  }

 .territory-stage .territory-rules-keys {
   display: none;
 }

#territory-root[data-lobby-view="rankings"] .territory-rules {
  display: none;
}

/* ≥901: records sit on the still (Racing card). Heat + start is one bar.
   Rules are a full-width strip — never a size-contained scroller.
   368 left the last rules line 7px past the fold at 1280×800 and 1440×900. */
@media (min-width: 901px) {
  .games-page:has(.territory-stage) .territory-stage .arcade.mode-menu,
  .games-page:has(.territory-stage) .mode-menu .game-layout:not(
      :has(.ad-slot--left:not(:empty):not([hidden]))
    ):not(:has(.ad-slot--right:not(:empty):not([hidden]))) {
    --territory-lobby-deck: 384px;
  }

  #territory-root.mode-menu[data-lobby-view="garage"] .lobby-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  #territory-root.mode-menu[data-lobby-view="garage"] .lobby-controls > .territory-hof {
    position: absolute;
    top: 22px;
    right: 16px;
    z-index: 6;
    width: min(320px, 28%);
    max-height: min(220px, calc(var(--territory-board-h) - 180px));
    margin: 0;
    overflow: auto;
    border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--hairline-strong));
    background: rgba(8, 8, 8, 0.78);
    backdrop-filter: blur(8px);
  }

  #territory-root.mode-menu[data-lobby-view="garage"] .lobby-controls > .territory-rules {
    contain: none;
    min-height: 0;
    overflow: visible;
    word-break: keep-all;
  }
}

/* In-play rules sit in the HUD and wrap. The coach used to paint on top
   of that line, so the wall-return and score rules were unreadable. */
.territory-stage .play-hud-msg:has(.play-rules:not([hidden])) {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  flex: 0 0 auto;
}

.territory-stage .play-hud-msg:has(.play-rules:not([hidden])) .play-coach,
.territory-stage .play-hud-msg:has(.play-rules:not([hidden])) .game-toast,
.territory-stage .play-hud-msg:has(.play-rules:not([hidden])) .play-keys,
.territory-stage .play-hud-msg:has(.play-rules:not([hidden])) .play-rules {
  position: static;
  inset: auto;
  width: auto;
  max-width: 100%;
  margin: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  text-align: left;
}

.territory-stage .play-hud-msg .play-rules {
  font: 500 12px/1.4 var(--mono);
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--white) 82%, var(--muted));
}

.territory-stage .play-rules[hidden] {
  display: none;
}

/* ── QA fixes: reachable result cards, phone board above the d-pad, lobby scroll ──
   768–900: cleared / game over / finish kept the ≤900 64:104 frame (≈1.6× the
   page width tall), so the stage-clear card centred far below the fold and the
   name field / submit / next could not be reached. Use the same 16:9 page-width
   board as play. 900.98px matches the play query so a fractional 900px
   viewport does not keep the tall frame. */
@media (min-width: 768px) and (max-width: 900.98px) {
  .territory-stage .mode-cleared .canvas-frame,
  .territory-stage .mode-gameover .canvas-frame,
  .territory-stage .mode-finished .canvas-frame {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: auto !important;
    height: min(
      calc(100vw * 9 / 16),
      calc(100dvh - var(--territory-play-chrome))
    ) !important;
    max-height: min(
      calc(100vw * 9 / 16),
      calc(100dvh - var(--territory-play-chrome))
    ) !important;
    margin: 0;
    flex: 0 0 auto;
  }
}

/* Result cards never outgrow the board: the souvenir block shrinks/scrolls
   first, and the whole card scrolls as a last resort, so name / submit / next
   stay reachable at any height. */
.territory-stage .clear-banner .end-card,
.territory-stage .board-overlay .end-card {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* <768 phone: the 64:104 frame at full width was taller than the space left
   between the HUD and the d-pad, so the sticky controls covered the bottom
   rows (and often the spawn). The frame now takes exactly the remaining
   height; the canvas letterboxes inside it so cells stay square. */
@media (max-width: 767px) {
  .territory-stage .mode-playing .play-column,
  .territory-stage .mode-paused .play-column {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0;
  }

  .territory-stage .mode-playing .canvas-frame,
  .territory-stage .mode-paused .canvas-frame {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
    aspect-ratio: auto !important;
  }

  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    position: static !important;
    flex: 0 0 auto;
  }
}

/* ≤900 lobby: rules / TOP TIMES under START can run past the fold; let the
   lobby scroll instead of clipping them. */
@media (max-width: 900.98px) {
  #territory-root.mode-menu .game-layout {
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* <768 phone result cards: on short phones the 64:104 frame ran past the
   viewport and the card's last button (next) could not be reached. Cap the
   frame at the space below the HUD; the card scrolls inside it. */
@media (max-width: 767px) {
  .territory-stage .mode-cleared .canvas-frame,
  .territory-stage .mode-gameover .canvas-frame,
  .territory-stage .mode-finished .canvas-frame {
    aspect-ratio: auto !important;
    height: min(calc(100vw * 104 / 64), calc(100dvh - var(--territory-play-hud) - 8px)) !important;
    max-height: min(calc(100vw * 104 / 64), calc(100dvh - var(--territory-play-hud) - 8px)) !important;
  }

  /* The portrait souvenir was taller than the card, so the score sentence
     and the name field sat under the fold while Next was already visible. */
  .territory-stage .clear-result .souvenir-still,
  .territory-stage .board-portrait .clear-result .souvenir-still {
    width: min(100%, 200px);
    max-height: 64px;
    aspect-ratio: 16 / 9;
  }

  .territory-stage .clear-result .end-actions-bar {
    position: static;
  }


}

/* Landscape phones are wider than 900 but have no keyboard. The 901px
   rule hides the d-pad for mouse desktops; a coarse no-hover pointer
   still needs it, in flow under the board. */
@media (min-width: 901px) and (hover: none) and (pointer: coarse) {
  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    display: flex !important;
    position: static !important;
    flex: 0 0 auto;
  }
}

/* Racing hero feel: title on the still, start beside the heat, no center mark. */
.territory-stage .lobby-hero {
  display: none;
}
.territory-stage .mode-menu .lobby-hero {
  display: grid;
  position: absolute;
  z-index: 3;
  left: 18px;
  right: 72px;
  bottom: 16px;
  gap: 6px;
  max-width: 38rem;
  pointer-events: none;
}
.territory-stage .lobby-hero__eyebrow {
  margin: 0;
  color: var(--accent);
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.territory-stage .lobby-hero__title {
  margin: 0;
  color: var(--white);
  font: 700 clamp(26px, 3vw, 40px)/1.05 var(--heading);
  letter-spacing: 0;
  text-transform: uppercase;
}
.territory-stage .lobby-hero__lead {
  margin: 0;
  max-width: 46ch;
  color: var(--body);
  font: 400 14px/1.45 var(--body-font);
}
.territory-stage .start-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.territory-stage .start-button__label,
.territory-stage .start-button__sub {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.territory-stage .start-button__sub {
  opacity: 0.72;
  font: 500 10px/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
@media (min-width: 901px) {
  .territory-stage .mode-menu .lobby-start-cluster {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    grid-template-areas:
      "label label"
      "diff go"
      "meta go"
      "guide guide"
      "note note";
    align-items: stretch;
    column-gap: 10px;
  }
  .territory-stage .mode-menu .lobby-start-cluster > .section-label {
    grid-area: label;
  }
  .territory-stage .mode-menu .lobby-start-cluster .difficulty-list {
    grid-area: diff;
    margin: 0;
  }
  .territory-stage .mode-menu .lobby-start-cluster .start-button {
    grid-area: go;
    width: auto;
    height: auto;
    min-height: 58px;
    margin-top: 0;
  }
  .territory-stage .mode-menu .lobby-start-cluster .difficulty-meta-line {
    grid-area: meta;
  }
  .territory-stage .mode-menu .lobby-start-cluster .touch-lobby-guide {
    grid-area: guide;
  }
  .territory-stage .mode-menu .lobby-start-cluster .art-note {
    grid-area: note;
  }
}

.territory-stage .mode-menu .start-button {
  height: auto;
  min-height: 52px;
}

@media (max-width: 900.98px) {
  .territory-stage .mode-playing .touch-controls.active,
  .territory-stage .mode-paused .touch-controls.active {
    justify-content: flex-start;
    gap: 12px;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .territory-stage .mode-paused .touch-controls.active {
    opacity: 0.4;
    pointer-events: none;
  }

  .territory-stage .mode-playing .play-hud,
  .territory-stage .mode-paused .play-hud,
  .territory-stage .mode-cleared .play-hud,
  .territory-stage .mode-gameover .play-hud,
  .territory-stage .mode-finished .play-hud {
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }
}

@media (max-width: 480px) {
  .territory-stage .mode-playing .draw-toggle,
  .territory-stage .mode-paused .draw-toggle,
  .territory-stage:not(.is-learning) .mode-playing .draw-toggle,
  .territory-stage:not(.is-learning) .mode-paused .draw-toggle {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
  }
}

.territory-stage .mode-menu .preview-stamp {
  padding: 0;
  border: 0;
  background: transparent;
  gap: 0;
}
.territory-stage .mode-menu .preview-stamp .status-dot,
.territory-stage .mode-menu .preview-stamp [data-i18n-stamp] {
  display: none;
}
 .territory-stage .how-button,
 .territory-stage .mode-menu .preview-stamp .how-button {
   width: 44px;
   height: 44px;
   min-width: 44px;
   min-height: 44px;
 }

.territory-stage .mode-playing .control-panel,
.territory-stage .mode-paused .control-panel,
.territory-stage .mode-gameover .control-panel,
.territory-stage .mode-cleared .control-panel,
.territory-stage .mode-finished .control-panel {
  display: none !important;
}
 
 /* Short landscape phones: a stacked HUD + d-pad left the 16:9 board as a
    thin strip. Put the pad beside the board and let the frame take the
    leftover height. Square cells still letterbox inside the frame. */
 @media (orientation: landscape) and (max-height: 520px) {
   .territory-stage .mode-playing .play-column,
   .territory-stage .mode-paused .play-column {
     display: grid !important;
     grid-template-columns: minmax(0, 1fr) auto;
     grid-template-rows: auto minmax(0, 1fr);
     min-height: 0;
     height: 100%;
   }
 
   .territory-stage .mode-playing .play-hud,
   .territory-stage .mode-paused .play-hud {
     grid-column: 1 / -1;
     --territory-play-hud: 72px;
   }
 
   .territory-stage .mode-playing .play-hud-msg,
   .territory-stage .mode-paused .play-hud-msg {
     display: none;
   }
 
   .territory-stage:has(.mode-playing) .mode-playing .canvas-frame,
   .territory-stage:has(.mode-paused) .mode-paused .canvas-frame,
   .territory-stage .mode-playing .canvas-frame,
   .territory-stage .mode-paused .canvas-frame {
     grid-column: 1;
     grid-row: 2;
     width: 100% !important;
     max-width: none !important;
     height: 100% !important;
     max-height: none !important;
     min-height: 0 !important;
     aspect-ratio: auto !important;
     flex: 1 1 auto !important;
   }
 
   .territory-stage .mode-playing .touch-controls.active,
   .territory-stage .mode-paused .touch-controls.active {
     grid-column: 2;
     grid-row: 2;
     display: flex !important;
     flex-direction: column;
     justify-content: flex-end;
     width: auto;
     padding: 4px 8px 8px 4px;
   }

  .territory-stage .mode-cleared,
  .territory-stage .mode-gameover,
  .territory-stage .mode-finished {
    --territory-play-hud: 72px;
    /* Real HUD is ~97px (stage row + time/lives). 80 slid the card under it. */
    --territory-play-chrome: 112px;
  }

  .territory-stage .mode-cleared .canvas-frame,
  .territory-stage .mode-gameover .canvas-frame,
  .territory-stage .mode-finished .canvas-frame {
    width: 100% !important;
    max-width: none !important;
    aspect-ratio: auto !important;
    height: calc(100dvh - var(--territory-play-chrome)) !important;
    max-height: calc(100dvh - var(--territory-play-chrome)) !important;
    min-height: 0 !important;
    overflow: hidden;
  }

  .territory-stage .mode-cleared .end-card,
  .territory-stage .mode-gameover .end-card,
  .territory-stage .mode-finished .end-card {
    max-height: 100%;
  }

  .territory-stage .mode-gameover .play-column > .board-overlay:not([hidden]),
  .territory-stage .mode-cleared .play-column > .clear-banner:not([hidden]),
  .territory-stage .mode-finished .play-column > .clear-banner:not([hidden]) {
    top: 100px;
    bottom: 0;
    height: auto;
  }


  .territory-stage .mode-cleared .play-hud-msg,
  .territory-stage .mode-gameover .play-hud-msg,
  .territory-stage .mode-finished .play-hud-msg {
    display: none;
  }

 }

/* Desktop start bar — same instrument as Racing: label, heat segment with
   pips, start on the right. Not one cramped strip. */
@media (min-width: 901px) {
  .territory-stage .mode-menu .lobby-start-cluster {
    display: grid;
    align-items: end;
    gap: 6px 16px;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 240px);
    grid-template-areas:
      "label go"
      "diff go";
    padding: 12px;
    border: 1px solid var(--line-strong);
    background: var(--panel2);
  }

  .territory-stage .mode-menu .lobby-start-cluster > .section-label {
    display: block;
    grid-area: label;
    margin: 0;
  }

  .territory-stage .mode-menu .lobby-start-cluster .art-note,
  .territory-stage .mode-menu .lobby-start-cluster .touch-lobby-guide,
  .territory-stage .mode-menu .lobby-start-cluster .difficulty-meta-line {
    display: none;
  }

  .territory-stage .mode-menu .lobby-start-cluster .difficulty-list {
    grid-area: diff;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line-strong);
    background: transparent;
  }

  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty .difficulty-card {
    display: grid;
    gap: 6px;
    justify-items: center;
    align-content: center;
    min-height: 52px;
    padding: 8px 6px;
    box-shadow: none;
    box-shadow: none;
  }

  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty .difficulty-card.on,
  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty .difficulty-card.selected {
    color: var(--txt);
    background: color-mix(in srgb, var(--difficulty-color, var(--acc)) 20%, var(--panel2));
    box-shadow: inset 0 -3px 0 var(--difficulty-color, var(--acc));
  }

  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty .difficulty-card .dpips {
    display: flex;
  }

  .territory-stage .mode-menu .lobby-start-cluster .start-button {
    grid-area: go;
    align-self: end;
    width: 100%;
    height: 58px;
    min-height: 58px;
    margin: 0;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--accent);
    box-shadow: none;
  }

  .territory-stage .mode-menu .lobby-start-cluster .start-button__sub {
    display: block;
  }
}

/* Play HUD labels stay quiet. Accent is the meter and the lives, not every caption. */
.territory-stage .play-hud .mini-label,
.territory-stage .play-hud .claim-hud-kicker,
.territory-stage .claim-hud-kicker {
  color: var(--dim, var(--muted));
}

.territory-stage .play-coach kbd {
  display: inline-block;
  margin: 0 1px;
  padding: 0 4px;
  border: 1px solid var(--line, var(--hairline-strong));
  border-bottom-width: 2px;
  background: var(--well, #0a0a0a);
  font: 700 9px/1.6 var(--mono);
  color: var(--txt, var(--white));
}

.territory-stage .mode-playing .play-hud-actions,
.territory-stage .mode-paused .play-hud-actions {
  flex-direction: row;
  align-self: center;
}

@media (max-width: 900.98px) {
  .territory-stage .mode-menu .lobby-start-cluster {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line-strong);
    background: var(--panel2);
  }

  .territory-stage .mode-menu .lobby-start-cluster .difficulty-meta-line,
  .territory-stage .mode-menu .lobby-start-cluster .art-note,
  .territory-stage .mode-menu .lobby-start-cluster .touch-lobby-guide {
    display: none;
  }

  .territory-stage .mode-menu .lobby-start-cluster .difficulty-list,
  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty .difficulty-card {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 6px 2px;
    overflow: hidden;
  }

  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty .difficulty-card strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
  }

  .territory-stage .mode-menu .lobby-start-cluster .seg.difficulty .difficulty-card .dpips {
    display: none;
  }

  .territory-stage .mode-menu .lobby-start-cluster .start-button {
    width: 100%;
    min-height: 48px;
    margin: 0;
  }

  .territory-stage .mode-playing .play-hud-row,
  .territory-stage .mode-paused .play-hud-row {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .territory-stage .mode-playing .field-vitals,
  .territory-stage .mode-paused .field-vitals {
    flex: 0 0 auto;
    order: 0;
    width: auto;
    max-width: none;
  }

  .territory-stage .mode-playing .play-hud-stage [data-bind="hud-scene"],
  .territory-stage .mode-paused .play-hud-stage [data-bind="hud-scene"] {
    display: none;
  }
}

/* Timer is the last HUD row, flush with the board. The key line sits beside lives. */
.territory-stage .mode-playing .play-hud,
.territory-stage .mode-paused .play-hud {
  grid-template-areas:
    "row actions"
    "clock clock";
  align-items: center;
  padding-bottom: 0;
}

.territory-stage .play-hud > .fuse-timer {
  grid-area: clock;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
}

.territory-stage .play-hud-row > .field-vitals {
  flex: 0 0 auto;
}

  .territory-stage .play-hud-row > .play-hud-msg {
    position: relative;
    display: flex;
    align-items: flex-end;
    flex: 1 1 auto;
    min-width: 0;
    height: 16px;
    min-height: 16px;
    max-height: 16px;
    margin: 0 0 8px 4px;
    overflow: hidden;
    align-self: flex-end;
  }

  .territory-stage .hint-bit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .territory-stage .play-hud-row > .play-hud-msg .play-coach,
  .territory-stage .play-hud-row > .play-hud-msg .play-keys,
  .territory-stage .play-hud-row > .play-hud-msg .game-toast,
  .territory-stage .play-hud-row > .play-hud-msg .play-rules,
  .territory-stage .territory-rules-controls {
    position: static;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font: 500 10px/1 var(--mono);
    letter-spacing: 0.02em;
    color: var(--dim, var(--muted));
  }

  .territory-stage .play-coach kbd,
  .territory-stage .play-keys kbd,
  .territory-stage .territory-rules-controls kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    margin: 0;
    padding: 0 5px;
    border: 1px solid var(--line-strong, #3a3a3a);
    border-bottom-width: 1px;
    background: #111;
    font: 700 10px/1 var(--mono);
    color: var(--txt, var(--white));
  }

/* Phone row cannot hold stage + claim + lives + the hint. Stage stays one
   line; the hint drops under it instead of clipping to a few glyphs. */
@media (max-width: 900.98px) {
  .territory-stage .mode-playing .play-hud-stage,
  .territory-stage .mode-paused .play-hud-stage {
    flex: 0 0 auto;
    min-width: max-content;
  }

  .territory-stage .mode-playing .play-hud-stage .mini-label,
  .territory-stage .mode-paused .play-hud-stage .mini-label,
  .territory-stage .mode-playing .play-hud-stage strong,
  .territory-stage .mode-paused .play-hud-stage strong {
    white-space: nowrap;
  }

  .territory-stage .mode-playing .claim-hud-meter,
  .territory-stage .mode-paused .claim-hud-meter {
    width: 72px;
  }

  .territory-stage .mode-playing .play-hud-row,
  .territory-stage .mode-paused .play-hud-row {
    flex-wrap: wrap;
  }

  .territory-stage .mode-playing .play-hud-row > .play-hud-msg,
  .territory-stage .mode-paused .play-hud-row > .play-hud-msg {
    flex: 1 1 100%;
    order: 5;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    margin: 0;
    overflow: visible;
    align-self: stretch;
  }

  .territory-stage .mode-playing .play-hud-row > .play-hud-msg:not(:has(:not([hidden]))),
  .territory-stage .mode-paused .play-hud-row > .play-hud-msg:not(:has(:not([hidden]))) {
    display: none;
  }

  .territory-stage .mode-playing .play-hud-row > .play-hud-msg .play-coach,
  .territory-stage .mode-paused .play-hud-row > .play-hud-msg .play-coach,
  .territory-stage .mode-playing .play-hud-row > .play-hud-msg .play-keys,
  .territory-stage .mode-paused .play-hud-row > .play-hud-msg .play-keys {
    flex: 1 1 auto;
    max-width: 100%;
  }
}



 


/* Narrow / short screens: the final result must show name entry + submit
   without an inner scroll. Lift the card out of the board box to the
   viewport and drop the lines that repeat the header and summary. */
@media (max-width: 899px) {
  .territory-stage .clear-banner.finish-banner {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.78);
  }
  .territory-stage .clear-banner.finish-banner .end-card.finish-result {
    position: relative;
    inset: auto;
    transform: none;
    width: 100%;
    max-width: 520px;
    max-height: none;
    height: auto;
    margin: 0;
  }
  .territory-stage .finish-result .finish-layout {
    max-height: none;
    overflow: visible;
  }
  .territory-stage .finish-result .result-hero .result-kicker,
  .territory-stage .finish-result .result-hero .result-copy,
  .territory-stage .finish-result .record-lock,
  .territory-stage .finish-result .souvenir-cta-copy > span {
    display: none;
  }
  .territory-stage .finish-result .end-title {
    min-height: 0;
    padding-block: 10px;
  }
  .territory-stage .finish-result .end-body {
    padding-block: 8px;
    gap: 8px;
  }
  .territory-stage .finish-result .record-submit {
    padding: 8px 10px;
    gap: 6px;
  }
  .territory-stage .finish-result .souvenir-cta {
    min-height: 40px;
    padding-block: 6px;
  }
  .territory-stage .finish-result .end-actions-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 10px 10px;
  }
  .territory-stage .finish-result .end-actions-bar > button {
    min-height: 44px;
    margin: 0;
  }
}
@media (max-width: 899px) and (max-height: 700px) {
  .territory-stage .finish-result .collected-scenes > div {
    max-height: 56px;
  }
  .territory-stage .finish-result .souvenir-cta {
    display: none;
  }
}

/* Lobby sound toggle (Racing's "Sound" chip): top-right of the start cluster, M toggles in play. */
.territory-stage .lobby-start-cluster { position: relative; }
.territory-stage .lobby-sound {
  position: absolute; top: -3px; right: 0; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border: 1px solid var(--hairline-strong, #3a3a3a); background: transparent; color: var(--muted, #9a9a9a);
  font: 600 10px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.territory-stage .lobby-sound:hover { color: #fff; border-color: var(--accent, #ff4d00); }
.territory-stage .lobby-sound svg { width: 14px; height: 14px; }
.territory-stage .lobby-sound .icon-off { display: none; }
.territory-stage .lobby-sound[aria-pressed="false"] .icon-on { display: none; }
.territory-stage .lobby-sound[aria-pressed="false"] .icon-off { display: block; }
.territory-stage .lobby-sound[aria-pressed="false"] { opacity: .7; }
#territory-root[data-lobby-view="rankings"] .lobby-sound { display: none; }
