@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

* { box-sizing: border-box; }

:root {
  --ui-bg: #10100c;
  --ui-panel: #1b1a12;
  --ui-panel-2: #262416;
  --ui-ink: #fff3b0;
  --ui-muted: #b7a764;
  --ui-dark: #080805;
  --ui-accent: #f2ce4d;
  --ui-accent-2: #c59321;
  --ui-red: #e35b35;
  --pixel-shadow: #070704;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #090907;
  color: var(--ui-ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: "Press Start 2P", system-ui, sans-serif;
}

body { image-rendering: pixelated; }

#game {
  width: 100vw;
  height: 100dvh;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0a0a07;
}

#game canvas { display: block; }

.ui-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.screen,
.screen-panel,
.game-hud,
.death-panel,
.countdown-overlay { pointer-events: auto; }

.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.main-menu {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(7,7,4,.22), rgba(7,7,4,.58) 70%, rgba(7,7,4,.88)),
    radial-gradient(circle at center, rgba(255,233,122,.08), transparent 62%);
}

.menu-shell {
  width: min(560px, calc(100vw - 28px));
  min-height: min(620px, calc(100dvh - 36px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.4vh, 22px);
  text-align: center;
  animation: menuIn .42s steps(6) both;
}

.menu-kicker {
  color: var(--ui-muted);
  font-size: clamp(8px, 1.7vw, 10px);
  line-height: 1.7;
  text-shadow: 3px 3px 0 var(--pixel-shadow);
  letter-spacing: 1px;
}

.game-title {
  margin: 0 0 10px;
  color: var(--ui-accent);
  font-size: clamp(36px, 9vw, 76px);
  line-height: .95;
  letter-spacing: -3px;
  text-shadow:
    4px 0 0 #8c6216,
    0 4px 0 #8c6216,
    4px 4px 0 #5b3d0d,
    8px 8px 0 #090805;
}

.menu-actions {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
}

.pixel-btn {
  --btn-bg: var(--ui-panel-2);
  --btn-top: #3a371f;
  --btn-border: #080805;
  position: relative;
  width: 100%;
  min-height: 58px;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
  color: var(--ui-ink);
  font: inherit;
  text-align: center;
  image-rendering: pixelated;
  transform: translateY(0);
}

.pixel-btn span {
  position: relative;
  z-index: 2;
  min-height: 58px;
  padding: 19px 18px 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bg));
  border: 4px solid var(--btn-border);
  box-shadow:
    inset 0 -6px 0 rgba(0,0,0,.28),
    inset 0 5px 0 rgba(255,255,255,.08),
    0 7px 0 #070704,
    0 13px 0 rgba(0,0,0,.28);
  text-shadow: 3px 3px 0 #050503;
  transition: transform .08s steps(2), filter .08s steps(2);
}

.pixel-btn::before,
.pixel-btn::after {
  content: "";
  position: absolute;
  z-index: 1;
  background: #080805;
  pointer-events: none;
}

.pixel-btn::before { left: 8px; right: 8px; top: -4px; height: 4px; }
.pixel-btn::after { left: 8px; right: 8px; bottom: -4px; height: 4px; }

.pixel-btn:hover span {
  transform: translateY(-3px);
  color: #fff8cc;
  filter: brightness(1.12);
}

.pixel-btn:active span {
  transform: translateY(6px);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,.35),
    inset 0 4px 0 rgba(255,255,255,.06),
    0 2px 0 #070704,
    0 5px 0 rgba(0,0,0,.28);
}

.pixel-btn.primary {
  --btn-bg: var(--ui-accent);
  --btn-top: #ffe784;
  --btn-border: #100d05;
  color: #171204;
}

.pixel-btn.primary span { text-shadow: 2px 2px 0 rgba(255,255,255,.28); }

.pixel-btn.small { min-height: 46px; width: min(220px, 100%); }
.pixel-btn.small span { min-height: 46px; padding: 15px 14px 11px; font-size: 10px; }

.menu-footer {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 8px;
  color: var(--ui-muted);
}

.menu-footer span {
  padding: 8px 10px 6px;
  background: rgba(8,8,5,.72);
  border: 3px solid #242112;
  box-shadow: 3px 3px 0 #050503;
}

.screen-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(7,7,4,.24), rgba(7,7,4,.84)),
    radial-gradient(circle at center, rgba(255,224,94,.08), transparent 66%);
}

.panel-card,
.death-card {
  width: min(460px, calc(100vw - 26px));
  background: var(--ui-panel);
  border: 4px solid #090805;
  padding: 22px;
  box-shadow:
    inset 0 0 0 4px #343019,
    inset 0 -10px 0 rgba(0,0,0,.25),
    8px 8px 0 #080805,
    0 24px 0 rgba(0,0,0,.18);
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
  animation: panelPop .24s steps(4) both;
}

.panel-card h2,
.death-card h2 {
  margin: 0;
  color: var(--ui-accent);
  font-size: clamp(18px, 5vw, 28px);
  line-height: 1.15;
  text-shadow: 4px 4px 0 #090805;
}

.board-list { width: 100%; display: grid; gap: 8px; }

.board-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 10px 9px;
  background: #111007;
  border: 3px solid #302c16;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.25);
  font-size: 9px;
  text-align: left;
}

.board-row span { color: var(--ui-muted); }
.board-row em { color: var(--ui-accent); font-style: normal; }
.board-row.first { border-color: var(--ui-accent-2); }

.credits-copy {
  display: grid;
  gap: 10px;
  color: var(--ui-muted);
  font-size: 9px;
  line-height: 1.8;
}

.credits-copy p { margin: 0; }
.credits-copy strong { color: var(--ui-accent); }

.game-hud {
  position: absolute;
  inset: 0;
  padding: 16px;
  transition: opacity .18s steps(3);
}

.hud-left,
.hud-right {
  position: absolute;
  top: 16px;
  display: flex;
  gap: 10px;
}

.hud-left { left: 16px; }
.hud-right { right: 16px; }

.hud-chip {
  min-width: 104px;
  padding: 10px 10px 8px;
  background: rgba(12,12,7,.82);
  border: 3px solid #2d2915;
  box-shadow:
    inset 0 -5px 0 rgba(0,0,0,.28),
    4px 4px 0 #050503;
  display: grid;
  gap: 5px;
}

.hud-chip.tiny { min-width: 92px; }
.hud-chip span { color: var(--ui-muted); font-size: 7px; line-height: 1; }
.hud-chip strong { color: var(--ui-accent); font-size: 13px; line-height: 1; text-shadow: 2px 2px 0 #050503; }

.mobile-hints {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  opacity: .78;
  font-size: 7px;
  color: var(--ui-muted);
}

.mobile-hints span {
  padding: 8px 8px 6px;
  background: rgba(12,12,7,.72);
  border: 2px solid #2d2915;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6,6,4,.22);
}

.countdown-number {
  color: var(--ui-accent);
  font-size: clamp(72px, 19vw, 180px);
  line-height: .9;
  text-shadow:
    6px 0 0 #8c6216,
    0 6px 0 #8c6216,
    10px 10px 0 #050503;
  animation: countPop .55s steps(5) both;
}

.countdown-label {
  position: absolute;
  top: calc(50% + clamp(58px, 11vw, 108px));
  color: var(--ui-muted);
  font-size: clamp(9px, 2.4vw, 13px);
  text-shadow: 3px 3px 0 #050503;
}

.death-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(5,4,3,.32), rgba(5,4,3,.82)),
    radial-gradient(circle at center, rgba(227,91,53,.11), transparent 60%);
}

.death-kicker { color: var(--ui-red); font-size: 9px; text-shadow: 3px 3px 0 #050503; }
.death-card p { margin: 0; color: var(--ui-muted); font-size: 9px; line-height: 1.8; }
.death-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.pixel-vignette,
.pixel-scanlines,
.pixel-noise {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.pixel-vignette {
  background:
    radial-gradient(circle at center, transparent 42%, rgba(0,0,0,.28) 72%, rgba(0,0,0,.74) 100%),
    linear-gradient(90deg, rgba(255,0,0,.035), transparent 20%, transparent 80%, rgba(0,170,255,.035));
  mix-blend-mode: multiply;
}

.pixel-scanlines {
  opacity: .18;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,.16) 0px,
      rgba(255,255,255,.16) 1px,
      rgba(0,0,0,.16) 2px,
      rgba(0,0,0,.16) 4px
    );
  animation: scanMove .22s linear infinite;
}

.pixel-noise {
  inset: -20%;
  opacity: .045;
  background-image:
    radial-gradient(circle at 20% 30%, white 0 1px, transparent 1px),
    radial-gradient(circle at 80% 60%, white 0 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, white 0 1px, transparent 1px);
  background-size: 31px 31px, 47px 47px, 73px 73px;
  animation: noiseMove .18s steps(2) infinite;
}

.runner-motion-canvas {
  position: absolute !important;
  inset: 0 !important;
  z-index: 30 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
  mix-blend-mode: screen !important;
}

@keyframes menuIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes panelPop { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes countPop { 0% { opacity: 0; transform: scale(.72); } 35% { opacity: 1; transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
@keyframes scanMove { from { transform: translateY(0); } to { transform: translateY(4px); } }
@keyframes noiseMove { 0% { transform: translate(0,0); } 25% { transform: translate(-3%,2%); } 50% { transform: translate(2%,-4%); } 75% { transform: translate(4%,3%); } 100% { transform: translate(-2%,0); } }

@media (max-width: 640px) {
  .hud-left,
  .hud-right { top: 12px; }
  .hud-left { left: 12px; }
  .hud-right { right: 12px; }
  .hud-chip { min-width: 86px; padding: 9px 8px 7px; }
  .hud-chip strong { font-size: 11px; }
  .death-actions { grid-template-columns: 1fr; }
  .mobile-hints { max-width: calc(100vw - 24px); }
}

@media (max-height: 560px) {
  .game-title { font-size: clamp(32px, 10vw, 54px); }
  .menu-shell { gap: 12px; }
  .pixel-btn span { min-height: 48px; padding: 15px 14px 11px; }
}

.pickup-toast {
  position: absolute;
  left: 50%;
  top: 92px;
  z-index: 8;
  transform: translateX(-50%) translateY(-8px) scale(.94);
  opacity: 0;
  padding: 10px 12px 8px;
  color: #171204;
  background: var(--ui-accent);
  border: 3px solid #080805;
  box-shadow:
    inset 0 -4px 0 rgba(0,0,0,.24),
    inset 0 4px 0 rgba(255,255,255,.12),
    4px 4px 0 #050503;
  font-size: 8px;
  line-height: 1;
  text-shadow: 1px 1px 0 rgba(255,255,255,.32);
  pointer-events: none;
}

.pickup-toast span {
  color: #ffffff;
  text-shadow: 2px 2px 0 #5b3d0d;
}

.pickup-toast strong {
  margin-left: 6px;
  color: #080805;
}

.pickup-toast.pop {
  animation: pickupPop .72s steps(6) both;
}

@keyframes pickupPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(.72);
  }
  18% {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px) scale(1.08);
  }
  58% {
    opacity: 1;
    transform: translateX(-50%) translateY(-12px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-28px) scale(.92);
  }
}

@media (max-width: 640px) {
  .pickup-toast {
    top: 82px;
    font-size: 7px;
  }
}
