@font-face {
  font-family: 'Anton';
  src: url('assets/fonts/Anton-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'InterDisplay';
  src: url('assets/fonts/InterDisplay-ExtraBold.otf') format('opentype');
  font-weight: 800;
  font-display: swap;
}

:root {
  --mint: #2ee6a6;
  --mint-dark: #0f7657;
  --asylum-bg: #0b1615;
  --amber: #ffbe0b;
  --danger: #ff2e55;
  --cyan: #00d9ff;
  --card-bg: rgba(11, 24, 23, 0.86);
  --card-border: rgba(46, 230, 166, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--asylum-bg);
  color: #f4fffb;
  font-family: 'InterDisplay', system-ui, -apple-system, sans-serif;
}

#game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  transition: filter 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Iconic viral Black & White dramatic slow-mo freeze on crash */
body.dramatic-bw #game-canvas {
  filter: grayscale(100%) contrast(142%) brightness(0.76);
}

body.fever-mode #game-canvas {
  filter: saturate(1.45) contrast(1.08);
}

/* Speed lines during Fever */
#speed-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background:
    repeating-conic-gradient(
      from 0deg at 50% 50%,
      rgba(255, 220, 60, 0.14) 0deg 2deg,
      transparent 2deg 11deg
    );
  mask-image: radial-gradient(circle at 50% 50%, transparent 40%, black 88%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 40%, black 88%);
  animation: spinLines 1.8s linear infinite;
}

body.fever-mode #speed-lines {
  opacity: 1;
}

@keyframes spinLines {
  from { transform: scale(1.15) rotate(0deg); }
  to   { transform: scale(1.15) rotate(360deg); }
}

/* Red / Blue Siren Vignette when chaser is right behind */
#siren-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  box-shadow: inset 0 0 110px 28px rgba(255, 30, 70, 0.72);
}

body.chaser-close #siren-vignette {
  opacity: 1;
  animation: sirenPulse 0.6s ease-in-out infinite alternate;
}

@keyframes sirenPulse {
  0%   { box-shadow: inset 0 0 100px 22px rgba(255, 28, 72, 0.72); }
  100% { box-shadow: inset 0 0 125px 32px rgba(0, 170, 255, 0.62); }
}

#bw-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}

#bw-flash.flash {
  animation: impactFlash 0.32s ease-out forwards;
}

@keyframes impactFlash {
  0%   { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ================= HUD ================= */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
  z-index: 15;
}

#hud.hidden {
  display: none;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-center {
  align-items: center;
  flex: 1;
  max-width: 340px;
}

.hud-right {
  align-items: flex-end;
}

.score-card {
  background: rgba(8, 22, 20, 0.78);
  border: 2px solid rgba(46, 230, 166, 0.45);
  border-radius: 16px;
  padding: 10px 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  min-width: 155px;
}

.score-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--mint);
}

.score-value {
  font-family: 'Anton', sans-serif;
  font-size: 36px;
  line-height: 1.05;
  color: #ffffff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.65);
}

.sub-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #bceee0;
  margin-top: 2px;
}

.mult-badge {
  background: var(--amber);
  color: #141414;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
}

.speed-badge {
  background: rgba(0, 217, 255, 0.18);
  border: 1px solid rgba(0, 217, 255, 0.55);
  color: #8df6ff;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.speed-badge.fast {
  background: rgba(255, 190, 11, 0.24);
  border-color: rgba(255, 190, 11, 0.72);
  color: #ffe066;
}

.speed-badge.hyper {
  background: rgba(255, 46, 85, 0.30);
  border-color: rgba(255, 46, 85, 0.85);
  color: #ffb3c1;
}

.zone-pill {
  background: rgba(8, 20, 22, 0.76);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12px;
  letter-spacing: 0.8px;
  color: #d9fff3;
  align-self: flex-start;
  backdrop-filter: blur(6px);
}

.fever-wrap {
  width: 100%;
  background: rgba(8, 20, 20, 0.78);
  border: 2px solid rgba(255, 190, 11, 0.45);
  border-radius: 14px;
  padding: 8px 12px;
  backdrop-filter: blur(8px);
}

.fever-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 5px;
  color: var(--amber);
}

.fever-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  overflow: hidden;
}

#fever-fill {
  width: 0%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffbe0b, #ff5400, #ff006e, #00f5d4);
  background-size: 200% 100%;
  transition: width 0.15s ease-out;
  animation: feverGrad 1.4s linear infinite;
}

@keyframes feverGrad {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.powerups-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.pu-chip {
  background: rgba(10, 24, 24, 0.85);
  border: 2px solid var(--cyan);
  border-radius: 99px;
  padding: 4px 11px;
  font-size: 12px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 217, 255, 0.25);
}

.pu-chip.shield { border-color: var(--mint); }
.pu-chip.fever  { border-color: var(--amber); background: rgba(255, 84, 0, 0.82); }

.pill-counter {
  background: rgba(8, 22, 20, 0.8);
  border: 2px solid rgba(255, 190, 11, 0.55);
  border-radius: 16px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Anton', sans-serif;
  font-size: 28px;
  color: var(--amber);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.hud-buttons {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(10, 24, 22, 0.8);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s, background 0.15s;
  backdrop-filter: blur(8px);
}

.icon-btn:hover {
  transform: translateY(-2px);
  background: rgba(46, 230, 166, 0.25);
}

.icon-btn.muted {
  opacity: 0.45;
}

/* ================= CALLOUTS & WARNINGS ================= */
#callout-layer {
  position: absolute;
  top: 125px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 20;
}

.callout-pop {
  font-family: 'Anton', sans-serif;
  font-size: clamp(24px, 4vw, 44px);
  letter-spacing: 1px;
  color: #fff;
  padding: 6px 20px;
  border-radius: 14px;
  background: rgba(12, 16, 18, 0.82);
  border: 2.5px solid var(--amber);
  text-shadow: 0 3px 0 #000;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  animation: popInOut 1.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.callout-pop.danger { border-color: var(--danger); color: #ffdf5d; }
.callout-pop.mint   { border-color: var(--mint); color: #b8ffea; }
.callout-pop.fever  {
  border-color: #fff;
  background: linear-gradient(90deg, #ff006e, #ff5400, #ffbe0b);
  color: #fff;
}

@keyframes popInOut {
  0%   { opacity: 0; transform: scale(0.55) translateY(18px) rotate(-3deg); }
  16%  { opacity: 1; transform: scale(1.06) translateY(0) rotate(1deg); }
  75%  { opacity: 1; transform: scale(1) translateY(-6px) rotate(0deg); }
  100% { opacity: 0; transform: scale(0.92) translateY(-28px); }
}

#chaser-warning {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 24, 68, 0.92);
  color: #fff;
  font-family: 'Anton', sans-serif;
  letter-spacing: 1.5px;
  font-size: 20px;
  padding: 7px 22px;
  border-radius: 99px;
  border: 2px solid #ffe066;
  box-shadow: 0 0 28px rgba(255, 24, 68, 0.75);
  z-index: 18;
  animation: warnBlink 0.55s ease-in-out infinite alternate;
}

#chaser-warning.hidden { display: none; }

@keyframes warnBlink {
  0% { transform: translateX(-50%) scale(0.97); opacity: 0.82; }
  100% { transform: translateX(-50%) scale(1.04); opacity: 1; }
}

/* ================= TOUCH CONTROLS ================= */
#touch-controls {
  position: absolute;
  bottom: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 16;
}

#touch-controls.hidden { display: none; }

.tc-mid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tc-btn {
  pointer-events: auto;
  width: 62px;
  height: 54px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 22, 20, 0.52);
  color: rgba(255, 255, 255, 0.9);
  font-size: 22px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.tc-btn:active {
  background: rgba(46, 230, 166, 0.45);
  transform: scale(0.94);
}

@media (hover: hover) and (pointer: fine) {
  #touch-controls { display: none !important; }
}

/* ================= OVERLAYS ================= */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 35%, rgba(12, 36, 32, 0.52), rgba(5, 11, 11, 0.84));
  backdrop-filter: blur(5px);
  z-index: 30;
}

.overlay.active {
  display: flex;
}

.menu-card {
  width: min(560px, 94vw);
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 24px;
  padding: 26px 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.68), 0 0 40px rgba(46, 230, 166, 0.14);
  text-align: center;
  max-height: 92vh;
  overflow-y: auto;
}

.menu-card.compact {
  width: min(380px, 90vw);
}

.badge-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.pill-tag {
  font-size: 11px;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 99px;
  background: rgba(46, 230, 166, 0.18);
  border: 1px solid rgba(46, 230, 166, 0.55);
  color: var(--mint);
}

.pill-tag.red {
  background: rgba(255, 46, 85, 0.2);
  border-color: rgba(255, 46, 85, 0.6);
  color: #ff9db0;
}

.pill-tag.cyan {
  background: rgba(0, 217, 255, 0.16);
  border-color: rgba(0, 217, 255, 0.55);
  color: #7eefff;
}

/* Character Selector */
.char-section {
  margin-bottom: 14px;
}

.char-label {
  font-size: 11px;
  letter-spacing: 1.8px;
  color: var(--mint);
  margin-bottom: 8px;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.char-card {
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 10px 8px;
  color: #e9fff8;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}

.char-card:hover {
  transform: translateY(-2px);
  background: rgba(46, 230, 166, 0.14);
}

.char-card.active {
  border-color: var(--amber);
  background: rgba(255, 190, 11, 0.18);
  box-shadow: 0 0 18px rgba(255, 190, 11, 0.28);
}

.char-emoji {
  font-size: 22px;
  line-height: 1;
}

.char-card strong {
  font-family: 'Anton', sans-serif;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: #ffffff;
}

.char-card small {
  font-size: 10px;
  line-height: 1.25;
  color: #b7e6d8;
}

/* Story Export Button & Preview */
.btn-story {
  background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-family: 'Anton', sans-serif;
  font-size: 18px;
  letter-spacing: 0.8px;
  cursor: pointer;
  box-shadow: 0 5px 0 #5b1866, 0 10px 24px rgba(221, 42, 123, 0.35);
  transition: transform 0.12s;
}

.btn-story:hover {
  transform: translateY(-2px);
}

.story-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.story-preview.hidden { display: none; }

#story-preview-img {
  width: 110px;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  border: 2px solid var(--amber);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.65);
  object-fit: cover;
  flex-shrink: 0;
}

.story-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  justify-content: center;
}

.small-btn {
  padding: 9px 16px !important;
  font-size: 15px !important;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

@media (max-width: 600px) {
  .char-grid { grid-template-columns: 1fr; }
}

.game-title {
  font-family: 'Anton', sans-serif;
  font-size: clamp(42px, 7.2vw, 66px);
  line-height: 0.98;
  letter-spacing: 1.5px;
  color: #ffffff;
  text-shadow: 0 5px 0 #092c22, 0 0 28px rgba(46, 230, 166, 0.35);
  margin-bottom: 14px;
}

.game-title .subtitle {
  display: block;
  margin-top: 8px;
  font-family: 'InterDisplay', sans-serif;
  font-size: 13px;
  letter-spacing: 2.6px;
  color: var(--amber);
  text-shadow: none;
}

.story-blurb {
  font-size: 14px;
  line-height: 1.55;
  color: #cdebe2;
  margin-bottom: 16px;
  font-weight: 500;
}

.story-blurb strong {
  color: #fff;
}

.best-strip {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
  color: #c5efe3;
  margin-bottom: 18px;
}

.best-strip strong {
  color: var(--amber);
  font-family: 'Anton', sans-serif;
  font-size: 18px;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

.cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.cta-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, #2ee6a6, #00c48c);
  color: #062119;
  border: none;
  border-radius: 14px;
  padding: 14px 26px;
  font-family: 'Anton', sans-serif;
  font-size: 22px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 0 #096348, 0 12px 28px rgba(46, 230, 166, 0.32);
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary small {
  font-family: 'InterDisplay', sans-serif;
  font-size: 11px;
  opacity: 0.78;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #096348, 0 16px 32px rgba(46, 230, 166, 0.42);
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #096348;
}

.btn-secondary {
  background: rgba(255, 190, 11, 0.16);
  color: var(--amber);
  border: 2px solid rgba(255, 190, 11, 0.55);
  border-radius: 14px;
  padding: 13px 20px;
  font-family: 'Anton', sans-serif;
  font-size: 19px;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 190, 11, 0.28);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: #bceee0;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 11px 18px;
  font-family: 'Anton', sans-serif;
  font-size: 17px;
  cursor: pointer;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  text-align: left;
  background: rgba(0, 0, 0, 0.28);
  padding: 12px;
  border-radius: 14px;
  font-size: 12px;
  color: #bfe7dc;
}

.ctrl-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

kbd {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  color: #fff;
  font-family: 'InterDisplay', monospace;
}

.menu-card::-webkit-scrollbar {
  width: 6px;
}
.menu-card::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 99px;
}
.menu-card::-webkit-scrollbar-thumb {
  background: rgba(46, 230, 166, 0.45);
  border-radius: 99px;
}

/* ================= GAME OVER (VIRAL B&W MEME STYLE) ================= */
.gameover-overlay {
  background: radial-gradient(circle at 50% 45%, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.86));
  backdrop-filter: blur(2px);
  gap: 16px;
}

.viral-meme-banner {
  text-align: center;
  animation: memeSlam 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes memeSlam {
  0%   { opacity: 0; transform: scale(1.6) rotate(-4deg); }
  100% { opacity: 1; transform: scale(1) rotate(-1.2deg); }
}

.meme-top-tag {
  display: inline-block;
  background: #ff2e55;
  color: #fff;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 3px 12px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.meme-headline {
  font-family: 'Anton', sans-serif;
  font-size: clamp(38px, 6.8vw, 66px);
  line-height: 0.98;
  color: #ffffff;
  text-shadow: 0 5px 0 #000, 0 0 28px rgba(255, 46, 85, 0.65);
  letter-spacing: 1.5px;
}

.meme-subline {
  font-family: 'Anton', sans-serif;
  font-size: clamp(22px, 3.6vw, 34px);
  color: #ffbe0b;
  text-shadow: 0 3px 0 #000;
  margin-top: 4px;
}

.gameover-card {
  width: min(490px, 92vw);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(12, 14, 15, 0.88);
}

.go-cause {
  font-size: 14px;
  color: #ffb3c1;
  margin-bottom: 10px;
}

.new-record {
  display: inline-block;
  background: linear-gradient(90deg, #ffbe0b, #ff5400);
  color: #141414;
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 12px;
  margin-bottom: 12px;
}

.new-record.hidden { display: none; }

.go-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.st-lbl {
  font-size: 10px;
  letter-spacing: 1.3px;
  color: #9ec9be;
}

.stat-box strong {
  font-family: 'Anton', sans-serif;
  font-size: 24px;
  color: #fff;
}

.overlay-heading {
  font-family: 'Anton', sans-serif;
  font-size: 38px;
  letter-spacing: 1px;
}

.pause-sub {
  font-size: 13px;
  color: #b5e4d6;
  margin-top: 6px;
}

@media (max-width: 600px) {
  #hud { padding: 10px 12px; }
  .score-value { font-size: 28px; }
  .pill-counter { font-size: 22px; padding: 6px 12px; }
  .go-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .controls-grid { grid-template-columns: 1fr; }
}
