/* ============================================================
   PICO-67 — neobrutalism × PICO-8 palette
   ============================================================ */

:root {
  /* PICO-8 palette */
  --c0: #000000;  /* black      */
  --c1: #1d2b53;  /* dark blue  */
  --c2: #7e2553;  /* dark purple*/
  --c3: #008751;  /* dark green */
  --c4: #ab5236;  /* brown      */
  --c5: #5f574f;  /* dark grey  */
  --c6: #c2c3c7;  /* light grey */
  --c7: #fff1e8;  /* white      */
  --c8: #ff004d;  /* red        */
  --c9: #ffa300;  /* orange     */
  --c10:#ffec27;  /* yellow     */
  --c11:#29adff;  /* blue       */
  --c12:#83769c;  /* purple     */
  --c13:#ff77a8;  /* pink       */
  --c14:#ffccaa;  /* peach      */

  --bg: var(--c7);
  --ink: var(--c0);
  --accent: var(--c11);

  --bw: 4px;                       /* border weight */
  --border: var(--bw) solid var(--ink);
  --shadow: 8px 8px 0 var(--ink);
  --shadow-sm: 5px 5px 0 var(--ink);
  --header-h: 86px;
}

/* falling pixel-art leaves, painted behind everything else */
#leaves {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--bg);
  /* halftone dot grid + a warm autumn wash */
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.16) 1.4px, transparent 1.5px),
    linear-gradient(180deg, rgba(255, 163, 0, 0.16), rgba(255, 241, 232, 0) 38%, rgba(171, 82, 54, 0.12));
  background-size: 24px 24px, 100% 100%;
  background-attachment: scroll, fixed;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 16px;
  line-height: 1.55;
  padding-top: var(--header-h);
  overflow-wrap: break-word;
}

a { color: inherit; }
img { max-width: 100%; display: block; }

/* ---------- header ---------- */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  background: var(--c10);
  border-bottom: 5px solid var(--ink);
}

/* autumn bunting under the header */
.site-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -17px;
  height: 12px;
  border-bottom: 3px solid var(--ink);
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    var(--c8) 0 16px,
    var(--c9) 16px 32px,
    var(--c10) 32px 48px,
    var(--c3) 48px 64px,
    var(--c4) 64px 80px,
    var(--c13) 80px 96px
  );
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  background: var(--c8);
  border: var(--border);
  box-shadow: 4px 4px 0 var(--ink);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}
.logo-mark i { background: transparent; }
.logo-mark i.on { background: var(--c10); }

.logo-text {
  font-size: clamp(19px, 3.2vw, 30px);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.logo-text .logo-num {
  background: var(--ink);
  color: var(--c10);
  padding: 3px 8px;
  margin-left: 4px;
}

.header-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- search (top right) ---------- */

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  background: var(--c7);
  border: var(--border);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.search:focus-within {
  background: var(--c11);
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}
.search-mark {
  position: relative;
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border: 3px solid var(--ink);
  border-radius: 50%;
}
.search-mark::after {
  content: "";
  position: absolute;
  right: -7px;
  bottom: -4px;
  width: 9px;
  height: 3px;
  background: var(--ink);
  transform: rotate(45deg);
}
.search input {
  width: min(30vw, 210px);
  min-width: 90px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
}
.search input::placeholder { color: var(--c5); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-key {
  border: 2px solid var(--ink);
  background: var(--c6);
  padding: 1px 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
}
.search.is-live .search-key { background: var(--c10); }

/* ---------- generic bits ---------- */

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 20px 60px; }

.panel {
  background: #fff;
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  background: var(--c7);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
a.chip { transition: transform .12s ease, box-shadow .12s ease; }
a.chip:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
a.chip:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }

.chip-dark { background: var(--ink); color: var(--c10); }
.chip-blue { background: var(--c11); }
.chip-pink { background: var(--c13); }
.chip-green { background: var(--c3); color: var(--c7); }
.chip-red { background: var(--c8); color: var(--c7); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border: var(--border);
  background: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translate(-3px, -3px); box-shadow: 8px 8px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.btn-ghost { background: var(--c7); }

h1, h2, h3 { text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 12px; }

/* ---------- home: hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 22px;
  align-items: stretch;
  margin-bottom: 34px;
}

.hero-main {
  background: var(--c11);
  border: 5px solid var(--ink);
  box-shadow: 12px 12px 0 var(--ink);
  padding: 30px 30px 26px;
}
.hero-main h1 {
  font-size: clamp(30px, 5.4vw, 58px);
  font-weight: 900;
  line-height: 1.02;
  margin-bottom: 14px;
}
.hero-main h1 mark {
  background: var(--c10);
  border: 3px solid var(--ink);
  padding: 0 8px;
  color: var(--ink);
}
.hero-main p { margin: 0 0 18px; max-width: 46ch; font-weight: 600; }

.hero-side {
  background: var(--c7);
  border: 5px solid var(--ink);
  box-shadow: 12px 12px 0 var(--c8);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-num { font-size: 40px; font-weight: 900; line-height: 1; }
.stat-lbl { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--c5); }
.pal-strip { display: flex; border: 3px solid var(--ink); height: 26px; margin-top: auto; }
.pal-strip i { flex: 1; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 20px;
}
.section-head h2 { font-size: 26px; margin: 0; }
.section-head .rule { flex: 1; height: 5px; background: var(--ink); }

/* ---------- home: game grid ---------- */

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 26px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 5px solid var(--ink);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform .14s ease, box-shadow .14s ease;
}
.card:nth-child(odd) { transform: rotate(-0.7deg); }
.card:nth-child(even) { transform: rotate(0.7deg); }
.card:hover { transform: translate(-5px, -5px) rotate(0deg); box-shadow: 14px 14px 0 var(--ink); }
.card:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }

/* ---- Developer's Choice: spinning PICO-8 palette ring ---- */
/* registered so the conic-gradient angle can actually be animated */
@property --pico-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

@keyframes pico-spin {
  from { --pico-angle: 0deg; }
  to   { --pico-angle: 360deg; }
}

.card.is-choice {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  outline: 5px solid var(--ink); /* black line between card and the spinning ring */
}
.card.is-choice .card-body { background: #fff; }
.card.is-choice::before {
  content: "";
  position: absolute;
  inset: -14px;
  z-index: -1;
  border: 5px solid var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
  background: repeating-conic-gradient(
    from var(--pico-angle),
    var(--c8)  0deg  10deg,
    var(--c9)  10deg 20deg,
    var(--c10) 20deg 30deg,
    var(--c3)  30deg 40deg,
    var(--c11) 40deg 50deg,
    var(--c13) 50deg 60deg
  );
  animation: pico-spin 6s linear infinite;
}
.card.is-choice:hover { box-shadow: none; }
.card.is-choice:hover::before {
  box-shadow: 14px 14px 0 var(--ink);
  animation-duration: 2.4s;   /* spins up on hover */
}

.card-thumb {
  position: relative;
  height: 150px;
  border-bottom: 5px solid var(--ink);
  background: var(--accent);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.card-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    45deg, rgba(0,0,0,.16) 0 4px, transparent 4px 12px);
}
.card-thumb.has-thumb { height: 200px; }
.card-thumb.has-thumb::after { display: none; }

/* ---- hover-to-play thumbnails (shelf cards + game pages) ----
   a canvas holds frame one; the animated <img> is revealed on hover */
.thumb-frame {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  background: var(--c1);
}
.thumb-frame img,
.thumb-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}
.thumb-frame.is-paused img { visibility: hidden; }
.thumb-frame:not(.is-paused) .thumb-still { display: none; }
.thumb-frame.no-freeze img { visibility: visible; }
.thumb-frame.no-freeze .thumb-still,
.thumb-frame.no-freeze .thumb-cue { display: none; }

.thumb-cue {
  position: absolute;
  left: 8px; bottom: 8px;
  z-index: 3;
  padding: 4px 8px;
  background: var(--ink);
  color: var(--c10);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity .12s ease;
}
.thumb-frame:not(.is-paused) .thumb-cue { opacity: 0; }

.card-num-badge {
  position: absolute;
  left: 8px; top: 8px;
  z-index: 3;
  padding: 2px 7px;
  background: var(--c10);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.card-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.card-num {
  font-size: 62px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  text-shadow: 4px 4px 0 var(--c7);
  z-index: 1;
}
.card-badges {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.card-badge {
  background: var(--ink);
  color: var(--c10);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 5px 9px;
  white-space: nowrap;
}
.card-badge.badge-red {
  background: var(--c8);
  color: var(--c7);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 3px 7px;
}
.card-badge.badge-yellow {
  background: var(--c10);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 3px 7px;
}

.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-title { font-size: 21px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.02em; }
.card-desc { margin: 0; font-size: 14px; color: #111; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.card-date { font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c5); }
.card-play {
  font-size: 12px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase;
  border: 3px solid var(--ink); background: var(--c10); color: var(--ink); padding: 6px 11px;
}

.card.is-hidden { display: none; }

.no-results {
  margin-top: 30px;
  background: var(--c10);
  text-align: center;
}
.no-results p { font-weight: 700; }

/* ---------- game page ---------- */

.crumbs { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }

.game-title {
  font-size: clamp(30px, 6vw, 62px);
  font-weight: 900;
  line-height: 1;
  margin: 0 0 6px;
  text-shadow: 5px 5px 0 var(--accent);
}
.game-sub { font-size: 13px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c5); margin-bottom: 26px; }

/* the console: game centred in the middle of the screen.
 *
 * The PICO-8 html shell sizes its canvas as a square off the *shortest* side of the
 * iframe, then paints its own button column (gamepad / pause / mute / fullscreen,
 * ~54px wide) right next to that canvas. A square iframe therefore clips those
 * buttons off the right edge. So: keep the square canvas side (--p8-canvas-h) driving
 * the iframe height, and make the iframe --p8-btn-space wider than it is tall.
 * The shell centres the canvas, so the gutter shows up on both sides.
 */
.console {
  position: relative;
  border: 6px solid var(--ink);
  background: var(--c1);
  box-shadow: 14px 14px 0 var(--ink);
  margin: 0 auto 30px;
  --p8-btn-space: 120px;                        /* button column (54px) + slack, per side */
  --p8-gutter: calc(var(--p8-btn-space) + 12px); /* + the 6px border on each side */
  --p8-canvas-h: min(808px, max(300px, calc(100vh - 312px)), calc(96vw - var(--p8-gutter)));
  width: calc(var(--p8-canvas-h) + var(--p8-gutter));
  max-width: 100%;
}

/* Developer's Choice carts get the counter-spinning ring */
.console.is-choice {
  box-shadow: none;
}
.console.is-choice::before {
  content: "";
  position: absolute;
  inset: -18px;
  z-index: -1;
  border: 5px solid var(--ink);
  box-shadow: 14px 14px 0 var(--ink);
  background: repeating-conic-gradient(
    from var(--pico-angle),
    var(--c10) 0deg  9deg,
    var(--c11) 9deg  18deg,
    var(--c8)  18deg 27deg,
    var(--c3)  27deg 36deg,
    var(--c13) 36deg 45deg,
    var(--c9)  45deg 54deg
  );
  animation: pico-spin 9s linear infinite reverse;
}
.console-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--c10);
  border-bottom: 5px solid var(--ink);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.dots { display: flex; gap: 5px; }
.dots i { width: 11px; height: 11px; border: 2px solid var(--ink); display: block; }
.dots i:nth-child(1) { background: var(--c8); }
.dots i:nth-child(2) { background: var(--c10); }
.dots i:nth-child(3) { background: var(--c3); }
.console-file { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-hint { background: var(--ink); color: var(--c10); padding: 4px 8px; }

.screen {
  width: 100%;
  /* wider than tall: the square canvas fills the height, the extra width is the
     gutter the pico-8 shell needs for its mute / fullscreen / pause buttons */
  height: var(--p8-canvas-h);
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(180deg, #16203f 0 3px, #1d2b53 3px 6px);
  border-top: 0;
}
.screen iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  display: block;
}

.game-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-bottom: 34px; }

.info-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; margin-bottom: 34px; }
.info-grid.has-shot { grid-template-columns: 1fr 1.4fr 0.95fr; align-items: start; }

.panel-shot { display: flex; flex-direction: column; }
.thumb-frame-lg {
  position: relative;
  inset: auto;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 4px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
}
.shot-note {
  margin: 16px 0 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c5);
}
.panel h2 { font-size: 16px; letter-spacing: 0.1em; border-bottom: 4px solid var(--ink); padding-bottom: 8px; }
.panel p:last-child { margin-bottom: 0; }

.keylist { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.keylist li { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; }
kbd {
  border: 3px solid var(--ink);
  background: var(--c6);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 3px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* mouse-only warning strip */
.alert {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 820px;
  margin: 0 auto 26px;
  padding: 14px 18px;
  background: var(--c8);
  color: var(--c7);
  border: var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.alert strong {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.alert-icon { flex: 0 0 auto; }

.chip-warn {
  background: var(--c8);
  color: var(--c7);
  border-color: var(--ink);
}
.chip-choice {
  background: var(--c10);
  color: var(--ink);
  border-color: var(--ink);
}

.pager { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pager a {
  flex: 1 1 240px;
  border: var(--border);
  background: var(--c7);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.pager a:hover { transform: translate(-3px,-3px); box-shadow: 8px 8px 0 var(--ink); }
.pager .pager-lbl { font-size: 10px; font-weight: 900; letter-spacing: 0.14em; color: var(--c5); display: block; }
.pager .pager-name { font-size: 16px; font-weight: 900; text-transform: uppercase; }
.pager .next { text-align: right; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 5px solid var(--ink);
  background: var(--ink);
  color: var(--c7);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.site-footer a { color: var(--c10); }

/* ---------- error page ---------- */

.oops { max-width: 640px; margin: 40px auto; text-align: center; }
.oops .big { font-size: 90px; font-weight: 900; line-height: 1; text-shadow: 8px 8px 0 var(--c8); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
}

/* touch: the shell hides its own button column, so hand the whole box to the canvas */
@media (pointer: coarse) {
  .console { --p8-btn-space: 0px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .btn, .chip, .search { transition: none; }
  .card.is-choice::before, .console.is-choice::before { animation: none; }
}

@media (max-height: 880px) {
  .crumbs { margin-bottom: 12px; }
  .game-title { font-size: clamp(24px, 4vw, 38px); text-shadow: 4px 4px 0 var(--accent); }
  .game-sub { margin-bottom: 14px; }
  .console { box-shadow: 10px 10px 0 var(--ink); margin-bottom: 22px; }
}

@media (max-width: 620px) {
  :root { --header-h: 76px; }
  .console { --p8-canvas-h: min(808px, max(300px, calc(100vh - 312px)), calc(94vw - var(--p8-gutter))); }
  .console.is-choice::before { inset: -12px; }
  .logo-mark { width: 30px; height: 30px; }
  .wrap { padding: 18px 14px 40px; }
  .header-nav .chip { display: none; }
  .search { padding: 5px 9px; }
  .search input { width: 34vw; }
  .search-key { display: none; }
}
