:root {
  --battle-red: #ff5a64;
  --battle-blue: #1cc5ef;
  --battle-ink: #090b0e;
  --battle-road: #3b4450;
}

html, body { background: #252c35; }
.game-shell {
  width: 100%;
  max-width: none;
  padding: max(.45rem, env(safe-area-inset-top)) max(.55rem, env(safe-area-inset-right)) max(.45rem, env(safe-area-inset-bottom)) max(.55rem, env(safe-area-inset-left));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: .45rem;
}
.game-header {
  grid-column: 1;
  grid-row: 1;
  min-height: 2.7rem;
  border: 0;
  color: white;
}
.game-header h1 {
  color: #fff;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-size: clamp(1.1rem, 3vh, 1.55rem);
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.game-header .back-link,
.game-header .icon-button,
.game-header .shell-tool {
  min-height: 2.35rem;
  height: 2.35rem;
  border: 2px solid #11161d;
  background: #f5f7fa;
  box-shadow: 3px 3px 0 #11161d;
}
.game-header .back-link { width: 2.35rem; }
.game-header .icon-button { min-width: 5.3rem; padding: .25rem .55rem; font-size: .7rem; }
.game-header .game-profile, .game-header .shell-status { display: none; }

.game-stage {
  position: relative;
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-height: 0;
  border: 3px solid var(--battle-ink);
  border-radius: clamp(1rem, 2.5vw, 2rem);
  background: var(--battle-road);
  box-shadow: 0 10px 0 #171c23, 0 24px 48px rgba(0,0,0,.28);
  isolation: isolate;
}
#phaser-game {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--battle-road);
  touch-action: none;
}
#phaser-game canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  border-radius: inherit;
  touch-action: none;
}
.battle-hud { position: absolute; inset: .65rem .75rem auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: .5rem; pointer-events: none; }
.team-score { display: flex; align-items: center; gap: .45rem; color: white; filter: drop-shadow(0 2px 0 rgba(0,0,0,.55)); }
.team-score--blue { justify-content: flex-end; }
.team-score span { font-size: clamp(.58rem, 1.65vw, .92rem); font-weight: 950; letter-spacing: .13em; }
.team-score strong { display: grid; place-items: center; width: clamp(2rem, 5vw, 3.25rem); aspect-ratio: 1; border: 3px solid var(--battle-ink); border-radius: 50%; background: var(--battle-red); font-size: clamp(1rem, 2.5vw, 1.65rem); box-shadow: 2px 3px 0 var(--battle-ink); }
.team-score--blue strong { order: -1; background: var(--battle-blue); }
.team-score small { padding: .25rem .42rem; border-radius: 999px; background: rgba(8,10,13,.52); font-size: clamp(.45rem, 1.2vw, .68rem); font-weight: 900; }
.round-status { display: grid; justify-items: center; gap: .12rem; padding: .38rem .8rem; border: 2px solid rgba(5,8,12,.65); border-radius: 999px; background: rgba(239,245,249,.9); color: #222a34; box-shadow: 2px 3px 0 rgba(5,8,12,.65); }
.round-status strong { font-size: clamp(.55rem, 1.4vw, .76rem); letter-spacing: .1em; }
.round-status span { max-width: 11rem; overflow: hidden; color: #57616e; font-size: clamp(.42rem, 1.05vw, .62rem); font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }

.touch-controls { position: absolute; z-index: 3; bottom: max(.75rem, env(safe-area-inset-bottom)); display: flex; gap: clamp(.45rem, 1.5vw, .85rem); }
.touch-controls--red { left: max(.75rem, env(safe-area-inset-left)); }
.touch-controls--blue { right: max(.75rem, env(safe-area-inset-right)); }
.touch-controls button { width: clamp(3.5rem, 8vw, 5.3rem); aspect-ratio: 1; border: clamp(4px, .55vw, 7px) solid var(--battle-ink); border-radius: 50%; background: var(--battle-red); color: var(--battle-ink); font: 950 clamp(1.55rem, 4vw, 2.8rem)/1 system-ui; box-shadow: 0 .35rem 0 var(--battle-ink), 0 .65rem 1rem rgba(0,0,0,.22); cursor: pointer; touch-action: none; }
.touch-controls--blue button { background: var(--battle-blue); }
.touch-controls button:is(:active, .is-pressed) { transform: translateY(.3rem); box-shadow: 0 .08rem 0 var(--battle-ink); }

.message-card { border: 4px solid var(--battle-ink); border-radius: 1.5rem; background: #f7f2e8; box-shadow: 8px 9px 0 var(--battle-ink); }
.message-card .eyebrow { margin: 0 0 .35rem; color: #596473; font-size: .72rem; font-weight: 950; letter-spacing: .15em; }
.message-card h2 { font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif; font-weight: 950; }
.message-card .primary { background: linear-gradient(90deg, var(--battle-red) 0 49%, var(--battle-blue) 51% 100%); color: #11151b; }
.vehicle-garage { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: .85rem 0 1rem; text-align: left; }
.vehicle-pick { min-width: 0; }
.vehicle-pick > strong { display: block; margin: 0 0 .32rem; color: #b42e3d; font-size: .72rem; font-weight: 950; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.vehicle-pick--blue > strong { color: #087ba4; }
.vehicle-pick > div { display: grid; gap: .32rem; }
.vehicle-pick button { min-width: 0; display: grid; grid-template-columns: 1.8rem 1fr; align-items: center; padding: .42rem .5rem; border: 2px solid #28313c; border-radius: .65rem; background: #fffdfa; color: #29333f; font: 900 .76rem/1.05 inherit; text-align: left; cursor: pointer; }
.vehicle-pick button span { grid-row: 1 / span 2; font-size: 1.2rem; }
.vehicle-pick button small { margin-top: .13rem; color: #6a7480; font-size: .52rem; font-weight: 750; }
.vehicle-pick--red button[aria-pressed="true"] { border-color: #9d2331; background: #ffe5e7; box-shadow: 2px 2px 0 #9d2331; }
.vehicle-pick--blue button[aria-pressed="true"] { border-color: #087ba4; background: #ddf7ff; box-shadow: 2px 2px 0 #087ba4; }

@media (pointer: fine) and (min-width: 900px) { .touch-controls { opacity: .82; } }
@media (orientation: portrait) and (max-width: 900px) {
  .game-shell {
    position: fixed;
    top: 50%;
    left: 50%;
    width: var(--game-visible-height, 100dvh);
    height: 100dvw;
    max-width: none;
    max-height: none;
    padding: .2rem;
    gap: .2rem;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center;
    overflow: hidden;
  }
  .game-stage { overflow: hidden; }
  .game-message {
    inset: 0;
    width: auto;
    height: var(--game-visible-height, 100dvh);
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    transform: none;
  }
  .message-card { width: min(100%, 24rem); max-height: calc(var(--game-visible-height, 100dvh) - 2rem); }
  .vehicle-garage { margin-top: .55rem; margin-bottom: .7rem; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .game-shell { grid-template-rows: 2.2rem minmax(0, 1fr); gap: .25rem; padding-top: max(.25rem, env(safe-area-inset-top)); padding-bottom: max(.25rem, env(safe-area-inset-bottom)); }
  .game-header { min-height: 2rem; }
  .game-header h1 { font-size: .78rem; }
  .game-header .back-link, .game-header .icon-button, .game-header .shell-tool { min-height: 1.85rem; height: 1.85rem; }
  .game-header .back-link { width: 1.85rem; }
  .game-header .icon-button { font-size: .58rem; }
  .game-header .shell-tools { display: none; }
  .battle-hud { inset: .35rem .5rem auto; }
  .message-card { width: min(100%, 42rem); }
  .message-card .eyebrow { margin-bottom: .1rem; }
  .vehicle-garage { gap: .45rem; margin: .35rem 0 .45rem; }
  .vehicle-pick > div { grid-template-columns: 1fr 1fr; gap: .25rem; }
  .vehicle-pick button { grid-template-columns: 1.25rem 1fr; padding: .3rem .35rem; font-size: .65rem; }
  .vehicle-pick button span { font-size: .9rem; }
  .vehicle-pick button small { font-size: .45rem; }
}
@media (prefers-reduced-motion: reduce) { .touch-controls button { transition: none; } }
