/* =========================================================
   Terminal theme — black / phosphor green
   ========================================================= */
:root {
  --bg: #030603;
  --bg-2: #061009;
  --panel: rgba(7, 18, 10, 0.86);
  --line: #123f20;
  --line-2: #1d6b36;
  --green: #39ff7a;
  --green-2: #22c55e;
  --green-dim: #1a8f42;
  --text: #b9f2c9;
  --muted: #6f9c7c;
  --amber: #ffc857;
  --red: #ff5f56;
  --glow: 0 0 6px rgba(57, 255, 122, 0.55), 0 0 18px rgba(57, 255, 122, 0.18);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --maxw: 1080px;
  color-scheme: dark;
}

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(57, 255, 122, 0.10), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(57, 255, 122, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
  overflow-x: hidden;
}

::selection { background: var(--green); color: var(--bg); }

a { color: var(--green); text-decoration: none; }
a:hover { text-shadow: var(--glow); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px dashed var(--green);
  outline-offset: 3px;
}

h1, h2, h3 { color: var(--green); font-weight: 700; line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: .02em; text-shadow: var(--glow); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--green); color: var(--bg); padding: 6px 10px;
}
.skip:focus { top: 12px; }

.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;
}

/* ---------- CRT overlay: scanlines + vignette + flicker ---------- */
.crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, .22) 3px, rgba(0, 0, 0, 0) 4px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%);
  animation: flicker 6s infinite steps(1);
}
.crt::after {
  content: ""; position: absolute; left: 0; right: 0; height: 120px; top: -120px;
  background: linear-gradient(to bottom, transparent, rgba(57, 255, 122, .045), transparent);
  animation: sweep 9s linear infinite;
}
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: .92; } 48% { opacity: 1; } 83% { opacity: .95; } 84% { opacity: 1; } }
@keyframes sweep { to { transform: translateY(calc(100vh + 240px)); } }

/* ---------- Top bar ---------- */
.topbar {
  width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: 22px 16px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: .08em; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--bg-2); color: var(--green); text-shadow: var(--glow); font-size: .9rem;
}
.brand:hover { text-shadow: none; }
.brand-name { color: var(--green); text-shadow: var(--glow); }

.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a {
  color: var(--muted); padding: 4px 10px; border-radius: 4px;
  transition: color .15s, background-color .15s;
}
.nav-dot { color: var(--green-dim); }
.nav a:hover { color: var(--bg); background: var(--green); text-shadow: none; }
.nav a:hover .nav-dot { color: var(--bg); }
.nav a[aria-current="page"] { color: var(--green); background: rgba(57, 255, 122, .08); box-shadow: inset 0 -2px 0 var(--green); }

/* ---------- Terminal window ---------- */
.window {
  flex: 1;
  width: calc(100% - 32px); max-width: var(--maxw); margin: 0 auto 24px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(57, 255, 122, .04), 0 20px 60px rgba(0, 0, 0, .6), 0 0 40px rgba(57, 255, 122, .06);
  overflow: hidden;
}
.window-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, #0b1d10, #07130b);
  font-size: .8rem; color: var(--muted);
}
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.dots i:first-child { background: #3b5e45; }
.window-title { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.window-tty { color: var(--green-dim); }
.window-body { padding: clamp(20px, 4vw, 44px); }

/* ---------- Prompt / terminal lines ---------- */
.prompt { color: var(--green); white-space: nowrap; }
.prompt-host { color: var(--green-2); }
.prompt-path { color: #7cc4ff; }
.cmd { margin: 0 0 .4em; color: #eafff0; overflow-wrap: anywhere; }
.cmd .typed { color: #eafff0; }
.out { margin: 0 0 1.4em; }
.muted { color: var(--muted); }
.accent { color: var(--green); }
.comment { color: var(--muted); }
.comment::before { content: "# "; color: var(--green-dim); }

.cursor {
  display: inline-block; width: .6em; height: 1.1em; vertical-align: text-bottom;
  background: var(--green); box-shadow: var(--glow);
  animation: blink 1.05s steps(1) infinite;
}
.is-typing::after {
  content: ""; display: inline-block; width: .6em; height: 1.1em; vertical-align: text-bottom;
  margin-left: 2px; background: var(--green); box-shadow: var(--glow);
}
@keyframes blink { 50% { opacity: 0; } }

/* sequence: steps hidden until played (JS only) */
html.js .seq:not(.is-static) [data-step] { visibility: hidden; }
html.js .seq:not(.is-static) [data-step].is-on { visibility: visible; animation: lineIn .25s ease-out; }
@keyframes lineIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- Glitch title ---------- */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0;
}
.glitch::before { color: #00ffd5; transform: translate(-2px, 0); }
.glitch::after { color: #b3ff00; transform: translate(2px, 0); }
.glitch:hover::before, .glitch.is-glitching::before { opacity: .7; animation: glitchA .35s steps(2) 2; }
.glitch:hover::after, .glitch.is-glitching::after { opacity: .7; animation: glitchB .35s steps(2) 2; }
@keyframes glitchA { 0% { clip-path: inset(10% 0 60% 0); } 50% { clip-path: inset(55% 0 10% 0); } 100% { clip-path: inset(30% 0 40% 0); } }
@keyframes glitchB { 0% { clip-path: inset(70% 0 5% 0); } 50% { clip-path: inset(5% 0 75% 0); } 100% { clip-path: inset(40% 0 30% 0); } }

/* ---------- Hero ---------- */
.hero { padding: 6px 0 18px; }
.hero-title { font-size: clamp(2.6rem, 11vw, 6rem); margin: .1em 0 .15em; letter-spacing: .06em; }
.hero-tagline { font-size: clamp(1rem, 2.4vw, 1.2rem); color: var(--text); max-width: 46ch; }

.ls { list-style: none; padding: 0; display: grid; gap: 2px; }
.ls li { display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline; }
.ls .perm { color: var(--muted); }
.ls a { font-weight: 700; }

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: .4em;
  font: inherit; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; font-size: .88rem;
  padding: 10px 16px; border-radius: 4px; cursor: pointer;
  color: var(--green); background: transparent; border: 1px solid var(--green);
  transition: background-color .15s, color .15s, box-shadow .15s, transform .15s;
}
.btn::before { content: "["; color: var(--green-dim); }
.btn::after { content: "]"; color: var(--green-dim); }
.btn:hover { background: var(--green); color: var(--bg); box-shadow: 0 0 22px rgba(57, 255, 122, .35); text-shadow: none; transform: translateY(-1px); }
.btn:hover::before, .btn:hover::after { color: var(--bg); }
.btn-solid { background: var(--green); color: var(--bg); }
.btn-solid::before, .btn-solid::after { color: var(--bg); }
.btn[disabled] { opacity: .5; cursor: progress; transform: none; }

/* ---------- Sections & panels ---------- */
.section { margin-top: clamp(36px, 6vw, 64px); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head .cmd { margin: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }

.panel {
  position: relative;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(3, 10, 5, .7);
  padding: 20px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.panel:hover { border-color: var(--line-2); box-shadow: 0 0 0 1px rgba(57, 255, 122, .08), 0 0 28px rgba(57, 255, 122, .08); }
.panel-label { font-size: .78rem; color: var(--green-dim); margin-bottom: 8px; letter-spacing: .08em; }
.panel p:last-child { margin-bottom: 0; }

/* ---------- Games ---------- */
.games { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.game { display: flex; flex-direction: column; padding: 0; overflow: hidden; scroll-margin-top: 24px; }
.game:hover { transform: translateY(-3px); }
.game:target { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 0 30px rgba(57, 255, 122, .2); }
.game-media {
  position: relative; aspect-ratio: 16 / 9; border-bottom: 1px solid var(--line);
  background:
    linear-gradient(rgba(57, 255, 122, .05) 1px, transparent 1px) 0 0 / 100% 14px,
    linear-gradient(90deg, rgba(57, 255, 122, .05) 1px, transparent 1px) 0 0 / 14px 100%,
    #020703;
  display: grid; place-items: center; overflow: hidden;
}
.game-media img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.9); transition: transform .4s; }
.game:hover .game-media img { transform: scale(1.04); }
.game-media .placeholder { color: var(--green); text-shadow: var(--glow); font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 700; letter-spacing: .1em; text-align: center; padding: 0 16px; }
.game-media .placeholder small { display: block; font-size: .75rem; color: var(--muted); letter-spacing: .2em; text-shadow: none; }
.game-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.game-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.game h2 { margin-bottom: .4em; font-size: 1.3rem; }
.game p { color: var(--text); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; list-style: none; padding: 0; margin: 0 0 16px; }
.tags li { font-size: .75rem; color: var(--green-2); border: 1px solid var(--line); border-radius: 3px; padding: 1px 7px; }
.game .actions { margin-top: auto; }

.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  padding: 1px 7px; border-radius: 3px; border: 1px solid currentColor;
}
.badge-released { color: var(--green); }
.badge-beta { color: #7cc4ff; }
.badge-in-dev { color: var(--amber); }

/* ---------- Prose (about / privacy / legal) ---------- */
.prose { max-width: 76ch; }
.prose h2 { margin-top: 2em; padding-top: .2em; }
.prose h2::before { content: "## "; color: var(--green-dim); }
.prose h3::before { content: "### "; color: var(--green-dim); }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .35em; }
.prose li::marker { content: "- "; color: var(--green); }
.prose a { text-decoration: underline; text-decoration-color: var(--green-dim); text-underline-offset: 3px; }
.prose strong { color: #eafff0; }
.toc { border-left: 2px solid var(--line-2); padding: 4px 0 4px 16px; margin: 0 0 28px; }
.toc ol { margin: 0; padding-left: 1.4em; }

/* ---------- Key/value list ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 1em; }
.kv dt { color: var(--green-dim); }
.kv dd { margin: 0; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 8px; } }

/* ---------- Forms ---------- */
.form { display: grid; gap: 18px; max-width: 680px; }
.form .row { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.field { display: grid; gap: 6px; }
.field label { color: var(--green); font-size: .88rem; }
.field label::before { content: "> "; color: var(--green-dim); }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; color: #eafff0;
  background: #020703; border: 1px solid var(--line-2); border-radius: 4px;
  padding: 10px 12px; caret-color: var(--green);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 180px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(57, 255, 122, .15); }
.field .hint { font-size: .78rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.field.has-error input, .field.has-error textarea, .field.has-error select { border-color: var(--red); }
.field .error { color: var(--red); font-size: .82rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.alert { border: 1px solid; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 22px; }
.alert-ok { border-color: var(--green); background: rgba(57, 255, 122, .07); color: var(--green); }
.alert-err { border-color: var(--red); background: rgba(255, 95, 86, .07); color: #ffb3ae; }

/* ---------- Footer status line ---------- */
.footer { width: calc(100% - 32px); max-width: var(--maxw); margin: 0 auto 22px; }
.statusline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px;
  font-size: .8rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
  background: rgba(3, 10, 5, .8);
}
.mode { background: var(--green); color: var(--bg); font-weight: 700; padding: 0 6px; border-radius: 2px; }
.status-mid { flex: 1; }
.status-links { display: flex; gap: 14px; }
.status-links a { color: var(--muted); }
.status-links a:hover { color: var(--green); }

/* ---------- Boot screen ---------- */
.boot {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  padding: 24px 16px; font-size: .85rem; color: var(--muted);
  display: flex; flex-direction: column; justify-content: flex-end;
  transition: opacity .45s ease, visibility .45s;
}
.boot[hidden] { display: none; }
.boot.is-leaving { opacity: 0; visibility: hidden; }
.boot-log { max-width: var(--maxw); width: 100%; margin: 0 auto; }
.boot-log p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.boot-log .ok { color: var(--green); }
.boot-skip { position: absolute; top: 16px; right: 16px; color: var(--muted); font-size: .75rem; }

/* ---------- Reveal on scroll ---------- */
html.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
html.js .reveal.is-visible { opacity: 1; transform: none; }
html.js .reveal-d1 { transition-delay: .08s; }
html.js .reveal-d2 { transition-delay: .16s; }
html.js .reveal-d3 { transition-delay: .24s; }

/* ---------- 404 ---------- */
.err-code { font-size: clamp(4rem, 18vw, 9rem); line-height: 1; margin: .1em 0; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .prompt-host { display: none; }
  .window-tty { display: none; }
  .topbar { padding-top: 16px; }
  .nav a { padding: 4px 7px; }
  .status-mid { flex-basis: 100%; order: 3; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .crt::after { display: none; }
  html.js .reveal { opacity: 1; transform: none; }
  @view-transition { navigation: none; }
}
