@font-face { font-family: "PS2P"; src: url("/fonts/press-start-2p.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "VT323"; src: url("/fonts/vt323.woff2") format("woff2"); font-display: swap; }

:root {
  --black: #000000; --night: #0F0F3F; --dkgreen: #005800; --green: #00A800;
  --lime: #B8F818; --purple: #6844FC; --magenta: #D800CC; --orange: #F87858;
  --gold: #F8B800; --white: #FCFCFC; --gray: #7C7C7C; --blue: #3CBCFC;
  --accent: var(--lime);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #111 radial-gradient(circle at 50% 30%, #1d1d2b 0%, #050505 70%);
  color: var(--white);
  font-family: "VT323", monospace;
  font-size: 22px;
  line-height: 1.25;
}
img { image-rendering: pixelated; image-rendering: crisp-edges; }
a { color: var(--lime); }
h1, h2, h3, .px { font-family: "PS2P", monospace; font-weight: normal; letter-spacing: 1px; }
h1 { font-size: 20px; line-height: 1.5; }
h2 { font-size: 14px; line-height: 1.6; color: var(--lime); }
h3 { font-size: 11px; color: var(--gold); margin: 1.2em 0 .5em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- CRT TV shell ---------- */
.tv { min-height: 100vh; display: flex; flex-direction: column; }
.screen {
  position: relative; flex: 1; overflow: hidden;
  background: var(--black);
  display: flex; flex-direction: column;
}
.screen::after { /* scanlines + vignette */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 50;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,.55) 100%);
}
.screen-inner { position: relative; flex: 1; overflow-y: auto; padding: 20px 18px 28px; container-type: inline-size; }
.tv-controls { display: none; }

.bezel { display: none; }
@media (min-width: 900px) and (min-height: 560px) {
  body { padding: 12px 0; overflow: hidden; }
  .tv {
    min-height: 0; position: relative; margin: 0 auto;
    width: min(96vw, calc((100vh - 60px) * 4 / 3)); aspect-ratio: 4 / 3;
  }
  .bezel { display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
  /* screen sits in the bezel's opening (273,172)-(1326,900) of 1600x1200, tucked slightly under the frame */
  .screen { position: absolute; left: 16.6%; top: 13.8%; width: 66.7%; height: 61.6%; flex: none; border-radius: 18px; }
  .screen-inner { padding: 22px 26px 30px; }
  .tv-controls {
    display: block; position: absolute; left: 0; right: 0; bottom: -30px; text-align: center;
    font-family: "PS2P"; font-size: 9px; color: #777;
  }
  .tv-controls .badge, .tv-controls .knobs { display: none; }
}

/* ---------- top bar ---------- */
.hud {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-family: "PS2P"; font-size: 10px; color: var(--gray); margin-bottom: 18px;
}
.hud a { color: var(--white); text-decoration: none; }
.sound-btn {
  font-family: "PS2P"; font-size: 10px; background: none; color: var(--white);
  border: 2px solid var(--gray); padding: 6px 8px; cursor: pointer;
}
.sound-btn[aria-pressed="true"] { border-color: var(--lime); color: var(--lime); }

/* ---------- menus + cursor ---------- */
.menu { list-style: none; padding: 0; margin: 0; display: inline-flex; flex-direction: column; gap: 14px; text-align: left; }
.menu-item {
  position: relative; display: inline-block; padding: 4px 0 4px 34px;
  font-family: "PS2P"; font-size: 14px; color: var(--white); text-decoration: none;
  background: none; border: 0; cursor: pointer; outline: none;
}
.menu-item::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 24px; height: 24px; margin-top: -12px;
  background: url("/img/cursor-leaf.png") center / contain no-repeat; image-rendering: pixelated;
  opacity: 0;
}
.menu-item.is-active, .menu-item:hover, .menu-item:focus-visible { color: var(--lime); }
.menu-item.is-active::before, .menu-item:hover::before, .menu-item:focus-visible::before {
  opacity: 1; animation: bob .6s steps(2) infinite;
}
@keyframes bob { 50% { transform: translateX(4px); } }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- title screen ---------- */
.title {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px;
  background: var(--black) url("/img/title-bg.png") center bottom / cover no-repeat;
}
.title-logo { width: min(560px, 90%); height: auto; margin-bottom: 30px; filter: drop-shadow(4px 4px 0 #000); }
.press-start { font-family: "PS2P"; font-size: 16px; color: var(--white); background: none; border: 0; cursor: pointer; text-shadow: 3px 3px 0 #000; }
.title .menu { background: rgba(0,0,0,.75); border: 4px double var(--white); padding: 18px 24px; }
.copyright { position: absolute; bottom: 14px; left: 0; right: 0; font-family: "PS2P"; font-size: 9px; color: var(--white); text-shadow: 2px 2px 0 #000; }
.title .hud { position: absolute; top: 22px; left: 30px; right: 30px; }

/* ---------- panels ---------- */
.panel { border: 4px double var(--white); background: rgba(15,15,63,.82); padding: 16px 18px; }
.page-bg { position: absolute; inset: 0; background: url("/img/select-bg.png") center / cover no-repeat; opacity: .55; }

/* ---------- character select ---------- */
.select-layout { display: grid; gap: 18px; }
@container (min-width: 640px) { .select-layout { grid-template-columns: 1.15fr 1fr; align-items: start; } }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab {
  font-family: "PS2P"; font-size: 9px; padding: 8px 10px; cursor: pointer;
  background: var(--black); color: var(--white); border: 2px solid var(--gray);
}
.tab[aria-pressed="true"] { border-color: var(--lime); color: var(--lime); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@container (min-width: 520px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.slot {
  position: relative; display: block; border: 4px solid var(--gray); background: var(--black);
  aspect-ratio: 1; outline: none; text-decoration: none;
}
.slot img { width: 100%; height: 100%; display: block; }
.slot .slot-name {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.75);
  font-family: "PS2P"; font-size: 7px; color: var(--white); padding: 4px 3px; text-align: center; line-height: 1.4;
}
.slot.is-active, .slot:hover, .slot:focus-visible { border-color: var(--lime); box-shadow: 0 0 0 3px var(--black), 0 0 0 6px var(--lime); }
.slot.is-active::after {
  content: "P1"; position: absolute; top: -12px; left: -8px; font-family: "PS2P"; font-size: 9px;
  background: var(--orange); color: var(--black); padding: 3px 4px;
}
.slot[hidden] { display: none; }

.preview { display: grid; grid-template-columns: 150px 1fr; gap: 16px; }
.preview .portrait-wrap, .card .portrait-wrap {
  background: radial-gradient(circle at 50% 70%, var(--accent) 0%, transparent 65%);
  display: flex; align-items: flex-end; justify-content: center;
}
.preview img { width: 150px; height: 200px; }
.preview h2 { margin: 0 0 6px; }
.type-badge { display: inline-block; font-family: "PS2P"; font-size: 8px; padding: 4px 6px; background: var(--accent); color: var(--black); margin-bottom: 8px; }
.tagline { color: var(--gold); margin: 6px 0 10px; }
@container (max-width: 480px) { .preview { grid-template-columns: 100px 1fr; } .preview img { width: 100px; height: 133px; } }

/* stat bars */
.stats { display: grid; gap: 6px; margin: 8px 0; }
.stat { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 8px; font-family: "PS2P"; font-size: 8px; }
.bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; height: 12px; }
.bar i { background: #222; border: 1px solid #333; }
.bar i.on { background: var(--lime); border-color: var(--green); }
.bar.hot i.on { background: var(--orange); border-color: #a33; }
.stat .val { grid-column: 2; font-family: "VT323"; font-size: 18px; color: var(--gray); margin-top: -4px; }
.unknown { font-family: "PS2P"; font-size: 9px; color: var(--gray); line-height: 1.8; }

.selected-flash {
  position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center;
  background: var(--white); color: var(--black); font-family: "PS2P"; font-size: 18px; text-align: center;
}
.selected-flash.show { display: flex; animation: flash .45s steps(3); }
@keyframes flash { 33% { background: var(--black); color: var(--white); } 66% { background: var(--white); } }

/* ---------- player card ---------- */
.card { display: grid; gap: 20px; }
@container (min-width: 620px) { .card { grid-template-columns: 220px 1fr; } .card .portrait-wrap { min-height: 0; align-self: start; padding: 12px 0; } .card .portrait-wrap img { width: 192px; height: 256px; } }
.card .portrait-wrap { min-height: 320px; border: 4px double var(--white); background-color: var(--night); }
.card .portrait-wrap img { width: 240px; height: 320px; }
.lineage { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: "PS2P"; font-size: 9px; }
.lineage span { border: 2px solid var(--gray); padding: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { border: 2px solid var(--accent); padding: 0 6px; }
.card-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.avail { font-family: "PS2P"; font-size: 9px; }
.avail.in-stock { color: var(--lime); } .avail.sold-out { color: var(--orange); } .avail.coming-soon { color: var(--gold); }

/* ---------- about ---------- */
.story { display: grid; gap: 18px; align-items: start; }
@container (min-width: 560px) { .story { grid-template-columns: 160px 1fr; } }
.story img { width: 160px; height: 160px; background: var(--night); border: 4px double var(--white); }
.textbox { min-height: 160px; }
.textbox p { margin: 0 0 10px; }
.textbox .more { font-family: "PS2P"; font-size: 10px; color: var(--lime); }

/* ---------- contact ---------- */
.countdown { font-family: "PS2P"; font-size: 22px; color: var(--orange); text-align: center; margin: 10px 0 24px; }
.center { text-align: center; }

/* ---------- age gate / 404 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 80; background: var(--black);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px;
}
.overlay[hidden] { display: none; }
.overlay p { max-width: 480px; }
.gameover-img { width: min(512px, 90%); height: auto; }
.gameover-text { font-family: "PS2P"; font-size: 22px; color: var(--orange); margin: 10px 0 20px; }

/* ---------- loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 100; background: var(--black); display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  font-family: "PS2P"; font-size: 12px;
}
.loader.show { display: flex; }
.loader .sprite {
  width: 96px; height: 96px; image-rendering: pixelated;
  background: url("/img/loading-sprite.png") 0 0 / 400% 100% no-repeat;
  animation: sprout .5s steps(4) infinite;
}
@keyframes sprout { to { background-position: 133.333% 0; } }

/* ---------- footer ---------- */
.footer { margin-top: 28px; font-size: 16px; color: var(--gray); text-align: center; }

/* ---------- on-screen pad (phones) ---------- */
.pad { display: none; }

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