/* Hallmark · shape: game screens over a full-bleed canvas · genre: atmospheric · theme: custom, night battlefield (by request: battle theme, realistic) · job: try · draw: none (app scope)
 * hero: title left, the living roach as the product shot right · nav: none · footer: none · imagery: none, everything painted on canvas · signature: the roach itself, glossy and twitching on the menu
 * axes: dark/condensed-display/single-red · posture: committed · contrast: pass · fold: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P3 H4 E3 S4 R3 V3 · weakest: hint line is small, kept to two short sentences */
@import url('./tokens.css');
@import url('./base.css');

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  -webkit-user-select: none;
  user-select: none;
}

#arena {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#arena.is-playing {
  cursor: none;
}

/* red edge: pulses on the last life, flashes on a hit */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-raised);
  opacity: 0;
  box-shadow: inset 0 0 18vmin var(--color-accent);
  transition: opacity var(--dur-long) var(--ease-out);
}
.vignette.is-hit {
  opacity: 0.9;
  transition-duration: 0ms;
}
.vignette.is-critical {
  animation: critical 1.1s var(--ease-in-out) infinite;
}
@keyframes critical {
  50% {
    opacity: 0.55;
  }
}

h1,
h2 {
  text-transform: uppercase;
  line-height: 0.9;
}

/* ---- controls ---- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  min-height: 48px;
  padding: var(--space-sm) var(--space-lg);
  font: 600 var(--text-md) / 1.2 var(--font-body);
  color: var(--color-ink);
  background: transparent;
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-out),
    border-color var(--dur-micro) var(--ease-out),
    scale var(--dur-micro) var(--ease-out);
}
.btn:active {
  scale: 0.97;
}
.btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  padding-inline: var(--space-xl);
}
.btn--primary:hover {
  background: color-mix(in oklab, var(--color-accent) 85%, var(--color-ink));
}
.btn--ghost {
  border-color: var(--color-rule);
}
.btn--ghost:hover {
  border-color: var(--color-ink-2);
  background: color-mix(in oklab, var(--color-paper) 60%, transparent);
}

/* ---- screens ---- */

.screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-lg);
  overflow-y: auto;
}
#pause,
#over {
  background: color-mix(in oklab, var(--shadow) 62%, transparent);
  backdrop-filter: blur(3px);
}

.screen--menu {
  place-items: center start;
  padding-inline: max(var(--space-lg), 7vw);
  /* the floor is bright marble now: shade the text side so the type holds */
  background: linear-gradient(90deg, oklch(14% 0.02 45 / 0.88) 0%, oklch(14% 0.02 45 / 0.6) 38%, transparent 62%);
}
.menu {
  max-width: 40rem;
  display: grid;
  gap: var(--space-lg);
}
/* sized to keep the one word on one line beside the roach */
.menu h1 {
  font-size: clamp(4rem, 9vw, 9rem);
  max-width: none;
  text-shadow: 0 6px 40px var(--shadow);
}
.menu .lead {
  color: var(--color-ink-2);
  max-width: 30ch;
}
.hint {
  color: var(--color-muted);
  font-size: var(--text-sm);
  max-width: 44ch;
}
.kicker {
  color: var(--color-alert);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.menu h1 + .lead {
  margin-top: calc(-1 * var(--space-sm));
}
.rules {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-md);
  margin: 0;
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-rule);
  max-width: 36rem;
  font-size: var(--text-sm);
}
.rules dt {
  font: 700 var(--text-md) / 1.4 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink);
}
.rules dd {
  margin: 0;
  color: var(--color-ink-2);
  line-height: 1.5;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  margin-inline: 1px;
  padding: 0 0.35em;
  border: 1px solid var(--color-rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  font: 600 var(--text-xs) / 1.5 var(--font-body);
  text-align: center;
  color: var(--color-ink);
  background: var(--color-paper-2);
}

.panel {
  width: min(100%, 26rem);
  display: grid;
  gap: var(--space-md);
  text-align: left;
}
.panel h2 {
  font-size: clamp(3.5rem, 10vw, 6rem);
}
#over h2 {
  color: var(--color-alert);
}
.score-big {
  font: 900 var(--text-display) / 1 var(--font-display);
}
.tally {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-lg);
  margin: 0;
  padding-block: var(--space-sm);
  border-block: 1px solid var(--color-rule-2);
}
.tally dt {
  color: var(--color-muted);
}
.tally dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

@media (max-width: 56rem) {
  .screen--menu {
    place-items: start center;
    padding-top: 12vh;
    background: linear-gradient(180deg, oklch(14% 0.02 45 / 0.88) 0%, oklch(14% 0.02 45 / 0.6) 50%, transparent 75%);
  }
  .menu {
    text-align: left;
  }
}

/* ---- HUD: type straight on the battlefield, no boxes ---- */

.hud {
  position: fixed;
  inset: var(--space-md) var(--space-lg) auto;
  z-index: var(--z-sticky);
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: start;
  gap: var(--space-md);
  pointer-events: none;
  text-shadow: 0 1px 8px var(--shadow);
}
.hud::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: 140px;
  z-index: -1;
  background: linear-gradient(180deg, oklch(14% 0.02 45 / 0.7), transparent);
}
.hud__god {
  color: var(--color-focus);
  font-weight: 600;
}
.hud__wave {
  display: grid;
}
.hud__label {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 500;
}
.hud__name {
  font: 700 var(--text-xl) / 1 var(--font-display);
  text-transform: uppercase;
}
.hud__score {
  font: 900 var(--text-3xl) / 1 var(--font-display);
}
.hud__status {
  display: grid;
  justify-items: end;
  gap: var(--space-2xs);
}
.hud__pause {
  pointer-events: auto;
  min-height: 40px;
  padding: var(--space-xs) var(--space-sm);
}

.lives {
  display: flex;
  gap: var(--space-2xs);
}
.lives i {
  width: 28px;
  height: 10px;
  background: var(--color-alert);
  box-shadow: 0 0 10px color-mix(in oklab, var(--color-alert) 60%, transparent);
  transition:
    background-color var(--dur-short) var(--ease-out),
    box-shadow var(--dur-short) var(--ease-out);
}
.lives i.is-lost {
  background: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--color-alert) 45%, transparent);
}

.blood {
  --fill: 0;
  width: 92px;
  height: 3px;
  background: var(--color-rule-2);
  position: relative;
  overflow: hidden;
}
.blood::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-accent);
  transform-origin: left;
  scale: var(--fill) 1;
  transition: scale var(--dur-short) var(--ease-out);
}

@media (max-width: 40rem) {
  .hud {
    inset: var(--space-sm) var(--space-md) auto;
    grid-template-columns: 1fr auto auto;
  }
  .hud__score {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: var(--text-2xl);
  }
}

/* ---- wave banner ---- */

.banner {
  position: fixed;
  inset: 30% 0 auto;
  z-index: var(--z-toast);
  pointer-events: none;
  display: grid;
  justify-items: center;
  gap: var(--space-2xs);
  text-shadow: 0 4px 30px var(--shadow);
  padding-block: var(--space-lg);
  background: linear-gradient(
    90deg,
    transparent,
    oklch(14% 0.02 45 / 0.7) 25%,
    oklch(14% 0.02 45 / 0.7) 75%,
    transparent
  );
  animation: arrive var(--dur-long) var(--ease-out);
}
.banner span {
  color: var(--color-muted);
  font-weight: 500;
}
.banner strong {
  font: 900 var(--text-display) / 0.9 var(--font-display);
  text-transform: uppercase;
}
.banner.is-alert strong {
  color: var(--color-alert);
}
@keyframes arrive {
  from {
    opacity: 0;
    scale: 1.08;
  }
}

.noscript {
  position: fixed;
  inset: auto var(--space-md) var(--space-md);
  padding: var(--space-md);
  background: var(--color-paper-2);
}

@media (prefers-reduced-motion: reduce) {
  .banner,
  .vignette.is-critical {
    animation: none;
  }
  .vignette.is-critical {
    opacity: 0.4;
  }
}
