:root {
  --bg: #0f172a;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --text: #e5eefb;
  --muted: #9fb0c7;
  --accent: #38bdf8;
  --accent-strong: #22c55e;
  --danger: #fb7185;
  --cell: #1e293b;
  --grid: rgba(148, 163, 184, 0.08);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.22), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.18), transparent 32rem),
    var(--bg);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.game-card {
  width: min(94vw, 620px);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.72));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero,
.scoreboard,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.status-pill {
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.92rem;
  white-space: nowrap;
}

.status-pill.playing {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}

.status-pill.ended {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.12);
}

.scoreboard {
  margin: 22px 0 18px;
}

.score-box {
  flex: 1;
  padding: 15px 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: var(--panel);
}

.score-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.score-box strong {
  font-size: 1.8rem;
  line-height: 1;
}

.board-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  background: var(--cell);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  background-color: #111827;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(4px);
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.overlay.hidden {
  visibility: hidden;
  opacity: 0;
}

.overlay strong {
  font-size: clamp(1.25rem, 4vw, 2rem);
}

.overlay span,
.hint {
  color: var(--muted);
}

.controls {
  margin-top: 18px;
  flex-wrap: wrap;
}

button {
  flex: 1;
  min-width: 130px;
  padding: 12px 16px;
  border: 0;
  border-radius: 16px;
  color: #082f49;
  background: linear-gradient(135deg, #7dd3fc, #38bdf8);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

#pauseBtn {
  color: #052e16;
  background: linear-gradient(135deg, #86efac, #22c55e);
}

#restartBtn {
  color: #3b0711;
  background: linear-gradient(135deg, #fda4af, #fb7185);
}

.hint {
  margin: 16px 4px 0;
  text-align: center;
  font-size: 0.92rem;
}

@media (max-width: 520px) {
  .game-card {
    padding: 18px;
    border-radius: 22px;
  }

  .hero,
  .scoreboard {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    text-align: center;
  }

  button {
    min-width: 100%;
  }
}
