/* LOOP COURIER — retro-arcade cabinet presentation
   Phosphor accents (lime / amber / cyan) on near-black space. */

@font-face {
  font-family: 'Press Start 2P';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/press-start-2p.woff2') format('woff2');
}

:root {
  --bg: #05060a;
  --bg-2: #0a0d16;
  --panel: #0d1120;
  --line: #1d2438;
  --ink: #e8f0e9;
  --ink-dim: #8b96a8;
  --lime: #a3ff3f;
  --amber: #ffd23f;
  --cyan: #39d7ff;
  --pink: #ff5db1;
  --red: #ff4d4d;
  --px: 'Press Start 2P', 'Courier New', monospace;
  --sans: 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bounce: cubic-bezier(.2, 1.6, .4, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(57, 215, 255, .07), transparent 60%),
    radial-gradient(900px 500px at 5% 110%, rgba(163, 255, 63, .05), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px clamp(14px, 3vw, 32px);
  border-bottom: 2px solid var(--line);
  background: linear-gradient(180deg, #0b0f1c, #070a12);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-mark { color: var(--lime); font-size: 22px; text-shadow: 0 0 12px var(--lime); }
.brand-name { font-family: var(--px); font-size: clamp(13px, 2.2vw, 18px); color: var(--lime); text-shadow: 0 0 10px rgba(163,255,63,.55); letter-spacing: 1px; }
.brand-tag { font-family: var(--px); font-size: 8px; color: var(--ink-dim); letter-spacing: 2px; }
.topbar-stats { display: flex; align-items: center; gap: 10px; }
.stat-chip {
  font-family: var(--px); font-size: 9px; color: var(--amber);
  border: 2px solid var(--line); padding: 7px 10px; border-radius: 4px;
  background: #0a0e1a; white-space: nowrap;
}
.stat-chip b { color: var(--ink); }
.icon-btn {
  font-family: var(--px); font-size: 11px; color: var(--cyan);
  background: #0a0e1a; border: 2px solid var(--line); border-radius: 4px;
  width: 34px; height: 32px; cursor: pointer;
}
.icon-btn.off { color: var(--ink-dim); text-decoration: line-through; }
.icon-btn:hover { border-color: var(--cyan); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas:
    "cabinet map"
    "debriefs debriefs";
  gap: clamp(16px, 3vw, 32px);
  padding: clamp(16px, 3vw, 32px);
  max-width: 1280px;
  margin: 0 auto;
}
.cabinet { grid-area: cabinet; min-width: 0; }
.routemap { grid-area: map; }
.debriefs { grid-area: debriefs; display: grid; gap: clamp(16px, 2.5vw, 28px); }

/* ---------- cabinet ---------- */
.cabinet {
  background: linear-gradient(180deg, #101427, #0a0d1a 60%, #080a14);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 0 0 2px #05060a, 0 24px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255,255,255,.05);
}
.cabinet-marquee {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 4px 12px;
}
.marquee-text {
  font-family: var(--px); font-size: clamp(8px, 1.4vw, 11px);
  color: var(--amber); letter-spacing: 3px; text-shadow: 0 0 12px rgba(255, 210, 63, .6);
}
.marquee-light {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--lime); box-shadow: 0 0 10px var(--lime);
  animation: blink 1.6s steps(2, jump-none) infinite;
}
.marquee-light:last-child { animation-delay: .8s; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
@keyframes blink { 50% { opacity: .25; } }

.screen-bezel {
  position: relative;
  background: #02030a;
  border: 3px solid #04050c;
  outline: 2px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #03040c;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.crt-scanlines {
  position: absolute; inset: 0; pointer-events: none; z-index: 8;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.crt-vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 9;
  background: radial-gradient(120% 105% at 50% 45%, transparent 62%, rgba(0,0,0,.5) 100%);
}

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; font-family: var(--px); }
.hud-row { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px 0; }
.hud-cluster { display: flex; gap: clamp(8px, 2vw, 18px); }
.hud-item label { display: block; font-size: 6.5px; color: var(--ink-dim); letter-spacing: 1px; margin-bottom: 4px; }
.hud-item b { font-size: clamp(9px, 1.6vw, 13px); color: var(--ink); font-weight: 400; text-shadow: 0 0 8px rgba(232,240,233,.4); }
.hud-item b:empty::before { content: '0'; }
#ui-score { color: var(--lime); }
#ui-credits { color: var(--amber); }
#ui-zone { color: var(--cyan); }
.hull-hearts { color: var(--pink); letter-spacing: 2px; }
.hud-combo b { color: var(--pink); }
.hud-combo.hot b { animation: pop .35s var(--bounce); }
@keyframes pop { 0% { transform: scale(1.9); } 100% { transform: scale(1); } }

.hud-job {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-width: min(66%, 420px);
}
.job-label { font-size: clamp(7px, 1.3vw, 9px); color: var(--cyan); letter-spacing: 1px; text-shadow: 0 0 8px rgba(57,215,255,.5); text-align: center; }
.job-label.urgent { color: var(--red); animation: blink .5s steps(2, jump-none) infinite; }
.job-timer { width: 100%; height: 7px; border: 2px solid var(--line); background: #060913; }
.job-timer-fill { display: block; height: 100%; width: 100%; background: var(--cyan); transition: width .12s linear; }
.job-timer-fill.low { background: var(--red); }

/* banners + toasts */
.banner-layer { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.banner {
  font-family: var(--px); text-align: center; color: var(--lime);
  font-size: clamp(11px, 2.4vw, 18px); line-height: 1.8;
  text-shadow: 0 0 16px rgba(163,255,63,.7);
  background: rgba(3, 6, 14, .82);
  border: 3px solid var(--lime);
  border-radius: 6px; padding: 16px 26px;
  animation: bannerIn .5s var(--bounce);
}
.banner small { display: block; font-size: .55em; color: var(--amber); }
.banner.out { animation: bannerOut .3s ease-in forwards; }
@keyframes bannerIn { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes bannerOut { to { transform: scale(1.25); opacity: 0; } }

.toast-layer { position: absolute; top: 86px; right: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  font-family: var(--px); font-size: 8px; line-height: 1.7;
  color: var(--amber); background: rgba(8, 10, 20, .92);
  border: 2px solid var(--amber); border-radius: 4px;
  padding: 8px 10px; max-width: 250px;
  animation: toastIn .45s var(--bounce);
}
.toast b { color: var(--ink); display: block; }
.toast.out { animation: bannerOut .3s ease-in forwards; }
@keyframes toastIn { 0% { transform: translateX(120%); } 100% { transform: none; } }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: rgba(2, 3, 9, .78);
  backdrop-filter: blur(2px);
  padding: 16px;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }

.title-card, .panel-card {
  text-align: center; max-width: 560px; width: 100%;
  animation: panelIn .4s var(--bounce);
}
@keyframes panelIn { 0% { transform: translateY(14px) scale(.96); opacity: 0; } 100% { transform: none; opacity: 1; } }
.title-eyebrow { font-family: var(--px); font-size: 7px; color: var(--cyan); letter-spacing: 2px; margin-bottom: 14px; }
.title-logo {
  font-family: var(--px); font-weight: 400;
  font-size: clamp(26px, 6vw, 46px); line-height: 1.25; color: var(--lime);
  text-shadow: 0 0 22px rgba(163,255,63,.6), 4px 4px 0 #173007;
  display: flex; flex-direction: column; margin-bottom: 12px;
}
.title-logo-2 { color: var(--cyan); text-shadow: 0 0 22px rgba(57,215,255,.6), 4px 4px 0 #082433; }
.title-tag { font-family: var(--px); font-size: clamp(7px, 1.2vw, 9px); color: var(--ink-dim); line-height: 2; margin-bottom: 22px; }
.title-blink {
  font-family: var(--px); font-size: 10px; color: var(--amber); margin-top: 20px;
  animation: blink 1.1s steps(2, jump-none) infinite;
}
.title-progress { font-family: var(--px); font-size: 7px; color: var(--ink-dim); margin-top: 14px; line-height: 2; }
.title-progress b { color: var(--lime); }

.panel-title { font-family: var(--px); font-size: clamp(13px, 2.6vw, 19px); color: var(--cyan); text-shadow: 0 0 14px rgba(57,215,255,.55); margin-bottom: 16px; }
.pause-sub, .hangar-credits { font-family: var(--px); font-size: 8px; color: var(--ink-dim); margin-bottom: 16px; line-height: 2; }
.hangar-credits b { color: var(--amber); }

.title-menu { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.arcade-btn {
  font-family: var(--px); font-size: clamp(9px, 1.6vw, 11px);
  color: var(--ink); background: #0c1120;
  border: 3px solid var(--line); border-radius: 6px;
  padding: 13px 22px; cursor: pointer; min-width: min(280px, 70vw);
  transition: transform .12s var(--bounce), border-color .12s, box-shadow .12s;
}
.arcade-btn:hover, .arcade-btn:focus-visible { border-color: var(--cyan); box-shadow: 0 0 14px rgba(57,215,255,.35); transform: translateY(-2px); outline: none; }
.arcade-btn:active { transform: translateY(1px); }
.arcade-btn.primary { color: #0a0d05; background: var(--lime); border-color: var(--lime); text-shadow: none; box-shadow: 0 0 18px rgba(163,255,63,.4); }
.arcade-btn.primary:hover { box-shadow: 0 0 26px rgba(163,255,63,.65); }
.btn-sub { font-size: 7px; color: inherit; opacity: .7; }

.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; margin-bottom: 14px; }
.howto-col h3 { font-family: var(--px); font-size: 9px; color: var(--amber); margin: 10px 0 8px; }
.key-list { list-style: none; display: grid; gap: 7px; }
.key-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); }
.key-list .keys { font-family: var(--px); font-size: 7px; color: var(--cyan); min-width: 86px; display: inline-flex; gap: 4px; }
kbd {
  font-family: var(--px); font-size: 7px; color: var(--cyan);
  border: 1.5px solid var(--line); border-bottom-width: 3px; border-radius: 4px;
  padding: 3px 5px; background: #0a0e1a;
}
.howto-goal { font-size: 14px; color: var(--ink-dim); margin-bottom: 18px; }

.end-flavor { font-size: 15px; color: var(--ink-dim); margin-bottom: 14px; }
.end-stats { list-style: none; font-family: var(--px); font-size: 9px; line-height: 2.4; color: var(--ink); margin-bottom: 20px; }
.end-stats b { color: var(--amber); }

/* hangar */
.trail-list { list-style: none; display: grid; gap: 10px; margin-bottom: 18px; }
.trail-item {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--line); border-radius: 6px; padding: 10px 12px;
  background: #0a0e1a; text-align: left;
}
.trail-item.equipped { border-color: var(--lime); box-shadow: 0 0 12px rgba(163,255,63,.25); }
.trail-swatch { width: 42px; height: 12px; border-radius: 6px; flex: none; }
.trail-info { flex: 1; min-width: 0; }
.trail-info b { font-family: var(--px); font-size: 8px; display: block; margin-bottom: 5px; }
.trail-info i { font-size: 12px; color: var(--ink-dim); font-style: normal; }
.trail-btn {
  font-family: var(--px); font-size: 7px; padding: 9px 10px; cursor: pointer;
  color: var(--ink); background: #0c1120; border: 2px solid var(--cyan); border-radius: 4px;
  flex: none;
}
.trail-btn:disabled { border-color: var(--line); color: var(--ink-dim); cursor: default; }
.trail-btn.equipped-tag { border-color: var(--lime); color: var(--lime); }

/* ---------- touch controls ---------- */
.touch-controls { display: none; }
.touch-controls.active {
  display: flex; justify-content: space-between; align-items: flex-end;
  position: absolute; inset: auto 0 0 0; z-index: 11;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.tc-cluster { display: flex; gap: 12px; pointer-events: auto; }
.tc-btn {
  font-family: var(--px); font-size: 15px; color: var(--ink);
  width: 64px; height: 64px; border-radius: 12px;
  background: rgba(12, 17, 32, .82); border: 3px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.tc-btn span { font-size: 6px; color: var(--ink-dim); }
.tc-btn.pressed { background: rgba(57, 215, 255, .3); border-color: var(--cyan); }
.tc-thrust { border-color: rgba(163,255,63,.5); }
.tc-thrust.pressed { background: rgba(163,255,63,.3); border-color: var(--lime); }
.tc-brake { border-color: rgba(255,93,177,.5); }
.tc-brake.pressed { background: rgba(255,93,177,.3); border-color: var(--pink); }
.tc-pause { position: absolute; top: -56px; right: 12px; width: 44px; height: 40px; font-size: 11px; border-radius: 8px; pointer-events: auto; }

/* ---------- hint bar ---------- */
.hint-bar {
  display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center;
  padding: 12px 6px 4px;
  font-family: var(--px); font-size: 7px; color: var(--ink-dim); letter-spacing: 1px;
}
.hint-bar kbd { font-size: 6px; }
.hint-mouse { color: var(--cyan); }

/* ---------- route map ---------- */
.routemap {
  background: var(--panel);
  border: 2px solid var(--line); border-radius: 10px;
  padding: 18px; align-self: start; position: sticky; top: 84px;
}
.side-title { font-family: var(--px); font-size: 10px; color: var(--amber); letter-spacing: 2px; margin-bottom: 16px; }
.map-track { list-style: none; position: relative; display: grid; gap: 4px; }
.map-track::before {
  content: ''; position: absolute; left: 9px; top: 12px; bottom: 12px;
  width: 3px; background: var(--line); border-radius: 2px;
}
.map-node { display: flex; gap: 14px; align-items: flex-start; padding: 8px 0; position: relative; }
.node-dot {
  width: 21px; height: 21px; flex: none; border-radius: 50%;
  border: 3px solid var(--line); background: var(--bg-2); z-index: 1;
  transition: all .3s;
}
.map-node b { font-family: var(--px); font-size: 8px; display: block; margin-bottom: 5px; color: var(--ink-dim); }
.map-node i { font-style: normal; font-family: var(--px); font-size: 6.5px; color: var(--ink-dim); line-height: 1.8; }
.map-node.next .node-dot { border-color: var(--amber); box-shadow: 0 0 10px rgba(255,210,63,.5); animation: blink 1.4s steps(2, jump-none) infinite; }
.map-node.next b { color: var(--amber); }
.map-node.unlocked .node-dot { border-color: var(--lime); background: var(--lime); box-shadow: 0 0 12px rgba(163,255,63,.6); }
.map-node.unlocked b { color: var(--lime); }
.map-node.unlocked i { color: var(--ink-dim); }
.map-note { font-size: 13px; color: var(--ink-dim); margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- debriefs ---------- */
.debrief {
  border: 2px solid var(--line); border-radius: 10px;
  background: linear-gradient(180deg, var(--panel), #0a0d18);
  overflow: hidden;
  position: relative;
}
.debrief-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 16px clamp(16px, 3vw, 28px);
  border-bottom: 2px solid var(--line);
  background: rgba(5, 7, 14, .5);
}
.debrief-code { font-family: var(--px); font-size: 8px; color: var(--cyan); letter-spacing: 2px; }
.debrief-title { font-family: var(--px); font-size: clamp(12px, 2.4vw, 17px); color: var(--ink); }
.debrief-body { padding: clamp(16px, 3vw, 28px); display: grid; gap: 18px; }
.debrief-lede { font-size: clamp(15px, 2vw, 17px); color: var(--ink); max-width: 65ch; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.info-card {
  border: 2px solid var(--line); border-radius: 8px; padding: 14px;
  background: rgba(5, 7, 14, .55);
}
.info-card h4 { font-family: var(--px); font-size: 9px; color: var(--amber); margin-bottom: 9px; line-height: 1.8; }
.info-card p { font-size: 14px; color: var(--ink-dim); }
.stat-bar { height: 8px; border: 1.5px solid var(--line); margin-top: 8px; background: #060913; }
.stat-bar i { display: block; height: 100%; background: var(--cyan); }
.stat-label { font-family: var(--px); font-size: 6px; color: var(--ink-dim); display: flex; justify-content: space-between; margin-top: 6px; }

.price-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.price-table th { font-family: var(--px); font-size: 7px; color: var(--cyan); text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); letter-spacing: 1px; }
.price-table td { padding: 10px; border-bottom: 1px solid var(--line); color: var(--ink-dim); }
.price-table td:first-child { color: var(--ink); font-weight: 600; }
.price-table .price { color: var(--amber); font-family: var(--px); font-size: 9px; white-space: nowrap; }

.crew-card { display: flex; gap: 14px; align-items: flex-start; }
.crew-avatar {
  width: 52px; height: 52px; flex: none; border-radius: 8px;
  border: 2px solid var(--line); display: grid; place-items: center;
  font-family: var(--px); font-size: 15px; background: #060913;
}
.crew-role { font-family: var(--px); font-size: 6.5px; color: var(--cyan); display: block; margin-bottom: 6px; letter-spacing: 1px; }

/* locked state */
.debrief.locked .debrief-body { display: none; }
.debrief-lock {
  display: none;
  padding: clamp(24px, 5vw, 44px) clamp(16px, 3vw, 28px);
  text-align: center;
}
.debrief.locked .debrief-lock { display: block; }
.debrief.locked { border-style: dashed; }
.debrief.locked .debrief-title { color: var(--ink-dim); }
.lock-glyph { font-size: 26px; display: block; margin-bottom: 12px; filter: grayscale(1); opacity: .7; }
.lock-text { font-family: var(--px); font-size: 8px; color: var(--ink-dim); line-height: 2.2; }
.lock-text b { color: var(--amber); }

/* unlock reveal */
.debrief.just-unlocked { border-color: var(--lime); box-shadow: 0 0 30px rgba(163,255,63,.3); }
.debrief.just-unlocked .debrief-body { animation: decrypt .9s steps(6) both; }
@keyframes decrypt {
  0% { opacity: 0; transform: translateY(10px); filter: hue-rotate(90deg) brightness(2); }
  100% { opacity: 1; transform: none; filter: none; }
}
.debrief.flash { animation: flashBorder 1.2s ease-out 2; }
@keyframes flashBorder { 0%, 100% { box-shadow: none; } 50% { box-shadow: 0 0 34px rgba(163,255,63,.55); } }

/* ---------- footer ---------- */
.footer {
  border-top: 2px solid var(--line);
  padding: 20px clamp(14px, 3vw, 32px) 32px;
  text-align: center;
  color: var(--ink-dim); font-size: 13px;
  display: grid; gap: 8px;
}
.link-btn {
  background: none; border: none; color: var(--cyan); cursor: pointer;
  font-family: var(--px); font-size: 7px; letter-spacing: 1px;
  border-bottom: 1px dashed var(--cyan); padding-bottom: 2px;
}
.link-btn:hover { color: var(--lime); border-color: var(--lime); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: "cabinet" "map" "debriefs";
  }
  .routemap { position: static; }
  .map-track { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .map-track::before { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .screen { aspect-ratio: 4 / 3.4; }
  .cabinet { padding: 6px; border-radius: 10px; }
  .howto-grid { grid-template-columns: 1fr; }
  .hud-job { top: 46px; min-width: 78%; }
  .key-list li { font-size: 13px; }
  .hint-bar .hint-mouse { display: none; }
}

/* coarse pointers: room for touch controls */
@media (pointer: coarse) {
  .screen { aspect-ratio: 4 / 3.6; }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-light, .title-blink, .map-node.next .node-dot { animation: none; }
  .debrief.just-unlocked .debrief-body { animation: none; }
}
