@font-face {
  font-family: 'Russo One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('img/russo-cyr.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Russo One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('img/russo-lat.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2190-21FF;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('img/oswald-cyr.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('img/oswald-lat.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2190-21FF;
}

:root {
  --bg: #05060F;
  --violet: #2B0B4A;
  --violet-hi: #6A1B8A;
  --pink: #FF4FA3;
  --floor: #0A0E1E;
  --neutral: #1B2440;
  --grid: #26315A;
  --cyan: #2EF2FF;
  --magenta: #FF2BD6;
  --orange: #FF8A1F;
  --purple: #9B4DFF;
  --text: #E8ECFF;
  --sub: #7F89B8;
  --hud-h: 104px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }

/* ---------------- background: the dusk grid ---------------- */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 108%, rgba(255, 79, 163, 0.20) 0%, rgba(106, 27, 138, 0.20) 26%, rgba(43, 11, 74, 0.10) 52%, transparent 72%),
    radial-gradient(90% 60% at 50% 118%, rgba(43, 11, 74, 0.55), transparent 70%),
    #05060F;
}
#stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(200, 220, 255, 0.75), transparent 60%),
    radial-gradient(1px 1px at 28% 11%, rgba(160, 190, 255, 0.55), transparent 60%),
    radial-gradient(1.4px 1.4px at 47% 18%, rgba(255, 210, 245, 0.6), transparent 60%),
    radial-gradient(1px 1px at 68% 9%, rgba(180, 210, 255, 0.6), transparent 60%),
    radial-gradient(1.2px 1.2px at 82% 24%, rgba(220, 200, 255, 0.6), transparent 60%),
    radial-gradient(1px 1px at 91% 13%, rgba(180, 220, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 6% 39%, rgba(180, 210, 255, 0.4), transparent 60%),
    radial-gradient(1px 1px at 95% 42%, rgba(255, 190, 235, 0.45), transparent 60%);
  opacity: 0.9;
  animation: twinkle 7s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.55; } to { opacity: 1; } }

#sunset {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.6s ease, filter 0.6s ease;
}
#sunGlow {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 130vmin;
  height: 130vmin;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%, rgba(255, 79, 163, 0.20), rgba(106, 27, 138, 0.15) 38%, transparent 68%);
  transition: opacity 0.6s ease, transform 0.8s ease;
}
#sun {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(55vmin, 530px);
  height: min(55vmin, 530px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: linear-gradient(180deg, #FFF0B0 0%, #FFD36A 14%, #FF9B5C 34%, #FF4FA3 58%, #B02CD0 82%, #6A1B8A 100%);
  -webkit-mask-image: repeating-linear-gradient(to bottom, #000 0 12px, transparent 12px 19px);
  mask-image: repeating-linear-gradient(to bottom, #000 0 12px, transparent 12px 19px);
  filter: drop-shadow(0 0 46px rgba(255, 79, 163, 0.6)) drop-shadow(0 0 110px rgba(106, 27, 138, 0.55));
  opacity: 0.92;
  transition: opacity 0.6s ease, filter 0.6s ease, transform 0.8s ease;
}
#horizon {
  position: absolute;
  left: -10%;
  right: -10%;
  top: 68%;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 79, 163, 0.05) 12%, #FF4FA3 50%, rgba(255, 79, 163, 0.05) 88%, transparent);
  box-shadow: 0 0 24px 6px rgba(255, 79, 163, 0.45), 0 0 90px 22px rgba(106, 27, 138, 0.35);
  opacity: 0.9;
}
#floor {
  position: absolute;
  left: -40%;
  right: -40%;
  top: 68%;
  height: 80%;
  background-image:
    linear-gradient(rgba(155, 77, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 77, 255, 0.22) 1px, transparent 1px);
  background-size: 64px 56px, 64px 56px;
  transform: perspective(420px) rotateX(68deg);
  transform-origin: top center;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,0.6) 40%, transparent 88%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,0.6) 40%, transparent 88%);
  animation: floormove 6s linear infinite;
  opacity: 0.9;
}
@keyframes floormove { from { background-position: 0 0, 0 0; } to { background-position: 0 56px, 0 0; } }
#bottomRim {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 79, 163, 0.85) 22%, #FF4FA3 50%, rgba(255, 79, 163, 0.85) 78%, transparent);
  box-shadow: 0 0 26px 5px rgba(255, 79, 163, 0.55);
  opacity: 0.85;
}
#arenaGlow {
  position: fixed;
  z-index: 1;
  pointer-events: none;
  border-radius: 40px;
  background: radial-gradient(62% 58% at 50% 62%, rgba(155, 77, 255, 0.62), rgba(106, 27, 138, 0.42) 40%, rgba(43, 11, 74, 0.16) 64%, transparent 82%);
  opacity: 0;
  transition: opacity 0.6s ease;
}
body.playing #arenaGlow { opacity: 0.95; }

body.playing #sun { opacity: 0; visibility: hidden; }
body.playing #floor { opacity: 0; visibility: hidden; }
body.playing #horizon { opacity: 0.5; }
body.playing #sunGlow { opacity: 0.6; }
body.playing #bottomRim { opacity: 0.55; }
body.menu #sunset { opacity: 1; }
body.victory #sunset { opacity: 1; filter: saturate(1.2) brightness(1.12); }
body.victory #sun { visibility: visible; opacity: 0.95; transform: translate(-50%, -48%) scale(1.06); }
body.victory #floor { visibility: visible; opacity: 0.55; }
body.victory #horizon { opacity: 1; }
body.defeat #sunset { filter: hue-rotate(-38deg) saturate(0.7) brightness(0.74); }
body.defeat #sun { visibility: visible; opacity: 0.28; }
body.defeat #floor { visibility: visible; opacity: 0.3; }

/* ---------------- phaser canvas and arena frame ---------------- */
#phaser {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
#phaser canvas { display: block; }
#arenaFrame {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  border: 2px solid rgba(46, 242, 255, 0.85);
  border-radius: 7px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 10px 1px rgba(46, 242, 255, 0.55),
    0 0 46px 6px rgba(46, 242, 255, 0.18),
    inset 0 0 26px rgba(46, 242, 255, 0.12);
  opacity: 0;
  transition: opacity 0.35s ease;
}
body.playing #arenaFrame, body.ending #arenaFrame { opacity: 1; animation: framebreathe 6.5s ease-in-out infinite; }
@keyframes framebreathe {
  0%, 100% {
    box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 0 10px 1px rgba(46,242,255,0.5), 0 0 42px 5px rgba(46,242,255,0.15), inset 0 0 26px rgba(46,242,255,0.12);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(255,255,255,0.16), 0 0 14px 2px rgba(46,242,255,0.68), 0 0 58px 9px rgba(46,242,255,0.22), inset 0 0 30px rgba(46,242,255,0.16);
  }
}
#arenaFrame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 5px;
  box-shadow: inset 0 0 60px rgba(106, 27, 138, 0.22);
}
#arenaFx {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.35s ease;
}
body.playing #arenaFx, body.ending #arenaFx { opacity: 1; }
#scan {
  position: absolute;
  left: 0; right: 0;
  height: 22%;
  background: linear-gradient(to bottom, transparent, rgba(46, 242, 255, 0.055) 45%, rgba(220, 245, 255, 0.09) 50%, rgba(46, 242, 255, 0.055) 55%, transparent);
  animation: scandrift 8s linear infinite;
  mix-blend-mode: screen;
}
@keyframes scandrift {
  0% { transform: translateY(-120%); }
  100% { transform: translateY(560%); }
}
.mote {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: rgba(180, 225, 255, 0.55);
  box-shadow: 0 0 6px rgba(120, 220, 255, 0.65);
  animation: motefloat linear infinite;
  opacity: 0;
}
@keyframes motefloat {
  0% { transform: translate(0, 18px); opacity: 0; }
  18% { opacity: 0.75; }
  80% { opacity: 0.4; }
  100% { transform: translate(14px, -60px); opacity: 0; }
}
#vignette {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  box-shadow: inset 0 0 140px 10px rgba(255, 43, 214, 0);
  transition: box-shadow 0.5s ease;
}
#vignette.on { box-shadow: inset 0 0 140px 10px rgba(255, 43, 214, 0.34); animation: vigpulse 2.2s ease-in-out infinite; }
@keyframes vigpulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
#deathVeil {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(26, 20, 46, 0) 20%, rgba(9, 10, 22, 0.7) 80%);
  opacity: 0;
  transition: opacity 0.8s ease;
}
body.dead #deathVeil { opacity: 1; }

/* ---------------- HUD ---------------- */
#hud {
  position: fixed;
  z-index: 10;
  top: calc(8px + var(--safe-t));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
body.playing #hud, body.ending #hud { opacity: 1; transform: translateY(0); }
.hudGrid {
  width: min(1120px, 100%);
  padding: 0 8px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "left mid right" "opps opps opps";
  align-items: start;
  gap: 6px 8px;
}
.hudLeft { grid-area: left; justify-self: start; }
.hudMid { grid-area: mid; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hudRight { grid-area: right; justify-self: end; }
#oppRow { grid-area: opps; }

.pod {
  position: relative;
  min-height: 44px;
  padding: 5px 14px 5px;
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(214, 236, 255, 0.95), rgba(110, 125, 210, 0.8) 46%, rgba(255, 122, 200, 0.85)) border-box;
  border: 1px solid transparent;
  background-clip: padding-box, border-box;
  box-shadow: 0 0 18px rgba(46, 242, 255, 0.14), inset 0 0 20px rgba(46, 242, 255, 0.06);
  color: var(--text);
}
.pod::before {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(13, 19, 44, 0.94), rgba(6, 9, 22, 0.95));
  z-index: 0;
}
.pod > * { position: relative; z-index: 1; }
.podLabel {
  display: block;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--sub);
  text-transform: uppercase;
  line-height: 1.1;
}
.terrTop { display: flex; align-items: center; gap: 8px; }
.terrValue {
  font-family: 'Russo One', 'Oswald', sans-serif;
  font-size: 22px;
  line-height: 1;
  color: #dff8ff;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(46, 242, 255, 0.55);
}
.terrBar {
  width: 86px;
  height: 5px;
  margin-top: 5px;
  border-radius: 4px;
  background: rgba(38, 49, 90, 0.85);
  overflow: hidden;
}
.terrBar i {
  display: block;
  height: 100%;
  width: 2%;
  border-radius: 4px;
  background: linear-gradient(90deg, #1a9cb4, var(--cyan));
  box-shadow: 0 0 10px rgba(46, 242, 255, 0.9);
  transition: width 0.25s ease-out;
}
.bestLine {
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--sub);
  white-space: nowrap;
}
.bestLine b {
  font-family: 'Russo One', sans-serif;
  font-weight: 400;
  color: #bff4ff;
  letter-spacing: 0.04em;
  margin-left: 4px;
}
.crownMark {
  display: none;
  width: 17px;
  height: 12px;
  flex: 0 0 17px;
  filter: drop-shadow(0 0 6px rgba(255, 215, 106, 0.8));
}
.crownMark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.crownMark.always { display: block; }
#terrCrown { display: none; margin-left: 2px; }
#terrCrown.on { display: block; animation: crownbob 2.4s ease-in-out infinite; }
@keyframes crownbob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.leaderPod {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 166px;
  padding: 5px 14px;
  justify-content: center;
}
.leaderPod .crownMark { width: 20px; height: 14px; flex-basis: 20px; }
.leaderPod.mine {
  box-shadow: 0 0 22px rgba(46, 242, 255, 0.28), inset 0 0 20px rgba(46, 242, 255, 0.1);
}
.leaderText { text-align: center; }
#leaderVal {
  font-family: 'Russo One', 'Oswald', sans-serif;
  font-size: 15px;
  line-height: 1.05;
  letter-spacing: 0.03em;
  color: #e9f7ff;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(46, 242, 255, 0.4);
}
.timerPod {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 18px;
  min-width: 150px;
  justify-content: center;
}
#timer {
  font-family: 'Russo One', 'Oswald', sans-serif;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: #f2f7ff;
  text-shadow: 0 0 16px rgba(160, 200, 255, 0.45);
}
.timerPod.low #timer {
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 79, 163, 0.9);
  animation: tickpulse 1s ease-in-out infinite;
}
@keyframes tickpulse { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.07); } 26% { transform: scale(1); } }
#multPod {
  font-family: 'Russo One', sans-serif;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 7px;
  color: #06131a;
  background: linear-gradient(180deg, #bffaff, #2ef2ff);
  box-shadow: 0 0 14px rgba(46, 242, 255, 0.75);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#multPod.on { opacity: 1; transform: scale(1); }
#multPod.hot { background: linear-gradient(180deg, #fff, #ffd0ec 40%, #ff4fa3); box-shadow: 0 0 18px rgba(255, 79, 163, 0.85); }
.hudRight .pod { text-align: right; min-width: 152px; }
#score {
  font-family: 'Russo One', 'Oswald', sans-serif;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  color: #f2f7ff;
  text-shadow: 0 0 12px rgba(46, 242, 255, 0.35);
  transition: transform 0.12s ease;
}
#score.bump { transform: scale(1.09); }
.scoreLine { display: flex; align-items: baseline; justify-content: flex-end; gap: 7px; }
.scoreLine span { font-size: 10px; letter-spacing: 0.18em; color: var(--sub); }

#oppRow {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  max-width: min(860px, 98vw);
  min-height: 24px;
  width: 100%;
}
.opp {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 7px 0 6px;
  border-radius: 7px;
  background: rgba(8, 12, 28, 0.84);
  border: 1px solid rgba(120, 137, 200, 0.32);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #cfd8f5;
  transition: opacity 0.3s ease, filter 0.3s ease, border-color 0.2s ease;
}
.opp.off { visibility: hidden; }
.opp svg { width: 13px; height: 13px; display: block; overflow: visible; }
.oppIcon { display: flex; align-items: center; }
.opp .oppPct { min-width: 24px; }
.opp.dead { opacity: 0.35; filter: grayscale(1); }
.opp.dead::after {
  content: '';
  position: absolute;
}
.opp .slash {
  display: none;
  position: absolute;
  left: 2px; right: 2px; top: 50%;
  height: 1.5px;
  background: #ff5f7a;
  transform: rotate(-18deg);
  box-shadow: 0 0 6px #ff2b4e;
}
.opp.dead .slash { display: block; }
.opp { position: relative; }
.opp.leader { border-color: rgba(255, 215, 106, 0.85); box-shadow: 0 0 14px rgba(255, 215, 106, 0.32); }
.opp .crownMark {
  display: none;
  position: absolute;
  left: 50%;
  top: -9px;
  margin-left: -8px;
  width: 16px;
  height: 11px;
  z-index: 2;
}
.opp.leader .crownMark { display: block; }
.opp[data-id="1"] { border-color: rgba(255, 43, 214, 0.35); }
.opp[data-id="2"] { border-color: rgba(255, 138, 31, 0.35); }
.opp[data-id="3"] { border-color: rgba(155, 77, 255, 0.35); }

/* ---------------- risk chip above player ---------------- */
#riskChip {
  position: fixed;
  z-index: 9;
  left: 0; top: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border-radius: 8px;
  border: 1px solid rgba(46, 242, 255, 0.72);
  background: rgba(6, 10, 24, 0.92);
  box-shadow: 0 0 14px rgba(46, 242, 255, 0.32), inset 0 0 10px rgba(46, 242, 255, 0.08);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) scale(0.7);
  transition: opacity 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  will-change: left, top;
}
#riskChip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  margin-left: -5px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(6, 10, 24, 0.92);
}
#riskChip .riskLabel {
  font-family: 'Oswald', sans-serif;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: #7f89b8;
  text-transform: uppercase;
}
#riskChip #riskVal {
  font-family: 'Russo One', sans-serif;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #d9fdff;
  text-shadow: 0 0 10px rgba(46, 242, 255, 0.7);
}
#riskChip.on { opacity: 1; transform: translate(-50%, -100%) scale(1); }
#riskChip.hot {
  border-color: rgba(255, 79, 163, 0.9);
  box-shadow: 0 0 18px rgba(255, 79, 163, 0.55), inset 0 0 10px rgba(255, 79, 163, 0.12);
}
#riskChip.hot #riskVal { color: #ffd0ec; text-shadow: 0 0 12px rgba(255, 79, 163, 0.9); }

/* ---------------- tutorial ---------------- */
#tutorial {
  position: fixed;
  z-index: 12;
  left: 0; right: 0;
  bottom: calc(22px + var(--safe-b));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#tutorial.on { opacity: 1; transform: translateY(0); }
#tutPill {
  pointer-events: none;
  max-width: min(560px, 92vw);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid rgba(160, 205, 255, 0.5);
  background: rgba(8, 12, 30, 0.88);
  box-shadow: 0 0 20px rgba(46, 242, 255, 0.18), inset 0 0 18px rgba(46, 242, 255, 0.06);
  font-size: 17px;
  color: #eaf3ff;
  line-height: 1.25;
  backdrop-filter: blur(6px);
}
#tutStep {
  font-family: 'Russo One', sans-serif;
  font-size: 12px;
  color: var(--cyan);
  letter-spacing: 0.08em;
  white-space: nowrap;
}
#tutHint {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #8fa0d6;
  text-transform: uppercase;
  opacity: 0.9;
}
#tutSkip {
  pointer-events: auto;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--sub);
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid rgba(127, 137, 184, 0.35);
  transition: color 0.15s ease, border-color 0.15s ease;
}
#tutSkip:hover { color: #cfd8f5; border-color: rgba(180, 200, 255, 0.6); }

/* ---------------- joystick ---------------- */
#joyLayer {
  position: fixed;
  z-index: 7;
  left: 0; right: 0;
  bottom: 0;
  height: 62%;
  pointer-events: none;
}
#joyLayer.active { pointer-events: auto; }
#joystick {
  position: fixed;
  z-index: 8;
  width: 148px;
  height: 148px;
  margin: 0;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
  transition: opacity 0.18s ease, transform 0.18s ease;
  will-change: left, top;
}
#joystick.on { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
#joystick.idle { opacity: 0.4; }
.jring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(210, 235, 255, 0.8);
  background: radial-gradient(circle, rgba(20, 40, 80, 0.22), rgba(8, 14, 32, 0.4) 68%, transparent 72%);
  box-shadow: 0 0 18px rgba(46, 242, 255, 0.22), inset 0 0 22px rgba(46, 242, 255, 0.1);
}
.jring::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px dashed rgba(127, 137, 184, 0.35);
}
.jknob {
  position: absolute;
  left: 50%; top: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #e8ffff, #2ef2ff 42%, #0d7f97 78%, #064a5c 100%);
  box-shadow: 0 0 22px rgba(46, 242, 255, 0.8), inset 0 0 12px rgba(255, 255, 255, 0.5);
  will-change: transform;
}

/* ---------------- floating score ---------------- */
#floatLayer { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
.scorePop {
  position: fixed;
  font-family: 'Russo One', sans-serif;
  font-size: 21px;
  color: #d9fdff;
  text-shadow: 0 0 14px rgba(46, 242, 255, 0.95), 0 2px 4px #000;
  pointer-events: none;
  white-space: nowrap;
}
.scorePop.secondary {
  font-size: 16px;
  color: #fff3c4;
  text-shadow: 0 0 14px rgba(255, 215, 106, 0.9), 0 2px 4px #000;
}
#banner {
  position: fixed;
  z-index: 13;
  left: 0; right: 0;
  top: 36%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9) skewX(-5deg);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 1.3, 0.4, 1);
}
#banner.on { opacity: 1; transform: scale(1) skewX(-5deg); }
#banner .bigText {
  font-family: 'Russo One', sans-serif;
  font-size: clamp(28px, 5.6vw, 62px);
  letter-spacing: 0.04em;
  line-height: 1;
  display: inline-block;
  position: relative;
  background: linear-gradient(180deg, #f4fbff 0%, #bcd9ff 34%, #ffffff 46%, #a678c8 52%, #ff9ad9 66%, #b06bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.18);
  filter: drop-shadow(0 3px 0 rgba(18, 8, 40, 0.9)) drop-shadow(0 0 26px rgba(255, 79, 163, 0.55));
  padding-bottom: 4px;
}
#banner .bigText::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 7px, rgba(5, 6, 15, 0.92) 7px 11px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 40%, #000 46%);
  mask-image: linear-gradient(to bottom, transparent 40%, #000 46%);
}
#toast {
  position: fixed;
  z-index: 12;
  left: 50%;
  top: 17%;
  transform: translate(-50%, -8px);
  padding: 6px 14px;
  border-radius: 9px;
  border: 1px solid rgba(120, 170, 230, 0.4);
  background: rgba(6, 10, 24, 0.88);
  font-family: 'Russo One', sans-serif;
  font-size: clamp(11px, 1.35vw, 15px);
  letter-spacing: 0.08em;
  color: #9ff4ff;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(46, 242, 255, 0.55);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- screens ---------------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-t)) 18px calc(20px + var(--safe-b));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.screen.show { opacity: 1; pointer-events: auto; }
#screenMenu {
  background: linear-gradient(180deg, rgba(5, 6, 15, 0.1) 0%, rgba(5, 6, 15, 0.02) 42%, rgba(5, 6, 15, 0.66) 100%);
  justify-content: flex-end;
  padding-bottom: calc(5.4vh + var(--safe-b));
}
.menuWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: min(560px, 100%);
}
.logoWrap {
  position: relative;
  margin-bottom: 4.2vh;
  text-align: center;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.55));
}
#logo {
  position: relative;
  display: inline-block;
  font-family: 'Russo One', sans-serif;
  font-size: clamp(38px, 6.6vw, 80px);
  white-space: nowrap;
  line-height: 0.94;
  letter-spacing: 0.035em;
  transform: skewX(-6deg);
  background: linear-gradient(180deg, #f4fbff 0%, #c4e0ff 30%, #ffffff 45%, #7d9ce0 50%, #c98de0 62%, #ff77cf 80%, #8f4dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1.3px rgba(226, 242, 255, 0.28);
  padding: 0 4px;
}
#logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 8px, rgba(5, 6, 15, 0.55) 8px 12px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 52%, #000 58%);
  mask-image: linear-gradient(to bottom, transparent 52%, #000 58%);
  pointer-events: none;
}
.logoSub {
  margin-top: 10px;
  display: inline-block;
  padding: 3px 12px 2px;
  border-radius: 7px;
  background: rgba(6, 8, 20, 0.62);
  font-family: 'Oswald', sans-serif;
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: 0.52em;
  color: #e5d7ff;
  text-indent: 0.52em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(155, 77, 255, 0.7);
  opacity: 0.95;
  transform: skewX(-6deg);
}
.logoGlow {
  position: absolute;
  left: 50%; top: 50%;
  width: 150%; height: 190%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, rgba(255, 79, 163, 0.22), rgba(46, 242, 255, 0.08) 45%, transparent 70%);
  filter: blur(18px);
  z-index: -1;
  pointer-events: none;
}

.menuBtns { display: flex; flex-direction: column; align-items: center; gap: 11px; width: 100%; }
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 240px;
  height: 54px;
  padding: 0 30px;
  border-radius: 13px;
  font-family: 'Russo One', sans-serif;
  font-size: 18px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: transform 0.14s ease, box-shadow 0.2s ease, filter 0.2s ease;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  height: 62px;
  font-size: 21px;
  color: #021418;
  background: linear-gradient(180deg, #d6feff 0%, #2ef2ff 42%, #13b8d6 100%);
  box-shadow: 0 0 0 1px rgba(220, 255, 255, 0.55), 0 0 26px rgba(46, 242, 255, 0.55), 0 8px 30px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 46%, transparent 62%);
  transform: translateX(-120%);
  animation: btnsheen 4.5s ease-in-out infinite;
}
@keyframes btnsheen { 0%, 62% { transform: translateX(-120%); } 78%, 100% { transform: translateX(120%); } }
.btn-primary.pulse { animation: retrypulse 2s ease-in-out infinite; }
@keyframes retrypulse { 0%, 100% { box-shadow: 0 0 0 1px rgba(220, 255, 255, 0.55), 0 0 22px rgba(46, 242, 255, 0.45), 0 8px 30px rgba(0, 0, 0, 0.4); } 50% { box-shadow: 0 0 0 1px rgba(220, 255, 255, 0.8), 0 0 44px rgba(46, 242, 255, 0.8), 0 8px 30px rgba(0, 0, 0, 0.4); } }
.btn-ghost {
  height: 46px;
  min-width: 190px;
  font-size: 14px;
  color: #cfdaf8;
  border: 1px solid rgba(140, 160, 220, 0.42);
  background: rgba(9, 13, 30, 0.55);
  box-shadow: inset 0 0 20px rgba(46, 242, 255, 0.05);
}
.btn-ghost:hover { border-color: rgba(46, 242, 255, 0.7); color: #eaf5ff; box-shadow: 0 0 18px rgba(46, 242, 255, 0.2); }
.menuRow { display: flex; align-items: center; gap: 12px; margin-top: 7px; }
.soundBtn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid rgba(140, 160, 220, 0.4);
  background: rgba(9, 13, 30, 0.55);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #b8c6ee;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.soundBtn:hover { border-color: rgba(46, 242, 255, 0.65); color: #eaf5ff; }
.soundBtn svg { width: 18px; height: 18px; }
.soundBtn.off { color: #66719a; }
.soundBtn.off .wave { opacity: 0; }
.soundBtn.off .muteMark { opacity: 1; }
.soundBtn .muteMark { opacity: 0; }
.record {
  margin-top: 18px;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--sub);
  text-align: center;
}
.record b {
  font-family: 'Russo One', sans-serif;
  font-weight: 400;
  color: #dfe8ff;
  letter-spacing: 0.06em;
  font-size: 14px;
  margin-left: 8px;
  text-shadow: 0 0 12px rgba(46, 242, 255, 0.35);
}
.recordSub { margin-top: 6px; font-size: 10px; letter-spacing: 0.16em; color: #67709a; }
.recordSub b { font-size: 12px; color: #bff4ff; }
.menuHint {
  margin-top: 9px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: #59638f;
  text-align: center;
}

/* how to play */
#screenHow {
  background: rgba(5, 6, 15, 0.55);
  backdrop-filter: blur(8px);
}
.panel {
  width: min(620px, 100%);
  padding: clamp(22px, 4vw, 38px);
  border-radius: 18px;
  border: 1px solid rgba(160, 205, 255, 0.34);
  background: linear-gradient(180deg, rgba(14, 20, 46, 0.94), rgba(6, 9, 22, 0.97));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 0 44px rgba(46, 242, 255, 0.14), 0 30px 80px rgba(0, 0, 0, 0.6);
}
.panelTitle {
  font-family: 'Russo One', sans-serif;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: 0.1em;
  text-align: center;
  margin: 0 0 22px;
  background: linear-gradient(180deg, #f4fbff, #c4e0ff 44%, #ff9ad9 70%, #b06bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: skewX(-5deg);
}
.howRow {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(70, 85, 140, 0.35);
}
.howRow:last-of-type { border-bottom: 0; }
.howIcon {
  flex: 0 0 42px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(46, 242, 255, 0.35);
  background: rgba(46, 242, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 14px rgba(46, 242, 255, 0.1);
}
.howIcon svg { width: 24px; height: 24px; }
.howText { font-size: 16px; line-height: 1.4; color: #dde6ff; padding-top: 3px; }
.howText b { color: #7ffaff; font-weight: 500; }
.howNote { margin: 18px 0 0; font-size: 13px; line-height: 1.5; color: var(--sub); text-align: center; }
.howBtns { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

/* end screen */
#screenEnd {
  background: radial-gradient(70% 70% at 50% 46%, rgba(11, 16, 38, 0.88), rgba(5, 6, 15, 0.96) 82%);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  justify-content: center;
}
#screenEnd::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(62% 54% at 50% 40%, rgba(255, 79, 163, 0.30), rgba(155, 77, 255, 0.16) 44%, transparent 76%);
  opacity: 0;
  transition: opacity 0.6s ease;
}
body.victory #screenEnd::before { opacity: 1; }
body.defeat #screenEnd::before { opacity: 0.65; background: radial-gradient(62% 54% at 50% 40%, rgba(106, 27, 138, 0.36), rgba(43, 11, 74, 0.2) 48%, transparent 76%); }
.endWrap { position: relative; z-index: 1; width: min(540px, 100%); display: flex; flex-direction: column; align-items: center; max-height: 100%; }
#mapOverview {
  display: block;
  width: 100%;
  height: auto;
  max-height: 24vh;
  object-fit: contain;
  border-radius: 9px;
  border: 1px solid rgba(120, 180, 230, 0.34);
  background: #0A0E1E;
  box-shadow: inset 0 0 24px rgba(46, 242, 255, 0.08), 0 0 16px rgba(46, 242, 255, 0.12);
  margin-bottom: 8px;
}
#mapLegend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: center;
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #b9c6ec;
  font-variant-numeric: tabular-nums;
}
#mapLegend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
#mapLegend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; box-shadow: 0 0 6px rgba(255,255,255,0.22); }
.endTitle {
  font-family: 'Russo One', sans-serif;
  font-size: clamp(42px, 10vw, 82px);
  line-height: 0.95;
  letter-spacing: 0.05em;
  text-align: center;
  transform: skewX(-6deg);
  margin: 0;
  background: linear-gradient(180deg, #f8fdff 0%, #c4e0ff 32%, #ffffff 45%, #a678c8 52%, #ff9ad9 70%, #b06bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(18, 8, 40, 0.9)) drop-shadow(0 0 30px rgba(46, 242, 255, 0.35));
  position: relative;
}
.endTitle::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 7px, rgba(5, 6, 15, 0.75) 7px 11px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 55%, #000 62%);
  mask-image: linear-gradient(to bottom, transparent 55%, #000 62%);
}
.endCause { margin: 12px 0 4px; font-size: 14px; letter-spacing: 0.2em; color: var(--sub); text-transform: uppercase; text-align: center; }
.endPanel {
  width: 100%;
  margin-top: 24px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(160, 205, 255, 0.3);
  background: linear-gradient(180deg, rgba(13, 19, 44, 0.88), rgba(6, 9, 22, 0.9));
  box-shadow: inset 0 0 30px rgba(46, 242, 255, 0.06), 0 20px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}
.endMapBox { width: 100%; }
.endStats { width: 100%; }
.statRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 2px;
  border-bottom: 1px solid rgba(70, 85, 140, 0.28);
  opacity: 0;
  transform: translateY(6px);
  animation: statin 0.3s cubic-bezier(0.2, 1.2, 0.4, 1) forwards;
}
.statRow:last-child { border-bottom: 0; }
@keyframes statin { to { opacity: 1; transform: translateY(0); } }
.statLabel { font-size: 13px; letter-spacing: 0.16em; color: var(--sub); text-transform: uppercase; }
.statVal { font-family: 'Russo One', sans-serif; font-size: 20px; color: #eaf4ff; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.statVal.cyan { color: #8ffaff; text-shadow: 0 0 12px rgba(46, 242, 255, 0.4); }
.recordTag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'Oswald', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: #26000f;
  background: linear-gradient(180deg, #ffd3ea, #ff4fa3);
  box-shadow: 0 0 10px rgba(255, 79, 163, 0.6);
  vertical-align: middle;
  opacity: 0;
  animation: statin 0.3s ease forwards;
}
.endBtns { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
.endBtns .btn-primary { width: 100%; }
.endBtns .btn-ghost { width: 100%; }
.endRecord { margin-top: 12px; font-size: 11px; letter-spacing: 0.18em; color: var(--sub); text-align: center; }

/* wipe transition */
#wipe {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(9, 14, 34, 0.95) 0 12px, rgba(46, 242, 255, 0.16) 12px 13px, rgba(9, 14, 34, 0.95) 13px 24px);
  opacity: 0;
  transform: translateX(-102%);
}
#wipe.run { animation: wipe 0.46s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
@keyframes wipe {
  0% { opacity: 1; transform: translateX(-102%); }
  46% { opacity: 1; transform: translateX(0); }
  54% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(102%); }
}

/* boot */
#boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #05060F;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sub);
  letter-spacing: 0.4em;
  font-size: 12px;
  transition: opacity 0.4s ease;
}
#boot.done { opacity: 0; pointer-events: none; }

/* ---------------- responsive ---------------- */
@media (max-width: 720px) {
  :root { --hud-h: 94px; }
  .hudGrid { gap: 5px; padding: 0 6px; }
  .pod { padding: 4px 9px; border-radius: 9px; min-height: 40px; }
  .pod::before { border-radius: 8px; }
  .podLabel { font-size: 8px; letter-spacing: 0.12em; }
  .terrValue { font-size: 17px; }
  .terrBar { width: 54px; height: 4px; }
  #timer { font-size: 23px; }
  .timerPod { min-width: 118px; gap: 6px; padding: 4px 10px; }
  #multPod { font-size: 11px; padding: 2px 6px; }
  #score { font-size: 17px; }
  .hudRight .pod { min-width: 112px; }
  .scoreLine span { font-size: 8px; letter-spacing: 0.12em; }
  #oppRow { gap: 4px; }
  .opp { height: 22px; padding: 0 6px 0 5px; font-size: 10px; border-radius: 6px; }
  .opp svg { width: 12px; height: 12px; }
  .opp .oppPct { min-width: 24px; }
  #tutPill { font-size: 14px; padding: 8px 13px; gap: 8px; }
  #tutStep { font-size: 10px; }
  #tutSkip { font-size: 10px; }
  #tutHint { font-size: 9px; letter-spacing: 0.1em; }
  .logoWrap { margin-bottom: 3.4vh; }
  .logoSub { letter-spacing: 0.38em; font-size: 10px; }
  .menuBtns { gap: 9px; }
  .btn { min-width: 210px; height: 48px; font-size: 16px; }
  .btn-primary { height: 56px; font-size: 19px; }
  .btn-ghost { height: 42px; font-size: 12px; min-width: 170px; }
  .soundBtn { height: 38px; font-size: 10px; }
  .record { margin-top: 13px; font-size: 10px; }
  .record b { font-size: 12px; }
  .menuHint { font-size: 9px; }
  .panel { padding: 18px 16px; }
  .howText { font-size: 14px; }
  .howNote { font-size: 12px; }
  .endPanel { padding: 12px 14px; }
  .statLabel { font-size: 11px; }
  .statVal { font-size: 17px; }
}
@media (max-height: 640px) {
  .logoWrap { margin-bottom: 14px; }
  #logo { font-size: clamp(30px, 7vh, 56px); }
  .logoSub { margin-top: 5px; }
  .menuBtns { gap: 7px; }
  .btn-primary { height: 50px; }
  .btn { height: 42px; }
  .record { margin-top: 9px; }
  .endPanel { margin-top: 12px; padding: 10px 14px; }
  .endTitle { font-size: clamp(34px, 8vh, 62px); }
}
@media (max-width: 400px) {
  .terrBar { width: 40px; }
  .hudRight .pod { min-width: 96px; }
  #score { font-size: 15px; }
  .opp .oppPct { min-width: 21px; }
}

.hudRight .pod { display: flex; align-items: center; gap: 9px; }
#btnPause {
  pointer-events: auto;
  width: 24px; height: 24px;
  flex: 0 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 6px;
  border: 1px solid rgba(160, 205, 255, 0.34);
  background: rgba(46, 242, 255, 0.06);
  transition: border-color 0.15s ease, background 0.15s ease;
}
#btnPause span { display: block; width: 3px; height: 11px; border-radius: 1px; background: #9fe9ff; box-shadow: 0 0 6px rgba(46, 242, 255, 0.55); }
#btnPause:hover { border-color: rgba(46, 242, 255, 0.7); background: rgba(46, 242, 255, 0.13); }
@media (max-width: 720px) {
  .hudRight .pod { gap: 6px; }
  #btnPause { width: 20px; height: 20px; flex-basis: 20px; }
  #btnPause span { height: 9px; width: 2.5px; }
}

@media (max-width: 360px) {
  .podLabel { display: none; }
  #hud .hudRight .podLabel { display: block; font-size: 8px; letter-spacing: 0.12em; }
  .terrValue { font-size: 15px; }
  .terrBar { display: none; }
  #timer { font-size: 20px; }
  .timerPod { min-width: 92px; padding: 5px 8px; }
  .hudRight .pod { min-width: 82px; padding: 5px 7px; }
  #score { font-size: 15px; }
  .opp { height: 20px; font-size: 9px; padding: 0 4px; gap: 3px; }
  .opp svg { width: 10px; height: 10px; }
  .opp .oppPct { min-width: 18px; }
  #joystick { width: 128px; height: 128px; }
  .jknob { width: 48px; height: 48px; margin: -24px 0 0 -24px; }
  #logo { font-size: clamp(32px, 9.5vw, 44px); }
  .btn { min-width: 180px; }
  .btn-primary { min-height: 54px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #screenMenu { justify-content: center; padding: 10px; }
  #tutHint { display: none; }
  .logoWrap { margin-bottom: 8px; }
  #logo { font-size: clamp(26px, 7vh, 48px); }
  .logoSub { display: none; }
  .menuBtns { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 560px; }
  .menuBtns .btn-primary { height: 44px; min-width: 150px; }
  .menuBtns .btn-ghost { height: 40px; min-width: 130px; }
  .menuRow { margin-top: 0; }
  .record { width: 100%; margin-top: 4px; }
  .menuHint { display: none; }
  #tutorial { bottom: calc(8px + var(--safe-b)); }
  #tutSkip { display: none; }
}

/* ---------------- expanded HUD, conquest build ---------------- */
@media (max-width: 720px) {
  .bestLine { font-size: 8px; margin-top: 3px; }
  .leaderPod { min-width: 128px; padding: 4px 9px; gap: 6px; }
  .leaderPod .crownMark { width: 16px; height: 11px; flex-basis: 16px; }
  #leaderVal { font-size: 12px; }
  #oppRow { max-width: 92vw; gap: 4px; }
  .opp { height: 21px; padding: 0 5px 0 4px; font-size: 9.5px; gap: 3px; }
  .opp svg { width: 11px; height: 11px; }
  .opp .oppPct { min-width: 19px; }
  .opp .crownMark { width: 13px; height: 9px; top: -7px; margin-left: -6px; }
  #mapOverview { max-height: 20vh; }
  .endPanel { margin-top: 12px; }
}
@media (max-width: 400px) {
  .leaderPod { min-width: 110px; padding: 4px 7px; }
  #leaderVal { font-size: 11px; }
  .leaderPod .podLabel { font-size: 7px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .screen { padding-top: calc(8px + var(--safe-t)); padding-bottom: calc(6px + var(--safe-b)); }
  .endWrap { width: min(900px, 100%); }
  .endTitle { font-size: clamp(28px, 7vh, 44px); }
  .endCause { margin: 2px 0 0; font-size: 10px; letter-spacing: 0.14em; }
  .endPanel { flex-direction: row; align-items: center; gap: 12px; margin-top: 6px; padding: 7px 10px; }
  .endMapBox { flex: 0 0 47%; }
  #mapOverview { max-height: 26vh; margin-bottom: 0; }
  #mapLegend { margin: 2px 0 0; font-size: 8px; gap: 2px 7px; }
  .endStats { flex: 1; min-width: 0; }
  .statRow { padding: 3px 2px; }
  .statLabel { font-size: 9px; }
  .statVal { font-size: 13px; }
  .endBtns { flex-direction: row; flex-wrap: wrap; justify-content: center; margin-top: 6px; gap: 8px; }
  .endBtns .btn-primary { width: auto; min-width: 150px; height: 42px; font-size: 16px; }
  .endBtns .btn-ghost { width: auto; min-width: 130px; height: 36px; font-size: 11px; }
  .endRecord { margin-top: 4px; font-size: 9px; }
}

@media (max-width: 430px) {
  .hudGrid { gap: 4px 4px; padding: 0 4px; }
  #oppRow { gap: 1px; max-width: 100%; min-height: 19px; }
  .opp { height: 19px; font-size: 8.5px; padding: 0 3px 0 2px; gap: 1px; border-radius: 5px; }
  .opp svg { width: 9px; height: 9px; }
  .opp .oppPct { min-width: 13px; }
  .opp .crownMark { width: 11px; height: 8px; top: -6px; margin-left: -5px; }
}

#screenHow { overflow-y: auto; }
@media (orientation: landscape) and (max-height: 540px) {
  #screenHow { justify-content: flex-start; padding-top: calc(8px + var(--safe-t)); }
  #screenHow .panel { width: min(780px, 100%); padding: 9px 16px; margin: auto; }
  #screenHow .panelTitle { font-size: 18px; margin: 0 0 4px; }
  #screenHow .howRow { padding: 5px 0; gap: 10px; align-items: center; }
  #screenHow .howIcon { flex: 0 0 30px; height: 30px; border-radius: 8px; }
  #screenHow .howIcon svg { width: 18px; height: 18px; }
  #screenHow .howText { font-size: 12px; line-height: 1.3; padding-top: 0; }
  #screenHow .howNote { margin: 6px 0 0; font-size: 10px; line-height: 1.35; }
  #screenHow .howBtns { margin-top: 8px; gap: 8px; }
  #screenHow .howBtns .btn { height: 38px; min-width: 150px; font-size: 12px; }
  #screenHow .howBtns .btn-primary { height: 40px; }
}
@media (max-width: 720px) and (max-height: 700px) {
  .endWrap { width: min(420px, 100%); }
  .endTitle { font-size: clamp(28px, 8vh, 44px); }
  .endCause { margin: 4px 0 0; font-size: 10px; }
  #mapOverview { max-height: 13vh; margin-bottom: 4px; }
  #mapLegend { margin: 2px 0 4px; font-size: 8px; }
  .endPanel { margin-top: 6px; padding: 8px 10px; }
  .statRow { padding: 3px 2px; }
  .statLabel { font-size: 9px; }
  .statVal { font-size: 13px; }
  .endBtns { margin-top: 6px; gap: 6px; flex-direction: row; flex-wrap: wrap; }
  .endBtns .btn-primary { width: auto; min-width: 150px; height: 42px; font-size: 15px; }
  .endBtns .btn-ghost { width: auto; min-width: 110px; height: 36px; font-size: 11px; }
  .endRecord { margin-top: 4px; font-size: 8px; }
}
