:root { color-scheme:dark; --ink:#060b12; --steel:#627e8b; --cyan:#9be6fb; --green:#47f01e; }
* { box-sizing:border-box; }
html,body { padding:0; margin:0; min-height:100%; }
body { background:radial-gradient(ellipse at 50% 10%, #27334a 0%,#0b101b 47%,#05070e 100%); color:#f5f7fc; font-family:Consolas,'DejaVu Sans Mono',monospace; }
/* Fit the entire scene, both HUD bars and controls inside the browser viewport.
   The 1280x500 playfield stays proportional at laptop and desktop sizes. */
.game-shell { width:min(calc(100vw - 24px), calc((100dvh - 205px) * 2.56), 1648px); margin:6px auto 5px; }
.game-frame { width:100%; position:relative; overflow:hidden; background:#090c16; border:2px solid #455d72; box-shadow:0 15px 65px #000a,0 0 0 1px #000 inset; }
.top-hud { min-height:54px; display:grid; grid-template-columns:minmax(295px,2.05fr) minmax(178px,1.22fr) minmax(180px,1.1fr) minmax(185px,1.0fr) 42px; align-items:center; gap:12px; position:relative; z-index:2; padding:6px 13px 5px 21px; background:linear-gradient(180deg,#04070a,#0b0e12); border-bottom:3px solid #3c5263; box-shadow:0 2px 0 #0009; text-shadow:0 1px 2px #000; }
.mission-block { min-width:0; }
.mission-line { font-size:clamp(14px,1.55vw,22px); line-height:1.16; font-weight:900; letter-spacing:.055em; white-space:nowrap; }
.mission-subline { display:flex; align-items:center; height:27px; gap:8px; line-height:1; }
.life-icon { display:flex; align-items:center; width:65px; overflow:hidden; }
.life-icon svg { width:69px; height:24px; }
.life-count { font-size:18px; font-weight:900; white-space:nowrap; }
.mission-clock,.convoy-small { color:#a9d8df; font-weight:700; font-size:clamp(10px,.9vw,13px); margin-left:9px; white-space:nowrap; }
.top-stat { white-space:nowrap; font-size:clamp(13px,1.55vw,22px); font-weight:900; letter-spacing:.07em; }
.top-stat strong { margin-left:7px; }
.rescue-stat { text-align:center; }
.person-icon { color:white; display:inline-block; font-size:21px; line-height:15px; vertical-align:baseline; }
.health-stat { display:flex; align-items:center; justify-content:flex-end; gap:9px; font-size:clamp(13px,1.45vw,20px); font-weight:900; }
.health-segments { display:flex; gap:2px; min-width:88px; flex:0 0 116px; height:18px; }
.health-segments span { background:#13310f; box-shadow:inset 0 0 0 1px #22352a; flex:1; }
.health-segments span.on { background:linear-gradient(180deg,#60ff39,#27cd00); box-shadow:inset 0 0 0 1px #1c9b05,0 0 5px #21fe3a55; }
.health-segments span.warn { background:linear-gradient(180deg,#ffc65d,#f47600); }
.pause { min-width:37px; height:31px; color:#b5e7ff; background:#162639; border:1px solid #628a9d; border-radius:4px; font:bold 21px Consolas,monospace; cursor:pointer; }
.pause:hover,.pause:focus-visible { background:#234864; outline:1px solid #b4ebff; }
.canvas-wrap { position:relative; width:100%; background:#201a35; overflow:hidden; }
#game { display:block; width:100%; height:auto; aspect-ratio:1280/500; }
.bottom-hud { display:grid; grid-template-columns:33% 44% 23%; min-height:88px; gap:0; padding:7px 7px 6px; background:linear-gradient(#050a0c,#0b1016 40%,#030709); border-top:3px solid #576b77; }
.hud-card { position:relative; min-width:0; margin:0 4px; border:2px solid #597787; border-top-color:#8da6ac; background:linear-gradient(180deg,#101c23,#070e14); box-shadow:inset 0 0 0 2px #111923,0 0 0 1px #000; clip-path:polygon(0 11px,11px 0,calc(100% - 11px) 0,100% 11px,100% 100%,0 100%); }
.panel-label { position:absolute; z-index:2; top:0; left:14px; font-weight:900; font-size:clamp(12px,1.4vw,20px); line-height:26px; color:var(--cyan); text-shadow:0 0 9px #3bacc755; }
.weapon-items { display:grid; grid-template-columns:30% 38% 32%; height:100%; padding:27px 10px 8px; }
.weapon { display:flex; align-items:center; position:relative; min-width:0; gap:6px; border-right:1px solid #293a44; }
.weapon:last-child {border:0;}
.weapon-symbol { line-height:1; flex:0 0 34px; text-align:center; font-weight:900; font-size:29px; color:#e4aa61; text-shadow:0 0 6px #f9c57866; }
.rocket-icon {color:#dceaf4; transform:rotate(-40deg); font-size:32px;}
.special-icon {color:#77d9f7; text-shadow:0 0 8px #44cffa; font-size:34px;}
.weapon-copy { display:flex; flex-direction:column; justify-content:center; min-width:0; gap:6px; }
.weapon-copy b { font-size:clamp(11px,1.22vw,18px); line-height:1; }
.mini-bar { background:#293038; border:1px solid #374957; height:7px; width:clamp(22px,3.5vw,65px); overflow:hidden; }
.mini-bar i {display:block; height:100%; width:100%; background:linear-gradient(90deg,#c87d31,#fbe08d);}
.mini-bar.cyanbar i {width:56%; background:linear-gradient(90deg,#2c8ab3,#8be7ff);}
.mini-bar.gunbar i {width:43%;}
.ammo { margin-left:auto; margin-right:5px; align-self:end; font-size:clamp(12px,1.2vw,17px); font-weight:900; }
.ammo.cyan { color:#7fdbfa; }
.radar { padding:1px 3px; background:#020b0d; }
#radar { display:block; width:100%; height:100%; min-height:63px; }
.fuel { padding:27px 16px 4px; }
.fuel-track {height:22px; border:2px solid #7b8b91; background:#1b2025; border-radius:4px; padding:3px; box-shadow:inset 0 0 6px #000; }
.fuel-fill { height:100%; width:100%; background:linear-gradient(180deg,#ffe65f 0%,#ffca05 100%); box-shadow:0 0 6px #facf2899; transition:width .18s linear; }
.fuel-number { display:flex; justify-content:space-between; color:#90b3bc; font-size:clamp(10px,.84vw,12px); font-weight:700; padding-top:4px; }
.overlay { position:absolute; inset:0; display:flex; justify-content:center; align-items:center; background:#060c1bc9; z-index:4; }
.overlay.hidden { display:none; }
.overlay-inner {max-width:90%; background:linear-gradient(#1c2935ef,#0a111bee); border:2px solid #91bfd2; padding:24px 54px; text-align:center; box-shadow:0 0 60px #000; }
.overlay-tag { color:#84c8dc; font-size:12px; font-weight:900; letter-spacing:.35em; }
.overlay h2 { font-size:clamp(28px,3vw,43px); margin:12px auto; }
.overlay p { font-size:18px; color:#e7f5ff; }
.overlay button { cursor:pointer; border:2px solid #74cce6; padding:12px 21px; background:#124d68; color:white; font-weight:900; letter-spacing:.09em; }
.overlay button:hover {background:#19718e;}
.controls { color:#9badbd; text-align:center; line-height:1.7; margin:4px 0; letter-spacing:.045em; font-size:clamp(10px,1.12vw,15px); }
.controls b {color:#d6effb;}
@media (max-width:950px){ .top-hud { grid-template-columns:minmax(190px,2fr) minmax(100px,1fr) minmax(110px,1fr) minmax(120px,1fr) 32px; gap:6px; padding:5px 6px; min-height:54px; } .mission-line {font-size:clamp(10px,1.65vw,15px);} .mission-subline {height:21px;gap:3px;} .mission-clock,.convoy-small {font-size:9px;margin-left:4px;} .life-icon {width:40px;} .life-icon svg {width:43px;height:16px;} .life-count {font-size:12px;} .top-stat {font-size:clamp(10px,1.5vw,14px);} .top-stat strong {margin-left:2px;} .person-icon {font-size:14px;} .health-stat {gap:4px;font-size:clamp(10px,1.4vw,13px);} .health-segments {flex-basis:62px; min-width:62px; height:12px; gap:1px;} .pause {height:25px;min-width:28px;font-size:17px;} .bottom-hud {min-height:75px;padding:4px 2px;} .panel-label {font-size:clamp(11px,1.3vw,15px);line-height:20px;left:8px;} .weapon-items {padding:22px 4px 5px;} .weapon {gap:3px;} .weapon-symbol {font-size:17px;flex-basis:17px;} .rocket-icon {font-size:19px;} .special-icon {font-size:20px;} .weapon-copy {gap:4px;} .weapon-copy b {font-size:clamp(8px,1.1vw,13px);} .ammo {font-size:clamp(9px,1.1vw,12px);margin-right:2px;} .mini-bar {height:4px;} .fuel {padding:22px 7px 2px;} .fuel-track{height:14px;padding:2px;} .fuel-number {font-size:9px;} #radar {min-height:60px;} }
@media (max-width:650px){.game-shell {width:100%; margin:0 auto 12px;}.top-hud {gap:4px;grid-template-columns:minmax(135px,1.8fr) minmax(70px,1fr) minmax(68px,1fr) minmax(72px,.9fr) 24px;padding:3px 4px;min-height:45px;} .mission-line{font-size:clamp(9px,1.85vw,12px);letter-spacing:0;} .mission-clock{display:none;} .convoy-small{display:none;} .life-icon{width:30px;} .life-icon svg{width:30px;} .life-count{font-size:10px;} .top-stat{font-size:clamp(8px,1.5vw,11px);letter-spacing:0;} .rescue-stat{text-align:left;} .person-icon {display:none;} .health-stat{font-size:clamp(8px,1.5vw,10px);display:block;} .health-segments{width:100%;min-width:0;flex-basis:auto;height:8px;margin-top:3px;} .pause {height:23px;min-width:22px;font-size:14px;padding:0;} .bottom-hud{grid-template-columns:42% 35% 23%;min-height:55px;} .hud-card{margin:0 2px;} .weapon-items{padding:19px 3px 2px;} .panel-label{font-size:9px;line-height:17px;left:6px;} .weapon-symbol{display:none;} .weapon-copy b{font-size:8px;} .ammo{font-size:9px;} #radar{min-height:42px;} .fuel{padding:19px 5px 2px;} .fuel-number {font-size:8px;} .fuel-number span:last-child{display:none;} .controls{padding:0 4px;font-size:10px;}}

/* Viewport height falls when browser toolbars, tabs and bookmarks consume space. */
@media (max-height: 780px) and (min-width: 950px) {
  .game-shell { width:min(calc(100vw - 20px), calc((100dvh - 185px) * 2.56), 1648px); margin:3px auto; }
  .top-hud { min-height:48px; padding-top:2px; padding-bottom:2px; }
  .bottom-hud { min-height:76px; padding-top:4px; padding-bottom:4px; }
  #radar { min-height:59px; }
  .controls { font-size:12px; margin:2px 0; }
}
@media (max-height: 560px) and (min-width: 650px) {
  .game-shell { width:min(calc(100vw - 16px), calc((100dvh - 150px) * 2.56), 1648px); margin:2px auto; }
  .top-hud { min-height:39px; }
  .bottom-hud { min-height:65px; }
  .controls { font-size:10px; margin:1px 0; }
}

/* V7: tighten the HUD to the approved widescreen arcade composition. */
.arrived-truck {height:24px;width:46px;vertical-align:middle;margin-right:5px;transform:translateY(-2px);}
.score-stat {text-align:center;}
.top-hud {background:linear-gradient(180deg,#05080b 0%,#0b0e13 73%,#020508 100%);}
.hud-card {border-color:#67859a;border-top-color:#9bafbc;}
#radar {image-rendering:auto;}
@media (max-width:950px){.arrived-truck {width:30px;height:17px;margin-right:0;}}
@media (max-width:650px){.arrived-truck {display:none;}}

/* V9 controller indicator, below the existing frame so the HUD stays identical. */
.controller-status { margin:1px 0 6px; font-size:11px; text-align:center; letter-spacing:.12em; color:#6e8c98; }
.controller-status.connected { color:#91ecc5; }
@media(max-width:650px){.controller-status{font-size:9px;}}

/* V10 build label: small, understated, always at the upper right of the HUD.
   Keep the pause button visible and the status meters in their own columns. */
.top-hud {
  grid-template-columns:minmax(280px,2.05fr) minmax(145px,1.22fr) minmax(150px,1.1fr) minmax(155px,1fr) 92px 36px 42px;
  gap:9px;
}
.build-version {
  display:block;
  min-width:0;
  text-align:right;
  white-space:nowrap;
  font:700 11px/1.2 Consolas,'DejaVu Sans Mono',monospace;
  letter-spacing:.055em;
  color:#93a7b3;
  opacity:.88;
}
@media (max-width:950px) {
  .top-hud {
    grid-template-columns:minmax(175px,2fr) minmax(85px,1fr) minmax(90px,1fr) minmax(105px,1fr) 67px 28px 32px;
    gap:5px;
  }
  .build-version {font-size:9px;letter-spacing:0;}
}
@media (max-width:650px) {
  .top-hud {
    grid-template-columns:minmax(120px,1.8fr) minmax(59px,1fr) minmax(61px,1fr) minmax(61px,.9fr) 51px 24px 24px;
    gap:3px;
  }
  .build-version {font-size:8px;overflow:hidden;text-overflow:clip;}
}


/* V12: Onscreen game controls for iOS / Android. Hidden on desktop/mouse
   systems so existing keyboard and Xbox players see the original artwork. */
.touch-controls,.mobile-help,.portrait-notice { display:none; }
.touch-controls { position:absolute; inset:0; z-index:3; pointer-events:none; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; }
.touch-pad,.touch-action { touch-action:none; -webkit-tap-highlight-color:transparent; }
.touch-pad { position:absolute; bottom:7%; left:3%; width:clamp(98px,15.5vw,148px); aspect-ratio:1; border:2px solid rgba(171,218,238,.58); background:rgba(2,16,30,.23); border-radius:50%; pointer-events:auto; box-shadow:inset 0 0 23px #02121c8e,0 0 8px #0006; }
.touch-pad-ring { position:absolute; inset:22%; border:1px solid rgba(163,216,236,.23); border-radius:50%; }
.touch-stick { position:absolute; left:50%; top:50%; width:43%; aspect-ratio:1; border-radius:50%; transform:translate(-50%,-50%); background:radial-gradient(circle at 35% 30%,#82dcf5aa,#1b506bc5); border:2px solid #b3e8f3aa; box-shadow:0 1px 14px #000a; }
.touch-pad-caption { position:absolute; left:0; right:0; bottom:-19px; text-align:center; font:800 11px Consolas,monospace; color:#d2ecf4; text-shadow:0 1px 3px #000; }
.touch-actions { position:absolute; bottom:3%; right:2.5%; display:grid; grid-template-columns:repeat(2,minmax(52px,1fr)); grid-template-rows:repeat(2, minmax(52px,1fr)); gap:8px; width:clamp(124px,20vw,178px); pointer-events:none; }
.touch-action { pointer-events:auto; min-width:0; min-height:52px; border:2px solid #a6d8e29c; border-radius:14px; font:bold clamp(11px,1.5vw,15px) Consolas,monospace; color:#fff; text-shadow:0 1px 2px #000; background:rgba(9,35,54,.64); box-shadow:inset 0 0 14px #0004,0 1px 10px #0007; padding:3px; cursor:pointer; }
.touch-action:active,.touch-action.pressed { transform:scale(.96); background:rgba(38,112,142,.86); border-color:#d8f5fc; }
.touch-gun { grid-row:1 / 3; grid-column:2; font-size:clamp(15px,2vw,22px); border-color:#ffdc83bb; background:rgba(117,66,15,.75); border-radius:38px; }
.touch-rocket { grid-column:1; grid-row:2; border-color:#ffc375aa; }
.touch-special { grid-column:1; grid-row:1; border-color:#90e6f8a8; }
.touch-face { position:absolute; right:0; top:-48px; min-height:38px; height:38px; width:52%; font-size:12px; }
@media (hover:none) and (pointer:coarse) {
  .touch-controls,.mobile-help {display:block;}
  .mobile-help {color:#9bcbdc;text-align:center;font:700 10px/1.4 Consolas,monospace;margin:4px 8px;}
  .controls {display:none;}
  /* Screen width is the limiting factor on phones, not the desktop formula
     that reserved 205px of vertical space below the game. */
  .game-shell {width:min(100%, 1648px);margin:0 auto;}
  .controller-status {margin:2px 0;}
  .canvas-wrap {touch-action:none;}
}
@media (hover:none) and (pointer:coarse) and (orientation:landscape) and (max-height:600px) {
  html,body {overscroll-behavior:none;}
  .game-frame {border-width:1px;}
  .top-hud {min-height:39px; padding-top:2px;padding-bottom:2px;}
  .mission-subline {height:17px;}
  .bottom-hud {min-height:51px;padding:3px 2px;}
  #radar {min-height:39px;}
  .panel-label {line-height:16px;}
  .weapon-items {padding-top:17px;}
  .fuel {padding-top:18px;}
  .canvas-wrap {height:clamp(135px,calc(100dvh - 115px),500px);}
  #game {width:100%;height:100%;aspect-ratio:auto;object-fit:contain;}
  .mobile-help,.controller-status {display:none;}
  .mission-line {font-size:clamp(9px,1.35vw,13px);}

  .touch-pad {width:clamp(90px,18dvh,145px);bottom:11%;left:3%;}
  .touch-actions {width:clamp(128px,29dvh,172px);bottom:9%;right:3%;gap:5px;grid-template-rows:repeat(2,minmax(48px,1fr));}
  .touch-action {min-height:48px;}
  .touch-face {top:-39px;height:34px;min-height:34px;}
}
@media (hover:none) and (pointer:coarse) and (orientation:portrait) and (max-width:680px) {
  .portrait-notice { display:block;text-align:center;padding:9px;background:#15374d;color:#ecfcff;font-weight:700;font-size:13px;margin:6px; }
  .touch-pad { width:26vw;bottom:6%;left:3%; }
  .touch-actions { width:37vw;bottom:4%;right:3%;gap:4px;grid-template-rows:repeat(2,42px); }
  .touch-action {min-height:42px;font-size:10px;}
  .touch-gun {font-size:14px;}
  .touch-face {top:-35px;height:30px;min-height:30px;font-size:9px;}
  .touch-pad-caption {display:none;}
}

/* V13: The touch overlay can be independently toggled even on touchscreen PCs. */
.settings-button {font-size:20px; padding:0;}
.settings-panel[hidden] {display:none !important;}
.settings-panel {
  position:absolute;right:7px;top:55px;z-index:8;
  width:min(310px,calc(100% - 14px));padding:13px 14px;
  background:linear-gradient(#192c3b,#0b1924);border:2px solid #79b7ce;
  box-shadow:0 12px 30px #000c;color:#e6f8ff;
  font:14px/1.5 Consolas,'DejaVu Sans Mono',monospace;
}
.settings-header {display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;color:#c4efff;}
.settings-header button {font:22px Consolas,monospace;color:white;background:#193a4d;border:1px solid #688e9f;min-width:32px;min-height:30px;cursor:pointer;}
.settings-panel label {display:block;margin-bottom:5px;color:#bed6dd;font-size:12px;text-transform:uppercase;}
.settings-panel select {display:block;width:100%;min-height:36px;font:14px Consolas,monospace;background:#0a2537;color:#e6f8ff;border:1px solid #689caf;padding:5px;}
.settings-panel p {font-size:11px;color:#a9c5ce;margin:10px 0 0;}
html.touch-disabled .touch-controls,
html.touch-disabled .mobile-help,
html.touch-disabled .portrait-notice {display:none !important;}
html.show-touch .touch-controls,
html.show-touch .mobile-help {display:block !important;}
html.show-touch .controls {display:none !important;}
@media (max-width:950px) {.settings-button {font-size:16px;min-width:25px;}}
@media (max-width:650px) {.settings-button {font-size:14px;min-width:22px;} .settings-panel{top:46px;} }

@media (max-width:480px) {
  .top-hud {grid-template-columns:minmax(88px,1.6fr) minmax(39px,.8fr) minmax(44px,1fr) minmax(42px,.8fr) 39px 22px 22px;gap:2px;padding:3px 4px;}
  .mission-line {font-size:8px;}
  .life-icon {display:none;}
  .top-stat {font-size:8px;}
  .top-stat strong {margin-left:1px;}
  .build-version {font-size:7px;}
  .health-stat {font-size:8px;}
  .settings-button,.pause {min-width:20px;height:22px;font-size:14px;}
}
