/* Invasión de Bugs — presentación. La lógica vive en src/bug-invasion.js. */

:root {
  --bg: #0f1216;
  --panel: #171b21;
  --line: #272d35;
  --ink: #e8ecf2;
  --ink-dim: #97a0ad;
  --verde: #57d98a;
  --ambar: #ffcc66;
  --rojo: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(90% 60% at 50% 0%, #1a1f27, var(--bg) 70%);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;                 /* el campo ocupa la ventana */
}

a { color: #8ec5ff; }

/* ---------- Marcador ---------- */
.hud {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(15,18,22,.92), rgba(15,18,22,.55) 70%, transparent);
  pointer-events: none;
}
.hud a { pointer-events: auto; }

.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat b {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.stat span {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.stat.record b { color: var(--ambar); }

#combo { color: var(--verde); transition: transform .12s ease-out; }
#combo.bump { transform: scale(1.35); }

.spacer { flex: 1; }

/* Barra de tiempo */
.timer {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 100%;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--verde), #7fd4ff);
  z-index: 6;
  will-change: transform;
}
.timer.low { background: linear-gradient(90deg, var(--rojo), var(--ambar)); }

/* ---------- Campo de juego ---------- */
#campo {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;               /* el dedo aplasta, no hace scroll */
  cursor: crosshair;
}

.bug {
  position: absolute;
  left: 0; top: 0;
  font-size: 22px;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  will-change: transform;
}
/* La transición sólo se aplica al aplastar: durante el juego el motor
   escribe el transform en cada frame y una transición lo frenaría. */
.bug.squashed {
  transition: transform .25s cubic-bezier(.5, -0.4, .7, .3);
  pointer-events: none;
}

.splat {
  position: absolute;
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: #86e08f;
  pointer-events: none;
  animation: salpicar .45s ease-out forwards;
}
@keyframes salpicar {
  from { transform: translate(0, 0) scale(1); opacity: .95; }
  to   { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}

.popup {
  position: absolute;
  font-size: 14px;
  font-weight: 700;
  color: var(--verde);
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  animation: subir .7s ease-out forwards;
}
@keyframes subir {
  from { transform: translate(-50%, -50%) scale(.8); opacity: 0; }
  25%  { transform: translate(-50%, -80%) scale(1.1); opacity: 1; }
  to   { transform: translate(-50%, -160%) scale(1); opacity: 0; }
}

/* ---------- Diálogos de estado ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 13, .78);
  backdrop-filter: blur(5px);
}
.overlay[hidden] { display: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 34px;
  text-align: center;
  max-width: min(92vw, 420px);
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.card h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.card h2 { margin: 0 0 6px; font-size: 22px; }
.card p { margin: 0 0 20px; color: var(--ink-dim); font-size: 14px; }
.card .big {
  font-size: 46px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 2px;
}
.card .nuevo { color: var(--ambar); font-weight: 600; font-size: 13px; }

.card button {
  padding: 11px 26px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 9px;
  background: var(--verde);
  color: #08130c;
  cursor: pointer;
  transition: filter .12s, transform .12s;
}
.card button:hover { filter: brightness(1.1); transform: translateY(-1px); }

.card .tecla {
  display: inline-block;
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink-dim);
}
kbd {
  font: inherit;
  font-size: 11px;
  background: #232932;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}

@media (prefers-reduced-motion: reduce) {
  .splat, .popup { animation-duration: .01ms; }
  .bug.squashed { transition-duration: .01ms; }
}
