:root {
  --bg:        #05070a;
  --panel:     #0a0e14;
  --panel-2:   #0d1219;
  --line:      #1b2430;
  --ink:       #e6edf3;
  --muted:     #78838f;
  --accent:    #22d3ee;
  --accent-dim:#0e7490;
  --good:      #34d399;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(900px 520px at 50% -10%, #0d1b26 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* faint CRT texture, purely decorative */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.014) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: overlay;
}

.wrap {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 56px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 34px;
  flex: 1;
}

/* ---------- header ---------- */

.head { text-align: center; }

.mark {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(2.1rem, 8vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.caret {
  display: inline-block;
  width: .48em;
  height: .92em;
  margin-left: .12em;
  vertical-align: -0.08em;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(34,211,238,.55);
  animation: blink 1.15s steps(1) infinite;
}

@keyframes blink { 0%,55% { opacity: 1; } 56%,100% { opacity: 0; } }

.lede {
  margin: 14px 0 0;
  font-size: clamp(1rem, 3.4vw, 1.2rem);
  color: #b9c4d0;
}

.sub {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: .7em;
  border-radius: 50%;
  background: var(--good);
  vertical-align: 1px;
  box-shadow: 0 0 0 0 rgba(52,211,153,.55);
  animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,.5); }
  70%  { box-shadow: 0 0 0 9px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* ---------- game panel ---------- */

.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px -30px rgba(0,0,0,.9);
}

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.stage-bar h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}

.readout {
  display: flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .14em;
  color: var(--muted);
}

.readout b {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.canvas-holder {
  position: relative;
  line-height: 0;
}

#flight {
  display: block;
  width: 100%;
  height: clamp(260px, 48vh, 420px);
  touch-action: none;
  outline: none;
  cursor: crosshair;
}

#flight:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent-dim);
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  padding: 11px 14px;
  list-style: none;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--muted);
}

kbd {
  display: inline-block;
  min-width: 1.55em;
  margin-right: 4px;
  padding: 1px 5px;
  border: 1px solid #263241;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #111823;
  color: #cbd5e1;
  font: inherit;
  text-align: center;
}

/* ---------- touch pad ---------- */

.touch {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: 10px;
  padding: 12px;
  justify-content: center;
}

.tbtn {
  flex: 1;
  max-width: 110px;
  padding: 14px 0;
  border: 1px solid #22303f;
  border-radius: 10px;
  background: rgba(10,16,22,.72);
  backdrop-filter: blur(4px);
  color: var(--accent);
  font-size: 1.05rem;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.tbtn:active { background: rgba(34,211,238,.2); }

/* ---------- footer ---------- */

.foot {
  margin-top: auto;
  padding-top: 6px;
  text-align: center;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  color: var(--muted);
  display: flex;
  gap: 10px;
  justify-content: center;
}

.foot a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid #22303f;
  transition: color .15s, border-color .15s;
}

.foot a:hover { color: var(--accent); border-color: var(--accent-dim); }

.muted { color: var(--muted); }

@media (max-width: 460px) {
  .wrap { padding-top: 40px; gap: 26px; }
  .hide-sm { display: none; }
  .readout { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .caret, .dot { animation: none; }
  .scanlines { display: none; }
}

/* ============ 3D stage ============ */

#flight { height: clamp(300px, 56vh, 520px); }

/* boot placeholder, shown until the renderer takes over */
.boot {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  background: #05080e;
}

.canvas-holder.loading .boot { display: flex; }

/* start prompt */
.overlay[hidden] { display: none; }  /* display:flex below would otherwise win */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 0 16px;
  background: linear-gradient(to bottom, rgba(4,7,12,.15), rgba(4,7,12,.72) 55%, rgba(4,7,12,.2));
  pointer-events: none;
}

.o-main {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(.78rem, 2.6vw, .95rem);
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--ink);
  text-shadow: 0 0 22px rgba(34,211,238,.5);
}

.o-sub {
  margin: 0;
  max-width: 30ch;
  font-family: var(--mono);
  font-size: .66rem;
  line-height: 1.8;
  letter-spacing: .08em;
  color: var(--muted);
}

.overlay kbd { background: #131c27; }

/* transient gate / miss callout */
.note {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -6px);
  padding: 5px 13px;
  border: 1px solid rgba(34,211,238,.35);
  border-radius: 999px;
  background: rgba(5,10,16,.75);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .16em;
  color: var(--accent);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
  white-space: nowrap;
}

.note.show { opacity: 1; transform: translate(-50%, 0); }

/* camera toggle in the key legend */
.cambtn {
  padding: 2px 9px;
  border: 1px solid #263241;
  border-radius: 4px;
  background: #111823;
  color: var(--accent);
  font: inherit;
  font-family: var(--mono);
  letter-spacing: .1em;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.cambtn:hover { border-color: var(--accent-dim); background: #16202c; }

/* ============ touch pad ============ */

.pad {
  position: absolute;
  inset: auto 0 0 0;
  display: none;
  gap: 8px;
  padding: 12px;
  justify-content: center;
  align-items: flex-end;
}

body.touch .pad:not([hidden]) { display: flex; }

.pbtn {
  flex: 1;
  max-width: 92px;
  padding: 13px 0;
  border: 1px solid #22303f;
  border-radius: 10px;
  background: rgba(10,16,22,.7);
  backdrop-filter: blur(4px);
  color: var(--accent);
  font-family: var(--mono);
  font-size: .95rem;
  line-height: 1;
  letter-spacing: .08em;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.pb-boost { font-size: .62rem; color: var(--good); border-color: #1d4034; }

.pbtn:active { background: rgba(34,211,238,.2); }

@media (max-width: 460px) {
  #flight { height: clamp(320px, 62vh, 460px); }
  .keys { font-size: .64rem; gap: 5px 12px; }
}
