:root {
  color-scheme: dark;
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
  color: #f4efde;
  background: #141c1c;
  --accent: #d6f68c;
  --muted: #b6bfb2;
  --edge: #384841;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.shell { width: min(1240px, calc(100% - 64px)); margin: 30px auto; }
.masthead { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font: 600 10px/1.5 var(--mono); letter-spacing: .19em; text-transform: uppercase; }
h1 { margin: 0; font-family: "Archivo Black", Impact, "Arial Black", sans-serif; font-size: clamp(28px, 5.3vw, 60px); font-weight: 900; font-style: italic; line-height: .98; letter-spacing: .015em; }
h1 em { color: var(--accent); font-style: inherit; }
.utilities { display: flex; align-items: center; gap: 7px; }
.utilities button, .touch button { border: 1px solid var(--edge); border-radius: 4px; background: #222c28; padding: 8px 11px; font: 600 11px/1.2 var(--mono); white-space: nowrap; }
.utilities button:hover, .touch button:hover { border-color: #779079; background: #2d3d31; }
.utilities button[aria-pressed="true"] { color: var(--accent); }

.game { border: 1px solid var(--edge); border-radius: 7px; overflow: hidden; background: #1d2724; box-shadow: 0 18px 50px #06100f49; }
.viewport { position: relative; isolation: isolate; aspect-ratio: 16/9; overflow: hidden; background: #728bc1; }
#world { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.hud { position: absolute; color: #fbf3db; }
.hud-location { top: 18px; left: 20px; text-shadow: 0 2px #172b33, 1px 0 #172b33, -1px 0 #172b33; }
.hud-label { display: block; color: #f0eddc; font: 600 9px/1.25 var(--mono); text-transform: uppercase; letter-spacing: .16em; }
.hud-location strong { display: block; margin-top: 3px; font: 700 clamp(12px, 2vw, 20px)/1.1 "Instrument Sans", "Segoe UI", sans-serif; }
.hud-status { top: 18px; right: 18px; display: flex; align-items: center; gap: 9px; background: #142723eb; border: 1px solid #e8ffcc42; border-radius: 4px; padding: 6px 9px; font: 700 10px/1.15 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
#flight-state { color: var(--accent); }
.altitude { padding-left: 8px; border-left: 1px solid #748776; color: #f5ebd7; white-space: nowrap; }
.camera { left: 18px; bottom: 17px; display: grid; grid-template-columns: auto auto; align-items: center; gap: 3px 12px; background: #142723eb; border: 1px solid #e8ffcc42; border-radius: 4px; padding: 7px 9px; text-align: left; }
.camera:hover { background: #263b30; border-color: var(--accent); }
.camera strong { font: 700 12px/1.1 var(--mono); }
.camera kbd { grid-column: 2; grid-row: 1 / span 2; }
.map { position: absolute; right: 18px; bottom: 17px; border: 1px solid #e8ffcc42; border-radius: 4px; padding: 3px; background: #142723d9; pointer-events: none; }
#map { display: block; width: clamp(56px, 8.5vw, 100px); height: auto; image-rendering: pixelated; }
.charge { position: absolute; bottom: 27px; left: 50%; translate: -50% 0; width: min(220px, 35%); padding: 8px 10px; background: #142723ef; border: 1px solid #e8ffcc62; border-radius: 4px; text-align: center; }
#charge-label { display: block; margin-bottom: 5px; color: var(--accent); font: 700 10px/1.1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.charge-track { display: block; height: 5px; background: #425347; }
.charge-track i { height: 100%; display: block; background: #ebff9c; transform: scaleX(0); transform-origin: left; }

.console { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 10px 20px; }
.console p { margin: 0; color: #e7ebd9; font-size: 13px; }
.console b { color: var(--accent); }
.keys { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 15px; }
.keys span { white-space: nowrap; color: var(--muted); font: 600 10px/1.15 var(--mono); }
kbd { display: inline-block; min-width: 18px; padding: 3px 4px; border: 1px solid #627063; border-radius: 3px; color: #f9f3df; background: #2b382f; font: 600 10px/1 var(--mono); text-align: center; }
.keys kbd + kbd { margin-left: 2px; }
.keys kbd:last-of-type { margin-right: 3px; }
.touch { display: none; }

.energy { top: 55px; right: 18px; width: 125px; display: grid; grid-template-columns: 1fr auto; gap: 4px; padding: 6px 8px; border: 1px solid #e8ffcc42; border-radius: 4px; background: #142723eb; font: 700 10px/1 var(--mono); text-transform: uppercase; }
.energy strong { color: var(--accent); }
.energy i { grid-column: 1 / -1; display: block; height: 3px; background: var(--accent); transform-origin: left; }
.title-screen { position: absolute; z-index: 5; inset: 0; display: flex; align-items: center; background: linear-gradient(90deg, #101c1cf5, #172927e8 23%, #17292775 47%, #17292708 75%); }
.title-panel { width: min(450px, 65%); margin-left: clamp(18px, 5vw, 67px); }
.title-panel > .eyebrow { color: var(--accent); }
.title-panel h2 { margin: 8px 0 12px; font: italic 900 clamp(31px, 7.4vw, 100px)/.86 "Archivo Black", Impact, "Arial Black", sans-serif; letter-spacing: .015em; text-shadow: 3px 4px #101b1a; }
.title-panel h2 em { color: var(--accent); }
.title-panel > p:not(.eyebrow) { max-width: 280px; margin: 0 0 18px; color: #f4efde; font-size: clamp(12px, 1.5vw, 16px); line-height: 1.35; }
.title-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.title-actions button, dialog button { min-height: 35px; border: 1px solid #78907b; border-radius: 4px; background: #293c32; padding: 7px 11px; font: 700 11px/1.2 var(--mono); }
button.primary { color: #1b2518; border-color: var(--accent); background: var(--accent); }
button.primary:hover { background: #e8ffa8; }
.title-actions button span { margin-left: 6px; }
.settings { width: min(280px, 70%); }
.settings h2 { font: 800 clamp(18px, 3vw, 28px)/1 "Segoe UI", sans-serif; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 7px 0; font-size: 12px; }
.settings input { accent-color: var(--accent); }
.settings input[type="range"] { width: 38%; }
.settings .title-actions { margin-top: 12px; }
.roster { margin-top: 15px; }
.roster-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.roster-heading h2, .roster-heading p { margin: 0; font: 700 11px/1.25 var(--mono); }
.roster-heading h2 { color: #f4efde; text-transform: uppercase; letter-spacing: .09em; }
.roster-heading p { color: var(--muted); text-align: right; }
.fighters { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.fighter { display: flex; align-items: center; gap: 5px; justify-content: center; min-height: 44px; border: 1px solid var(--edge); border-radius: 4px; background: #202b27; padding: 3px 2px; font: 700 10px/1 var(--mono); }
.fighter canvas { width: 29px; height: 34px; image-rendering: pixelated; }
.fighter:hover, .fighter[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #2f3b2a; }
dialog { color: #f4efde; width: min(460px, calc(100% - 24px)); border: 1px solid #647568; border-radius: 7px; background: #1c2924; padding: 18px; }
dialog::backdrop { background: #081213bd; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; font-size: 20px; }
dialog p { color: #dce0d1; font-size: 13px; }
dialog label { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 6px; font: 700 11px/1.2 var(--mono); }
dialog input { min-width: 0; border: 1px solid #78907b; border-radius: 4px; padding: 7px; font: 600 12px/1.2 var(--mono); }

@media (max-width: 640px) {
  .shell { width: calc(100% - 24px); margin: 16px auto; }
  .masthead { flex-wrap: wrap; margin-bottom: 12px; gap: 10px; }
  .viewport { aspect-ratio: 4/3; }
  .hud-location { top: 10px; left: 10px; }
  .hud-status { top: 10px; right: 9px; font-size: 9px; gap: 5px; }
  .energy { top: 41px; right: 9px; width: 88px; }
  .camera { left: 8px; bottom: 8px; gap: 2px 6px; }
  .map { right: 8px; bottom: 8px; }
  .charge { bottom: 9px; }
  .console { padding: 10px; }
  .fighters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .touch { flex-wrap: wrap; }
}
@media (pointer: coarse) {
  .touch { display: flex; justify-content: space-between; align-items: end; gap: 8px; margin-top: 10px; touch-action: none; }
  .touch button { min-height: 44px; min-width: 44px; padding: 6px; touch-action: none; user-select: none; }
  .touch button[data-held="true"] { color: #1c2718; background: var(--accent); }
  .dpad { display: grid; grid-template-columns: repeat(3, 44px); gap: 3px; }
  .dpad button:first-child { grid-column: 2; }
  .dpad button:nth-child(2) { grid-column: 1; grid-row: 2; }
  .dpad button:nth-child(3) { grid-column: 2; grid-row: 2; }
  .dpad button:nth-child(4) { grid-column: 3; grid-row: 2; }
  .touch-actions { display: flex; gap: 4px; }
  .keys { display: none; }
}

.back-link { color: #d6f68c; text-decoration: none; border: 1px solid #384841; border-radius: 4px; padding: 8px 11px; font: 600 11px/1.2 Consolas, monospace; white-space: nowrap; }
.back-link:hover { border-color: #d6f68c; }
