/* SkyBounty UI — "sticker" arcade style: thick navy ink outlines, pressable 3D edges. */
:root {
  --sky: #3aa8f0;
  --sky-deep: #1f7fd1;
  --cloud: #ffffff;
  --sun: #ffd23f;
  --sun-deep: #e8a90c;
  --candy: #ff4f5e;
  --candy-deep: #c92f3f;
  --grass: #7bd36b;
  --grass-deep: #45a045;
  --ink: #1d2b53;
  --ink-soft: #4a5a86;
  --paper: #fffdf6;
  --boost: #38b6ff;
  --missile: #ff7a2f;
  --shadow: rgba(29, 43, 83, 0.35);
  --display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --text: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--sky); color: var(--ink);
  font-family: var(--text); font-weight: 700;
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
  touch-action: none;
}
/* The stage is sized from JS (--app-w/--app-h, see viewport.ts): on phones the browser's own
   100%/inset:0 often stops short of the real screen (iOS home-screen apps after a rotation,
   collapsing toolbars), which left a strip of page background along the bottom. */
#game, #ui {
  position: fixed; top: 0; left: 0; right: auto; bottom: auto;
  width: 100vw; width: var(--app-w, 100vw);
  height: 100vh; height: 100lvh; height: var(--app-h, 100lvh);
}
html { min-height: 100lvh; }
#game canvas { display: block; }
/* scrollable panels must still scroll by finger even though the page itself never pans */
.panel, .card-big, .menu { touch-action: pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#ui { pointer-events: none; z-index: 10; }
#ui .interactive, #ui button, #ui input, #ui select, #ui a { pointer-events: auto; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

/* ------------------------------------------------------------------ stickers */
.btn {
  --face: var(--cloud); --edge: #c9d6ea; --fg: var(--ink);
  position: relative; border: 3px solid var(--ink); border-radius: 16px;
  background: var(--face); color: var(--fg);
  font-family: var(--display); font-size: 20px; letter-spacing: 0.02em;
  padding: 10px 22px 12px; cursor: pointer;
  box-shadow: 0 5px 0 0 var(--ink), inset 0 -5px 0 0 var(--edge);
  transform: translateY(0); transition: transform 80ms ease, box-shadow 80ms ease, filter 120ms;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 0 var(--ink), inset 0 -5px 0 0 var(--edge); filter: brightness(1.04); }
.btn:active, .btn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 0 var(--ink), inset 0 -2px 0 0 var(--edge); }
.btn:disabled { filter: grayscale(0.7) opacity(0.6); cursor: not-allowed; transform: none; }
.btn.primary { --face: var(--sun); --edge: var(--sun-deep); }
.btn.go { --face: var(--grass); --edge: var(--grass-deep); --fg: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.danger { --face: var(--candy); --edge: var(--candy-deep); --fg: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.small { font-size: 15px; padding: 6px 14px 8px; border-radius: 12px; box-shadow: 0 3px 0 0 var(--ink), inset 0 -3px 0 0 var(--edge); }
.btn.huge { font-size: 44px; padding: 12px 64px 18px; border-radius: 24px; border-width: 4px;
  box-shadow: 0 8px 0 0 var(--ink), inset 0 -8px 0 0 var(--edge); }
.btn.huge:hover { box-shadow: 0 10px 0 0 var(--ink), inset 0 -8px 0 0 var(--edge); }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--cloud); border: 3px solid var(--ink); border-radius: 999px;
  padding: 4px 12px 4px 6px; box-shadow: 0 3px 0 var(--ink); font-size: 14px;
}
.chip .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); background: var(--grass); }
.badge-devnet {
  font-family: var(--display); font-size: 13px; letter-spacing: 0.06em;
  background: #9b5cff; color: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 1px 8px 2px;
  text-shadow: 0 1px 0 var(--ink);
}
.badge-demo { background: var(--grass-deep); }

/* ------------------------------------------------------------------ main menu */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; }
.menu { justify-content: center; gap: 18px; padding: 24px; }
.logo {
  font-family: var(--display); font-size: clamp(56px, 9vw, 118px); line-height: 0.9; margin: 0 0 6px;
  color: var(--sun); letter-spacing: 0.01em;
  -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill;
  text-shadow: 0 9px 0 var(--ink);
  transform: rotate(-3deg); animation: bob 4s ease-in-out infinite;
}
.logo span { color: var(--cloud); }
.tagline { font-size: 17px; color: var(--ink); background: rgba(255, 255, 255, 0.75); border-radius: 999px; padding: 4px 16px; margin: 0 0 8px; }
@keyframes bob { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .logo { animation: none; } }
.menu-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 14px; margin-top: 6px; }
.topbar { position: absolute; top: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.topbar .left, .topbar .right { display: flex; gap: 10px; align-items: center; }

/* ------------------------------------------------------------------ panels */
.panel-wrap { justify-content: center; padding: 20px; }
.panel {
  width: min(920px, 100%); max-height: calc(var(--app-h, 100vh) - 40px); overflow: auto;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 26px;
  box-shadow: 0 10px 0 var(--ink); padding: 22px 26px 26px; pointer-events: auto;
}
.panel h2 { font-family: var(--display); font-weight: 400; font-size: 36px; margin: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel p { line-height: 1.5; max-width: 70ch; }
.muted { color: var(--ink-soft); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  border: 3px solid var(--ink); border-radius: 18px; background: #fff; padding: 12px 14px; cursor: pointer; text-align: left;
  box-shadow: 0 4px 0 var(--ink); transition: transform 90ms, background 120ms;
}
.card:hover { transform: translateY(-2px); }
.card.selected { background: #fff4c7; box-shadow: 0 4px 0 var(--ink), inset 0 0 0 3px var(--sun); }
.card h3 { font-family: var(--display); font-weight: 400; font-size: 24px; margin: 2px 0; }
.card .role { font-size: 12px; font-weight: 900; letter-spacing: 0.08em; color: var(--ink-soft); }
.card img.plane { width: 100%; height: 96px; object-fit: contain; image-rendering: auto; }
.stat { display: grid; grid-template-columns: 64px 1fr 48px; align-items: center; gap: 8px; font-size: 13px; margin: 3px 0; }
.stat .bar { height: 10px; border: 2px solid var(--ink); border-radius: 6px; background: #e6edf7; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--sky); }
.stat b { text-align: right; white-space: nowrap; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.swatch.selected { outline: 4px solid var(--sun); outline-offset: 2px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.field { display: grid; gap: 6px; margin: 10px 0; }
.field label { font-size: 14px; }
.field input[type=text] { font: inherit; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 12px; background: #fff; }
.field input[type=range] { width: 260px; accent-color: var(--sky-deep); }
table.board { width: 100%; border-collapse: collapse; font-size: 15px; }
table.board th { text-align: left; font-size: 12px; color: var(--ink-soft); padding: 6px 8px; }
table.board td { padding: 7px 8px; border-top: 2px dashed #d3dcec; }
table.board tr.me td { background: #fff4c7; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 18px; }
.key { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 2px dashed #d3dcec; }
kbd, .kbd { font-family: var(--display); font-weight: 400; background: #fff; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 8px; padding: 1px 8px; min-width: 30px; text-align: center; display: inline-block; }
button.kbd { cursor: pointer; }
button.kbd.listening { background: var(--sun); }

/* ------------------------------------------------------------------ modal */
.modal-back { position: absolute; inset: 0; z-index: 55; background: rgba(29, 43, 83, 0.45); display: flex; align-items: center; justify-content: center; pointer-events: auto; padding: 16px; }
.modal { width: min(440px, 100%); background: var(--paper); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 10px 0 var(--ink); padding: 22px 24px; }
.modal h2 { font-family: var(--display); font-weight: 400; font-size: 32px; margin: 0 0 12px; display: flex; gap: 10px; align-items: center; }
.ledger { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 17px; }
.ledger td { padding: 7px 0; border-bottom: 2px dashed #d3dcec; }
.ledger td:last-child { text-align: right; font-family: var(--display); font-weight: 400; font-size: 20px; }
.ledger tr.total td { border-bottom: 0; font-size: 19px; }
.txstate { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #eef4fd; border: 2px solid var(--ink); margin: 8px 0; }
.txstate.ok { background: #e2f7dc; }
.txstate.err { background: #ffe1e4; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--ink); border-right-color: transparent; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { font-size: 13px; color: var(--ink-soft); line-height: 1.45; }

/* ------------------------------------------------------------------ matchmaking & countdown */
.mm { justify-content: center; gap: 14px; }
.mm .big { font-family: var(--display); font-size: 44px; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; color: #fff; text-shadow: 0 6px 0 var(--ink); }
.mm .count { font-family: var(--display); font-size: 30px; }
.slots { display: grid; grid-template-columns: repeat(8, 30px); gap: 8px; }
.slots i { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(255,255,255,0.5); }
.slots i.on { background: var(--sun); box-shadow: 0 3px 0 var(--ink); animation: pop 240ms ease-out; }
@keyframes pop { from { transform: scale(0.3); } 70% { transform: scale(1.2); } to { transform: scale(1); } }
.countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.countdown span {
  font-family: var(--display); font-size: 200px; color: var(--sun); -webkit-text-stroke: 16px var(--ink); paint-order: stroke fill;
  text-shadow: 0 12px 0 var(--ink); animation: cd 900ms ease-out both;
}
.countdown span.go { color: var(--grass); }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(0.9); opacity: 1; } 40% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 0.9; } }

/* ------------------------------------------------------------------ HUD */
.hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--display); font-weight: 400; }
.hud .tl { position: absolute; top: calc(14px + env(safe-area-inset-top)); left: calc(16px + env(safe-area-inset-left)); width: 290px; }
.hud .tc { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; }
.hud .tr { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right)); text-align: right; }
.hud .bc { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: flex-end; }
.hud .bl { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: calc(16px + env(safe-area-inset-left)); display: flex; gap: 8px; flex-wrap: wrap; max-width: 40vw; }
.hud .side { position: absolute; top: 118px; right: 16px; width: 260px; display: grid; gap: 8px; justify-items: end; }
.hud .side .board-mini { width: 230px; }
.hp-frame { position: relative; height: 30px; border: 3px solid var(--ink); border-radius: 12px; background: rgba(29, 43, 83, 0.55); overflow: hidden; box-shadow: 0 3px 0 var(--ink); }
.hp-fill { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(180deg, #8ff07d, #3fbf4a); transition: transform 120ms linear; }
.hp-fill.mid { background: linear-gradient(180deg, #ffe066, #f2b40f); }
.hp-fill.low { background: linear-gradient(180deg, #ff8a8a, #e8323f); }
.hp-ghost { position: absolute; inset: 0; transform-origin: left; background: #fff; opacity: 0.55; transition: transform 500ms ease-out 180ms; }
.sh-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; transform-origin: left; background: linear-gradient(180deg, #9fd8ff, #3a8dff); }
.hp-text { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 10px; color: #fff; font-size: 18px; text-shadow: 0 2px 0 var(--ink); }
.hp-label { display: flex; justify-content: space-between; color: #fff; font-size: 15px; text-shadow: 0 2px 0 var(--ink); margin-bottom: 4px; }
.timer { font-size: 38px; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; line-height: 1; }
.phase-note { font-family: var(--text); font-weight: 800; font-size: 13px; color: #fff; text-shadow: 0 1px 0 var(--ink); }
.kills { font-size: 62px; line-height: 0.9; color: var(--sun); -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.kills small { font-size: 20px; color: #fff; -webkit-text-stroke: 4px var(--ink); vertical-align: top; margin-left: 4px; }
.earned { font-family: var(--text); font-weight: 900; font-size: 14px; color: #fff; background: rgba(29,43,83,0.65); border-radius: 8px; padding: 2px 8px; display: inline-block; margin-top: 4px; }
.feed { margin-top: 8px; display: grid; gap: 4px; justify-items: end; font-family: var(--text); font-weight: 800; font-size: 14px; }
.feed div { background: rgba(29, 43, 83, 0.62); color: #fff; padding: 3px 10px; border-radius: 8px; animation: feedIn 200ms ease-out; }
.feed .me { background: rgba(255, 210, 63, 0.92); color: var(--ink); }
.feed .bad { background: rgba(255, 79, 94, 0.9); }
@keyframes feedIn { from { transform: translateX(30px); opacity: 0; } }
.board-mini { background: rgba(29, 43, 83, 0.5); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; color: #fff; font-family: var(--text); font-weight: 800; font-size: 14px; }
.board-mini div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.board-mini div.me { color: var(--sun); }
.board-mini .bot { opacity: 0.75; }
.meter { width: 150px; }
.meter .lab { display: flex; justify-content: space-between; color: #fff; font-size: 14px; text-shadow: 0 2px 0 var(--ink); margin-bottom: 3px; }
.meter .bar { height: 16px; border: 3px solid var(--ink); border-radius: 9px; background: rgba(29,43,83,0.55); overflow: hidden; }
.meter .bar i { display: block; height: 100%; transform-origin: left; }
.meter.boost i { background: linear-gradient(180deg, #8fdcff, var(--boost)); }
.meter.ammo i { background: linear-gradient(180deg, #fff3b0, var(--sun)); }
.missiles { display: flex; gap: 5px; padding-bottom: 2px; }
.missiles i { width: 14px; height: 30px; border: 3px solid var(--ink); border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #ffb38a, var(--missile)); }
.missiles i.off { background: rgba(29,43,83,0.45); }
.cool { display: flex; gap: 6px; }
.cool span { font-size: 13px; color: #fff; background: rgba(29,43,83,0.6); border: 2px solid var(--ink); border-radius: 8px; padding: 2px 7px; }
.cool span.ready { background: var(--grass-deep); }
.pu-chip { font-family: var(--text); font-weight: 900; font-size: 13px; color: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 3px 9px; text-shadow: 0 1px 0 var(--ink); box-shadow: 0 3px 0 var(--ink); }
.vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 250ms;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(255, 30, 50, 0.4) 100%); }
.dmgflash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255,60,80,0) 40%, rgba(255,60,80,0.8) 100%); }
@media (prefers-reduced-motion: reduce) { .dmgflash { display: none; } }
.vignette.on { opacity: 1; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.warn { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); font-size: 30px; color: #fff; -webkit-text-stroke: 6px var(--candy-deep); paint-order: stroke fill; opacity: 0; }
.warn.on { opacity: 1; animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.killbanner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
.killbanner .k { font-family: var(--display); font-size: 92px; color: var(--sun); -webkit-text-stroke: 12px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); animation: kb 1.6s ease-out both; }
.killbanner .b { font-family: var(--display); font-size: 30px; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; animation: kb2 1.6s ease-out both; }
@keyframes kb { 0% { transform: scale(3) rotate(-8deg); opacity: 0; } 15% { transform: scale(0.9) rotate(-3deg); opacity: 1; } 25% { transform: scale(1.08) rotate(-3deg); } 80% { opacity: 1; } 100% { transform: scale(1) rotate(-3deg) translateY(-20px); opacity: 0; } }
@keyframes kb2 { 0%, 12% { transform: translateY(20px); opacity: 0; } 25% { transform: translateY(0); opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.pickup-label { position: absolute; top: 62%; left: 50%; transform: translateX(-50%); font-size: 30px; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; animation: kb2 1.3s ease-out both; }
.toasts { position: absolute; right: 16px; bottom: 16px; display: grid; gap: 8px; justify-items: end; width: 340px; }
.toast { pointer-events: auto; font-family: var(--text); font-weight: 800; font-size: 14px; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; gap: 10px; animation: feedIn 200ms ease-out; }
.toast a { color: var(--sky-deep); }
.toast.ok { background: #e2f7dc; } .toast.err { background: #ffe1e4; }
.minimap { position: absolute; left: 16px; bottom: 60px; border: 3px solid var(--ink); border-radius: 12px; background: rgba(29,43,83,0.35); box-shadow: 0 3px 0 var(--ink); }
.debug { position: absolute; left: 16px; top: 90px; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; color: #fff; background: rgba(0,0,0,0.55); padding: 6px 8px; border-radius: 6px; white-space: pre; }

/* ------------------------------------------------------------------ death / results */
.over { justify-content: center; background: radial-gradient(ellipse at center, rgba(29,43,83,0.25), rgba(29,43,83,0.7)); animation: fadeIn 300ms ease-out; pointer-events: auto; }
@keyframes fadeIn { from { opacity: 0; } }
.over h1 { font-family: var(--display); font-weight: 400; font-size: clamp(44px, 7vw, 84px); margin: 0; color: var(--candy); -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); transform: rotate(-2deg); text-align: center; }
.over .card-big { margin-top: 18px; background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink); padding: 16px 26px; min-width: 320px; text-align: center; }
.over .card-big .line { display: flex; justify-content: space-between; gap: 24px; font-size: 18px; padding: 6px 0; border-bottom: 2px dashed #d3dcec; }
.over .card-big .line:last-child { border-bottom: 0; }
.over .card-big b { font-family: var(--display); font-weight: 400; font-size: 22px; }
.over .actions { display: flex; gap: 14px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }

/* ------------------------------------------------------------------ touch controls */
.touch { position: absolute; inset: 0; pointer-events: none; z-index: 5; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.touch.off { display: none; }
.touch button { touch-action: none; -webkit-tap-highlight-color: transparent; }
.touch .tzone { position: absolute; left: 0; top: 64px; bottom: 0; width: 48%; pointer-events: auto; touch-action: none; }
.touch .stick { position: absolute; left: 110px; top: calc(100% - 120px); width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.75); background: rgba(29,43,83,0.18); opacity: 0.45; transition: opacity 120ms; pointer-events: none; }
.touch .stick.live { opacity: 1; transition: none; }
.touch .stick i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255,255,255,0.85); border: 3px solid var(--ink); }
.touch .stick span { position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap; font-family: var(--display); font-size: 13px; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.touch .stick.live span { display: none; }
.touch .ttop { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; pointer-events: auto; }
.touch .ts { width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--ink); background: var(--paper); font-size: 20px; line-height: 1; padding: 0; box-shadow: 0 3px 0 var(--ink); color: var(--ink); }
.touch .rotate-hint { display: none; position: absolute; top: 64px; left: 50%; transform: translateX(-50%); background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 14px; font-weight: 800; box-shadow: 0 4px 0 var(--ink); white-space: nowrap; }
@media (orientation: portrait) and (max-width: 760px) { .touch .rotate-hint { display: block; } }
/* in-match layout while the touch controls are on screen: keep thumbs' areas clear */
body.touch-ui .hud .side .board-mini, body.touch-ui .hud .cool { display: none; }
/* phones: minimap top-left under the health bar (the stick owns the bottom-left) */
body.touch-ui .minimap { display: block; left: calc(12px + env(safe-area-inset-left)); top: 76px; bottom: auto; width: 168px; height: auto; opacity: 0.9; pointer-events: none; }
body.touch-ui .hud .bl { bottom: auto; top: 148px; left: calc(12px + env(safe-area-inset-left)); max-width: 34vw; font-size: 12px; }
body.touch-ui .hud .side { top: auto; bottom: auto; top: 96px; right: 12px; width: 240px; }
body.touch-ui .hud .side .feed { font-size: 12px; }
body.touch-ui .hud .side .feed div:nth-child(n+3) { display: none; }
body.touch-ui .hud .bc { bottom: calc(8px + env(safe-area-inset-bottom)); transform: translateX(-50%) scale(0.82); transform-origin: bottom center; }
body.touch-ui .hud .tl { width: 220px; }
body.touch-ui .toasts { bottom: auto; top: 84px; right: auto; left: 50%; transform: translateX(-50%); width: 300px; justify-items: center; }
.touch .ttop { top: 12px; left: 248px; transform: none; }


@media (max-width: 760px) {
  .menu-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .hud .side { display: none; }
  .minimap { width: 160px; height: auto; }
  .btn.huge { font-size: 34px; padding: 10px 44px 14px; }
}
@media (max-height: 760px) {
  .logo { font-size: clamp(48px, 7vw, 86px); }
  .menu { gap: 12px; }
}

/* ------------------------------------------------------------------ reconnect banner */
.reconnect { position: absolute; top: 78px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 14px;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); padding: 10px 14px 10px 16px;
  max-width: calc(100vw - 24px); font-size: 15px; animation: feedIn 200ms ease-out; }
.reconnect b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.reconnect .muted { font-size: 13px; }
.reconnect .spin { width: 26px; height: 26px; flex: none; border-radius: 50%; border: 4px solid #cfd8ea; border-top-color: var(--sky-deep); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ killcam */
body.killcam .hud .tl, body.killcam .hud .bc, body.killcam .hud .side, body.killcam .hud .bl,
body.killcam .minimap, body.killcam .hud .tr, body.killcam .touch { opacity: 0; transition: opacity 200ms; pointer-events: none; }
.kc { position: absolute; inset: 0; z-index: 40; pointer-events: auto; cursor: default; }
.kc-bar { position: absolute; left: 0; right: 0; height: 9vh; max-height: 84px; background: #0e1630; animation: kcBar 380ms cubic-bezier(.2,.9,.3,1) both; }
.kc-bar.top { top: 0; transform-origin: top; }
.kc-bar.bot { bottom: 0; transform-origin: bottom; }
@keyframes kcBar { from { transform: scaleY(0); } }
.kc-tag { position: absolute; top: calc(min(9vh, 84px) / 2); left: 22px; transform: translateY(-50%); display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-size: clamp(20px, 3vw, 30px); letter-spacing: 0.08em; color: #fff; animation: fadeIn 400ms 150ms both; }
.kc-tag .rec { width: 14px; height: 14px; border-radius: 50%; background: var(--candy); box-shadow: 0 0 0 4px rgba(255,79,94,0.3); animation: kcRec 1s steps(2) infinite; }
@keyframes kcRec { 50% { opacity: 0.15; } }
.kc-skip { position: absolute; top: calc(min(9vh, 84px) / 2); right: 18px; transform: translateY(-50%); background: transparent; border: 2px solid rgba(255,255,255,0.55);
  color: #fff; border-radius: 999px; padding: 6px 14px; font-family: var(--text); font-weight: 800; font-size: 14px; cursor: pointer; animation: fadeIn 400ms 300ms both; }
.kc-skip:hover { background: rgba(255,255,255,0.14); }
.kc-card { position: absolute; left: 50%; bottom: calc(min(9vh, 84px) + 18px); transform: translateX(-50%); display: flex; align-items: center; gap: 16px;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink); padding: 10px 22px 12px 12px; max-width: calc(100vw - 24px);
  animation: kcCard 520ms 200ms cubic-bezier(.2,1.4,.4,1) both; }
@keyframes kcCard { from { transform: translate(-50%, 140%) rotate(-3deg); } }
.kc-plane { width: 112px; height: 70px; object-fit: contain; flex: none; background: linear-gradient(180deg, #bfe6ff, #e9f6ff); border: 3px solid var(--ink); border-radius: 14px; padding: 4px; }
.kc-plane.none { display: grid; place-items: center; font-size: 36px; }
.kc-how { font-family: var(--text); font-weight: 900; font-size: 13px; letter-spacing: 0.12em; color: var(--candy-deep); }
.kc-name { font-family: var(--display); font-size: clamp(26px, 4vw, 40px); line-height: 1; color: var(--ink); margin: 2px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.kc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kc-chips span { font-family: var(--text); font-weight: 800; font-size: 13px; background: #e8eef9; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; }
.kc-chips span.low { background: #ffe1e4; }
.kc-chips span.money { background: var(--sun); }
.kc-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255,255,255,0.12); }
.kc-prog i { position: absolute; inset: 0; background: var(--candy); transform-origin: left; transform: scaleX(0); }
.kc.out { animation: fadeOut 240ms ease-in both; }
@keyframes fadeOut { to { opacity: 0; } }
@media (max-height: 430px) { .kc-plane { width: 80px; height: 50px; } .kc-card { padding: 6px 14px 8px 8px; gap: 10px; } }

/* ------------------------------------------------------------------ death & match recap */
.over.death, .over.results { overflow-y: auto; justify-content: safe center; padding: 24px 12px 28px; }
.over.death h1 { font-size: clamp(42px, 6.5vw, 76px); }
.recap-card { margin-top: 16px; width: min(640px, 100%); background: var(--paper); border: 4px solid var(--ink); border-radius: 24px;
  box-shadow: 0 8px 0 var(--ink); padding: 16px 18px 18px; animation: popIn 420ms cubic-bezier(.2,1.3,.4,1) both; }
@keyframes popIn { from { transform: translateY(24px) scale(0.96); opacity: 0; } }
.who { display: flex; align-items: center; gap: 16px; text-align: left; }
.who-plane { width: 150px; height: 92px; flex: none; object-fit: contain; padding: 6px; border: 3px solid var(--ink); border-radius: 16px;
  background: linear-gradient(180deg, #9fd8ff 0%, #d8f0ff 70%, #f4fbff 100%); box-shadow: inset 0 -6px 0 rgba(29,43,83,0.08); }
.who-plane.none { display: grid; place-items: center; font-size: 44px; }
.who-how { font-family: var(--text); font-weight: 900; font-size: 12px; letter-spacing: 0.16em; color: var(--ink-soft); }
.who-name { font-family: var(--display); font-size: clamp(28px, 4.4vw, 42px); line-height: 1.02; margin: 2px 0 8px; word-break: break-word; }
.who-name.small { font-size: clamp(22px, 3.4vw, 30px); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { font-family: var(--text); font-weight: 800; font-size: 13px; background: #e8eef9; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; }
.chips span.low { background: #ffe1e4; }
.chips span.hot { background: var(--candy); color: #fff; }
.money-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.pill { font-family: var(--text); font-weight: 900; font-size: 14px; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px; background: #e8eef9; box-shadow: 0 3px 0 var(--ink); }
.pill.bad { background: #ffd6da; color: var(--candy-deep); }
.pill.good { background: #dff6d6; color: var(--grass-deep); }
.sep { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; font-family: var(--text); font-weight: 900; font-size: 12px; letter-spacing: 0.16em; color: var(--ink-soft); }
.sep.first { margin-top: 2px; }
.sep::before, .sep::after { content: ''; flex: 1; border-top: 2px dashed #cdd7ea; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 9px; background: #f0f5fd; border: 3px solid var(--ink);
  border-radius: 16px; box-shadow: 0 4px 0 var(--ink); animation: popIn 380ms cubic-bezier(.2,1.4,.4,1) both; min-width: 0; }
.tile .lab { font-family: var(--text); font-weight: 900; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.tile b { font-family: var(--display); font-weight: 400; font-size: clamp(24px, 3.2vw, 32px); line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 11px; color: var(--ink-soft); font-weight: 800; }
.tile.good b { color: var(--grass-deep); }
.tile.bad b { color: var(--candy-deep); }

.res-head { display: flex; align-items: center; gap: 18px; }
.res-head h1 { font-size: clamp(40px, 6vw, 74px); color: #fff; text-align: left; }
.res-head h1.gold { color: var(--sun); }
.res-sub { font-family: var(--text); font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--ink); font-size: 17px; margin-top: 6px; }
.medal { width: 92px; height: 92px; flex: none; border-radius: 50%; border: 5px solid var(--ink); box-shadow: 0 7px 0 var(--ink); display: grid; place-items: center;
  transform: rotate(-8deg); animation: medalIn 700ms 150ms cubic-bezier(.2,1.6,.4,1) both; position: relative; }
.medal span { font-family: var(--display); font-size: 30px; color: var(--ink); }
.medal::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; border: 3px dashed rgba(29,43,83,0.25); }
.medal.gold { background: radial-gradient(circle at 35% 30%, #fff6c2, #ffd23f 55%, #e8a90c); }
.medal.silver { background: radial-gradient(circle at 35% 30%, #ffffff, #d6deea 55%, #9aa8c0); }
.medal.bronze { background: radial-gradient(circle at 35% 30%, #ffe0c2, #f0a05a 55%, #b8692a); }
.medal.plain { background: radial-gradient(circle at 35% 30%, #ffffff, #cfe6ff 60%, #8fc4f2); }
@keyframes medalIn { from { transform: rotate(-200deg) scale(0); } }
.res-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; width: min(1060px, 100%); align-items: start; }
.res-grid .recap-card { width: 100%; }
.res-side { display: grid; gap: 0; }
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.award { display: flex; align-items: center; gap: 10px; text-align: left; background: #fff4c7; border: 3px solid var(--ink); border-radius: 16px; padding: 8px 10px;
  box-shadow: 0 4px 0 var(--ink); animation: popIn 420ms cubic-bezier(.2,1.5,.4,1) both; }
.award .ico { font-size: 26px; width: 40px; height: 40px; display: grid; place-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 12px; flex: none; }
.award b { display: block; font-family: var(--display); font-weight: 400; font-size: 19px; line-height: 1.1; }
.award span { font-size: 13px; color: var(--ink-soft); font-weight: 800; }
.money-card { margin-top: 16px; background: var(--ink); color: #fff; border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 rgba(29,43,83,0.55);
  padding: 14px 18px 12px; animation: popIn 420ms 120ms cubic-bezier(.2,1.3,.4,1) both; }
.mc-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--text); font-weight: 900; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: #b9c6e6; margin-bottom: 6px; }
.mrow { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 2px dashed rgba(255,255,255,0.14); font-weight: 800; font-size: 15px; }
.mrow b { font-family: var(--display); font-weight: 400; font-size: 19px; font-variant-numeric: tabular-nums; }
.mrow.good b { color: #9cf08a; }
.mrow.note { color: #b9c6e6; font-size: 13px; }
.mrow.note b { font-size: 15px; color: #ffb3bb; }
.mnet { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0 2px; font-weight: 900; }
.mnet b { font-family: var(--display); font-weight: 400; font-size: 34px; }
.mnet b small { font-family: var(--text); font-weight: 900; font-size: 12px; color: #b9c6e6; }
.mnet.good b { color: #9cf08a; }
.mnet.bad b { color: #ff8f9a; }
.mc-foot { font-size: 12px; color: #93a3c9; font-weight: 700; margin-top: 4px; }
.board-card { padding: 8px 12px 10px; }
.board-card table.board td { padding: 6px 6px; }
.board-card td.pilot { display: flex; align-items: center; gap: 8px; max-width: 220px; }
.board-card td.pilot img { width: 40px; height: 25px; object-fit: contain; flex: none; }
.board-card td.pilot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-card .dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink); font-family: var(--display); font-size: 14px; }
.dot.m1 { background: var(--sun); } .dot.m2 { background: #d6deea; } .dot.m3 { background: #f0a05a; }
@media (max-width: 700px) {
  .res-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles.four { grid-template-columns: repeat(4, 1fr); }
  .awards { grid-template-columns: 1fr; }
  .medal { width: 70px; height: 70px; } .medal span { font-size: 24px; }
}
@media (max-width: 520px) {
  .tiles.four { grid-template-columns: repeat(2, 1fr); }
  .who { flex-direction: column; text-align: center; } .who .chips { justify-content: center; }
}
@media (max-height: 520px) {
  .recap-card { margin-top: 8px; padding: 10px 12px 12px; }
  .over.death h1, .res-head h1 { font-size: 38px; }
  .who-plane { width: 110px; height: 68px; }
  .tile { padding: 6px 4px; } .tile b { font-size: 22px; }
  .over .actions { margin-top: 12px; }
  .over .btn.huge { font-size: 28px; padding: 8px 34px 12px; }
}
/* recap layout refinements */
body.recap .hud > *:not(.flash) { opacity: 0; transition: opacity 250ms; }
body.recap .minimap, body.recap .touch { opacity: 0; pointer-events: none; }
.over.death, .over.results { background: radial-gradient(ellipse at 50% 40%, rgba(29,43,83,0.35), rgba(14,22,48,0.82)); backdrop-filter: blur(2px); }
.res-head { width: min(1060px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.res-title { display: flex; align-items: center; gap: 18px; }
.over .res-actions { margin-top: 0; }
.over .res-actions .btn.huge { font-size: 34px; padding: 8px 40px 14px; }
table.board tr.gap td { text-align: center; color: var(--ink-soft); padding: 0; border-top: 0; letter-spacing: 0.3em; }
@media (max-width: 860px) { .res-head { justify-content: center; } .over .res-actions { width: 100%; } }
.res-head h1 { font-size: clamp(36px, 5vw, 64px); }
.over .res-actions { gap: 10px; }
.over .res-actions .btn.huge { font-size: 28px; padding: 6px 30px 11px; border-radius: 18px; }
.over .res-actions .btn:not(.huge) { font-size: 16px; padding: 10px 16px 13px; }
.board-card table.board td { padding: 4px 6px; }
.board-card td.pilot img { width: 34px; height: 21px; }
.board-card table.board th { padding: 2px 6px 4px; }

/* phones in landscape: everything on one screen */
@media (max-height: 520px) {
  .over.death, .over.results { padding: 8px 10px 10px; }
  .over.death h1 { font-size: 30px; -webkit-text-stroke: 6px var(--ink); text-shadow: 0 4px 0 var(--ink); }
  .res-head h1 { font-size: 30px; -webkit-text-stroke: 6px var(--ink); text-shadow: 0 4px 0 var(--ink); }
  .res-sub { font-size: 13px; margin-top: 2px; }
  .medal { width: 54px; height: 54px; border-width: 4px; box-shadow: 0 4px 0 var(--ink); } .medal span { font-size: 18px; }
  .recap-card, .money-card { margin-top: 6px; border-radius: 18px; }
  .who { gap: 10px; }
  .who-plane { width: 84px; height: 54px; border-radius: 12px; }
  .who-name { font-size: 24px; margin: 0 0 4px; }
  .chips span { font-size: 11px; padding: 1px 8px; }
  .money-row { margin-top: 6px; gap: 6px; }
  .pill { font-size: 12px; padding: 2px 10px; box-shadow: 0 2px 0 var(--ink); }
  .sep { margin: 6px 0 6px; font-size: 10px; }
  .tiles { gap: 6px; }
  .tile { padding: 3px 4px 4px; border-radius: 12px; box-shadow: 0 2px 0 var(--ink); }
  .tile b { font-size: 20px; } .tile .lab { font-size: 9px; } .tile .sub { display: none; }
  .awards { margin-top: 8px; gap: 6px; } .award { padding: 4px 8px; } .award .ico { width: 30px; height: 30px; font-size: 18px; } .award b { font-size: 15px; }
  .over .actions { margin-top: 8px; }
  .over .btn.huge { font-size: 22px; padding: 5px 24px 9px; border-radius: 16px; }
  .over .actions .btn:not(.huge) { font-size: 14px; padding: 7px 14px 10px; }
  .mrow { padding: 3px 0; font-size: 13px; } .mrow b { font-size: 16px; } .mnet b { font-size: 26px; }
}
/* killcam colour grade (the replay reads as "the past") */
#game canvas { transition: filter 300ms ease; }
body.killcam #game canvas { filter: saturate(0.5) contrast(1.06) brightness(0.97); }

/* ------------------------------------------------------------------ training flight */
body.training .hud .tr, body.training .hud .tc, body.training .hud .side .board-mini, body.training .hud .killbanner { display: none; }
.coach { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 30; width: min(560px, calc(100vw - 24px)); pointer-events: none; display: grid; justify-items: center; gap: 10px; }
.coach-card { width: 100%; pointer-events: auto; background: var(--paper); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); padding: 10px 16px 12px; }
.coach-card.pop { animation: coachPop 460ms cubic-bezier(.2,1.5,.4,1); }
@keyframes coachPop { from { transform: translateY(-14px) scale(0.94); } }
.coach-card.done { border-color: var(--ink); background: linear-gradient(180deg, #fff9dd, var(--paper)); animation: coachPop 520ms cubic-bezier(.2,1.5,.4,1); }
.coach-head { display: flex; align-items: center; gap: 10px; }
.coach-tag { font-family: var(--text); font-weight: 900; font-size: 12px; letter-spacing: 0.14em; color: #fff; background: var(--sky-deep); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.coach-tag.gold { background: var(--sun); color: var(--ink); }
.coach-safe { font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.coach-dots { display: flex; gap: 6px; }
.coach-dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: #dfe7f5; }
.coach-dots i.done { background: var(--grass); }
.coach-dots i.now { background: var(--sun); animation: dotPulse 900ms ease-in-out infinite; }
@keyframes dotPulse { 50% { transform: scale(1.3); } }
.coach-head .coach-exit, .coach-head .btn { margin-left: auto; }
.coach-head .btn + .btn { margin-left: 6px; }
.coach-title { font-family: var(--display); font-size: clamp(24px, 3.4vw, 32px); line-height: 1.1; margin: 6px 0 2px; display: flex; align-items: center; gap: 10px; }
.coach-title.big { font-size: clamp(28px, 4.4vw, 40px); }
.coach-ico { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border: 3px solid var(--ink); border-radius: 12px; background: var(--sun); font-size: 22px; }
.coach-how { font-weight: 800; font-size: 15px; color: var(--ink-soft); line-height: 1.35; }
.coach-sub { margin-top: 4px; font-family: var(--text); font-weight: 900; font-size: 12px; letter-spacing: 0.12em; color: var(--sun-deep); text-transform: uppercase; }
.coach-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.coach-toast { font-family: var(--display); font-size: clamp(26px, 4vw, 40px); color: #fff; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink);
  opacity: 0; transform: scale(0.6) rotate(-3deg); transition: opacity 160ms, transform 260ms cubic-bezier(.2,1.6,.4,1); }
.coach-toast.show { opacity: 1; transform: scale(1) rotate(-3deg); }
.coach-toast.good { color: var(--sun); }
.coach-toast.bad { color: #ff8f9a; }
.train-offer { text-align: center; position: relative; padding-top: 44px; }
.train-offer h2 { justify-content: center; }
.offer-badge { position: absolute; top: -34px; left: 50%; transform: translateX(-50%) rotate(-8deg); width: 68px; height: 68px; display: grid; place-items: center; font-size: 34px;
  background: var(--sun); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 5px 0 var(--ink); }
.howto-train { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fff4c7; border: 3px solid var(--ink); border-radius: 16px; padding: 10px 12px; box-shadow: 0 4px 0 var(--ink); margin-bottom: 8px; }
.menu .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-height: 520px) {
  .coach-card { padding: 6px 12px 8px; border-radius: 16px; }
  .coach-title { font-size: 20px; margin: 2px 0 0; } .coach-ico { width: 28px; height: 28px; font-size: 16px; }
  .coach-how { font-size: 12px; }
  .coach-toast { font-size: 24px; -webkit-text-stroke: 5px var(--ink); }
}
@media (max-height: 520px) {
  .coach-title.big { font-size: 24px; }
  .coach-card.done .coach-how { font-size: 11.5px; }
  .coach-actions { margin-top: 6px; gap: 6px; }
  .coach-actions .btn.go { font-size: 18px; padding: 6px 16px 9px; }
}

/* missile dodge pop */
.dodge-pop { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 8; animation: dodgePop 1.15s cubic-bezier(.2,1.4,.4,1) both; }
.dodge-pop b { display: block; font-family: var(--display); font-weight: 400; font-size: clamp(34px, 5vw, 56px); color: #9fe8ff; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); letter-spacing: .03em; transform: rotate(-4deg); }
.dodge-pop.close b { color: #fff; font-size: clamp(40px, 6.2vw, 68px); }
.dodge-pop span { display: inline-block; margin-top: 4px; font-family: var(--text); font-weight: 900; font-size: 15px; color: #fff; background: var(--ink); border-radius: 999px; padding: 2px 12px; letter-spacing: .06em; text-transform: uppercase; }
@keyframes dodgePop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5) skewX(-18deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) skewX(0); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -64%) scale(.96); } }
@media (prefers-reduced-motion: reduce) { .dodge-pop { animation: none; } }

/* ------------------------------------------------------------------ Mysterious Cave */
.hud .tl, .hud .tc, .hud .tr, .hud .bc, .hud .side, .hud .bl, .minimap, .hud .toasts { transition: opacity 260ms; }
body.cave-cine .hud .tl, body.cave-cine .hud .tc, body.cave-cine .hud .tr, body.cave-cine .hud .bc, body.cave-cine .hud .side,
body.cave-cine .hud .bl, body.cave-cine .minimap, body.cave-cine .hud .warn, body.cave-cine .touch, body.cave-cine .mystic-badge,
body.cave-cine .cave-banner { opacity: 0 !important; pointer-events: none; }
body.cave-cine canvas { cursor: none !important; }

.cave-banner { position: absolute; left: 50%; top: 21%; transform: translateX(-50%); text-align: center; pointer-events: none; z-index: 9; animation: caveIn .6s cubic-bezier(.2,1.4,.4,1) both; }
.cave-banner.out { animation: caveOut .45s ease-in both; }
.cave-banner .cb-kicker { font-family: var(--text); font-weight: 900; font-size: 14px; letter-spacing: .22em; color: #7dffd8; text-shadow: 0 2px 0 var(--ink), 0 0 18px rgba(125,255,216,.7); }
.cave-banner .cb-title { font-family: var(--display); font-size: clamp(30px, 4.6vw, 54px); color: #fff; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink), 0 0 30px rgba(125,255,216,.55); letter-spacing: .03em; margin: 2px 0; }
.cave-banner .cb-sub { display: inline-block; font-family: var(--text); font-weight: 900; font-size: 14px; color: #fff; background: rgba(29,43,83,.85); border: 2px solid #7dffd8; border-radius: 999px; padding: 3px 14px; }
@keyframes caveIn { 0% { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(.7); filter: blur(6px); } 100% { opacity: 1; transform: translateX(-50%) scale(1); filter: none; } }
@keyframes caveOut { to { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.94); } }

.mystic-badge { position: absolute; top: 92px; left: 16px; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(29,43,83,.92), rgba(31,111,134,.88)); border: 3px solid #7dffd8; box-shadow: 0 3px 0 var(--ink), 0 0 22px rgba(125,255,216,.45);
  pointer-events: none; z-index: 6; animation: mysticIn .7s cubic-bezier(.2,1.5,.4,1) both, mysticGlow 2.2s ease-in-out .7s infinite; }
.mystic-badge img { width: 42px; height: 42px; border-radius: 50%; animation: mysticBob 1.6s ease-in-out infinite; }
.mystic-badge b { display: block; font-family: var(--display); font-weight: 400; font-size: 18px; color: #7dffd8; letter-spacing: .05em; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.mystic-badge .mb-chips { display: flex; gap: 6px; margin-top: 2px; }
.mystic-badge .mb-chips span { font-family: var(--text); font-weight: 900; font-size: 12px; color: var(--ink); border-radius: 999px; padding: 1px 8px; }
.mystic-badge .mb-chips .hp { background: #8ff07d; }
.mystic-badge .mb-chips .dmg { background: #ffb15c; }
.mystic-badge.lost { animation: mysticLost .85s cubic-bezier(.5,0,.8,.4) both; }
@keyframes mysticIn { 0% { opacity: 0; transform: translateX(-40px) scale(.5); } 100% { opacity: 1; transform: none; } }
@keyframes mysticGlow { 50% { box-shadow: 0 3px 0 var(--ink), 0 0 34px rgba(125,255,216,.8); } }
@keyframes mysticBob { 50% { transform: translateY(-2px) rotate(-6deg); } }
@keyframes mysticLost { 0% { transform: none; opacity: 1; filter: none; } 25% { transform: scale(1.12) rotate(-3deg); filter: brightness(1.8) saturate(.2); } 100% { transform: translate(-30px, 60px) scale(.6) rotate(-18deg); opacity: 0; filter: grayscale(1); } }
body.touch-ui .mystic-badge { top: 70px; left: 240px; transform: scale(.85); transform-origin: left top; }
@media (prefers-reduced-motion: reduce) { .cave-banner, .mystic-badge, .mystic-badge img { animation: none; } }

/* ------------------------------------------------------------------ friends' rooms */
.friends-btn { margin-top: 10px; font-size: 17px; padding: 10px 22px; --face: #b48cff; --edge: #7d5cc7; --fg: #fff; text-shadow: 0 2px 0 var(--ink); }
.modal.friends { width: min(640px, 94vw); text-align: center; }
.friends-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0; text-align: left; }
.fcol { display: grid; gap: 10px; align-content: start; background: rgba(29,43,83,0.06); border: 3px solid var(--ink); border-radius: 16px; padding: 14px; }
.fcol h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 22px; }
.fcol p { margin: 0; font-size: 14px; }
.room-input { font-family: var(--display); font-size: 30px; letter-spacing: .3em; text-align: center; text-transform: uppercase; padding: 8px 6px 8px 14px; border: 3px solid var(--ink); border-radius: 12px; width: 100%; box-sizing: border-box; }
.room-input.bad { animation: shake .4s; border-color: #ff4f5e; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.bots-toggle.off { opacity: .65; text-decoration: line-through; }
@media (max-width: 560px) { .friends-cols { grid-template-columns: 1fr; } }

.mm.private .kicker { font-family: var(--text); font-weight: 900; letter-spacing: .28em; color: #b48cff; text-shadow: 0 2px 0 var(--ink); }
.mm.private .room-code { font-family: var(--display); font-size: clamp(56px, 11vw, 112px); letter-spacing: .18em; color: #fff; -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); margin: 2px 0 10px; user-select: all; }
.mm.private .pilots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 720px; margin: 6px auto 16px; }
.mm.private .pilot { font-family: var(--text); font-weight: 900; font-size: 15px; background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 14px; box-shadow: 0 3px 0 var(--ink); animation: pilotIn .35s cubic-bezier(.2,1.5,.4,1) both; }
.mm.private .pilot.me { background: #ffd23f; }
.mm.private .pilot.wait { opacity: .6; }
@keyframes pilotIn { from { transform: scale(.4); opacity: 0; } }
.mm.private .col { display: grid; gap: 10px; justify-items: center; }
.mm.private .waiting { display: flex; gap: 10px; align-items: center; font-family: var(--text); font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--ink); }

/* Bomber: fat round bomb pips; the next one fills from the bottom while it regenerates */
.missiles.bombs i { width: 22px; height: 26px; border-radius: 50% 50% 40% 40%; background: radial-gradient(circle at 35% 30%, #9aa3b5, #3a3f55 70%); }
.missiles.bombs i.off { background: linear-gradient(0deg, rgba(255,177,92,0.85) var(--fill, 0%), rgba(29,43,83,0.45) var(--fill, 0%)); }
/* Locust: a bay of small bombs */
.missiles.bombs.light i { width: 12px; height: 16px; background: radial-gradient(circle at 35% 30%, #e4f59a, #5d6b22 70%); }
.missiles.bombs.light i.off { background: linear-gradient(0deg, rgba(228,245,154,0.85) var(--fill, 0%), rgba(29,43,83,0.45) var(--fill, 0%)); }
/* full-screen help (iPhone: install to home screen) */
.fs-help .fs-steps { text-align: left; margin: 8px auto; padding-left: 22px; max-width: 420px; line-height: 1.5; }
.fs-help .fs-steps li { margin: 4px 0; }
/* notches: keep menus clear of the camera cut-out in landscape */
.menu { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }

/* phones in landscape: everything on the main menu fits without scrolling */
.menu { overflow-y: auto; justify-content: safe center; }
@media (max-height: 520px) {
  .menu { gap: 8px; padding-top: 52px; padding-bottom: 10px; }
  .topbar { top: 8px; }
  .topbar .mode-chip { display: none; }
  .logo { font-size: 44px; -webkit-text-stroke-width: 7px; text-shadow: 0 5px 0 var(--ink); margin: 0; }
  .tagline { display: none; }
  .btn.huge { font-size: 30px; padding: 6px 40px 10px; }
  .menu-grid { grid-template-columns: repeat(6, auto); gap: 8px; margin-top: 0; }
  .menu-grid .btn { font-size: 14px; padding: 8px 12px 10px; }
  .menu .row .btn, .menu .friends-btn { font-size: 14px; padding: 8px 14px 10px; }
}
@media (max-height: 520px) {
  .modal { max-height: calc(var(--app-h, 100vh) - 16px); overflow-y: auto; }
  .fs-help .offer-badge { display: none; }
  .fs-help h2 { font-size: 26px; margin: 0 0 4px; }
  .fs-help .fs-steps { font-size: 14px; line-height: 1.35; margin: 4px auto; }
  .fs-help p { font-size: 13px; margin: 4px 0; }
  .fs-help .row { margin-top: 8px !important; }
}

/* ---- touch buttons: glassy discs with icons, live ammo / cooldown / boost rings ---- */
.touch .tpad { position: absolute; right: env(safe-area-inset-right); bottom: env(safe-area-inset-bottom); width: 330px; height: 250px; transform-origin: bottom right; pointer-events: none; }
.touch .tb { position: absolute; width: 70px; height: 70px; border-radius: 50%; padding: 0; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 3px solid rgba(29,43,83,0.9); color: #fff; background: var(--c); opacity: 0.86;
  box-shadow: 0 4px 0 rgba(29,43,83,0.9), inset 0 -6px 0 rgba(0,0,0,0.16), inset 0 6px 10px rgba(255,255,255,0.35);
  transition: transform 60ms, box-shadow 60ms, opacity 120ms; overflow: visible; }
.touch .tb .ic { width: 46%; height: 46%; filter: drop-shadow(0 2px 0 rgba(29,43,83,0.85)); pointer-events: none; }
.touch .tb b { font-family: var(--display); font-weight: 400; font-size: 10.5px; letter-spacing: .04em; line-height: 1; text-shadow: 0 1.5px 0 rgba(29,43,83,0.9); pointer-events: none; }
/* cooldown / empty sweep (--cd = fraction NOT ready) */
.touch .tb::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(rgba(29,43,83,0.62) calc(var(--cd, 0) * 360deg), transparent 0); }
.touch .tb em { position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 12px; font-style: normal;
  font-family: var(--display); font-size: 14px; line-height: 19px; color: var(--ink); background: var(--paper); border: 2.5px solid var(--ink); z-index: 1; }
.touch .tb em:empty { display: none; }
.touch .tb.empty { opacity: 0.6; }
.touch .tb.on { transform: translateY(3px) scale(0.93); box-shadow: 0 1px 0 rgba(29,43,83,0.9), inset 0 4px 10px rgba(0,0,0,0.2); opacity: 1; filter: brightness(1.12); }
.touch .fire { --c: var(--candy); width: 108px; height: 108px; right: 22px; bottom: 22px; }
.touch .fire .ic { width: 42%; height: 42%; }
.touch .fire b { font-size: 14px; }
.touch .msl  { --c: var(--missile); right: 142px; bottom: 14px; }
.touch .bst  { --c: var(--boost); right: 34px; bottom: 146px; }
.touch .roll { --c: var(--grass); right: 128px; bottom: 106px; }
.touch .jmp  { --c: #b48cff; width: 58px; height: 58px; right: 226px; bottom: 64px; }
.touch .jmp b { font-size: 9px; }
@media (max-height: 460px) { .touch .tpad { transform: scale(0.86); } }
@media (max-height: 380px) { .touch .tpad { transform: scale(0.76); } }
@media (orientation: portrait) { .touch .tpad { transform: scale(0.9); } }
@media (orientation: portrait) and (max-width: 760px) {
  body.touch-ui .hud .tl { width: calc(50vw - 64px); }
  .touch .ttop { top: auto; bottom: calc(260px + env(safe-area-inset-bottom)); left: auto; right: 14px; flex-direction: column; }
  .touch .rotate-hint { top: 150px; font-size: 13px; }
  .touch .tpad { bottom: calc(46px + env(safe-area-inset-bottom)); }
  .touch .stick { top: calc(100% - 170px); }
}

/* garage on phones (touch + short screen only, PC layout unchanged): plane beside the controls */
@media (pointer: coarse) and (max-height: 600px) {
  .screen.panel-wrap:has(.garage) { padding: 8px; }
  .panel:has(.garage) { padding: 10px 16px 12px; max-height: calc(var(--app-h, 100vh) - 16px); }
  .panel:has(.garage) .panel-head { margin-bottom: 6px; }
  .panel:has(.garage) .panel-head h2 { font-size: 26px; margin: 0; }
  .garage { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); grid-template-areas: "pic desc" "pic side"; column-gap: 16px; align-items: center; }
  .garage .g-desc { grid-area: desc; font-size: 13px; margin: 0; }
  .garage .plane { grid-area: pic; width: 100% !important; }
  .garage .g-side { grid-area: side; }
  .garage .field { margin: 6px 0; }
  .garage .swatch { width: 34px; height: 34px; }
  .garage .swatches { gap: 8px; }
  .garage input[type=text] { padding: 6px 10px; font-size: 15px; }
}
@media (pointer: coarse) and (max-height: 360px) {
  .garage .g-desc { display: none; }
  .garage .swatch { width: 30px; height: 30px; }
}

/* tutorial on phones: a compact card tucked top-left (where the minimap usually is), so the
   middle of the screen — where your plane flies — stays clear */
body.touch-ui.training:not(.train-cave) .minimap { display: none; }
/* cave step on phones: the minimap (with the ✦ cave) sits top-right instead */
body.touch-ui.training.train-cave .minimap { left: auto; right: calc(12px + env(safe-area-inset-right)); top: 12px; }
body.touch-ui .coach { top: 70px; left: calc(10px + env(safe-area-inset-left)); transform: none; width: min(340px, 42vw); justify-items: start; gap: 6px; }
body.touch-ui .coach-card { padding: 6px 10px 8px; border-radius: 14px; border-width: 3px; box-shadow: 0 4px 0 var(--ink); opacity: 0.95; }
body.touch-ui .coach-head { gap: 6px; }
body.touch-ui .coach-tag { font-size: 9.5px; padding: 1px 7px; letter-spacing: 0.1em; }
body.touch-ui .coach-safe { display: none; }
body.touch-ui .coach-dots { gap: 4px; }
body.touch-ui .coach-dots i { width: 8px; height: 8px; border-width: 1.5px; }
body.touch-ui .coach-head .btn { font-size: 11px; padding: 3px 9px 5px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
body.touch-ui .coach-title { font-size: 15px; margin: 4px 0 1px; gap: 6px; }
body.touch-ui .coach-ico { width: 22px; height: 22px; font-size: 13px; border-width: 2px; border-radius: 7px; }
body.touch-ui .coach-how { font-size: 11px; line-height: 1.25; }
body.touch-ui .coach-sub { font-size: 9.5px; margin-top: 2px; }
body.touch-ui .coach-toast { font-size: 20px; -webkit-text-stroke: 4px var(--ink); text-shadow: 0 3px 0 var(--ink); }
/* the end-of-lesson card has big buttons: centre it again (the flying is over) */
body.touch-ui .coach:has(.coach-card.done) { left: 50%; transform: translateX(-50%); top: 56px; width: min(440px, calc(100vw - 24px)); justify-items: center; }
body.touch-ui .coach-card.done .coach-title { font-size: 22px; }
body.touch-ui .coach-card.done .coach-how { font-size: 12px; }
@media (max-width: 640px) {
  body.touch-ui .coach { width: 205px; }
  body.touch-ui .coach-title { font-size: 13px; }
  body.touch-ui .coach-how { font-size: 10px; }
}

/* tutorial bombs step on PC: move the card off the top centre so you can see the Bomber above you */
body.training.train-bombs:not(.touch-ui) .coach { top: 78px; left: 16px; transform: none; width: min(400px, 34vw); justify-items: start; }
/* matchmaking / private-room overlay: hide the in-game HUD behind it, and fit short phone screens */
body:has(.overlay-layer .mm) .hud, body:has(.overlay-layer .mm) .minimap { opacity: 0; pointer-events: none; }
@media (max-height: 520px) {
  .mm { gap: 6px; padding: 8px; }
  .mm .big { font-size: 30px; -webkit-text-stroke-width: 5px; text-shadow: 0 4px 0 var(--ink); }
  .mm .count { font-size: 22px; }
  .mm .slots { grid-template-columns: repeat(8, 16px); gap: 6px; }
  .mm .slots i { width: 16px; height: 16px; border-width: 2px; }
  .mm .tagline { display: block; font-size: 13px; margin: 0; padding: 2px 12px; }
  .mm.private .room-code { font-size: 44px; -webkit-text-stroke-width: 6px; margin: 0 0 4px; }
  .mm.private .pilots { margin: 2px auto 6px; }
}

/* tutorial: switching into the Bomber (covers the plane swap) */
.swap-fx { position: fixed; inset: 0; z-index: 60; pointer-events: none; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.95), rgba(255,236,170,0.55) 35%, rgba(58,168,240,0) 70%);
  animation: swapFlash 2.3s ease-out forwards; }
.swap-card { text-align: center; animation: swapCard 2.3s cubic-bezier(.2,1.4,.4,1) forwards; }
.swap-kicker { font-family: var(--text); font-weight: 900; letter-spacing: .3em; font-size: 14px; color: var(--ink); }
.swap-title { font-family: var(--display); font-size: clamp(40px, 8vw, 88px); line-height: 1; color: var(--sun);
  -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); transform: rotate(-3deg); }
.swap-sub { margin-top: 10px; font-weight: 900; font-size: 18px; color: #fff; text-shadow: 0 2px 0 var(--ink); }
@keyframes swapFlash { 0% { opacity: 0; } 10% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes swapCard { 0% { transform: scale(0.4); opacity: 0; } 18% { transform: scale(1.06); opacity: 1; } 28% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: scale(1.1); opacity: 0; } }
@media (max-height: 520px) { .swap-title { font-size: 40px; -webkit-text-stroke-width: 5px; } .swap-sub { font-size: 14px; } }

/* friends' match: leave mid-match (hidden until you're flying; two taps) */
.hud .leave-btn { display: none; margin: 6px auto 0; pointer-events: auto; font-family: var(--text); font-weight: 900; font-size: 12px; letter-spacing: .04em;
  color: var(--ink); background: rgba(255,255,255,0.85); border: 2.5px solid var(--ink); border-radius: 999px; padding: 3px 12px; box-shadow: 0 2px 0 var(--ink); cursor: pointer; }
.hud .leave-btn.on { display: block; }
.hud .leave-btn.armed { background: #ff8f9a; color: #fff; text-shadow: 0 1px 0 var(--ink); }
body.killcam .hud .leave-btn, body.recap .hud .leave-btn { display: none; }
/* death screen: change plane */
.plane-btn { display: inline-flex; align-items: center; gap: 8px; }
.plane-btn img { width: 54px; height: auto; margin: -6px 0; }
.plane-pick { width: min(720px, calc(100vw - 24px)); }
.plane-pick h2 { margin: 0 0 10px; }
.pp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pp-card { display: grid; justify-items: center; gap: 2px; padding: 8px 6px 10px; background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; font-family: var(--text); color: var(--ink); }
.pp-card img { width: 100%; max-width: 130px; height: auto; }
.pp-card b { font-family: var(--display); font-weight: 400; font-size: 20px; line-height: 1; }
.pp-card span { font-size: 11px; font-weight: 900; letter-spacing: .12em; color: var(--ink-soft); }
.pp-card.selected { background: #fff4c7; outline: 4px solid var(--sun); outline-offset: 1px; }
.pp-card:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
@media (max-height: 520px) {
  .plane-pick { padding: 10px 14px; }
  .plane-pick h2 { font-size: 22px; margin-bottom: 6px; }
  .pp-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .pp-card { padding: 4px 3px 6px; border-width: 2px; border-radius: 12px; }
  .pp-card b { font-size: 14px; }
  .pp-card span { display: none; }
}

/* "Your plane is still flying" prompt: must fit a landscape phone with both buttons visible */
.modal.resume { max-width: 560px; max-height: calc(var(--app-h, 100vh) - 24px); overflow-y: auto; }
.modal.resume h2 { font-size: clamp(22px, 6vh, 34px); margin: 0 0 8px; }
.modal.resume p { margin: 6px 0; }
.modal.resume .row { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
@media (max-height: 520px) {
  .modal.resume { padding: 14px 20px; }
  .modal.resume p { font-size: 14px; }
  .modal.resume .btn.huge { font-size: 22px; padding: 10px 28px; }
}

/* ------------------------------------------------------------------ team mode */
.friends .toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.friends .small-note { font-size: 12.5px; margin: -2px 0 0; }
.teams-toggle { opacity: .75; }
.teams-toggle.on { opacity: 1; background: #b48cff; color: #fff; }
.mm.private .no-team-head { font-family: var(--text); font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--ink); margin-top: 2px; }
.mm.private .pilots:empty { display: none; }
.team-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; width: min(920px, 100%); margin: 4px auto 14px; }
.team-card { display: grid; grid-template-rows: auto 1fr auto; gap: 8px; background: var(--paper); border: 3px solid var(--ink); border-top: 12px solid var(--team); border-radius: 16px; padding: 10px; box-shadow: 0 4px 0 var(--ink); min-height: 150px; }
.team-name { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--display); font-size: 24px; color: var(--team); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }
.team-name small { font-family: var(--text); font-weight: 900; font-size: 14px; color: var(--ink); -webkit-text-stroke: 0; }
.team-list { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.team-list .pilot { font-size: 13px !important; padding: 3px 10px !important; border-color: var(--team) !important; box-shadow: 0 2px 0 var(--ink) !important; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-list .empty { color: var(--ink-soft); font-size: 13px; text-align: center; padding-top: 6px; }
.team-join { background: var(--team); color: #fff; text-shadow: 0 2px 0 rgba(29,43,83,.6); font-size: 15px; padding: 8px 6px; }
.team-join.mine { background: #fff; color: var(--ink); text-shadow: none; }
.team-join:disabled { cursor: default; filter: saturate(.55); }
.team-join.mine:disabled { filter: none; }
.team-standings { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.team-standings .ts { display: flex; gap: 8px; align-items: baseline; background: var(--paper); border: 3px solid var(--ink); border-left: 10px solid var(--team); border-radius: 12px; padding: 4px 12px; box-shadow: 0 3px 0 var(--ink); }
.team-standings .ts.mine { background: #fff6cc; }
.team-standings .ts b { font-family: var(--display); font-weight: 400; font-size: 18px; }
.team-standings .ts span { font-weight: 900; font-size: 13px; color: var(--ink-soft); }
@media (max-width: 720px) { .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-height: 520px) {
  .team-grid { gap: 8px; margin: 2px auto 8px; }
  .team-card { min-height: 0; padding: 6px 8px; gap: 5px; border-top-width: 8px; }
  .team-name { font-size: 18px; }
  .team-join { font-size: 13px; padding: 5px 4px; }
}
/* the team lobby is taller: never cut it off — compact on short screens, scroll as a last resort */
.mm.private.teamed { overflow-y: auto; justify-content: safe center; touch-action: pan-y; overscroll-behavior: contain; }
@media (max-height: 520px) {
  .mm.private.teamed { gap: 4px; padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .mm.private.teamed .kicker { font-size: 11px; }
  .mm.private.teamed .room-code { font-size: 34px; -webkit-text-stroke-width: 5px; text-shadow: 0 4px 0 var(--ink); margin: 0; }
  .mm.private.teamed .tagline { display: none; }
  .mm.private.teamed .no-team-head { font-size: 13px; margin: 0; }
  .mm.private.teamed .pilots { margin: 0 auto 2px; }
  .mm.private.teamed .btn.small { padding: 4px 12px; font-size: 13px; }
  .mm.private.teamed .col { gap: 6px; }
  .mm.private.teamed .col .btn.huge { font-size: 22px; padding: 8px 30px; }
  .mm.private.teamed .team-list .empty { padding-top: 0; }
}
@media (max-height: 520px) {
  /* Play-with-friends box: keep CREATE ROOM / JOIN on screen on a landscape phone */
  .modal.friends h2 { font-size: 24px; margin: 0; }
  .modal.friends .friends-cols { margin: 6px 0; gap: 10px; }
  .modal.friends .fcol { padding: 10px; gap: 8px; }
  .modal.friends .fcol h3 { font-size: 18px; }
  .modal.friends .fcol p.muted { display: none; }
}

/* Bomber on touch: FIRE becomes an aiming joystick for the 360° turret */
.touch .fire.aim { --c: #ff6b5e; }
.touch .fire.aim .aring { position: absolute; inset: 14%; border-radius: 50%; border: 2px dashed rgba(255,255,255,0.75); pointer-events: none; }
.touch .fire.aim .aknob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.28); border: 3px solid rgba(29,43,83,0.85);
  box-shadow: 0 3px 0 rgba(29,43,83,0.8); transition: transform 40ms linear; pointer-events: none; }
.touch .fire.aim .aknob .ic { width: 62%; height: 62%; }
.touch .fire.aim b { position: absolute; bottom: 7px; font-size: 11px; }
.touch .fire.aim.on { transform: none; filter: brightness(1.1); }

/* friends' room code in the top-right corner (tap to copy the invite link) */
.room-tag { display: inline-flex; align-items: baseline; gap: 6px; margin-top: 6px; padding: 3px 10px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.35);
  background: rgba(29,43,83,0.65); color: #fff; font-family: var(--text); font-weight: 900; cursor: pointer; pointer-events: auto; }
.room-tag small { font-size: 10px; letter-spacing: .14em; opacity: .75; }
.room-tag b { font-family: var(--display); font-weight: 400; font-size: 17px; letter-spacing: .12em; }
.room-tag.copied b::after { content: ' ✓ link copied'; font-family: var(--text); font-weight: 900; font-size: 11px; letter-spacing: 0; color: #9ff0b0; }
.hud .tr .room-tag { display: inline-flex; }
body.touch-ui .room-tag { padding: 2px 8px; }
body.touch-ui .room-tag b { font-size: 15px; }
.gfx-reset { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(29,43,83,0.85);
  color: #fff; font-family: var(--text); font-weight: 900; font-size: 18px; text-align: center; padding: 24px; }

/* touch stick: the knob turns orange while it is close to the centre (slowing down) */
.touch .stick.slow i { background: #ffb347; }
.touch .stick.slow::after { content: 'SLOW'; position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); font-family: var(--display); font-size: 13px; color: #ffb347; text-shadow: 0 2px 0 var(--ink); }
