/* ---- Theme tokens ---- */
:root {
  --brass: #C9A24B;
  --red: #E63329;
  --green: #34C759;
  --blue: #29ABE2;
  --radius: 4px;
  --font-display: 'Monoton', cursive;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html[data-theme="day"] {
  --bg: #FBF7F0;
  --surface: #FFFFFF;
  --text: #2B1F3D;
  --text-secondary: #6B5E80;
  --border: rgba(43, 31, 61, 0.14);
  --scanline-alpha: 0.06;
}

html[data-theme="night"] {
  --bg: #1F1730;
  --surface: #2A2040;
  --text: #E8E0F2;
  --text-secondary: #A89EC4;
  --border: #3D2F55;
  --scanline-alpha: 0.22;
}

/* ---- Reset ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  transition: background 0.2s ease, color 0.2s ease;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Nav ---- */
.nav {
  border-bottom: 0.5px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.brand img {
  border-radius: 2px;
}
.nav-links {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}
.nav-links a:hover {
  color: var(--text);
}

/* ---- Hero ---- */
.hero {
  padding: 32px 20px;
}
.hero-card {
  position: relative;
  background: var(--bg);
  border-top: 3px solid var(--brass);
  border-radius: var(--radius);
  padding: 28px 24px;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, var(--scanline-alpha)) 0px,
    rgba(0, 0, 0, var(--scanline-alpha)) 1px,
    transparent 1px,
    transparent 4px
  );
}
.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.hero-copy {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 220px;
}
.hero-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.hero h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
}
.lede {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}

.btn {
  display: inline-block;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--blue);
}
.btn-primary {
  background: var(--surface);
  color: var(--blue);
}
.btn-primary:hover {
  background: var(--blue);
  color: var(--surface);
}

.tv-frame {
  position: relative;
  z-index: 1;
  width: 150px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 3px solid var(--brass);
  border-radius: 10px;
  padding: 16px 10px 22px;
  text-decoration: none;
}
.tv-frame:hover,
.tv-frame:focus-visible {
  border-color: var(--blue);
}
.tv-antenna {
  position: absolute;
  top: -13px;
  width: 2px;
  height: 16px;
  background: var(--brass);
}
.tv-antenna::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brass);
}
.tv-antenna-left {
  left: 38%;
  transform: rotate(-25deg);
  transform-origin: bottom center;
}
.tv-antenna-right {
  left: 62%;
  transform: rotate(25deg);
  transform-origin: bottom center;
}
.tv-screen {
  width: 100%;
  height: 72px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.07) 0px,
      rgba(255, 255, 255, 0.07) 1px,
      transparent 1px,
      transparent 4px
    ),
    #15101F;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tv-play-icon {
  font-size: 16px;
  color: var(--red);
}
.tv-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
}
.tv-knob {
  position: absolute;
  bottom: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.tv-knob-green { right: 24px; background: var(--green); }
.tv-knob-blue { right: 10px; background: var(--blue); }
.tv-leg {
  position: absolute;
  bottom: -8px;
  width: 16px;
  height: 10px;
  border-radius: 2px;
  background: var(--brass);
}
.tv-leg-left { left: 12px; }
.tv-leg-right { right: 12px; }


/* ---- Memphis divider ---- */
.memphis-divider {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 4px;
}
.memphis-divider span {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid;
}
.memphis-divider span.c-red { border-bottom-color: var(--red); }
.memphis-divider span.c-green { border-bottom-color: var(--green); }
.memphis-divider span.c-blue { border-bottom-color: var(--blue); }

/* ---- Games ---- */
.games {
  padding: 12px 20px 40px;
}
.games h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 14px;
}
.empty-state {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0;
}
.empty-state a {
  color: var(--blue);
  text-decoration: underline;
}
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.game-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: block;
}
.game-card:hover {
  border-color: var(--blue);
}
.game-card-thumb {
  height: 70px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.game-card-title {
  font-size: 13px;
  margin: 0;
}

/* ---- Footer ---- */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px 32px;
  border-top: 0.5px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}
.site-footer a {
  color: var(--blue);
}
#theme-toggle {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
}
#theme-toggle:hover {
  border-color: var(--brass);
}

@media (max-width: 480px) {
  .hero-inner { flex-direction: column; align-items: flex-start; }
  .tv-frame { align-self: center; }
}

/* ---- CRT power-on boot animation ---- */
#crt-boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  pointer-events: none;
  transform-origin: center center;
  animation: crt-boot-sequence 750ms ease-out forwards;
}

@keyframes crt-boot-sequence {
  0%   { transform: scaleX(0.04) scaleY(0.004); background: #000; opacity: 1; }
  8%   { transform: scaleX(1)    scaleY(0.004); background: #fff; opacity: 1; }
  11%  { transform: scaleX(1)    scaleY(0.004); background: #000; opacity: 1; }
  16%  { transform: scaleX(1)    scaleY(0.012); background: #fff; opacity: 1; }
  32%  { transform: scaleX(1)    scaleY(1);     background: #fff; opacity: 1; }
  46%  { transform: scaleX(1)    scaleY(1);     background: #000; opacity: 1; }
  100% { transform: scaleX(1)    scaleY(1);     background: #000; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #crt-boot {
    animation: none;
    opacity: 0;
    display: none;
  }
}

