:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3dd6c6;
  --accent-dim: #2a9d8f;
  --danger: #ef476f;
  --grid: #1e2a3a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 214, 198, 0.12), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.game-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  align-items: flex-start;
}

.panel {
  flex: 1 1 160px;
  max-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.stat-box h2 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-box canvas {
  display: block;
  margin: 0 auto;
  background: var(--grid);
  border-radius: 8px;
}

.value {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.board-wrap {
  position: relative;
  flex: 0 0 auto;
}

#board {
  display: block;
  background: var(--grid);
  border: 2px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 25, 0.85);
  border-radius: 8px;
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  text-align: center;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 90%;
}

.overlay-card h2 {
  margin: 0 0 0.5rem;
}

.overlay-card p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

button {
  cursor: pointer;
  font: inherit;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

button:hover {
  background: #243044;
  border-color: var(--accent-dim);
}

button:active {
  transform: scale(0.98);
}

#btn-start {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  color: #0f1419;
  border: none;
  font-weight: 600;
}

#btn-start:hover {
  filter: brightness(1.08);
}

#overlay-btn {
  background: var(--accent);
  color: #0f1419;
  border: none;
  font-weight: 600;
}

.help ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.help li {
  margin-bottom: 0.25rem;
}

kbd {
  display: inline-block;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
  background: var(--grid);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

.footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .panel-left {
    order: 2;
    flex-direction: row;
    max-width: 100%;
    flex: 1 1 100%;
    justify-content: center;
  }

  .panel-left .stat-box {
    flex: 1;
    max-width: 160px;
  }

  .board-wrap {
    order: 1;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  #board {
    max-width: 100%;
    height: auto;
  }

  .panel-right {
    order: 3;
    max-width: 100%;
  }
}
