:root {
  font-family: ui-monospace, 'SF Mono', Menlo, Monaco, monospace;
  color-scheme: dark;
  --bg: #050507;
  --fg: #e5e5e5;
  --muted: #888;
  --dim: #555;
  --border: #1f1f26;
  --accent: #4ade80;
  --danger: #f87171;
  --cell: #0d0d13;
  --cell-hover: #13131a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  background: radial-gradient(ellipse at top, #0a0a14 0%, var(--bg) 70%);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 100vh;
}

header h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff, #888);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.25rem;
}

header h1::before {
  content: '> ';
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

.home-link {
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s;
}
.home-link:hover { opacity: 0.75; }

.tagline {
  color: var(--muted);
  font-size: 0.9rem;
}

/* HUD */
.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(13, 13, 18, 0.6);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.stat .label {
  font-size: 0.65rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat .value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  aspect-ratio: 1;
}

.cell {
  background: var(--cell);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  cursor: pointer;
  position: relative;
  transition: background 0.1s, transform 0.1s;
  overflow: hidden;
}

.cell:hover {
  background: var(--cell-hover);
}

.cell .bug {
  display: block;
  transform: scale(0);
  transition: transform 0.15s cubic-bezier(0.3, 1.7, 0.6, 1);
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(74, 222, 128, 0.3));
}

.cell.active .bug {
  transform: scale(1);
}

.cell.smashed {
  animation: smash 0.3s ease;
}

.cell.smashed::after {
  content: '+1';
  position: absolute;
  color: var(--accent);
  font-weight: 600;
  font-size: 1rem;
  animation: floatUp 0.6s ease forwards;
  pointer-events: none;
}

.cell.missed::after {
  content: '-1';
  position: absolute;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.9rem;
  animation: floatUp 0.6s ease forwards;
  pointer-events: none;
}

@keyframes smash {
  0% { transform: scale(1); }
  40% { transform: scale(0.88); background: rgba(74, 222, 128, 0.15); }
  100% { transform: scale(1); }
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-24px); }
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 2rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.05em;
}

button:hover {
  background: rgba(74, 222, 128, 0.1);
  box-shadow: 0 0 20px rgba(74, 222, 128, 0.2);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  min-height: 1.2em;
}

footer {
  margin-top: auto;
  padding-top: 1rem;
  text-align: center;
}

footer a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
}

footer a:hover {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
