:root {
  --amber: #FFB000;
  --amber-rgb: 255, 176, 0;
  --red: #FF3B3B;
  --sys: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; position: fixed; inset: 0; width: 100%; height: 100%; background: #000; color: #fff; overflow: hidden; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-family: var(--sys); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#safe-probe { position: fixed; visibility: hidden; pointer-events: none; top: 0; left: 0;
  padding: var(--sat) var(--sar) var(--sab) var(--sal); }
.mono { font-family: var(--mono); }
.readout { font-family: var(--mono); font-weight: 800; font-stretch: condensed; letter-spacing: -0.02em; }

/* Buttons: flat, Apple-like rounded rects. No glow, no pulse. */
.btn { appearance: none; border: 0; border-radius: 10px; padding: 9px 14px; min-height: 36px;
  font: 600 15px var(--sys); letter-spacing: 0.01em; color: var(--amber);
  background: rgba(var(--amber-rgb), 0.16); cursor: pointer; touch-action: manipulation; white-space: nowrap; }
.btn:active { background: rgba(var(--amber-rgb), 0.28); }
.btn.prominent { background: var(--amber); color: #000; }
.btn.prominent:active { background: #d99600; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.static { pointer-events: none; }
.btn.small { padding: 6px 10px; min-height: 30px; font-size: 13px; border-radius: 8px; }
.btn.mono { font-family: var(--mono); font-weight: 700; }
.btn:focus-visible { outline: 2px solid rgba(var(--amber-rgb), 0.6); outline-offset: 2px; }

/* Touch controls (flat strokes, no glow) */
#controls { position: absolute; inset: 0; pointer-events: none; }
#controls > * { position: absolute; pointer-events: auto; transform: translate(-50%, -50%); }
.ctl { border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 700 11px var(--mono); color: var(--amber); border: 1.5px solid var(--amber); background: rgba(0,0,0,0.25);
  touch-action: none; padding: 0; appearance: none; }
.ctl span { pointer-events: none; line-height: 1.15; }
.ctl .ring-inner { position: absolute; inset: 30%; border-radius: 50%; border: 1px solid rgba(var(--amber-rgb), 0.3); pointer-events: none; }
.stick { border-color: rgba(var(--amber-rgb), 0.8); background: transparent; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; margin: -15% 0 0 -15%; border-radius: 50%;
  border: 2px solid var(--amber); background: rgba(var(--amber-rgb), 0.15); pointer-events: none; }
.hold { background: rgba(var(--amber-rgb), 0.08); font-size: 12px; }
.hold .ring-inner { border-color: rgba(var(--amber-rgb), 0.35); }
.hold.down { background: rgba(var(--amber-rgb), 0.3); }
.ring.filled { background: rgba(var(--amber-rgb), 0.3); color: #fff; }
.mapTap { border: 0; background: transparent; border-radius: 12px; }

/* Overlays */
#overlay { position: absolute; inset: 0; pointer-events: none; }
#overlay > * { pointer-events: auto; }
.scrim { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.scroll { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
.card { background: rgba(255,255,255,0.06); border: 1px solid rgba(var(--amber-rgb), 0.8); padding: 18px; }
.briefing { margin: calc(64px + var(--sat)) calc(16px + var(--sar)) calc(50px + var(--sab)) calc(16px + var(--sal)); display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.cap { font: 600 10px var(--mono); color: rgba(var(--amber-rgb), 0.55); letter-spacing: 0.02em; }
.cap.strong { font-weight: 700; color: rgba(var(--amber-rgb), 0.7); }
.title { color: var(--amber); font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goals { padding: 12px; border: 1px solid rgba(var(--amber-rgb), 0.4); display: flex; flex-direction: column; gap: 6px; }
.goal { display: flex; align-items: center; gap: 8px; font: 500 13px var(--mono); color: rgba(255,255,255,0.9); }
.star { width: 16px; height: 16px; flex: none; color: var(--amber); }
.lede { font: 500 13px var(--mono); color: rgba(255,255,255,0.85); line-height: 1.35; }
.lede b { color: var(--amber); font-weight: 500; }
.map { width: 100%; height: 150px; display: block; background: #000; border: 1px solid rgba(var(--amber-rgb), 0.5); }
.targets { display: flex; gap: 6px; }
.tcard { flex: 1; min-width: 0; background: #000; border: 1px solid rgba(var(--amber-rgb), 0.4); padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tcard img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.tcard .n { font: 700 11px var(--mono); color: var(--amber); }
.tcard .k { font: 600 8px var(--mono); color: var(--red); white-space: nowrap; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.sound-btn { display: inline-flex; align-items: center; gap: 6px; }
.sound-btn svg { width: 16px; height: 16px; }

.dim55 { background: rgba(0,0,0,0.55); }
.dim60 { background: rgba(0,0,0,0.6); }
.endcard { margin: 20px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 420px; }
.endcard .head { font-size: 32px; }
.endcard .score { font-size: 44px; color: var(--amber); }
.endcard .stars { display: flex; gap: 10px; }
.endcard .stars .star { width: 26px; height: 26px; }
.endcard .pay { font: 500 13px var(--mono); color: rgba(255,255,255,0.85); font-variant-numeric: tabular-nums; text-align: center; }
.paused { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.paused .readout { font-size: 30px; color: var(--amber); }

/* Hangar sheet */
.sheet { position: absolute; inset: 0; background: #000; }
.sheet .bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.sheet .bg::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,0.25); }
.hangar { position: relative; padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(24px + var(--sab)) calc(16px + var(--sal));
  display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }
.hangar .hdr { display: flex; align-items: center; gap: 10px; }
.hangar .hdr .readout { color: var(--amber); }
.coin { width: 22px; height: 22px; }
.bigspin { position: relative; height: 200px; }
.bigspin canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.bigspin .ring { position: absolute; left: 50%; bottom: 12px; width: 230px; height: 40px; margin-left: -115px; border-radius: 50%;
  border: 1px solid rgba(var(--amber-rgb), 0.35); }
.bigspin .lbl { position: absolute; left: 0; bottom: 0; font-size: 18px; color: var(--amber); }
.item { display: flex; align-items: center; gap: 12px; padding: 10px; background: rgba(0,0,0,0.65); border: 1px solid rgba(var(--amber-rgb), 0.35); }
.item.on { border-color: rgba(var(--amber-rgb), 0.8); }
.item .icon { width: 40px; height: 40px; object-fit: contain; flex: none; }
.item .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .nm { font: 700 14px var(--mono); color: var(--amber); }
.item .fx { font: 400 10px var(--mono); color: rgba(255,255,255,0.7); }
.item .pips { height: 14px; width: auto; align-self: flex-start; }
.shiprow { gap: 10px; }
.shiprow canvas { width: 126px; height: 126px; flex: none; }
@media (max-width: 380px) { .shiprow canvas { width: 96px; height: 96px; } }
.stat { display: flex; align-items: center; gap: 6px; max-width: 140px; }
.stat b { font: 700 9px var(--mono); color: rgba(255,255,255,0.6); width: 28px; }
.stat .track { flex: 1; height: 5px; background: #2e2e2e; position: relative; }
.stat .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--amber); }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: rgba(0,0,0,0.6); border: 1px solid rgba(var(--amber-rgb), 0.35); }
.seg button { flex: 1; min-height: 30px; border-radius: 999px; border: 1px solid transparent; background: transparent;
  font: 700 11px var(--mono); color: rgba(var(--amber-rgb), 0.55); cursor: pointer; }
.seg button.on { color: var(--amber); background: rgba(var(--amber-rgb), 0.22); border-color: rgba(var(--amber-rgb), 0.9); }
.panel { padding: 10px; background: rgba(0,0,0,0.65); display: flex; flex-direction: column; gap: 6px; }
.panel.bordered { border: 1px solid rgba(var(--amber-rgb), 0.35); gap: 10px; }
.toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle-row hr { border: 0; }
.divider { height: 1px; background: rgba(var(--amber-rgb), 0.3); }
.switch { position: relative; width: 51px; height: 31px; flex: none; border-radius: 999px; background: #39393d; border: 0; padding: 0; cursor: pointer; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch.on { background: var(--amber); }
.switch.on::after { transform: translateX(20px); }
.missions { margin: auto calc(16px + var(--sar)) 0 calc(16px + var(--sal)); padding: 16px 16px calc(16px + var(--sab)); background: #1c1c1e; border-radius: 14px 14px 0 0; width: 100%; max-width: 640px; }
.missions .r { display: flex; align-items: center; padding: 12px 4px; border-bottom: 1px solid #333; font: 15px var(--mono); }
.missions .r.locked { color: #8e8e93; }

/* Top-bar HANGAR button (same flat style as PWR / pause) */
#top-hangar { position: absolute; transform: translate(-50%, -50%); z-index: 5; }
#top-hangar[hidden] { display: none; }

/* Native-style confirm (iOS alert look; flat, no glow) */
.alert { width: 270px; background: rgba(36,36,38,0.96); border-radius: 14px; overflow: hidden; text-align: center; }
.alert .msg { padding: 19px 16px 15px; }
.alert .t { font: 600 17px var(--sys); color: #fff; }
.alert .d { font: 400 13px var(--sys); color: rgba(255,255,255,0.75); margin-top: 4px; line-height: 1.3; }
.alert .acts { display: flex; border-top: 0.5px solid rgba(255,255,255,0.22); }
.alert .acts button { flex: 1; appearance: none; border: 0; background: transparent; min-height: 44px; font: 400 17px var(--sys); color: var(--amber); cursor: pointer; }
.alert .acts button + button { border-left: 0.5px solid rgba(255,255,255,0.22); }
.alert .acts button.strong { font-weight: 600; }
.alert .acts button.destructive { color: var(--red); }
.alert .acts button:active { background: rgba(255,255,255,0.08); }

/* Hangar ship cards: whole card is tappable */
.shiprow { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.shiprow.on { border-color: var(--amber); background: rgba(var(--amber-rgb), 0.10); }
.item .nm .tag, .bigspin .lbl .tag { margin-left: 8px; font: 700 9px var(--mono); color: rgba(var(--amber-rgb), 0.6); letter-spacing: 0.04em; vertical-align: middle; }
.btn.need { opacity: 0.55; background: rgba(var(--amber-rgb), 0.08); }
.bigstats { display: flex; align-items: center; gap: 12px; margin: -4px 0 4px; }
.bigstats .bars { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bigstats .stat { max-width: none; }
.bigstats .bigbtn { flex: none; }
/* Silent-switch hint: plain dim amber text, no glow */
.sound-hint { font: 500 10px var(--mono); color: rgba(var(--amber-rgb), 0.5); }
.panel .sound-hint { padding-top: 6px; }
.sound-toast { position: absolute; left: 50%; top: calc(64px + var(--sat)); transform: translateX(-50%); z-index: 20; pointer-events: none;
  padding: 8px 12px; border-radius: 10px; background: rgba(28,28,30,0.94); color: rgba(var(--amber-rgb), 0.85); font: 600 12px var(--mono); white-space: nowrap; }

/* Game area + flight controls: no browser gestures at all (no pinch, no double-tap zoom, no pan). The .btn default of
   'manipulation' still allows pinch-zoom on iOS, so buttons over the cockpit are forced to 'none' too. */
#game, #controls, #controls *, #top-hangar { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
