/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a1118;
  --bg-panel: #111d27;
  --bg-card: #182530;
  --border: #1e3040;
  --text: #e8eef4;
  --text-dim: #6a7d8e;
  --accent: #22dd44;
  --accent-hover: #1bc03a;
  --accent-glow: rgba(34, 221, 68, 0.25);
  --danger: #ff3b4a;
  --danger-glow: rgba(255, 59, 74, 0.25);
  --warning: #ff9f1a;
  --gold: #ffcc00;
  --gold-glow: rgba(255, 204, 0, 0.25);
  --road: #1a1a2e;
  --road-marking: rgba(255, 255, 255, 0.2);
  --tile: #3a3a5c;
  --tile-safe: #22dd44;
  --tile-death: #ff3b4a;
  --sidewalk: #4a4a3a;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-chicken {
  width: auto;
  height: 120px;
  animation: loading-bounce 1.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 20px rgba(34, 221, 68, 0.3));
}

@keyframes loading-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.loading-title {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 20px 0 12px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-prompt {
  color: var(--text-dim);
  font-size: 0.95rem;
  letter-spacing: 1px;
  animation: loading-pulse 2s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ===== APP LAYOUT ===== */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-panel);
  border-radius: var(--radius);
  margin-bottom: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.balance-label { color: var(--text-dim); font-size: 0.85rem; }
.balance { font-weight: 700; color: var(--gold); font-size: 1.15rem; text-shadow: 0 0 12px var(--gold-glow); }

.main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

/* ===== CONTROLS PANEL ===== */
.controls-panel {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-group label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }

.bet-row { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.bet-row input { flex: 1; min-width: 0; padding: 9px 8px; }

input, select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 0 0 2px var(--accent-glow);
}
input:disabled, select:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== BUTTONS ===== */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.15s;
  padding: 8px 14px;
  font-family: var(--font);
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-small { padding: 6px 10px; font-size: 0.8rem; background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-max { background: linear-gradient(135deg, var(--gold), #d4a300); color: #000; border: none; font-weight: 700; }
.btn-icon {
  background: transparent;
  color: var(--text-dim);
  font-size: 1.1rem;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}
.btn-icon:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,0.06); filter: none; }
.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }

.btn-go {
  background: linear-gradient(135deg, #22dd44, #18a535);
  color: #000;
  font-size: 1.2rem;
  letter-spacing: 1px;
  animation: pulse-go 1.5s infinite;
  box-shadow: 0 0 16px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-cashout {
  background: linear-gradient(135deg, var(--gold), #d4a300);
  color: #000;
  font-size: 1rem;
  box-shadow: 0 0 12px var(--gold-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-large { padding: 12px 20px; width: 100%; }

.hidden { display: none !important; }

@keyframes pulse-go {
  0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
  50% { box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(34, 221, 68, 0.1); }
}

.action-buttons { display: flex; flex-direction: column; gap: 8px; }

/* ===== SVG SPRITE & ICON SIZING ===== */
.header-icon {
  width: auto;
  height: 28px;
}

.btn-svg-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.btn-svg-icon-inline {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-left: 4px;
}

.chicken-sprite {
  width: auto;
  height: 48px;
  display: block;
}

.car-sprite {
  width: 56px;
  height: auto;
  display: block;
}

.killer-car .car-sprite {
  width: 72px;
}

.debris-sprite {
  width: 30px;
  height: 30px;
}

.flag-sprite {
  width: 40px;
  height: 40px;
}

.check-sprite {
  width: 40px;
  height: 40px;
}

/* ===== GAME INFO ===== */
.game-info {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.info-value { font-weight: 700; }
.info-value.pop { animation: pop 0.3s ease; }

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.green { color: var(--accent) !important; }
.red { color: var(--danger) !important; }

.status-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

/* ===== AUTO PLAY ===== */
.autoplay-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: rgba(0,0,0,0.15);
}

.autoplay-section summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.auto-controls { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.auto-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.auto-row label { font-size: 0.8rem; color: var(--text-dim); flex-shrink: 0; }
.auto-row input { width: 80px; text-align: right; padding: 5px 8px; font-size: 0.85rem; }

/* ===== ROAD SCENE ===== */
.road-scene {
  background: var(--bg-panel);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  min-height: 600px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.road-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.road-viewport {
  width: 100%;
  height: clamp(420px, calc(100vh - 180px), 700px);
  overflow: hidden;
  position: relative;
  background: #0e0e1c;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.6);
}

.road-scroll {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== SIDEWALKS ===== */
.sidewalk {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.sidewalk-start {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.55) 40%, rgba(0,0,0,0.65) 100%),
    url('/assets/road-sidewalk.png') repeat;
  background-size: auto, 100px 100px;
  border-top: 3px solid #6a6a5a;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.06),
    inset 0 -3px 10px rgba(0,0,0,0.5);
}

.sidewalk-finish {
  background:
    linear-gradient(0deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.55) 40%, rgba(0,0,0,0.65) 100%),
    url('/assets/road-sidewalk.png') repeat;
  background-size: auto, 100px 100px;
  border-bottom: 3px solid #6a6a5a;
  box-shadow:
    inset 0 -2px 0 rgba(255,255,255,0.06),
    inset 0 3px 10px rgba(0,0,0,0.5);
}

/* Sidewalk badges */
.sidewalk-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

.start-badge {
  background: rgba(34, 221, 68, 0.1);
  border: 1px solid rgba(34, 221, 68, 0.2);
  box-shadow: 0 0 12px rgba(34, 221, 68, 0.1);
}

.start-arrow {
  width: 18px;
  height: 18px;
  color: var(--accent);
  animation: arrow-bounce 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes arrow-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.start-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #66ff88);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

.finish-badge {
  background: rgba(255, 204, 0, 0.1);
  border: 1px solid rgba(255, 204, 0, 0.2);
  box-shadow: 0 0 12px rgba(255, 204, 0, 0.1);
}

.finish-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), #ffe066);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

/* ===== CHICKEN ===== */
.chicken {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  top: 0;
  z-index: 10;
  transition: top 0.35s cubic-bezier(0.22, 1, 0.36, 1), left 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.7));
}

.chicken.idle {
  animation: chickenIdle 1.5s ease-in-out infinite;
}

.chicken.hopping {
  animation: chickenHop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chicken.landing {
  animation: chickenLand 0.2s ease forwards;
}

.chicken.dead {
  animation: chickenDead 0.5s ease forwards;
  filter: drop-shadow(0 0 12px rgba(255, 59, 74, 0.7));
}

.chicken.cashout-anim {
  animation: chickenCashout 0.7s ease;
  filter: drop-shadow(0 0 16px rgba(255, 204, 0, 0.7));
}

@keyframes chickenIdle {
  0%, 100% { transform: translateX(-50%) translateY(-50%); }
  50% { transform: translateX(-50%) translateY(calc(-50% - 3px)); }
}

@keyframes chickenHop {
  0% { transform: translateX(-50%) translateY(-50%) scale(1); }
  15% { transform: translateX(-50%) translateY(calc(-50% + 4px)) scale(1.1, 0.85); }
  40% { transform: translateX(-50%) translateY(calc(-50% - 22px)) scale(0.9, 1.15); }
  70% { transform: translateX(-50%) translateY(calc(-50% - 10px)) scale(1); }
  100% { transform: translateX(-50%) translateY(-50%) scale(1); }
}

@keyframes chickenLand {
  0% { transform: translateX(-50%) translateY(-50%) scale(1.1, 0.85); }
  100% { transform: translateX(-50%) translateY(-50%) scale(1); }
}

@keyframes chickenDead {
  0%   { transform: translateX(-50%) translateY(-50%) scale(1) rotate(0deg); }
  15%  { transform: translateX(-50%) translateY(-50%) scale(1.3) rotate(0deg); }
  30%  { transform: translateX(calc(-50% + 6px)) translateY(-50%) scale(1.05) rotate(3deg); }
  45%  { transform: translateX(calc(-50% - 5px)) translateY(-50%) scale(1.0) rotate(-2deg); }
  60%  { transform: translateX(calc(-50% + 3px)) translateY(-50%) scale(1.0) rotate(1deg); }
  75%  { transform: translateX(calc(-50% - 2px)) translateY(-50%) scale(1.0) rotate(-0.5deg); }
  100% { transform: translateX(-50%) translateY(-50%) scale(1.0) rotate(0deg); opacity: 1; }
}

@keyframes chickenCashout {
  0% { transform: translateX(-50%) translateY(-50%) scale(1); }
  35% { transform: translateX(-50%) translateY(calc(-50% - 20px)) scale(1.4); }
  70% { transform: translateX(-50%) translateY(calc(-50% - 5px)) scale(1.1); }
  100% { transform: translateX(-50%) translateY(-50%) scale(1); }
}

/* ===== ROAD LANES ===== */
.lanes-container {
  display: flex;
  flex-direction: column;
}

.road-lane {
  height: 96px;
  position: relative;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
  overflow: visible;
}

.lane-road {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0) 20%, rgba(0,0,0,0) 80%, rgba(0,0,0,0.18) 100%),
    url('/assets/road-asphalt.png') repeat;
  background-size: auto, 128px 128px;
}

.lane-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
}

.lane-line-top {
  top: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
}
.lane-line-bottom {
  bottom: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.5) 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
}

/* Dashed center line */
.lane-dashes {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(
    90deg,
    rgba(255,255,200,0.18) 0px,
    rgba(255,255,200,0.18) 18px,
    transparent 18px,
    transparent 38px
  );
  filter: drop-shadow(0 0 2px rgba(255,255,200,0.08));
}

.lane-dashes.right {
  animation: dash-scroll-right 2s linear infinite;
}
.lane-dashes.left {
  animation: dash-scroll-left 2s linear infinite;
}

@keyframes dash-scroll-right {
  0% { background-position: 0 0; }
  100% { background-position: 40px 0; }
}
@keyframes dash-scroll-left {
  0% { background-position: 0 0; }
  100% { background-position: -40px 0; }
}

.car-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* ===== LANE STATES ===== */
.road-lane.upcoming .lane-road {
  /* default asphalt texture from .lane-road */
}

.road-lane.current {
  cursor: pointer;
}

.road-lane.current .lane-road {
  box-shadow: inset 0 0 20px rgba(34, 221, 68, 0.15);
}

.road-lane.current:hover .lane-road {
  box-shadow: inset 0 0 30px rgba(34, 221, 68, 0.3);
}

.road-lane.current .lane-multiplier {
  color: var(--accent);
  background: rgba(34, 221, 68, 0.12);
  animation: mult-pulse 1.2s ease infinite;
}

@keyframes mult-pulse {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.1); }
}

.road-lane.crossed .lane-road {
  box-shadow: inset 0 0 30px rgba(34, 221, 68, 0.08);
}

.road-lane.crossed .road-car {
  opacity: 0.2;
}

.road-lane.crossed .lane-dashes {
  opacity: 0.3;
}

/* Frozen cars (stopped in place after chicken crosses safely) */
.road-car.frozen {
  transition: opacity 0.5s ease;
  opacity: 0.2;
}

.lane-dashes.frozen {
  opacity: 0.15;
}

.road-lane.death .lane-road {
  box-shadow: inset 0 0 40px rgba(255, 59, 74, 0.3);
  animation: death-lane-pulse 0.6s ease;
}

@keyframes death-lane-pulse {
  0% { box-shadow: inset 0 0 0 rgba(255, 59, 74, 0); }
  30% { box-shadow: inset 0 0 60px rgba(255, 59, 74, 0.45); }
  100% { box-shadow: inset 0 0 40px rgba(255, 59, 74, 0.2); }
}

.road-lane.safe-flash .lane-road {
  animation: lane-safe-flash 0.8s ease;
}

@keyframes lane-safe-flash {
  0% { box-shadow: inset 0 0 0 rgba(34, 221, 68, 0); }
  30% { box-shadow: inset 0 0 50px rgba(34, 221, 68, 0.3); }
  100% { box-shadow: inset 0 0 10px rgba(34, 221, 68, 0.05); }
}

/* Road decorations */
.road-decor {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  filter: brightness(0.85) contrast(1.1);
  mix-blend-mode: luminosity;
}

.road-decor img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* Lane checkmark */
.lane-check {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 4;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lane-check.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 0.7;
}

/* ===== FLOATING MULTIPLIER POP-UP ===== */
.floating-mult {
  position: absolute;
  transform: translate(-50%, -50%) scale(0);
  z-index: 20;
  font-weight: 800;
  color: var(--gold);
  text-shadow:
    0 0 10px var(--gold-glow),
    0 0 20px rgba(255, 204, 0, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: floatingMultPop 0.85s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

@keyframes floatingMultPop {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.25);
    opacity: 1;
  }
  40% {
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 1;
  }
  55% {
    transform: translate(-50%, -50%) scale(1.0);
    opacity: 1;
  }
  75% {
    transform: translate(-50%, -60%) scale(1.0);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -80%) scale(0.7);
    opacity: 0;
  }
}

/* ===== FLOATING CASH AMOUNT ===== */
.floating-amount {
  position: absolute;
  transform: translate(-50%, -50%) scale(0);
  z-index: 20;
  font-weight: 800;
  font-size: 1.6rem;
  pointer-events: none;
  animation: floatingAmountPop 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.floating-amount-win {
  color: var(--accent);
  text-shadow:
    0 0 10px var(--accent-glow),
    0 0 20px rgba(34, 221, 68, 0.2),
    0 2px 4px rgba(0, 0, 0, 0.6);
}

.floating-amount-loss {
  color: var(--danger);
  text-shadow:
    0 0 10px var(--danger-glow),
    0 0 20px rgba(255, 59, 74, 0.2),
    0 2px 4px rgba(0, 0, 0, 0.6);
}

@keyframes floatingAmountPop {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
  70% {
    transform: translate(-50%, -65%) scale(1.0);
    opacity: 0.85;
  }
  100% {
    transform: translate(-50%, -100%) scale(0.8);
    opacity: 0;
  }
}

/* ===== MULTIPLIER LABELS ===== */
.lane-multiplier {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.55);
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  z-index: 3;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.road-lane.crossed .lane-multiplier {
  color: var(--accent);
  background: rgba(34, 221, 68, 0.12);
}

.road-lane.death .lane-multiplier {
  color: var(--danger);
  background: rgba(255, 59, 74, 0.15);
}

/* ===== CARS ===== */
.road-car {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  will-change: left;
}

.road-car-left {
  animation: car-drive-left linear infinite;
}

.road-car-right {
  animation: car-drive-right linear infinite;
}

.car-body {
  display: inline-block;
}

.road-car-right .car-body {
  transform: scaleX(-1);
}

@keyframes car-drive-left {
  0% { left: 110%; }
  100% { left: -15%; }
}

@keyframes car-drive-right {
  0% { left: -15%; }
  100% { left: 110%; }
}

/* ===== KILLER CAR ===== */
.killer-car {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}

/* Killer comes from the right side (cars driving left) */
.killer-from-right {
  animation: killer-smash-from-right 0.3s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

@keyframes killer-smash-from-right {
  0% { left: 110%; }
  100% { left: 42%; }
}

/* Killer comes from the left side (cars driving right) */
.killer-from-left {
  animation: killer-smash-from-left 0.3s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

@keyframes killer-smash-from-left {
  0% { left: -25%; }
  100% { left: 42%; }
}

/* Debris particles on death */
.debris {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  animation: debris-fly 0.6s ease-out forwards;
}

@keyframes debris-fly {
  0% { transform: scale(0.8) translate(0, 0); opacity: 0.7; }
  100% { transform: scale(0.2) translate(var(--dx, 20px), var(--dy, -25px)); opacity: 0; }
}

.debris:nth-child(odd) { --dx: -25px; --dy: -20px; }
.debris:nth-child(even) { --dx: 20px; --dy: -30px; }
.debris:nth-child(3n) { --dx: -15px; --dy: 18px; }

/* ===== TRAFFIC LIGHT ===== */
.traffic-light {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #1a1a1a;
  padding: 6px;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  z-index: 15;
  border: 1px solid #333;
}

.light {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  opacity: 0.15;
  transition: opacity 0.3s, box-shadow 0.3s;
}

.light.red { background: #ff3b4a; }
.light.yellow { background: #ff9f1a; }
.light.green { background: #22dd44; }
.light.active { opacity: 1; box-shadow: 0 0 10px currentColor; }

/* ===== SCREEN SHAKE ===== */
.road-scene.shake { animation: shake 0.5s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-10px) rotate(-0.5deg); }
  30% { transform: translateX(10px) rotate(0.5deg); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-2px); }
}

/* ===== CONFETTI ===== */
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  z-index: 20;
  animation: confetti-fall linear forwards;
  pointer-events: none;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(250px) rotate(720deg) scale(0.3); opacity: 0; }
}

/* ===== IRIS WIPE (cartoon TV transition) ===== */
.iris-wipe {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

.iris-wipe::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 0 #0a0a14;
}

.iris-wipe.closing::before {
  animation: iris-close 0.45s ease-in forwards;
}

.iris-wipe.opening::before {
  animation: iris-open 0.5s ease-out forwards;
}

@keyframes iris-close {
  0% {
    width: 1500px;
    height: 1500px;
    box-shadow: 0 0 0 0 #0a0a14;
  }
  100% {
    width: 0;
    height: 0;
    box-shadow: 0 0 0 1500px #0a0a14;
  }
}

@keyframes iris-open {
  0% {
    width: 0;
    height: 0;
    box-shadow: 0 0 0 1500px #0a0a14;
  }
  100% {
    width: 1500px;
    height: 1500px;
    box-shadow: 0 0 0 0 #0a0a14;
  }
}

/* ===== HISTORY ===== */
.history-section {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.history-section h3 {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  font-weight: 600;
}

.history-table-wrap { overflow-x: auto; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th {
  text-align: left;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(30, 48, 64, 0.5);
}

.history-table tr.win { background: rgba(34, 221, 68, 0.04); }
.history-table tr.loss { background: rgba(255, 59, 74, 0.04); }
.history-table tr:hover { background: rgba(255,255,255,0.02); }

/* ===== INSUFFICIENT BALANCE ===== */
.input-shake {
  animation: input-shake 0.5s ease;
  border-color: var(--danger) !important;
  box-shadow: 0 0 8px var(--danger-glow) !important;
}

@keyframes input-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.balance-flash {
  animation: balance-flash 0.6s ease;
}

@keyframes balance-flash {
  0%, 100% { color: var(--gold); }
  25% { color: var(--danger); }
  50% { color: var(--gold); }
  75% { color: var(--danger); }
}

/* ===== INFO MODAL ===== */
.info-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.info-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-size: 0.85rem;
}

.info-step div {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.info-step strong {
  color: var(--text);
}

.info-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.info-shortcuts {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.info-shortcuts kbd, .info-step kbd {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal.show { display: flex; }

.modal-content {
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 { font-size: 1.1rem; }

.fairness-field {
  margin-bottom: 12px;
}

.fairness-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fairness-field input {
  width: 100%;
  font-size: 0.8rem;
  font-family: monospace;
}

.verify-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.8rem;
}

.verify-table th, .verify-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.verify-table tr.win td:last-child { color: var(--accent); }
.verify-table tr.loss td:last-child { color: var(--danger); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    order: 2;
  }

  .road-scene {
    order: 1;
    min-height: 350px;
  }

  .road-viewport {
    height: clamp(300px, 50vh, 420px);
  }

  .header h1 { font-size: 1.1rem; }

  .chicken-sprite { height: 38px; width: auto; }
  .car-sprite { width: 44px; }
  .killer-car .car-sprite { width: 58px; }

  .floating-mult { font-size: 1.4rem !important; }
  .floating-amount { font-size: 1.3rem !important; }
}
