/* ==========================================================================
   Security Hub — arcade cabinet
   Palette and effects derived from vladsecurity.com; see the design spec in
   docs/superpowers/specs/ for what was kept, what changed and why.
   ========================================================================== */

/* Self-hosted so no visitor request reaches a third party. OFL, see fonts/OFL.txt.
   ponytail: latin subset only (Google's split); other scripts fall back to the
   monospace stack. Add the latin-ext/cyrillic files if copy ever needs them. */
@font-face {
  font-family: "Press Start 2P";
  font-display: swap;
  src: url("fonts/PressStart2P-latin.woff2") format("woff2");
}

@font-face {
  font-family: "VT323";
  font-display: swap;
  src: url("fonts/VT323-latin.woff2") format("woff2");
}

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Lifted verbatim from the live site's compiled stylesheet. */
  --bg: hsl(220 20% 6%);
  --card: hsl(220 25% 10%);
  --primary: hsl(180 100% 50%);
  --border: hsl(180 100% 25%);
  --magenta: hsl(300 100% 50%);
  --green: hsl(120 100% 50%);
  --yellow: hsl(60 100% 50%);
  --red: hsl(0 100% 50%);
  --radius: 0.25rem;

  /* Raised from the source's 180 50% 40%, which fails AA on this background. */
  --muted: hsl(180 45% 62%);

  --chassis: #05070a;
  --chassis-hi: #1a1f2b;

  --font-display: "Press Start 2P", "Courier New", ui-monospace, monospace;
  --font-body: "VT323", "Courier New", ui-monospace, monospace;

  --tile-size: 184px;
  --sweep-duration: 8s;

  /* The source's .pixel-corners silhouette: a 4px notch off each corner. */
  /* Chips: the same silhouette at half the notch, so small labels keep their corners. */
  --chip-notch: polygon(
    0 2px, 2px 2px, 2px 0,
    calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px,
    100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%,
    2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px)
  );
  --pixel-notch: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Page shell
   -------------------------------------------------------------------------- */

html {
  scrollbar-color: hsl(180 100% 50% / 0.45) var(--chassis);
}

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

body {
  margin: 0;
  padding: clamp(0.5rem, 2vw, 2.5rem);
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, #0d1420 0%, var(--chassis) 60%),
    var(--chassis);
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Skip link — the tile grid is long and keyboard-driven. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: var(--bg);
  font-size: 0.7rem;
  text-decoration: none;
}

.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* --------------------------------------------------------------------------
   Cabinet
   -------------------------------------------------------------------------- */

.cabinet {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(8px, 1.4vw, 20px);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--chassis-hi) 0%, #0a0d14 35%, #05070a 100%);
  box-shadow:
    0 0 0 1px hsl(180 100% 50% / 0.14),
    0 0 60px hsl(180 100% 50% / 0.08),
    0 30px 80px rgb(0 0 0 / 0.75),
    inset 0 1px 0 hsl(180 100% 80% / 0.12);
}

/* The screen. Everything decorative stacks inside here. */
.screen {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 16px;
  background: var(--bg);
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 0 40px rgb(0 0 0 / 0.9);
}

/* Scanlines — 1px dark over 1px clear, the same ratio as the source. */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgb(0 0 0 / 0.16) 0 1px,
    transparent 1px 2px
  );
}

/* Vignette plus a faint bulge highlight, standing in for CRT curvature. */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgb(0 0 0 / 0.55) 100%),
    radial-gradient(60% 40% at 50% 0%, hsl(180 100% 70% / 0.05), transparent 70%);
}

/* One brighter line travelling down the tube. */
.sweep {
  position: absolute;
  left: 0;
  right: 0;
  top: -20%;
  height: 200px;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent,
    hsl(180 100% 70% / 0.05) 45%,
    hsl(180 100% 85% / 0.09) 50%,
    hsl(180 100% 70% / 0.05) 55%,
    transparent
  );
  animation: sweep var(--sweep-duration) linear infinite;
}

/* Perspective grid receding to the bottom edge. Fixed height, not a
   percentage — the screen is as tall as the board, and a proportional floor
   stretches until the perspective reads as nothing. */
.gridfloor {
  position: absolute;
  inset: auto 0 0 0;
  height: 420px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
  /* A steeper angle foreshortens 420px down to a hairline. 55deg over a
     longer perspective distance keeps the floor readable as a floor. */
  transform: perspective(520px) rotateX(55deg);
  transform-origin: bottom center;
  background:
    repeating-linear-gradient(90deg, transparent 0 47px, hsl(180 100% 50% / 0.32) 47px 48px),
    repeating-linear-gradient(0deg, transparent 0 47px, hsl(180 100% 50% / 0.32) 47px 48px);
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 92%);
  mask-image: linear-gradient(to top, #000 0%, transparent 92%);
}

.screen__inner {
  position: relative;
  z-index: 2;
  padding: clamp(1rem, 3vw, 2.25rem) clamp(0.75rem, 3vw, 2.25rem) clamp(1rem, 3vw, 2rem);
}

/* --------------------------------------------------------------------------
   HUD
   -------------------------------------------------------------------------- */

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-bottom: clamp(1.5rem, 5vw, 3rem);
  font-size: clamp(0.5rem, 1.4vw, 0.625rem);
  letter-spacing: 0.08em;
}

.hud__cell {
  color: var(--muted);
}

.hud__cell b {
  color: var(--primary);
  font-weight: inherit;
  font-variant-numeric: tabular-nums;
}

.hud__cell--hi b {
  color: var(--yellow);
}

.hud__initials {
  color: var(--yellow);
}

.hud__sound {
  margin-left: auto;
  padding: 0.4rem 0.6rem;
  border: 2px solid hsl(180 100% 50% / 0.35);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: inherit;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.hud__sound:hover,
.hud__sound:focus-visible {
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 12px hsl(180 100% 50% / 0.4);
}

.hud__sound[aria-pressed="true"] {
  color: var(--green);
  border-color: var(--green);
}

/* --------------------------------------------------------------------------
   Marquee
   -------------------------------------------------------------------------- */

.marquee {
  margin: 0 0 1rem;
  text-align: center;
  font-size: clamp(1.1rem, 4.4vw, 2.4rem);
  line-height: 1.35;
  font-weight: 400;
  color: var(--primary);
  /* Last two layers hint at CRT chromatic fringing. */
  text-shadow:
    0 0 5px currentColor,
    0 0 10px currentColor,
    0 0 24px currentColor,
    2px 0 hsl(300 100% 50% / 0.45),
    -2px 0 hsl(180 100% 60% / 0.45);
  animation: flicker 4.5s infinite steps(1, end);
}

.player {
  margin: -0.25rem 0 0.9rem;
  text-align: center;
  font-size: clamp(0.55rem, 1.6vw, 0.75rem);
  letter-spacing: 0.22em;
  color: var(--muted);
}

.player b {
  font-weight: inherit;
  color: var(--primary);
  text-shadow: 0 0 5px currentColor, 0 0 12px currentColor;
}

.attract {
  margin: 0 0 clamp(2rem, 6vw, 3.5rem);
  text-align: center;
  font-size: clamp(0.55rem, 1.7vw, 0.75rem);
  letter-spacing: 0.1em;
  color: hsl(180 100% 50% / 0.85);
  min-height: 1.4em;
}

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */

.board {
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 5vw, 3rem);
}

.section {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2.5vw, 1.5rem);
}

.secthead {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.secthead__rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, hsl(180 100% 50% / 0.5), transparent);
}

.secthead__title {
  margin: 0;
  font-size: clamp(0.55rem, 1.6vw, 0.75rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--primary);
  text-shadow: 0 0 5px currentColor, 0 0 10px currentColor, 0 0 20px currentColor;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Tiles
   -------------------------------------------------------------------------- */

.slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Wrapper exists so the marching-ants cursor can sit outside the tile's
   clip-path without being cut off. It is a flex container so the tile fills
   the row height — taglines differ in length and would otherwise ragged. */
.slot {
  position: relative;
  display: flex;
  width: var(--tile-size);
}

.tile {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  width: 100%;
  min-height: var(--tile-size);
  padding: 1.25rem 0.9rem;
  background: var(--card);
  border: 2px solid var(--accent);
  color: var(--accent);
  text-align: center;
  text-decoration: none;
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 35%, transparent);
  clip-path: var(--pixel-notch);
  transition: transform 0.25s ease-out, box-shadow 0.25s ease-out, background-color 0.25s;
}

.tile:hover,
.tile:focus-visible,
.slot.is-selected .tile {
  transform: translateY(-4px);
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  box-shadow:
    0 0 20px color-mix(in srgb, var(--accent) 55%, transparent),
    0 0 44px color-mix(in srgb, var(--accent) 28%, transparent),
    inset 0 0 22px color-mix(in srgb, var(--accent) 14%, transparent);
}

/* A finger has no hover, so the tile lights the moment it is pressed. */
.tile:active {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--accent) 16%, var(--card));
  box-shadow:
    0 0 20px color-mix(in srgb, var(--accent) 55%, transparent),
    0 0 44px color-mix(in srgb, var(--accent) 28%, transparent),
    inset 0 0 22px color-mix(in srgb, var(--accent) 18%, transparent);
}

.tile:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.tile__icon {
  display: block;
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 70%, transparent));
  transition: transform 0.25s ease-out;
}

.tile:hover .tile__icon,
.slot.is-selected .tile__icon {
  transform: scale(1.12);
}

.tile__title {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent);
}

.tile__tag {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.15;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Services has no destination yet. */
.tile--soon {
  opacity: 0.62;
  cursor: not-allowed;
}

.tile__badge {
  font-size: 0.45rem;
  letter-spacing: 0.15em;
  color: var(--yellow);
  white-space: nowrap;
}

/* Marching-ants select cursor. */
.slot.is-selected::after,
.slot:has(.tile:focus-visible)::after {
  content: "";
  position: absolute;
  inset: -7px;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, var(--accent) 50%, transparent 0),
    linear-gradient(90deg, var(--accent) 50%, transparent 0),
    linear-gradient(0deg, var(--accent) 50%, transparent 0),
    linear-gradient(0deg, var(--accent) 50%, transparent 0);
  background-size: 10px 2px, 10px 2px, 2px 10px, 2px 10px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  animation: ants 0.5s linear infinite;
}

/* --------------------------------------------------------------------------
   Player Stats, featured tiles and controls hint
   -------------------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: clamp(1.25rem, 3vw, 2.25rem);
  max-width: 1000px;
  margin: 0 auto clamp(2.25rem, 6vw, 3.5rem);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  background: hsl(220 25% 10% / 0.78);
  border: 2px solid hsl(180 100% 50% / 0.32);
  box-shadow: inset 0 0 28px hsl(180 100% 50% / 0.07);
  clip-path: var(--pixel-notch);
}

.stats__title {
  margin: 0 0 1rem;
  font-size: clamp(0.55rem, 1.6vw, 0.75rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--primary);
  text-shadow: 0 0 5px currentColor, 0 0 10px currentColor, 0 0 20px currentColor;
}

.stats__bio {
  margin: 0 0 0.75rem;
  font-family: var(--font-body);
  font-size: 1.4rem;
  line-height: 1.3;
  color: hsl(180 100% 76%);
}

.stats__intro {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--muted);
}

.stats__loadout {
  display: grid;
  align-content: start;
  gap: 0.7rem;
  margin: 0;
}

.stats__row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  align-items: baseline;
  gap: 0.75rem;
}

.stats__row dt {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats__row dd {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
}

.chip {
  padding: 0.2rem 0.5rem 0.15rem;
  border: 2px solid hsl(180 100% 50% / 0.38);
  background: hsl(180 100% 50% / 0.06);
  color: var(--primary);
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1;
  letter-spacing: 0.04em;
  clip-path: var(--chip-notch);
}

/* Wiki and Blog are Vlad's own work: double-width cartridges. */
.slot--featured {
  width: calc(var(--tile-size) * 2 + clamp(1rem, 2.5vw, 1.5rem));
}

.slot--featured .tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: start;
  column-gap: 1.4rem;
  row-gap: 0.55rem;
  padding: 1.5rem 1.75rem;
  text-align: left;
}

.slot--featured .tile__icon {
  grid-row: 1 / span 2;
  align-self: center;
  width: 72px;
  height: 72px;
}

.slot--featured .tile__title {
  align-self: end;
  font-size: 0.95rem;
}

.slot--featured .tile__tag {
  align-self: start;
  font-size: 1.35rem;
}

.controls {
  margin: clamp(2.25rem, 5vw, 3rem) 0 0;
  text-align: center;
  font-size: 0.625rem;
  letter-spacing: 0.15em;
  color: var(--muted);
}

/* Author display would otherwise defeat the hidden attribute. */
.controls[hidden] {
  display: none;
}

/* Keyboard instructions mean nothing to a thumb. */
@media (pointer: coarse) {
  .controls {
    display: none;
  }
}

@media (max-width: 640px) {
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats__row {
    grid-template-columns: 7rem minmax(0, 1fr);
  }

  .slot--featured {
    width: 100%;
  }

  .slot--featured .tile {
    min-height: 0;
    padding: 1.1rem 1.2rem;
  }

  .slot--featured .tile__icon {
    width: 52px;
    height: 52px;
  }
}

/* --------------------------------------------------------------------------
   Coin slot and footer
   -------------------------------------------------------------------------- */

.coin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.coin[hidden] {
  display: none;
}

.coin__slot {
  position: relative;
  width: 132px;
  padding: 0.7rem;
  border: 2px solid hsl(180 100% 50% / 0.4);
  border-radius: var(--radius);
  background: #04060a;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.coin__slot:hover,
.coin__slot:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 16px hsl(180 100% 50% / 0.45);
}

.coin__mouth {
  display: block;
  height: 10px;
  border-radius: 2px;
  background: #000;
  box-shadow: inset 0 0 6px hsl(180 100% 50% / 0.6);
}

.coin__label {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--yellow);
  text-shadow: 0 0 8px currentColor;
  animation: blink 1.1s steps(1, end) infinite;
}

.status {
  margin: clamp(1.5rem, 4vw, 2.25rem) 0 0;
  text-align: center;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: hsl(180 100% 50% / 0.7);
  animation: flicker 4.5s infinite steps(1, end);
}

/* --------------------------------------------------------------------------
   Snake — the overlay built by snake.js, loaded only when someone finds it.
   -------------------------------------------------------------------------- */

body.is-playing {
  overflow: hidden;
}

.snake {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  /* Safety net for very short viewports: scroll instead of clipping QUIT. */
  align-items: safe center;
  overflow-y: auto;
  justify-content: center;
  padding: 1rem;
  background: rgb(2 4 7 / 0.93);
  animation: fade-in 0.25s ease-out;
}

.snake:focus {
  outline: none;
}

/* Same scanline treatment as the cabinet, so the game reads as the same tube. */
.snake::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgb(0 0 0 / 0.22) 0 1px,
    transparent 1px 2px
  );
}

.snake__frame {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: clamp(1rem, 3vw, 1.6rem);
  background: var(--card);
  border: 2px solid var(--primary);
  box-shadow: 0 0 24px hsl(180 100% 50% / 0.4), inset 0 0 30px hsl(180 100% 50% / 0.08);
  clip-path: var(--pixel-notch);
}

.snake__hud {
  display: flex;
  gap: clamp(0.9rem, 3vw, 2rem);
  font-size: clamp(0.5rem, 1.6vw, 0.65rem);
  color: var(--muted);
  letter-spacing: 0.08em;
}

.snake__hud b {
  color: var(--primary);
  font-weight: inherit;
  font-variant-numeric: tabular-nums;
}

.snake__stage {
  position: relative;
  width: min(74vmin, 460px);
  aspect-ratio: 1;
}

.snake__canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* An author `display` beats the UA stylesheet's [hidden] { display: none },
   so this panel must opt back out explicitly or it dims the live playfield. */
.snake__msg[hidden] {
  display: none;
}

.snake__msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  text-align: center;
  background: rgb(4 6 10 / 0.82);
  /* Taps fall through to the canvas, which starts, resumes and retries. */
  pointer-events: none;
}

.snake__msg strong {
  font-size: clamp(0.85rem, 3.4vw, 1.3rem);
  font-weight: normal;
  color: var(--primary);
  text-shadow: 0 0 6px currentColor, 0 0 16px currentColor;
}

.snake__msg span {
  font-size: clamp(0.45rem, 1.8vw, 0.6rem);
  color: var(--yellow);
  letter-spacing: 0.12em;
  animation: blink 1.1s steps(1, end) infinite;
}

/* On-screen pad, only where a finger is the pointer. */
.snake__pad {
  display: none;
}

@media (pointer: coarse) {
  .snake__pad {
    display: grid;
    grid-template-areas:
      ". up ."
      "left mid right"
      ". down .";
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
    gap: 6px;
    justify-content: center;
  }
}

.snake__pad-btn {
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid hsl(180 100% 50% / 0.45);
  background: var(--card);
  color: var(--primary);
  font: inherit;
  font-size: 0.6rem;
  cursor: pointer;
  /* A held finger must stay a press, not turn into a pan. */
  touch-action: none;
  user-select: none;
  clip-path: var(--pixel-notch);
  transition: background-color 0.1s, box-shadow 0.1s;
}

.snake__pad-btn:active {
  background: color-mix(in srgb, var(--primary) 22%, var(--card));
  box-shadow: inset 0 0 16px hsl(180 100% 50% / 0.35);
}

.snake__pad-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Pixel arrow drawn with a clip-path, pointing per button. */
.snake__pad-btn:not(.snake__pad-btn--mid)::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  clip-path: polygon(50% 12%, 92% 72%, 8% 72%);
  filter: drop-shadow(0 0 4px currentColor);
}

.snake__pad-btn--up { grid-area: up; }
.snake__pad-btn--left { grid-area: left; }
.snake__pad-btn--mid { grid-area: mid; color: var(--yellow); }
.snake__pad-btn--right { grid-area: right; }
.snake__pad-btn--down { grid-area: down; }

.snake__pad-btn--right::before { transform: rotate(90deg); }
.snake__pad-btn--down::before { transform: rotate(180deg); }
.snake__pad-btn--left::before { transform: rotate(270deg); }

.snake__hint {
  margin: 0;
  font-size: clamp(0.5rem, 1.6vw, 0.6rem);
  letter-spacing: 0.1em;
  color: var(--muted);
  text-align: center;
}

.snake__close {
  padding: 0.45rem 0.8rem;
  border: 2px solid hsl(180 100% 50% / 0.4);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.5rem;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.snake__close:hover,
.snake__close:focus-visible {
  color: var(--primary);
  border-color: var(--primary);
}

/* A landscape phone is too short to stack the pad under the playfield, so the
   pad, hint and QUIT move into a column beside it. */
@media (pointer: coarse) and (orientation: landscape) {
  .snake__frame {
    display: grid;
    grid-template-areas:
      "hud hud"
      "stage pad"
      "stage hint"
      "stage close";
    grid-template-rows: auto 1fr auto auto;
    gap: 0.5rem 1.5rem;
    justify-items: center;
  }

  .snake__hud { grid-area: hud; }
  .snake__stage { grid-area: stage; width: min(calc(100dvh - 8rem), 460px); }
  .snake__pad { grid-area: pad; align-self: center; }
  .snake__hint { grid-area: hint; max-width: 180px; }
  .snake__close { grid-area: close; }
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
  52% { opacity: 1; }
  54% { opacity: 0.9; }
  56% { opacity: 1; }
}

@keyframes sweep {
  from { top: -20%; }
  to { top: 120%; }
}

@keyframes ants {
  to {
    background-position: 10px 0, -10px 100%, 0 -10px, 100% 10px;
  }
}

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

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  :root {
    --tile-size: 150px;
  }

  .cabinet {
    padding: 6px;
    border-radius: 12px;
  }

  .screen {
    border-radius: 9px;
  }

  .secthead__title {
    letter-spacing: 0.16em;
    white-space: normal;
  }

  .hud {
    gap: 0.5rem 1rem;
  }

  .hud__sound {
    margin-left: 0;
  }

  /* Floor the pixel face at 10px on a phone. */
  .hud,
  .attract,
  .player {
    font-size: 0.625rem;
  }

  .secthead__title,
  .stats__title {
    font-size: 0.7rem;
  }
}

/* --------------------------------------------------------------------------
   Glitch — signal interference behind the board (glitch.js)
   -------------------------------------------------------------------------- */

/* Between the grid floor (z 0) and the content (z 2). */
.glitch {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent);
}

/* During a burst the floor loses horizontal hold and its hue slips. */
.is-glitching .gridfloor {
  animation: glitch-floor 0.3s steps(1, end);
}

.is-glitching .sweep {
  opacity: 0.4;
}

@keyframes glitch-floor {
  0% { transform: perspective(520px) rotateX(55deg) translateX(-9px); filter: hue-rotate(80deg); }
  30% { transform: perspective(520px) rotateX(55deg) translateX(12px); filter: none; }
  60% { transform: perspective(520px) rotateX(55deg) translateX(-4px); filter: hue-rotate(-60deg); }
  100% { transform: perspective(520px) rotateX(55deg); filter: none; }
}

/* --------------------------------------------------------------------------
   Reduced motion
   The source ships flicker, pulse-glow and scanlines with no guard; this
   build adds more motion still, so all of it is gated here.
   -------------------------------------------------------------------------- */

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

  .sweep {
    display: none;
  }

  /* Static cursor in place of the marching ants. */
  .slot.is-selected::after,
  .slot:has(.tile:focus-visible)::after {
    background-image: none;
    border: 2px solid var(--accent);
  }

  .tile:hover,
  .tile:focus-visible,
  .tile:active,
  .slot.is-selected .tile {
    transform: none;
  }
}
