@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #000000;
  --fog: #d0d8e0;
  --muted: #8b9592;
  --green: #8dffb0;
  --cream: #f3ede2;
  --gold: #c6a572;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--ink); }
body {
  margin: 0;
  background: var(--ink);
  color: var(--fog);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* -------- Boot / loading screen -------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000;
  color: var(--green);
  font-family: var(--mono);
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
}
.boot[hidden] { display: none !important; }
.boot-static {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}
.scanlines,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0 2px,
    rgba(0, 0, 0, 0.28) 2px 3px
  );
  opacity: 0.55;
}
.vignette {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.72) 100%);
}
.glitchbar {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #e8ffe8;
  box-shadow: 0 0 8px 2px rgba(141, 255, 176, 0.55);
  opacity: 0;
  pointer-events: none;
}
.boot-copy {
  position: relative;
  z-index: 2;
  width: min(640px, calc(100% - 48px));
  min-height: 7.5rem;
}
.boot-line,
.boot-load {
  margin: 0 0 0.7rem;
  font-size: clamp(15px, 2.4vw, 22px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(141, 255, 176, 0.45);
  line-height: 1.45;
}
.boot-load {
  margin-top: 1.15rem;
  font-size: clamp(20px, 3.2vw, 28px);
  letter-spacing: 0.16em;
}
.boot-line[hidden],
.boot-load[hidden] { display: none; }
.cursor {
  display: inline-block;
  width: 0.7em;
  height: 1em;
  margin-left: 0.15em;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  vertical-align: -0.1em;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}
.boot-skip {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 2;
}
.boot.is-ready .boot-skip { opacity: 0.7; }

/* -------- Main stage -------- */
.stage {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 56px;
  padding-top: max(48px, env(safe-area-inset-top));
  padding-bottom: max(56px, env(safe-area-inset-bottom));
}
.stage[hidden] { display: none !important; }

.wordmark {
  text-align: center;
  margin: 0 0 72px;
}
.wm-title {
  margin: 0;
  font-size: clamp(13px, 1.4vw, 15px);
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #f2f5f3;
}
.wm-url {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--muted);
}

.row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(48px, 8vw, 112px);
  width: 100%;
  max-width: 920px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-decoration: none;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  width: 240px;
}
.tile .cap,
.tile .banner {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
a.tile:focus-visible {
  outline: none;
}
a.tile:focus-visible .sq {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green), 0 0 28px rgba(141, 255, 176, 0.22);
}

.sq {
  display: grid;
  place-items: center;
  width: 240px;
  height: 240px;
  border: 1px solid rgba(141, 255, 176, 0.28);
  background: #000;
  overflow: hidden;
}
.sq img {
  width: 92%;
  height: 92%;
  object-fit: contain;
  display: block;
}

.tile.acm {
  cursor: pointer;
  transition: transform 0.25s ease;
}
.tile.acm .sq {
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.tile.acm:hover .sq {
  border-color: rgba(141, 255, 176, 0.7);
  box-shadow: 0 0 36px rgba(141, 255, 176, 0.16);
}
.tile.acm:hover .cap { color: var(--green); }

.tile.dnd {
  cursor: default;
  pointer-events: none;
  user-select: none;
  width: 200px;
}
.tile.dnd .hanger {
  display: block;
  width: 168px;
  height: auto;
}
.banner {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid rgba(198, 165, 114, 0.55);
  color: var(--cream) !important;
  letter-spacing: 0.32em !important;
  font-size: 10px !important;
}

/* -------- Mobile -------- */
@media (max-width: 700px) {
  .stage { padding-left: 20px; padding-right: 20px; }
  .wordmark { margin-bottom: 48px; }
  .row {
    flex-direction: column;
    align-items: center;
    gap: 56px;
  }
  .tile { width: 200px; }
  .sq { width: 200px; height: 200px; }
  .tile.dnd { width: 180px; }
  .tile.dnd .hanger { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .cursor { animation: none; opacity: 1; }
}

/* -------- Gate game: Defend the Transmission -------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.gate {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: #000;
  color: var(--green);
  font-family: var(--mono);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.gate[hidden] { display: none !important; }
.g-canvas {
  position: absolute;
  inset: 0;
  display: block;
  outline: none;
  touch-action: none;
}
.gate .scanlines, .gate .vignette { z-index: 1; }

.g-top {
  position: absolute;
  z-index: 4;
  top: max(12px, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  pointer-events: none;
}
.g-chip {
  pointer-events: auto;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(141, 255, 176, 0.25);
  padding: 9px 12px;
  min-height: 36px;
  cursor: pointer;
}
.g-chip:hover, .g-chip:focus-visible { color: var(--green); border-color: rgba(141, 255, 176, 0.7); outline: none; }
.g-chip[aria-pressed="true"] { color: var(--green); }
.g-skip {
  color: #000;
  background: var(--green);
  border-color: var(--green);
  font-weight: 600;
  padding: 9px 16px;
}
.g-skip:hover, .g-skip:focus-visible { color: #000; background: #e8ffe8; box-shadow: 0 0 18px rgba(141, 255, 176, 0.45); }

.g-hud {
  position: absolute;
  z-index: 3;
  top: calc(max(12px, env(safe-area-inset-top)) + 46px);
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid rgba(141, 255, 176, 0.18);
  pointer-events: none;
}
.g-hud[hidden] { display: none; }
.g-hud b { color: var(--green); font-weight: 400; letter-spacing: 0.12em; text-shadow: 0 0 8px rgba(141, 255, 176, 0.5); }
.g-lives { display: inline-flex; align-items: center; gap: 8px; }
.pips { display: inline-flex; gap: 5px; }
.pip {
  display: inline-block;
  width: 9px; height: 11px;
  border-radius: 50% 50% 46% 46%;
  background: #e2e9e5;
  box-shadow: inset 0 -3px 0 rgba(93, 255, 134, 0.85);
}
.pip.off { background: transparent; box-shadow: inset 0 0 0 1px rgba(141, 255, 176, 0.3); }

.g-panel {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100% - 40px));
  padding: 28px 26px 26px;
  background: rgba(0, 8, 3, 0.86);
  border: 1px solid rgba(141, 255, 176, 0.35);
  box-shadow: 0 0 40px rgba(141, 255, 176, 0.08), inset 0 0 30px rgba(141, 255, 176, 0.04);
  text-align: center;
}
.g-panel[hidden] { display: none; }
.g-kicker {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.g-title {
  margin: 0 0 14px;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--green);
  text-shadow: 0 0 14px rgba(141, 255, 176, 0.5);
}
.g-copy {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fog);
  letter-spacing: 0.04em;
}
.g-copy b { color: var(--green); font-weight: 400; letter-spacing: 0.12em; }
.g-ctrl {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.g-ctrl-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .g-ctrl-desk { display: none; }
  .g-ctrl-touch { display: block; }
}
.g-rm {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--cream);
  letter-spacing: 0.04em;
}
.g-rm[hidden] { display: none; }
.g-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}
.g-btn {
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  min-width: 140px;
  min-height: 46px;
  padding: 12px 18px;
  cursor: pointer;
  color: var(--green);
  background: transparent;
  border: 1px solid rgba(141, 255, 176, 0.5);
}
.g-btn:hover, .g-btn:focus-visible { border-color: var(--green); box-shadow: 0 0 20px rgba(141, 255, 176, 0.25); outline: none; }
.g-primary { color: #000; background: var(--green); border-color: var(--green); font-weight: 600; }
.g-primary:hover, .g-primary:focus-visible { background: #e8ffe8; }
/* reduced motion: make skip the primary action */
.gate.reduced #gskip2 { order: -1; color: #000; background: var(--green); border-color: var(--green); font-weight: 600; }
.gate.reduced #gstart { color: var(--green); background: transparent; border-color: rgba(141, 255, 176, 0.5); font-weight: 400; }

.g-win .g-title { font-size: clamp(20px, 5.6vw, 28px); }
.g-load {
  margin: 4px 0 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.replay {
  margin-top: 64px;
  font: inherit;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(139, 149, 146, 0.7);
  background: none;
  border: 0;
  padding: 10px;
  cursor: pointer;
}
.replay[hidden] { display: none; }
.replay:hover, .replay:focus-visible { color: var(--green); outline: none; }

/* -------- Updates signup -------- */
.updates {
  margin-top: 64px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  font-family: var(--mono);
}
.updates .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.upd-label {
  display: block;
  margin-bottom: 14px;
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}
.upd-row { display: flex; gap: 0; }
.upd-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--green);
  background: #000;
  border: 1px solid rgba(141, 255, 176, 0.28);
  border-right: 0;
  border-radius: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.upd-input::placeholder { color: rgba(139, 149, 146, 0.6); }
.upd-input:focus { border-color: rgba(141, 255, 176, 0.75); box-shadow: 0 0 18px rgba(141, 255, 176, 0.12); }
.upd-btn {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 18px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #000;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 0;
  cursor: pointer;
}
.upd-btn:hover, .upd-btn:focus-visible { background: #e8ffe8; outline: none; box-shadow: 0 0 18px rgba(141, 255, 176, 0.35); }
.upd-btn:disabled { opacity: 0.6; cursor: default; }
.upd-msg {
  min-height: 1.4em;
  margin: 12px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.updates.is-error .upd-msg { color: var(--gold); }
.updates.is-done .upd-row { display: none; }
.updates.is-done .upd-msg { color: var(--green); font-size: 12px; text-shadow: 0 0 10px rgba(141, 255, 176, 0.4); }
.updates + .replay { margin-top: 28px; }
@media (max-width: 700px) {
  .updates { margin-top: 52px; }
  .upd-row { flex-direction: column; gap: 10px; }
  .upd-input { border-right: 1px solid rgba(141, 255, 176, 0.28); }
}
