/* SpiderBen10's Arcade — red & blue 80s arcade cabinet */
:root {
  color-scheme: dark;
  --night: #0a0f2e;
  --panel: #111a4c;
  --panel-2: #0d1440;
  --red: #e3262f;
  --red-dark: #8e1219;
  --blue: #2456e8;
  --blue-light: #6ea0ff;
  --web: #9fb0e0;
  --yellow: #ffd23f;
  --text: #f2f4ff;
  --muted: #9aa6d6;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --term: "VT323", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--term);
  font-size: 22px;
  line-height: 1.2;
  /* faint spider-web lattice behind everything */
  background:
    radial-gradient(circle at 0 0, transparent 0 60px, rgba(159, 176, 224, 0.07) 61px 62px, transparent 63px 120px, rgba(159, 176, 224, 0.06) 121px 122px, transparent 123px 190px, rgba(159, 176, 224, 0.05) 191px 192px, transparent 193px),
    radial-gradient(circle at 100% 100%, transparent 0 80px, rgba(227, 38, 47, 0.08) 81px 82px, transparent 83px 160px, rgba(227, 38, 47, 0.06) 161px 162px, transparent 163px),
    linear-gradient(180deg, #0a0f2e 0%, #0b1236 60%, #140a24 100%);
  background-attachment: fixed;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---------- Marquee ---------- */
.marquee {
  position: relative;
  border: 4px solid var(--red);
  box-shadow: 0 0 0 4px var(--blue), 0 0 40px rgba(227, 38, 47, 0.35), 8px 8px 0 4px #000;
  background: #050818;
  overflow: hidden;
}
.marquee canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 120;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.marquee::after { /* CRT scanlines */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.2) 2px 3px);
}
.marquee-text {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 16px 12px;
  background: linear-gradient(180deg, transparent, rgba(5, 8, 24, 0.9) 45%);
  z-index: 1;
}
.eyebrow {
  margin: 0 0 6px;
  font-family: var(--pixel);
  font-size: clamp(7px, 1.2vw, 10px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow);
  animation: blink 1.2s steps(2) infinite;
}
h1 {
  margin: 0;
  font-family: var(--pixel);
  font-size: clamp(18px, 4.6vw, 44px);
  line-height: 1.15;
  text-wrap: balance;
  font-weight: normal;
}
.h-red { color: var(--red); text-shadow: 3px 3px 0 #000, 0 0 12px rgba(227, 38, 47, 0.6); }
.h-blue { color: var(--blue-light); text-shadow: 3px 3px 0 #000, 0 0 12px rgba(36, 86, 232, 0.7); }
.byline {
  margin: 8px 0 0;
  font-size: clamp(18px, 2.4vw, 24px);
  color: var(--text);
}
.byline strong { color: var(--yellow); font-weight: normal; }
.tag { color: var(--blue-light); }

/* ---------- Section heads ---------- */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
h2 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: normal;
  font-size: clamp(11px, 1.8vw, 15px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  text-shadow: 2px 2px 0 #000;
}
.hint { margin: 0; color: var(--muted); font-size: 20px; }
kbd {
  font-family: var(--pixel); font-size: 9px; color: var(--yellow);
  border: 1px solid var(--muted); padding: 3px 5px; margin-right: 4px; background: var(--panel-2);
}

/* ---------- Grade picker ---------- */
.grade-panel { margin-bottom: 28px; }
.hint strong { color: var(--yellow); font-weight: normal; }
.grades {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 6px;
}
@media (max-width: 720px) { .grades { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.grade-btn {
  font-family: var(--pixel); font-size: clamp(10px, 1.6vw, 14px);
  min-height: 44px; padding: 6px 0;
  color: var(--text); background: var(--panel);
  border: 2px solid var(--blue); box-shadow: 3px 3px 0 #000;
  cursor: pointer;
}
.grade-btn:hover, .grade-btn:focus-visible { outline: none; border-color: var(--yellow); }
.grade-btn.on { background: var(--red); border-color: var(--yellow); color: #fff; box-shadow: 3px 3px 0 #000, 0 0 14px rgba(227, 38, 47, 0.5); }
.grade-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }

/* ---------- Cabinets ---------- */
.cabinets {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 22px;
}
.cabinet {
  display: flex; flex-direction: column;
  height: 100%;
  color: inherit; text-decoration: none;
  background: var(--panel);
  border: 3px solid var(--blue);
  box-shadow: 6px 6px 0 #000;
  transition: transform 0.12s ease;
}
.cabinet .cab-top {
  font-family: var(--pixel); font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; text-align: center;
  padding: 8px; background: var(--red); color: #fff; border-bottom: 3px solid var(--red-dark);
}
.cabinet .screen {
  position: relative;
  margin: 12px 12px 0;
  border: 3px solid #000;
  outline: 2px solid var(--web);
  aspect-ratio: 16 / 10;
  background: #000;
  overflow: hidden;
}
.cabinet .screen img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: pixelated; }
.cabinet .screen::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.18) 2px 3px);
}
.cabinet .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.cabinet h3 { margin: 0; font-family: var(--pixel); font-weight: normal; font-size: 13px; line-height: 1.4; color: var(--yellow); }
.cabinet p { margin: 0; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.chip { font-family: var(--pixel); font-size: 8px; padding: 4px 6px; border: 1px solid var(--blue-light); color: var(--blue-light); }
.chip.grade { border-color: var(--red); color: #ff8a90; }
.chip.grade.off { border-color: var(--muted); color: var(--muted); }
.start {
  font-family: var(--pixel); font-size: 10px; text-align: center;
  padding: 10px; background: var(--blue); color: #fff; border-top: 3px solid #13307f;
}
.cabinet:hover, .cabinet:focus-visible, .cabinet.selected {
  outline: none;
  border-color: var(--yellow);
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 #000, 0 0 24px rgba(255, 210, 63, 0.35);
}
.cabinet.selected .start, .cabinet:focus-visible .start { background: var(--red); animation: blink 0.9s steps(2) infinite; }

.cabinet.soon { border-style: dashed; border-color: var(--muted); box-shadow: none; }
.cabinet.soon .cab-top { background: var(--panel-2); color: var(--muted); border-bottom-color: var(--panel-2); }
.cabinet.soon .screen { display: grid; place-items: center; background: repeating-linear-gradient(45deg, #070b24 0 10px, #0b1236 10px 20px); }
.cabinet.soon .screen span { font-family: var(--pixel); font-size: 10px; color: var(--muted); animation: blink 1.4s steps(2) infinite; }

/* ---------- Credits ---------- */
.scores { margin-top: 36px; }
.scores table { width: 100%; border-collapse: collapse; font-size: 22px; font-variant-numeric: tabular-nums; }
.scores .table-wrap { overflow-x: auto; }
.scores th {
  font-family: var(--pixel); font-weight: normal; font-size: 9px; letter-spacing: 0.08em;
  color: var(--muted); text-align: left; padding: 6px 10px 8px 0;
}
.scores td { padding: 6px 10px 6px 0; border-top: 1px solid #1d2766; }
.scores td:first-child { color: var(--red); font-family: var(--pixel); font-size: 11px; }
.scores td.creator { color: var(--yellow); }

footer { color: var(--muted); font-size: 19px; border-top: 2px solid #1d2766; padding-top: 14px; }
footer p { margin: 0 0 4px; }
footer .fine { font-size: 17px; opacity: 0.8; }

@keyframes blink { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .eyebrow, .cabinet.selected .start, .cabinet:focus-visible .start, .cabinet.soon .screen span { animation: none; }
  .cabinet { transition: none; }
}
@media (max-width: 560px) {
  .marquee-text { position: static; background: #050818; }
}

/* Adaptive math switch under the grade picker */
.adapt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; }
.adapt .hint { margin: 0; }
.adapt-btn, .adapt-reset {
  font: inherit; font-size: 0.95em; cursor: pointer; color: #fff; background: var(--navy, #0a0f2e);
  border: 2px solid var(--blue, #2456e8); padding: 6px 12px; box-shadow: 3px 3px 0 #000;
}
.adapt-btn.on { border-color: var(--yellow, #ffd23f); }
.adapt-btn strong { color: var(--yellow, #ffd23f); }
.adapt-btn:not(.on) strong { color: #9aa3c7; }
.adapt-btn:hover, .adapt-btn:focus-visible, .adapt-reset:hover, .adapt-reset:focus-visible { outline: none; border-color: var(--yellow, #ffd23f); }
.adapt-reset { border-color: #3a4170; color: #c9cff0; font-size: 0.85em; }

/* ---------- Credits link on the marquee ---------- */
.credits-badge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  font-family: var(--pixel); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--yellow); text-decoration: none;
  background: rgba(5, 8, 24, 0.85); border: 2px solid var(--blue-light); padding: 6px 8px; box-shadow: 3px 3px 0 #000;
}
.credits-badge:hover, .credits-badge:focus-visible { outline: none; border-color: var(--yellow); }
.credits-link { color: var(--yellow); }

/* ---------- Subject tabs + "fits my grade" ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 12px;
  font-family: var(--pixel); font-size: clamp(9px, 1.2vw, 11px); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text); background: var(--panel);
  border: 2px solid var(--blue); box-shadow: 3px 3px 0 #000; cursor: pointer;
}
.tab-count { font-size: 8px; color: var(--blue-light); border: 1px solid currentColor; padding: 3px 4px; }
.tab:hover, .tab:focus-visible { outline: none; border-color: var(--yellow); }
.tab.on { background: var(--red); border-color: var(--yellow); color: #fff; box-shadow: 3px 3px 0 #000, 0 0 14px rgba(227, 38, 47, 0.5); }
.tab.on .tab-count { color: var(--yellow); }
.tab:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 18px; }
.fit-btn {
  font: inherit; font-size: 0.95em; cursor: pointer; color: #fff; background: var(--night);
  border: 2px solid var(--blue); padding: 6px 12px; box-shadow: 3px 3px 0 #000; min-height: 40px;
}
.fit-btn.on { border-color: var(--yellow); }
.fit-btn strong { color: var(--yellow); font-weight: normal; }
.fit-btn:not(.on) strong { color: #9aa3c7; }
.fit-btn:hover, .fit-btn:focus-visible { outline: none; border-color: var(--yellow); }

/* ---------- Shelves (Favorites / Recently played / New / All) ---------- */
#shelves { display: flex; flex-direction: column; gap: 26px; }
.shelf-title {
  margin: 0 0 12px; font-family: var(--pixel); font-weight: normal; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue-light); text-shadow: 2px 2px 0 #000;
}
.shelf-favorites .shelf-title { color: var(--yellow); }
.shelf-new .shelf-title { color: #ff8a90; }
.shelf-count { color: var(--muted); font-size: 9px; }
.empty { margin: 0; padding: 16px; border: 2px dashed var(--muted); color: var(--muted); }
.empty strong { color: var(--yellow); font-weight: normal; }

.cabinets > li { position: relative; min-width: 0; }
.cabinets.mini { grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 18px; }
.cabinets.mini .cabinet h3 { font-size: 11px; }
.cabinets.mini .start { padding: 7px; font-size: 9px; }

/* Favorite star sits on the cabinet's top strip */
.fav {
  position: absolute; top: 0; right: 0; z-index: 1;
  width: 34px; height: 34px; padding: 0;
  font-size: 20px; line-height: 1; cursor: pointer;
  color: #fff; background: transparent; border: 0;
}
.fav.on { color: var(--yellow); text-shadow: 0 0 8px rgba(255, 210, 63, 0.7), 2px 2px 0 #000; }
.fav:hover, .fav:focus-visible { outline: 2px solid var(--yellow); outline-offset: -2px; color: var(--yellow); }
.cabinet .cab-top { padding-inline: 36px; }

.chip.new { border-color: var(--yellow); color: var(--yellow); }
.chip.dev { border-color: var(--muted); color: var(--muted); border-style: dashed; }

/* Games for other grades (shown when "Fits my grade" is off) */
.cabinet.off-grade { border-color: #3a4170; }
.cabinet.off-grade .screen img { filter: grayscale(1) brightness(0.6); }
.cabinet.off-grade h3, .cabinet.off-grade p { opacity: 0.6; }
.cabinet.off-grade .cab-top, .cabinet.off-grade .start { background: #2a3160; border-color: #1d2766; color: var(--muted); }

/* ---------- Phones: compact list (thumbnail + title + chips) ---------- */
@media (max-width: 599.98px) {
  .cabinets, .cabinets.mini { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cabinet { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; box-shadow: 4px 4px 0 #000; }
  .cabinet .cab-top, .cabinet .start, .cabinet .tagline { display: none; }
  .cabinet .screen { margin: 8px; outline-width: 1px; border-width: 2px; }
  .cabinet .body { padding: 8px 40px 8px 2px; gap: 6px; }
  .cabinet h3, .cabinets.mini .cabinet h3 { font-size: 10px; }
  .chips { padding-top: 0; gap: 4px; }
  .chip { font-size: 7px; padding: 3px 4px; }
  .cabinet:hover, .cabinet:focus-visible, .cabinet.selected { transform: none; box-shadow: 4px 4px 0 #000, 0 0 16px rgba(255, 210, 63, 0.35); }
  .fav { top: 50%; transform: translateY(-50%); width: 40px; height: 44px; right: 2px; }
  .tab { padding: 6px 9px; }
  .credits-badge { top: 6px; right: 6px; font-size: 8px; padding: 4px 6px; }
}

/* ---------- Credits page ---------- */
.back-bar { display: flex; }
.back-link {
  font-family: var(--pixel); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--yellow); text-decoration: none; padding: 10px 12px;
  background: var(--panel); border: 2px solid var(--blue); box-shadow: 3px 3px 0 #000;
}
.back-link:hover, .back-link:focus-visible { outline: none; border-color: var(--yellow); }
.marquee-plain { background: radial-gradient(ellipse at 80% 0, #2a0c2c, #050818 70%); }
.marquee-plain .marquee-text { position: static; background: none; padding: 22px 18px 20px; }
.credits-page .scores { margin-top: 0; }
.credit-notes dl { margin: 12px 0 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; }
.credit-notes dt { font-family: var(--pixel); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--blue-light); padding-top: 6px; }
.credit-notes dd { margin: 0; }
.credit-notes strong { color: var(--yellow); font-weight: normal; }
@media (max-width: 560px) { .credit-notes dl { grid-template-columns: minmax(0, 1fr); gap: 4px; } .credit-notes dd { margin-bottom: 10px; } }
@media (max-width: 599.98px) { #keys-hint { display: none; } }
.credits-page main { display: flex; flex-direction: column; gap: 32px; }

/* DEV ribbon (dev/test site only, see ribbon.js) */
.dev-ribbon {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; text-align: center;
  font: 12px/1.6 "Press Start 2P", monospace; padding: 4px 8px; text-decoration: none;
  background: #ffd23f; color: #0a0f2e; border-top: 3px solid #e3262f; box-shadow: 0 -2px 0 #000;
}
