:root {
  --bg: #050505;
  --phosphor: #e8a200;
  --phosphor-dim: #a07010;
  --phosphor-faint: #3a2800;
  --phosphor-bg: rgba(232, 162, 0, 0.08);
  --phosphor-glow: rgba(232, 162, 0, 0.18);
  --border: #b07800;
  --border-dim: #3a2800;
  --error: #cc2200;
}

* { box-sizing: border-box; }

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--phosphor);
  font-family: "Space Mono", ui-monospace, "SFMono-Regular", monospace;
  font-size: 14px;
  line-height: 1.5;
  cursor: text;
}

/* ── Background ─────────────────────────────────── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(232, 162, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 162, 0, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(232, 162, 0, 0.06) 0%, transparent 70%);
}

/* ── CRT overlay ────────────────────────────────── */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.18) 50%
  );
  background-size: 100% 4px;
  opacity: 0.55;
}

.crt-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.32) 100%);
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
  color: var(--phosphor);
  font-weight: 700;
}

code {
  font-family: "Space Mono", ui-monospace, "SFMono-Regular", monospace;
  font-size: 0.9em;
  color: var(--bg);
  background: var(--phosphor-dim);
  padding: 0 4px;
}

h1, h2, h3, p, label {
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Layout ─────────────────────────────────────── */
.vault-header,
.vault-catalog,
.vault-footer {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin-left: auto;
  margin-right: auto;
}

.vault-header {
  padding: 3rem 0 2rem;
  border-bottom: 1px dashed var(--border-dim);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border-dim);
  padding: 0.5rem 1rem;
  background: var(--phosphor-bg);
}

.catalog-label {
  margin: 0;
  font-weight: 700;
  color: var(--phosphor);
}

.header-date {
  margin: 0;
  font-weight: 700;
  color: var(--phosphor-dim);
}

.vault-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 0 12px var(--phosphor-glow);
}

.vault-header h1 .accent {
  color: var(--bg);
  background: var(--phosphor);
  padding: 0 10px;
}

.header-desc {
  margin: 1.5rem 0;
  max-width: 64ch;
  color: var(--phosphor-dim);
}

.header-controls {
  display: flex;
  gap: 1.5rem;
  flex-direction: column;
}

@media (min-width: 768px) {
  .header-controls {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.search-wrap {
  flex: 1;
  max-width: 500px;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 0.8rem;
}

.search-input-wrapper .prompt {
  font-weight: 700;
  margin-right: 0.5rem;
  color: var(--phosphor-dim);
}

.search-wrap input {
  width: 100%;
  padding: 0.8rem 0;
  border: none;
  background: transparent;
  color: var(--phosphor);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  text-transform: uppercase;
}

.search-wrap input::placeholder {
  color: var(--phosphor-faint);
}

.header-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
  border-top: 2px solid var(--border-dim);
  min-width: 90px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--phosphor-dim);
}

.stat-num {
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: 0.2rem;
  color: var(--phosphor);
}

/* ── Catalog ────────────────────────────────────── */
.vault-catalog {
  padding: 2rem 0;
}

.catalog-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.catalog-bar h2 {
  margin: 0;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border-dim);
  display: inline-block;
  color: var(--phosphor-dim);
}

.catalog-note {
  margin: 0;
  color: var(--phosphor-faint);
  font-size: 0.8rem;
}

/* ── Franchise group ─────────────────────────────── */
.group {
  margin-bottom: 3rem;
}

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.3rem 0.8rem;
  margin-bottom: 1.2rem;
  background: var(--phosphor);
  color: var(--bg);
}

.group-head h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.group-head .count {
  font-size: 0.78rem;
  font-weight: 700;
}

/* ── Games grid ─────────────────────────────────── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
}

/* ── Game card ──────────────────────────────────── */
.game-card {
  border: 1px solid var(--border-dim);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}

.game-card:hover {
  border-color: var(--border);
}

.game-card[open] {
  border-color: var(--border);
}

.game-card summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: transparent;
}

.game-card summary::-webkit-details-marker { display: none; }

/* ── Cover art ──────────────────────────────────── */
.game-cover {
  width: 100%;
  height: 130px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.game-cover svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Per-game cover backgrounds */
.game-card[data-game-id="tm-original"]     .game-cover { background: linear-gradient(135deg, #081320 0%, #0c2850 60%, #153f7a 100%); }
.game-card[data-game-id="tm-sunrise"]      .game-cover { background: linear-gradient(135deg, #140800 0%, #5a2500 50%, #b85800 100%); }
.game-card[data-game-id="tm-nations-eswc"] .game-cover { background: linear-gradient(135deg, #150003 0%, #580010 50%, #b0001a 100%); }
.game-card[data-game-id="tm-united"]       .game-cover { background: linear-gradient(135deg, #0a0618 0%, #311460 50%, #6830b8 100%); }
.game-card[data-game-id="tm-forever"]      .game-cover { background: linear-gradient(135deg, #001008 0%, #004828 50%, #009048 100%); }
.game-card[data-game-id="tm2"]             .game-cover { background: linear-gradient(135deg, #001018 0%, #00334a 50%, #006888 100%); }
.game-card[data-game-id="tm-turbo"]        .game-cover { background: linear-gradient(135deg, #160018 0%, #4a0090 40%, #aa00e0 100%); }
.game-card[data-game-id="tm-2020"]         .game-cover { background: linear-gradient(135deg, #001428 0%, #002860 50%, #0050b8 100%); }
.game-card[data-game-id="shootmania-storm"].game-cover { background: linear-gradient(135deg, #150000 0%, #580000 50%, #b00e00 100%); }
.game-card[data-game-id="questmania"]      .game-cover { background: linear-gradient(135deg, #0e0012 0%, #400050 50%, #780098 100%); }

.cover-year {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-family: "Space Mono", monospace;
  font-size: 2.2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.12);
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}

.cover-franchise {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: "Space Mono", monospace;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  pointer-events: none;
  user-select: none;
}

/* ── Card info area ─────────────────────────────── */
.game-info {
  padding: 0.85rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border-top: 1px solid var(--border-dim);
}

.game-card[open] .game-info {
  border-top-color: var(--border);
}

.game-name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.game-name {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--phosphor);
  line-height: 1.3;
}

.toggle-icon {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--phosphor-dim);
  font-size: 0.82rem;
  margin-top: 1px;
}

.game-card[open] .toggle-icon::after { content: "[-]"; }
.game-card:not([open]) .toggle-icon::after { content: "[+]"; }

.game-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.pill {
  border: 1px dashed var(--border-dim);
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--phosphor-dim);
}

.pill-count {
  border: 1px solid var(--border-dim);
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--phosphor-dim);
}

/* ── Build list (inside open card) ─────────────── */
.game-body {
  padding: 0 1rem 1rem;
  border-top: 1px dashed var(--border-dim);
}

.game-desc {
  margin: 0.8rem 0;
  color: var(--phosphor-dim);
  text-transform: none;
  font-size: 0.82rem;
}

.builds {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.build {
  border-left: 3px solid var(--border);
  padding: 0.8rem;
  background: rgba(232, 162, 0, 0.04);
}

.build-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.build-head strong {
  font-size: 0.88rem;
  font-weight: 700;
}

.muted {
  margin: 0;
  color: var(--phosphor-dim);
  font-size: 0.8rem;
}

.build-meta {
  color: var(--phosphor-dim);
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

.build-meta::before {
  content: ">> ";
  color: var(--phosphor-faint);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.btn {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border-dim);
  background: transparent;
  color: var(--phosphor-dim);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover {
  border-color: var(--border);
  background: var(--phosphor-bg);
  color: var(--phosphor);
}

.btn-primary {
  background: var(--phosphor);
  color: var(--bg);
  border-color: var(--phosphor);
}

.btn-primary:hover {
  background: transparent;
  color: var(--phosphor);
}

.empty-state {
  padding: 2rem;
  border: 1px dashed var(--border-dim);
  text-align: center;
  color: var(--phosphor-dim);
  text-transform: uppercase;
  background: var(--phosphor-bg);
  grid-column: 1 / -1;
}

/* ── Footer ─────────────────────────────────────── */
.vault-footer {
  padding: 2rem 0;
  border-top: 1px dashed var(--border-dim);
  text-align: center;
  margin-top: 4rem;
}

.vault-footer p {
  margin: 0;
  color: var(--phosphor-faint);
  font-size: 0.8rem;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 600px) {
  .games-grid {
    grid-template-columns: 1fr;
  }
}
