@font-face {
  font-family: 'Midway HUD';
  src: url('./assets/game/fonts/hud-ko.woff2') format('woff2');
  font-display: swap;
}
:root { color-scheme: dark; --ink: #f2eedc; --muted: #a7bab8; --navy: #0b1d29; --panel: #122d39; --accent: #dfbc78; --sea: #103949; }
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; background: var(--navy); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif; }
button { font: inherit; color: inherit; background: #203e49; border: 0; padding: 10px 15px; cursor: pointer; }
button:hover { background: #345661; }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; }
[hidden] { display: none !important; }
#game-shell { height: 100dvh; display: flex; flex-direction: column; }
.flight-header { display: flex; align-items: center; gap: 30px; padding: 10px 24px; min-height: 56px; background: var(--navy); anchor-name: --flight-header; }
.wordmark { white-space: nowrap; font-weight: 700; letter-spacing: .03em; font-size: 17px; }
.wordmark strong { color: var(--accent); margin-left: 6px; }
.flight-header p { flex: 1; margin: 0; color: var(--muted); }
.flight-header button { padding: 7px 14px; }
@media (max-width: 700px) {
  .flight-header:has(#controls-button:not([hidden])) { display: grid; grid-template-columns: 1fr repeat(3, auto); gap: 2px 6px; }
  .flight-header:has(#controls-button:not([hidden])) #objective { grid-row: 2; grid-column: 1 / -1; }
  .flight-header:has(#controls-button:not([hidden])) button { padding: 5px 8px; font-size: 13px; white-space: nowrap; }
}
#viewport { flex: 1; position: relative; min-height: 0; overflow: hidden; background: var(--sea); }
#game, #markers { width: 100%; height: 100%; display: block; position: absolute; inset: 0; image-rendering: pixelated; }
#markers { pointer-events: none; }
#enemy-altitudes { position: absolute; inset: 4px; z-index: 1; pointer-events: none; }
#enemy-altitudes:empty { display: none; }
#enemy-altitudes span {
  position: absolute; top: 0; left: 0; width: calc(7ch + 8px); padding: 2px 4px; border-radius: 3px;
  background: #10212df2; color: #f5f5ef; text-align: center; white-space: nowrap;
  font: 700 clamp(12px, 1.1vw, 16px)/1.25 ui-monospace, monospace;
}
#enemy-altitudes [data-sign="+"] { color: #ffab78; }
#enemy-altitudes [data-sign="−"] { color: #87dfff; }
#pause { z-index: 2; }
#flight-hud { --hud-center: 40%; --hud-map-space: 222px; }
#boost-panel {
  --signal: #ffd17b; --unlit: #3c555b;
  position: absolute; top: 27%; left: clamp(8px, 2vw, 20px); width: 168px;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 5px 4px; padding: 6px 7px;
  background: #172d33; color: #edf4dc; font: 12px/16px 'Midway HUD', monospace; pointer-events: none;
  box-shadow: 0 -2px #77978e, -2px 0 #77978e, 2px 0 #10242c, 0 2px #10242c;
}
#boost-panel label { display: flex; align-items: center; gap: 4px; color: var(--signal); }
#boost-panel label::before {
  content: ''; width: 8px; height: 12px; background: currentColor;
  clip-path: polygon(4px 0,8px 0,8px 2px,6px 2px,6px 4px,4px 4px,4px 6px,8px 6px,
    8px 8px,6px 8px,6px 10px,4px 10px,4px 12px,2px 12px,2px 8px,0 8px,0 4px,2px 4px,2px 2px,4px 2px);
}
#boost-readout { text-align: right; white-space: nowrap; }
#boost-panel.hot { --signal: #ff9b78; }
#boost-panel.cooling { --signal: #a6e2d5; }
#boost-gauge {
  --cell: calc(100% / var(--cells));
  grid-column: 1 / -1; appearance: none; width: 100%; height: 8px; border: 0;
  background: linear-gradient(90deg, var(--signal) calc(var(--lit, 0) * var(--cell)), var(--unlit) 0);
  mask: repeating-linear-gradient(90deg, #000 0 calc(var(--cell) - 2px), transparent 0 var(--cell));
}
#boost-gauge::-webkit-progress-bar { background: transparent; }
#boost-gauge::-webkit-progress-value { background: transparent; }
#boost-gauge::-moz-progress-bar { background: transparent; }
@media (forced-colors: active) {
  #boost-gauge { forced-color-adjust: none; --signal: Highlight; --unlit: GrayText; }
}
@media (pointer: coarse) and (max-height: 650px) {
  #flight-hud { --hud-map-space: 132px; }
}
@media (max-width: 700px) and (orientation: portrait) {
  #flight-hud { --hud-map-space: 8px; --hud-map-bottom: 269px; --hud-phone-dot: 1.5px; --hud-phone-center: 50%; }
}
@media (max-width: 700px) and (orientation: landscape) {
  #flight-hud { --hud-map-space: 152px; }
}
#viewport > midway-altimeter {
  position: absolute; left: 16px; bottom: 14px; width: clamp(84px, 14vh, 142px); pointer-events: none;
}
#preflight:not([hidden]) ~ midway-altimeter, #success:not([hidden]) ~ midway-altimeter { visibility: hidden; }
@media (pointer: coarse) {
  #viewport > midway-altimeter { bottom: auto; top: clamp(51px, 14vh, 99px); left: 9px; width: clamp(55px, 11vh, 88px); }
}
#game { touch-action: none; }
#departure-ui { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: clamp(16px,3.5vw,54px); pointer-events: none; background: linear-gradient(to top,#08151ee8,transparent 28%); }
.departure-caption p { margin: 0 0 3px; color: #f1ddaf; font-size: clamp(11px,1.1vw,15px); font-weight: 600; }
.departure-caption strong { display: block; font-size: clamp(24px,3.3vw,46px); line-height: 1.15; letter-spacing: -.045em; text-shadow: 0 2px 8px #10212d; }
.departure-track { width: clamp(84px,12vw,175px); height: 2px; margin-top: 13px; background: #d7e3e44d; }
.departure-track i { display: block; height: 100%; background: var(--accent); transform-origin: left; }
#skip-departure { pointer-events: auto; background: #102532c9; border: 1px solid #c7d2ca80; padding: 8px 13px; font-size: 13px; }
#skip-departure kbd { margin-left: 5px; color: var(--accent); font-size: 15px; }
.departing #objective, .departing .payload, .departing .flight-footer nav button:not(#pause-button):not(#sound) { visibility: hidden; }
.departing #pause { z-index: 3; }
#touch-flight { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#stick { position: absolute; left: 14%; top: 72%; width: clamp(66px,16vh,112px); aspect-ratio: 1; transform: translate(-50%,-50%); border: 2px solid #e4e6c999; background: #102b3670; border-radius: 50%; }
#stick.active { border-color: var(--accent); }
#stick span { position: absolute; inset: 29%; background: #dfbc789c; border-radius: 50%; }
.touch-actions { position: absolute; right: max(12px,env(safe-area-inset-right)); bottom: 10%; display: flex; gap: 8px; }
.touch-actions button { pointer-events: auto; touch-action: none; user-select: none; min-width: 48px; min-height: 44px; border: 1px solid #b7cabe; background: #122d39dc; }
.touch-actions button.active { background: #806340; }
#touch-boost {
  font: 12px/1 'Midway HUD', monospace; color: #ffd17b; background: #172d33; border: 2px solid #77978e;
  box-shadow: inset -2px -2px #10242c;
}
#touch-boost.active { color: #172d33; background: #ffd17b; border-color: #edf4dc; }
#settings { width: min(360px,92vw); }
#settings label { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 7px 0; }
#settings select { color: var(--ink); background: var(--panel); padding: 4px 8px; }
#settings form { text-align: right; }
#settings p { font-size: 13px; }
#notice { position: absolute; left: 50%; top: 24px; transform: translateX(-50%); padding: 9px 20px; max-width: 80%; background: #0b1d29eb; color: var(--ink); text-align: center; pointer-events: none; }
#notice:empty { padding: 0; }
@media (max-width: 700px) {
  #notice { left: 8px; top: 8px; max-width: calc(100% - 164px); transform: none; padding: 4px 8px; }
}
@media (pointer: coarse) and (max-height: 650px) {
  #preflight { align-items: stretch; padding-block: 5px; }
  .briefing { overflow-y: auto; }
  #fleet-panel { transform: scale(.60); transform-origin: top right; right: 6px; top: 6px; }
  #notice { top: 4px; font-size: 12px; padding: 3px 8px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 650px) {
  .touch-actions { right: max(148px,env(safe-area-inset-right)); bottom: 8px; }
}
#loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--navy); z-index: 5; }
#fleet-panel { position: absolute; right: 20px; top: 20px; width: 196px; padding: 14px 10px 8px; background: #0b1d29e8; }
.target-caption { color: var(--muted); font-size: 13px; }
#fleet-panel h2 { font-size: 23px; margin: 2px 0; }
#fleet-panel p { color: var(--condition-color, var(--accent)); margin: 0 0 9px; font-size: 13px; }
#target-health { display: block; appearance: none; width: 100%; height: 6px; border: 0; background: #334752; margin-bottom: 13px; }
#target-health::-webkit-progress-bar { background: #334752; }
#target-health::-webkit-progress-value { background: var(--condition-color); }
#target-health::-moz-progress-bar { background: var(--condition-color); }
#map { display: block; width: 176px; height: 176px; image-rendering: pixelated; }
.map-legend { display: flex; justify-content: space-between; font-size: 10px; margin-top: 6px; color: var(--muted); }
.map-legend span:first-child { color: #9ecdb7; }.map-legend span:nth-child(2) { color: #e49473; }
#preflight { position: absolute; inset: 0; display: flex; align-items: center; padding: 26px clamp(24px, 5vw, 90px); background: #07192375; }
.briefing { width: 410px; padding: 30px 32px 22px; background: #0b1d29f5; }
h1 { font-size: clamp(34px, 3.4vw, 52px); line-height: 1.08; letter-spacing: -.045em; margin: 0 0 15px; }
h1 span { display: block; color: var(--accent); font-size: 1.42em; letter-spacing: -.045em; }
fieldset { margin: 0; padding: 0; border: 0; }legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.factions { display: flex; gap: 5px; margin-bottom: 10px; }.factions button { flex: 1; }
.factions button[aria-pressed=true] { background: var(--accent); color: var(--navy); font-weight: 700; }
.aircraft-list { display: grid; gap: 6px; }
.aircraft-choice { display: flex; align-items: center; gap: 12px; text-align: left; padding: 8px 12px; background: #17313c; min-height: 64px; }
.aircraft-choice[aria-pressed=true] { background: #38505a; box-shadow: inset 4px 0 var(--accent); }
.aircraft-choice canvas { width: 64px; height: 64px; image-rendering: pixelated; flex-shrink: 0; }
.aircraft-choice strong { display: block; font-size: 15px; }.aircraft-choice small { color: var(--muted); }
#airframe-spec, #loadout { font-size: 12px; }
#airframe-spec { color: var(--muted); margin: 10px 0 2px; }
#loadout { color: var(--accent); margin: 0 0 12px; }
#credits table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
#credits th, #credits td { padding: 4px 6px; border-bottom: 1px solid var(--panel); text-align: right; }
#credits th:first-child, #credits td:first-child { text-align: left; }
#credits summary { cursor: pointer; color: var(--accent); }
#credits details { margin: 1em 0; }
.launch { width: 100%; color: var(--navy); background: var(--accent); font-size: 18px; font-weight: 700; padding: 13px; }.launch:hover { background: #f0d69e; }
.text-button { background: transparent; padding: 5px 0; color: var(--muted); font-size: 12px; }
.flight-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 22px; background: var(--navy); }
#flight-controls[popover]:not(:popover-open) { display: none; }
#flight-controls:popover-open {
  inset: 56px 8px auto auto; top: anchor(--flight-header bottom, 56px); margin: 4px 0 0; width: max-content; max-width: calc(100% - 16px);
  display: grid; gap: 8px; padding: 10px; border: 1px solid #45616a; color: var(--ink);
}
#flight-controls:popover-open nav { justify-content: flex-start; margin: 0; }
.instruments { display: flex; gap: 26px; }.instruments > div { white-space: nowrap; }.instruments span { display: block; font-size: 11px; color: var(--muted); }.instruments strong { font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }.instruments small { font-size: 11px; color: var(--muted); margin-left: 4px; }.payload strong { color: var(--accent); font-size: 20px; }
.instruments > div:has(#speed) { font-family: 'Midway HUD', monospace; }
.instruments #speed { font-size: 24px; font-weight: 400; color: #ffd17b; }
.instruments > div:has(#speed) :is(span, small) { font-size: 12px; }
nav { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }nav button { font-size: 12px; padding: 8px 11px; }
#success { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0b1d29f5; padding: 18px 25px; align-items: center; display: flex; gap: 20px; white-space: nowrap; }#success strong { color: var(--accent); font-size: 24px; }
#pause { position: absolute; inset: 0; background: #071923b0; display: flex; align-items: center; justify-content: center; gap: 22px; }#pause strong { font-size: 32px; }
dialog { color: var(--ink); background: var(--navy); border: 0; max-width: 600px; padding: 28px; }dialog::backdrop { background: #06111ccc; }dialog p { color: var(--muted); }dialog a { color: var(--accent); }dialog h2 { margin-top: 0; }
@media(max-height: 850px) { .briefing { padding: 20px 24px 12px; }h1 { font-size: 35px; margin-bottom: 10px; }h1 span { display: inline; font-size: 1em; }.aircraft-choice { min-height: 55px; }.aircraft-choice canvas { width: 48px; height: 48px; } }
@media(max-width: 1050px) { .flight-footer { padding: 9px 14px; gap: 8px; }.instruments { gap: 18px; }nav { max-width: 380px; }nav button { padding: 6px 8px; }.flight-header { padding: 8px 14px; gap: 15px; } }
@media(max-width: 700px) { .flight-header p { font-size: 11px; }.wordmark { font-size: 14px; }#preflight { padding: 10px; }.briefing { width: 330px; max-height: 100%; overflow-y: auto; padding: 17px 20px; }#fleet-panel { right: 8px; top: 8px; transform: scale(.72); transform-origin: right top; }.instruments { gap: 13px; }.instruments strong { font-size: 20px; }.payload strong { font-size: 16px; }.flight-footer { display: block; }.flight-footer nav { max-width: none; justify-content: flex-start; margin-top: 8px; }#success { max-width: 95%; white-space: normal; gap: 8px; padding: 10px; } }
@media (orientation: portrait) {
  .cockpit-view .touch-actions { bottom: max(10%, 25vw); }
}
@media(prefers-reduced-motion: reduce) { * { transition: none !important; } }

.briefing { max-height: 100%; overflow-y: auto; }
#mode-picker { display: grid; gap: 7px; margin: 0 0 16px; }
#mode-picker button { display: grid; grid-template-columns: 1fr auto; text-align: left; padding: 11px 15px; }
#mode-picker strong { font-size: 18px; }
#mode-picker button::after { content: '→'; align-self: center; color: var(--accent); }
#game-shell:has(#preflight:not([hidden])) :is(.instruments, .flight-footer button:not(#sound)) { display: none; }
#game-shell:has(#preflight:not([hidden])) .flight-footer { justify-content: flex-end; }
#game-shell[data-theatre="tropical"] { --accent: #a5e8ce; }
#island-setup { display: grid; grid-template-columns: 48px minmax(0,1fr) auto; gap: 5px 8px; align-items: center; margin-bottom: 8px; }
#island-setup label, #island-count { font-size: 12px; color: var(--muted); }
#island-setup label, #coast-island { grid-column: 2; }
.island-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
#island-count { text-align: right; }
#coast-island { min-width: 0; background: var(--navy); color: var(--ink); border: 1px solid #45616a; padding: 7px; }
#shuffle-islands { font-size: 12px; padding: 7px 10px; }
#island-preview { grid-column: 1; grid-row: 1 / 3; width: 48px; image-rendering: pixelated; background: #10557a; }
#game-shell[data-theatre="tropical"] #launch { margin-top: 5px; padding: 8px; background: #203e49; color: var(--ink); font-size: 15px; }
#game-shell[data-theatre="tropical"] #launch:hover { background: #345661; }
#campaign-error { font-size: 13px; color: #ffc8a8; }
#mission-launch { display: grid; grid-template-columns: 1fr auto; width: 100%; text-align: left; border-left: 3px solid var(--accent); background: #29434b; margin: 0 0 14px; }
#mission-launch:hover { background: #36545d; }
#mission-launch strong { font-size: 18px; }
#mission-launch span { align-self: center; color: var(--accent); font-size: 22px; }
#mission-card { position: absolute; left: clamp(12px,3vw,44px); bottom: 20px; max-width: min(520px,70%); padding: 11px 16px; background: #0b1d29f2; border-left: 3px solid var(--accent); }
#mission-scene { display: block; color: var(--accent); font-size: 13px; }
#game-shell:not(.campaign) #mission-scene { display: none; }
#dive-guide { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 8px; pointer-events: none; }
.campaign #dive-guide { margin-top: 5px; }
#dive-cue { display: block; font-size: 14px; color: var(--accent); }
#dive-input { font-family: inherit; font-size: 12px; font-weight: 600; white-space: nowrap; padding: 1px 5px; color: var(--ink); background: #29434b; border-radius: 3px; }
#dive-gauge { display: block; grid-column: 1 / -1; width: 100%; height: 4px; margin-top: 2px; accent-color: var(--accent); }
.campaign #success { max-width: 94%; white-space: normal; flex-wrap: wrap; gap: 8px 18px; z-index: 3; }
.campaign #pause { z-index: 4; }
@media (max-width: 700px), (max-height: 580px) {
  #mission-card { bottom: 6px; left: 6px; max-width: calc(100% - 12px); padding: 6px 10px; font-size: 13px; }
}
@media (pointer: coarse) {
  .campaign.flying #mission-card, #mission-card:has(#dive-guide:not([hidden])) { bottom: 6px; max-width: calc(100% - 155px); pointer-events: none; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 650px) {
  .campaign.flying #mission-card, #mission-card:has(#dive-guide:not([hidden])) { left: calc(14% + 60px); right: 264px; }
  #mission-card:has(#dive-guide:not([hidden])) { width: fit-content; bottom: 60px; }
}
