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

:root {
  --head-h: 40px;   /* header with the paccastudio menu item */
  --foot-h: 32px;   /* footer with the paccastudio link */
  --ink: #04060c;
  --line: #172033;
  --muted: #6a7494;
  --text: #c8cde0;
  --phos: #39ff8a;
  --phos-dim: #1d9c55;
  --amber: #ffb43a;
  --blue: #5cd0ff;
  --red: #ff5a52;
  --mono: 'Courier New', Courier, monospace;
}

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--mono);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Header and footer ─────────────────────────────────────────────────────── */
.page-bar {
  flex: none;
  height: var(--head-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(14px, env(safe-area-inset-left));
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
  position: relative;
  z-index: 5;
}
.page-bar.foot {
  height: var(--foot-h);
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: #3e4660;
}
.game-name { color: var(--blue); font-weight: bold; letter-spacing: 4px; display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.game-name .dot { width: 9px; height: 9px; border-radius: 2px; background: var(--blue); box-shadow: 0 0 8px var(--blue); }
.page-bar nav { display: flex; align-items: center; gap: 8px; }
.page-bar a { color: #9aa4cc; text-decoration: none; }
.page-bar a:hover, .page-bar a:focus-visible { color: #eef0fa; }
.pacca {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #2c3450;
  border-radius: 6px;
  letter-spacing: 1px;
}
.pacca img { display: block; border-radius: 4px; }
.pacca:hover { border-color: var(--muted); }
.tool {
  height: 30px;
  min-width: 34px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #9aa4cc;
  border: 1px solid #2c3450;
  border-radius: 6px;
  font: bold 12px var(--mono);
  letter-spacing: 1px;
  cursor: pointer;
}
.tool:hover, .tool:focus-visible { color: #eef0fa; border-color: var(--muted); }
.tool .mute { display: none; }
.tool.off .wave { display: none; }
.tool.off .mute { display: inline; }

/* ── Stage ─────────────────────────────────────────────────────────────────── */
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ── HUD: the green phosphor of the guidance computer ──────────────────────── */
#hud[hidden] { display: none; }
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: var(--mono);
}
.panel {
  position: absolute;
  top: 10px;
  background: rgba(2, 14, 8, 0.72);
  border: 1px solid rgba(57, 255, 138, 0.22);
  border-radius: 6px;
  padding: 8px 11px;
  min-width: 172px;
  backdrop-filter: blur(3px);
}
#hud-left { left: max(10px, env(safe-area-inset-left)); }
#hud-right { right: max(10px, env(safe-area-inset-right)); }
.row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.55;
}
.lbl { flex: 1; color: var(--phos-dim); font-size: 10px; letter-spacing: 1.5px; }
.val { color: var(--phos); font-size: 16px; font-weight: bold; min-width: 60px; text-align: right; text-shadow: 0 0 6px rgba(57, 255, 138, 0.45); font-variant-numeric: tabular-nums; }
.val.warn { color: var(--amber); text-shadow: 0 0 6px rgba(255, 180, 58, 0.5); }
.val.bad { color: var(--red); text-shadow: 0 0 6px rgba(255, 90, 82, 0.5); }
.u { color: #157a42; font-size: 10px; width: 26px; }
.bar { height: 5px; margin: 3px 0 5px; background: rgba(57, 255, 138, 0.1); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--phos); box-shadow: 0 0 6px var(--phos); }
.bar i.warn { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.bar i.bad { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* annunciator lights */
.lamps {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 5px;
}
.lamp {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 5px 8px;
  border-radius: 3px;
  text-align: center;
  color: rgba(200, 210, 230, 0.18);
  background: rgba(10, 14, 22, 0.75);
  border: 1px solid rgba(200, 210, 230, 0.1);
  white-space: nowrap;
  display: none;
}
.lamp.show { display: block; }
.lamp.on.blue { color: #e8f8ff; background: #1f8fd0; border-color: #8fe1ff; box-shadow: 0 0 14px rgba(92, 208, 255, 0.85); }
.lamp.on.amber { color: #1e1200; background: var(--amber); border-color: #ffe0a0; box-shadow: 0 0 12px rgba(255, 180, 58, 0.7); }
.lamp.on.green { color: #02140a; background: var(--phos); border-color: #b5ffd5; box-shadow: 0 0 12px rgba(57, 255, 138, 0.6); }
.lamp.blink.on { animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

#btn-pause {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  width: 34px;
  height: 30px;
  margin-top: 0;
  background: rgba(10, 14, 22, 0.6);
  color: #9aa4cc;
  border: 1px solid #2c3450;
  border-radius: 6px;
  font: bold 12px var(--mono);
  cursor: pointer;
  display: none;
}

/* radio: the calls between the crew and the ground */
#radio {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(620px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  align-items: center;
}
.call {
  background: rgba(4, 8, 14, 0.78);
  border-left: 3px solid var(--phos);
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #e4e8f4;
  border-radius: 2px;
  animation: callIn 0.18s ease-out;
  max-width: 100%;
}
.call b { color: var(--phos); letter-spacing: 1.5px; font-size: 11px; margin-right: 8px; text-transform: uppercase; }
.call.crew { border-left-color: var(--blue); }
.call.crew b { color: var(--blue); }
@keyframes callIn { from { opacity: 0; transform: translateY(6px); } }

#tip[hidden] { display: none; }
#tip {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 24px));
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  color: #f2f5ff;
  background: rgba(20, 60, 40, 0.82);
  border: 1px solid rgba(57, 255, 138, 0.5);
  border-radius: 6px;
  padding: 8px 12px;
  pointer-events: none;
}

/* ── Touch controls ────────────────────────────────────────────────────────── */
#touch[hidden] { display: none; }
#touch {
  position: absolute;
  inset: auto 0 0 0;
  height: 0;
  pointer-events: none;
}
.t-tilt {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.t-tilt button {
  pointer-events: auto;
  touch-action: none;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid rgba(57, 255, 138, 0.45);
  background: rgba(4, 30, 16, 0.6);
  color: var(--phos);
  font: bold 20px var(--mono);
}
.t-tilt #t-level { width: 50px; height: 50px; font-size: 16px; margin-bottom: 30px; }
.t-tilt button.down { background: rgba(57, 255, 138, 0.35); border-color: var(--phos); }
#t-lever {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 76px;
  height: 200px;
  border-radius: 14px;
  border: 2px solid rgba(255, 180, 58, 0.5);
  background: rgba(30, 18, 2, 0.55);
  pointer-events: auto;
  touch-action: none;
  overflow: hidden;
}
#t-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, rgba(255, 180, 58, 0.55), rgba(255, 220, 140, 0.3)); }
#t-knob { position: absolute; left: 6px; right: 6px; height: 12px; bottom: 6px; border-radius: 6px; background: var(--amber); box-shadow: 0 0 10px rgba(255, 180, 58, 0.8); }
#t-label { position: absolute; left: 0; right: 0; top: 8px; text-align: center; font-size: 10px; font-weight: bold; letter-spacing: 1px; color: var(--amber); }

/* ── Screens: title, missions, briefing, results ───────────────────────────── */
.screen[hidden] { display: none; }
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(2, 4, 10, 0.55), rgba(2, 4, 10, 0.88));
}
.screen.clear { background: rgba(2, 4, 10, 0.25); }
.box {
  width: min(640px, 100%);
  margin: auto;
  background: rgba(5, 9, 18, 0.9);
  border: 1px solid rgba(92, 208, 255, 0.22);
  border-radius: 10px;
  padding: 26px 26px 22px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}
.box.narrow { width: min(460px, 100%); }
.box h2 { color: #f2f5ff; font-size: 20px; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 6px; }
.box h3 { color: var(--phos); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; margin: 18px 0 8px; }
.box p { font-size: 14px; line-height: 1.55; color: #b9c1d8; margin-bottom: 8px; }
.box .meta { color: var(--muted); font-size: 12px; letter-spacing: 1px; margin-bottom: 14px; }
.box .lead { color: #d5dbec; }

/* the logo: an annunciator light switching on */
.logo {
  display: inline-block;
  margin: 6px auto 16px;
  padding: 18px 26px 16px;
  border-radius: 6px;
  background: #1a86c4;
  border: 2px solid #9ae4ff;
  color: #f2fbff;
  font-weight: bold;
  font-size: clamp(28px, 7vw, 46px);
  line-height: 1;
  letter-spacing: 0.14em;
  text-align: center;
  box-shadow: 0 0 34px rgba(92, 208, 255, 0.75), inset 0 0 18px rgba(255, 255, 255, 0.25);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
  animation: lampOn 1.4s steps(1) 1;
}
.logo span { display: block; }
@keyframes lampOn {
  0% { background: #0c1a26; color: #24394b; box-shadow: none; border-color: #2a3d4f; text-shadow: none; }
  30% { background: #1a86c4; color: #f2fbff; box-shadow: 0 0 34px rgba(92, 208, 255, 0.75); border-color: #9ae4ff; }
  38% { background: #0c1a26; color: #24394b; box-shadow: none; border-color: #2a3d4f; text-shadow: none; }
  52% { background: #1a86c4; color: #f2fbff; box-shadow: 0 0 34px rgba(92, 208, 255, 0.75); border-color: #9ae4ff; }
}
.title { text-align: center; }
.title .tag { color: var(--muted); letter-spacing: 2px; font-size: 12px; margin-bottom: 22px; }
.menu { display: flex; flex-direction: column; gap: 10px; width: min(320px, 100%); margin: 0 auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid rgba(57, 255, 138, 0.55);
  background: rgba(57, 255, 138, 0.06);
  color: var(--phos);
  font: bold 14px var(--mono);
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover, .btn:focus-visible { background: var(--phos); color: #02140a; outline: none; }
.btn.primary { background: var(--phos); color: #02140a; }
.btn.primary:hover, .btn.primary:focus-visible { background: #8dffbe; }
.btn.ghost { border-color: #2c3450; color: #9aa4cc; background: transparent; }
.btn.ghost:hover, .btn.ghost:focus-visible { background: #1b2236; color: #eef0fa; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btns .btn { flex: 1 1 160px; }

/* mission list */
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 14px; }
.card {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #22304a;
  background: rgba(10, 16, 30, 0.85);
  color: var(--text);
  font-family: var(--mono);
  cursor: pointer;
}
.card:hover, .card:focus-visible { border-color: var(--phos); outline: none; background: rgba(12, 30, 26, 0.9); }
.card .n { color: var(--muted); font-size: 11px; letter-spacing: 2px; }
.card .nm { color: #f2f5ff; font-weight: bold; font-size: 15px; letter-spacing: 1px; }
.card .pl { color: #9aa4cc; font-size: 12px; }
.card .ft { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.card.locked { opacity: 0.45; cursor: not-allowed; }
.stars { color: #ffd34a; letter-spacing: 2px; font-size: 15px; }
.stars .off { color: #2f3850; }

.objs { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.objs li { display: flex; gap: 10px; font-size: 13px; color: #c8cde0; line-height: 1.4; }
.objs li .s { color: #2f3850; font-size: 15px; }
.objs li.got .s { color: #ffd34a; }
.small { font-size: 12px !important; color: var(--muted) !important; }

/* results */
.result h2.ok { color: var(--phos); }
.result h2.bad { color: var(--red); }
.result h2.mid { color: var(--amber); }
.big-stars { font-size: 34px; letter-spacing: 8px; color: #ffd34a; margin: 10px 0 4px; }
.big-stars .off { color: #283148; }
.pts { font-size: 28px; color: #ffd34a; font-weight: bold; letter-spacing: 2px; }
.pts small { font-size: 12px; color: var(--muted); letter-spacing: 1px; margin-left: 6px; }
.badge { display: inline-block; margin-left: 10px; padding: 3px 8px; border-radius: 4px; background: #ffd34a; color: #2a1d00; font-size: 11px; letter-spacing: 1px; vertical-align: middle; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; font-size: 13px; margin-top: 12px; }
.stats span:nth-child(odd) { color: var(--muted); }
.stats span:nth-child(even) { color: #e6eaf6; text-align: right; font-variant-numeric: tabular-nums; }
.stats .y { color: var(--phos) !important; }
.stats .n { color: var(--red) !important; }
.fact { margin-top: 16px; padding: 12px 14px; border-left: 3px solid var(--blue); background: rgba(92, 208, 255, 0.06); border-radius: 2px; }
.fact h3 { color: var(--blue); margin-top: 0; }
.fact p { font-size: 13px; }

.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.keys kbd { color: var(--phos); font-family: var(--mono); font-weight: bold; white-space: nowrap; }
.keys span { color: #c8cde0; }
.tips { margin: 0; padding-left: 18px; }
.tips li { font-size: 13px; line-height: 1.5; color: #b9c1d8; margin-bottom: 6px; }

/* ── Small screens ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .panel { min-width: 0; padding: 6px 8px; top: 8px; }
  .val { font-size: 14px; min-width: 46px; }
  .lbl { font-size: 9px; letter-spacing: 1px; }
  .u { width: 22px; font-size: 9px; }
  .lamps { top: 98px; display: flex; flex-wrap: wrap; justify-content: center; width: calc(100% - 20px); gap: 4px; }
  .lamp { font-size: 8px; padding: 3px 5px; letter-spacing: 0.5px; }
  #tip { font-size: 12px; }
  body.touch #tip { bottom: 296px; }
  .box { padding: 20px 16px 16px; }
  .box h2 { font-size: 17px; }
  body.touch #radio { bottom: 228px; }
}
@media (max-width: 440px) {
  .page-bar { padding: 0 10px; }
  .game-name { letter-spacing: 1.5px; font-size: 11px; gap: 6px; }
  .game-name .dot { width: 7px; height: 7px; }
  .page-bar nav { gap: 5px; }
  .tool { min-width: 30px; padding: 0 6px; }
  .pacca { padding: 5px 7px; gap: 6px; }
  .pacca img { width: 16px; height: 16px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  :root { --head-h: 30px; --foot-h: 22px; }
  .page-bar { font-size: 11px; }
  .page-bar.foot { font-size: 10px; }
  .tool { height: 24px; min-width: 28px; }
  .pacca { padding: 3px 8px; }
  .panel { top: 6px; padding: 5px 8px; }
  .row { line-height: 1.35; }
  .lamps { top: 6px; bottom: auto; grid-template-columns: repeat(2, auto); }
  #radio { bottom: 10px; width: min(420px, calc(100% - 300px)); }
  #t-lever { height: min(170px, 60vh); }
  .t-tilt button { width: 54px; height: 54px; }
}
body.touch #btn-pause { display: block; }
@media (min-width: 641px) {
  body.touch .lamps { top: 46px; }
}
