:root {
  --bg: #020106;
  --bg-deep: #090415;
  --panel: rgba(12, 7, 29, 0.88);
  --violet: #6d59ff;
  --violet-soft: #a490ff;
  --violet-glow: rgba(109, 89, 255, 0.44);
  --magenta: #ff5adf;
  --text: #f7f5ff;
  --muted: #aaa3bd;
  --dim: #6e6684;
  --line: rgba(143, 125, 255, 0.23);
  --tech: "Chakra Petch", sans-serif;
  --body: "Space Grotesk", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); color-scheme: dark; }
html, body, body * {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
::selection { color: inherit; background: transparent; }
body {
  min-height: 100vh; color: var(--text); background:
    radial-gradient(circle at 50% -10%, rgba(109, 89, 255, 0.2), transparent 37%),
    linear-gradient(180deg, #07030f 0%, #020106 55%, #05020d 100%);
  font-family: var(--body); overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .36;
  background-image: radial-gradient(rgba(255,255,255,.3) .65px, transparent .65px);
  background-size: 28px 28px; mask-image: linear-gradient(to bottom, black, transparent 72%);
}
button, a { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 20; opacity: .12;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(109,89,255,.16) 4px);
  mix-blend-mode: screen;
}

.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(18px, 4vw, 58px); border-bottom: 1px solid var(--line);
  background: rgba(2,1,6,.82); backdrop-filter: blur(18px); position: relative; z-index: 5;
}
.brand { color: var(--text); text-decoration: none; font: 700 18px var(--tech); letter-spacing: .08em; display: flex; align-items: center; gap: 11px; }
.brand b { color: var(--violet-soft); font-weight: 600; }
.brand-mark { color: var(--violet); text-shadow: 0 0 15px var(--violet); font-size: 14px; }
.topbar-actions, .identity { display: flex; align-items: center; }
.identity { gap: 8px; color: var(--muted); font: 600 11px var(--tech); letter-spacing: .1em; }
.identity-profile-image {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--violet);
  object-fit: cover; flex: none;
}
.identity-dot { width: 5px; height: 5px; background: #65f5ac; border-radius: 50%; box-shadow: 0 0 9px #65f5ac; }

main {
  width: min(1220px, calc(100% - 32px), calc(145.16vh - 281px));
  margin: 0 auto; padding: 20px 0 10px; position: relative; z-index: 2;
}
.mission-strip {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 38px;
  border: 1px solid var(--line); border-bottom: 0; padding: 0 15px; background: rgba(10,6,24,.7);
  font: 600 10px var(--tech); letter-spacing: .14em; color: var(--dim);
}
.eyebrow { color: var(--violet-soft); }
.mission-copy { color: var(--muted); }
.mission-copy b { color: var(--text); }

.game-frame {
  position: relative; border: 1px solid var(--line); background: #020106; overflow: hidden;
  box-shadow: 0 22px 80px rgba(0,0,0,.55), inset 0 0 80px rgba(109,89,255,.035);
  aspect-ratio: 900 / 620;
}
#game { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.corner { position: absolute; width: 17px; height: 17px; z-index: 8; pointer-events: none; }
.corner-tl { top: 7px; left: 7px; border-top: 1px solid var(--violet); border-left: 1px solid var(--violet); }
.corner-tr { top: 7px; right: 7px; border-top: 1px solid var(--violet); border-right: 1px solid var(--violet); }
.corner-bl { bottom: 7px; left: 7px; border-bottom: 1px solid var(--violet); border-left: 1px solid var(--violet); }
.corner-br { bottom: 7px; right: 7px; border-bottom: 1px solid var(--violet); border-right: 1px solid var(--violet); }

.screen {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 6; padding: 24px;
  background: radial-gradient(circle at 50% 48%, rgba(39,30,98,.56), rgba(2,1,6,.9) 60%);
  backdrop-filter: blur(3px);
}
.screen-card { width: min(650px, 92%); text-align: center; }
.kicker { font: 600 11px var(--tech); letter-spacing: .34em; color: var(--violet-soft); }
.screen h1 { margin: 17px 0 13px; font: 700 clamp(42px, 7vw, 82px)/.82 var(--tech); letter-spacing: -.055em; }
.screen h1 em { color: transparent; font-style: normal; -webkit-text-stroke: 1px var(--violet-soft); text-shadow: 0 0 30px var(--violet-glow); }
.screen h2 { margin: 14px 0 18px; font: 700 clamp(32px, 5vw, 54px)/1 var(--tech); }
.screen p { max-width: 580px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.55; }
.mode-actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; }
.primary, .secondary {
  min-width: 180px; padding: 13px 20px; border: 1px solid var(--violet); background: transparent;
  font: 700 12px var(--tech); letter-spacing: .14em; cursor: pointer; transition: .18s ease;
}
.primary { background: var(--violet); color: #090415; box-shadow: 0 0 25px var(--violet-glow); }
.primary:hover, .primary:focus-visible { background: var(--violet-soft); border-color: var(--violet-soft); box-shadow: 0 0 34px var(--violet-glow); outline: none; transform: translateY(-1px); }
.secondary { color: var(--violet-soft); }
.secondary:hover, .secondary:focus-visible { background: rgba(109,89,255,.16); outline: none; }
.control-grid { margin-top: 22px; display: flex; justify-content: center; flex-wrap: wrap; gap: 7px 18px; color: var(--dim); font: 500 9px var(--tech); letter-spacing: .11em; }
.control-grid b { color: var(--violet-soft); }
.screen-card.compact { width: min(520px, 92%); }
.end-score { border-block: 1px solid var(--line); margin: 18px auto; padding: 12px; display: flex; justify-content: center; align-items: baseline; gap: 20px; }
.end-score span { color: var(--dim); font: 600 10px var(--tech); letter-spacing: .2em; }
.end-score b { color: var(--violet-soft); font: 700 34px var(--tech); }
.hud { display: grid; grid-template-columns: 1.2fr .7fr 1fr 1fr 1.2fr; border: 1px solid var(--line); border-top: 0; background: rgba(10,6,24,.82); }
.hud-cell { min-height: 59px; padding: 10px 15px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.hud-cell:last-child { border: 0; text-align: right; }
.hud-cell span { color: var(--dim); font: 600 9px var(--tech); letter-spacing: .2em; }
.hud-cell b { color: var(--text); font: 700 21px var(--tech); letter-spacing: .04em; }
.pilot-one b { color: var(--violet-soft); }
.pilot-two b { color: var(--magenta); }

.lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.briefing { min-height: 94px; border: 1px solid var(--line); background: rgba(10,6,24,.58); display: grid; grid-template-columns: 62px 1fr; align-items: center; padding: 14px 18px; }
.section-number { align-self: start; color: var(--violet); font: 700 12px var(--tech); }
.briefing h2 { font: 700 12px var(--tech); letter-spacing: .18em; margin-bottom: 7px; }
.briefing p { color: var(--muted); font-size: 12px; line-height: 1.45; }
.briefing p b { color: var(--violet-soft); }

.touch-controls { display: none; margin-top: 12px; gap: 8px; }
.touch-player { flex: 1; display: grid; grid-template-columns: auto repeat(4, 1fr); gap: 5px; align-items: center; }
.touch-player span { color: var(--violet-soft); font: 700 10px var(--tech); }
.touch-player button { min-height: 46px; border: 1px solid var(--line); background: rgba(109,89,255,.09); font: 700 18px var(--tech); touch-action: none; }
.touch-player button.active { background: var(--violet); color: #05020d; }
@media (max-width: 760px) {
  .topbar { padding-inline: 14px; }
  .brand { font-size: 13px; }
  .identity { display: none; }
  main { width: calc(100% - 16px); padding-top: 8px; }
  .mission-strip { grid-template-columns: 1fr auto; }
  .eyebrow { display: none; }
  .screen { padding: 12px; }
  .screen h1 { font-size: clamp(34px, 11vw, 58px); }
  .screen p { font-size: 11px; max-width: 440px; }
  .mode-actions { margin-top: 14px; }
  .primary, .secondary { min-width: 0; flex: 1; padding-inline: 10px; font-size: 10px; }
  .control-grid { display: none; }
  .hud { grid-template-columns: repeat(5, 1fr); }
  .hud-cell { min-height: 46px; padding: 6px; }
  .hud-cell span { font-size: 7px; letter-spacing: .08em; }
  .hud-cell b { font-size: 13px; }
  .lower-grid { grid-template-columns: 1fr; }
  .touch-controls { display: flex; flex-direction: column; }
}

@media (max-height: 650px) and (orientation: landscape) {
  .topbar { height: 45px; }
  main { padding-top: 5px; width: min(980px, calc(100% - 12px), calc(145.16vh - 149px)); }
  .mission-strip, .lower-grid { display: none; }
  .hud { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .hud-cell { min-width: 0; min-height: 40px; padding: 4px 6px; }
  .hud-cell span { white-space: nowrap; font-size: 7px; letter-spacing: .06em; }
  .hud-cell b { white-space: nowrap; font-size: 13px; }
  .touch-controls { position: fixed; inset: auto 8px 6px; z-index: 10; pointer-events: none; }
  .touch-player { pointer-events: auto; opacity: .76; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .scanlines { display: none; }
}

/* ===== coin slot + flight records (paid-run arcade UI) ===== */

.coin-slot {
  display: inline-flex; align-items: center; gap: 9px; min-height: 18px;
  margin-top: 18px;
  font-family: var(--tech); font-size: 11px; font-weight: 600;
  letter-spacing: .18em; color: var(--dim); text-transform: uppercase;
}
.coin-light {
  width: 7px; height: 7px; border-radius: 50%; background: var(--dim);
  box-shadow: 0 0 0 1px rgba(255,255,255,.08); flex: none;
}
.coin-slot.ready { color: var(--violet-soft); }
.coin-slot.ready .coin-light { background: var(--violet-soft); box-shadow: 0 0 10px var(--violet); }
.coin-slot.busy .coin-light { background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.8); animation: coin-pulse .8s ease-in-out infinite alternate; }
.coin-slot.error { color: #ff7d9c; }
.coin-slot.error .coin-light { background: #ff5a8b; box-shadow: 0 0 10px rgba(255,90,139,.7); }
@keyframes coin-pulse { to { opacity: .28; } }

.records {
  margin-top: 14px; border: 1px solid var(--line); border-top: 0;
  background: var(--panel); padding: 14px 18px 16px;
}
.records-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.records-note {
  font: 600 9px var(--tech); letter-spacing: .17em; color: var(--dim); text-transform: uppercase;
}
.records-list { list-style: none; display: grid; gap: 2px; }
.records-list li {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px;
  align-items: center; padding: 5px 8px;
  font-family: var(--tech); font-size: 13px; letter-spacing: .06em;
  color: var(--muted); border-bottom: 1px solid rgba(143,125,255,.08);
}
.records-list li:last-child { border-bottom: 0; }
.records-list li.you { color: var(--text); background: rgba(109,89,255,.14); }
.records-list li.empty { display: block; text-align: center; color: var(--dim); padding: 10px 0 4px; }
.records-list .rk { color: var(--dim); font-weight: 700; }
.records-list li.you .rk { color: var(--violet-soft); }
.records-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.records-list .sc { color: var(--text); font-weight: 700; }
.records-list .wv { color: var(--dim); font-size: 11px; }
