:root {
  --bg-deep: #0b0716;
  --bg-card: #160f28;
  --bg-card-2: #1c1336;
  --purple: #a855f7;
  --purple-bright: #c084fc;
  --purple-dim: #6d28d9;
  --violet-glow: rgba(168, 85, 247, 0.35);
  --text-main: #f4f1fb;
  --text-muted: #a597c4;
  --food: #fb7185;
  --food-glow: rgba(251, 113, 133, 0.45);
  --border: rgba(168, 85, 247, 0.25);
}

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

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 15%, rgba(168, 85, 247, 0.18), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(124, 58, 237, 0.16), transparent 50%),
    var(--bg-deep);
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app { width: 100%; max-width: 460px; }

.card {
  background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 26px 26px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.02) inset,
    0 30px 60px -20px rgba(0,0,0,0.6),
    0 0 60px -15px var(--violet-glow);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: -60%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: conic-gradient(from 180deg, transparent, var(--violet-glow), transparent 35%);
  animation: spin 16s linear infinite;
  opacity: 0.4;
  pointer-events: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

header { text-align: center; margin-bottom: 18px; position: relative; z-index: 1; }

h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--purple-bright), var(--purple), #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% auto;
  animation: shimmer 4s ease-in-out infinite;
  margin-bottom: 12px;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.score-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.score-pill {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.score-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--purple-bright);
}

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 0 30px -10px var(--violet-glow), inset 0 0 30px rgba(0,0,0,0.4);
  margin-bottom: 18px;
  z-index: 1;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 50% 50%, rgba(168,85,247,0.05), transparent 70%),
    #08050f;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8, 5, 15, 0.78);
  backdrop-filter: blur(3px);
  text-align: center;
  padding: 20px;
  transition: opacity 0.2s;
}

.overlay.hidden { display: none; }

.overlay p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.overlay h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  color: var(--food);
  text-shadow: 0 0 18px var(--food-glow);
}

.final-score {
  color: var(--text-main) !important;
  font-size: 15px !important;
}

.final-score span {
  color: var(--purple-bright);
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}

.primary-btn {
  background: linear-gradient(135deg, var(--purple), var(--purple-dim));
  border: none;
  color: white;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 22px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 0 20px -4px var(--violet-glow);
  transition: transform 0.15s, box-shadow 0.2s;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 26px -2px var(--violet-glow);
}

.primary-btn:active { transform: translateY(0) scale(0.97); }

.dpad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.dpad-mid { display: flex; gap: 6px; align-items: center; }

.dpad-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid var(--border);
  color: var(--purple-bright);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.dpad-btn:active {
  background: rgba(168, 85, 247, 0.25);
  transform: scale(0.92);
}

@media (pointer: coarse) {
  .dpad { display: flex; }
}

.reset-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  z-index: 1;
}

.reset-btn:hover {
  border-color: var(--food);
  color: var(--food);
  background: rgba(251, 113, 133, 0.06);
}

@media (max-width: 380px) {
  h1 { font-size: 20px; }
}