/* POSTAL PANIC — Level 62. Conveyor-sort arcade. Dark only. */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;
  --violet: #9b69f2;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --space-gutter: clamp(16px, 4vw, 48px);

  /* zone accents — neon, tuned to the Lab palette */
  --zone-red: #ff5560;
  --zone-blue: #45f0ff;
  --zone-green: #41ff8b;
  --zone-yellow: #ffc857;
  --zone-violet: #9b69f2;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 520px at 50% -12%, rgba(255, 61, 139, 0.06), transparent 70%),
    radial-gradient(900px 480px at 88% 8%, rgba(69, 240, 255, 0.05), transparent 72%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* faint global scanline texture — the depot CRT */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  opacity: 0.5;
}

::selection { background: rgba(69, 240, 255, 0.3); }
[hidden] { display: none !important; }

a { color: var(--cyan); }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
  border-radius: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px; top: -56px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(68px); }

/* ---------- fixed back-to-lab link ---------- */
.lab-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 120;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 8px 10px;
  background: rgba(10, 10, 18, 0.72);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s, border-color 0.15s, text-shadow 0.15s, transform 0.15s var(--ease-out);
}
.lab-link:hover,
.lab-link:focus-visible {
  color: var(--cyan);
  border-color: var(--cyan);
  text-shadow: var(--glow-cyan);
  transform: translateX(-2px);
}

/* ---------- header / chrome ---------- */
.site-header {
  padding: clamp(58px, 9vw, 76px) var(--space-gutter) 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  align-items: center;
}
.level {
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 200, 87, 0.3);
}
.wordmark {
  position: relative;
  margin: 6px 0 2px;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(22px, 6vw, 44px);
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 16px rgba(69, 240, 255, 0.5), 3px 3px 0 var(--magenta);
}
.wordmark::before,
.wordmark::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  pointer-events: none;
  clip-path: inset(0 0 100% 0);
}
.wordmark::before {
  color: var(--cyan);
  transform: translate(-2px, 0);
  text-shadow: none;
  mix-blend-mode: screen;
  animation: glitch-a 4.2s steps(2) infinite;
}
.wordmark::after {
  color: var(--magenta);
  transform: translate(2px, 0);
  text-shadow: none;
  mix-blend-mode: screen;
  animation: glitch-b 3.3s steps(2) infinite;
}
@keyframes glitch-a {
  0%, 92%, 100% { clip-path: inset(0 0 100% 0); transform: translate(-2px, 0); }
  93% { clip-path: inset(18% 0 38% 0); transform: translate(-4px, -1px); }
  96% { clip-path: inset(62% 0 8% 0); transform: translate(3px, 1px); }
}
@keyframes glitch-b {
  0%, 90%, 100% { clip-path: inset(0 0 100% 0); transform: translate(2px, 0); }
  91% { clip-path: inset(56% 0 18% 0); transform: translate(4px, 1px); }
  95% { clip-path: inset(8% 0 72% 0); transform: translate(-3px, -1px); }
}
.tagline {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}
.cursor { color: var(--cyan); margin-left: 2px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- layout ---------- */
.app {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px var(--space-gutter) 64px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.control-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 10px 16px;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s, background 0.12s;
}
.btn:hover:not(:disabled) {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(69, 240, 255, 0.22);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #05050d; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 18px rgba(69, 240, 255, 0.5); }

/* ---------- HUD ---------- */
.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.hud-card {
  min-width: 0;
  min-height: 62px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.hud-card::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--line);
}
.hud-card:nth-child(1)::after { background: var(--cyan); }
.hud-card:nth-child(2)::after { background: var(--red); }
.hud-card:nth-child(3)::after { background: var(--magenta); }
.hud-card:nth-child(4)::after { background: var(--green); }
.hud-card--high::after { background: var(--gold); }
.hud dt {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.hud dd {
  font-family: var(--pixel);
  font-size: 14px;
  line-height: 1.2;
  color: var(--text);
  overflow-wrap: anywhere;
}
.hud-card--high dd { color: var(--gold); }
.hud-card__lives { color: var(--red); letter-spacing: 1px; }

/* ---------- stage ---------- */
.stage-panel {
  position: relative;
  background: linear-gradient(180deg, var(--surface), rgba(18, 18, 29, 0.35));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  overflow: hidden;
}
/* CRT vignette over the stage */
.stage-panel::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 8px;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.42) 100%);
  box-shadow: inset 0 0 80px rgba(69, 240, 255, 0.05);
  z-index: 2;
}
.game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  max-height: 70vh;
  background: var(--bg);
  border-radius: 8px;
  touch-action: manipulation;
  position: relative;
  z-index: 1;
}

/* ---------- overlays ---------- */
.overlay-panel {
  position: absolute;
  inset: 10px;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 22px;
  border-radius: 8px;
  background: rgba(10, 10, 18, 0.86);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.overlay-kicker {
  font-family: var(--pixel);
  font-size: clamp(13px, 3vw, 17px);
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 200, 87, 0.4);
}
.overlay-hint {
  max-width: 480px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.3px;
  line-height: 1.75;
}
.overlay-tap {
  max-width: 480px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  line-height: 1.7;
}

.score-panel { gap: 16px; }
.score-panel h2 {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(15px, 4.5vw, 20px);
  color: var(--red);
  text-shadow: 0 0 14px rgba(255, 85, 96, 0.5);
}
.new-high {
  font-family: var(--pixel);
  font-size: 11px;
  color: var(--green);
  text-shadow: 0 0 12px rgba(65, 255, 139, 0.5);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }
.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(440px, 100%);
}
.score-grid div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 10px;
}
.score-grid dt {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.score-grid dd {
  margin-top: 6px;
  font-family: var(--pixel);
  font-size: 13px;
  color: var(--text);
}

/* ---------- bin controls ---------- */
.bin-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.bin-button {
  --accent: var(--line);
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s var(--ease-out), border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.bin-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 30%, transparent);
  transform: translateY(-2px);
}
.bin-button:active {
  transform: translateY(1px);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
}
.bin-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent);
}

.bin-button__swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent);
}
.bin-button__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--text);
}
.bin-button__keys { display: inline-flex; gap: 4px; }
.bin-button kbd {
  min-width: 22px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--dim);
  background: rgba(0, 0, 0, 0.3);
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.1;
}

.bin-button--red { --accent: var(--zone-red); }
.bin-button--blue { --accent: var(--zone-blue); }
.bin-button--green { --accent: var(--zone-green); }
.bin-button--yellow { --accent: var(--zone-yellow); }
.bin-button--violet { --accent: var(--zone-violet); }

/* ---------- privacy + footer ---------- */
.privacy-note {
  margin: 0 auto;
  max-width: 620px;
  text-align: center;
  color: var(--dim);
  font-size: 12.5px;
}
.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px var(--space-gutter);
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  display: grid;
  gap: 4px;
}
.site-footer a { color: var(--cyan); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

/* ---------- responsive ---------- */
@media (min-width: 680px) {
  .control-panel { flex-direction: row; justify-content: space-between; align-items: center; }
  .hud { grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(680px, 100%); }
  .bin-controls { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .bin-button { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; row-gap: 6px; }
  .bin-button__keys { grid-column: 1 / -1; }
}

@media (pointer: coarse) {
  .btn { min-height: 46px; }
  .game-canvas { max-height: 58vh; }
}

@media (max-width: 480px) {
  .wordmark { letter-spacing: 1px; }
  .game-canvas { aspect-ratio: 4 / 3; max-height: 50vh; }
  .score-grid { grid-template-columns: 1fr; }
  .control-actions { width: 100%; }
  .control-actions .btn { flex: 1; }
}

@media (max-width: 360px) {
  .bin-button { padding: 9px 9px; gap: 8px; }
  .bin-button kbd { min-width: 19px; font-size: 10px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .cursor { animation: none; }
  .wordmark::before, .wordmark::after { animation: none; clip-path: inset(0 0 100% 0); }
  .new-high { animation: none; }
  .bin-button:hover { transform: none; }
}
