:root {
  --bg: #070a12;
  --panel: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8edf7;
  --muted: #8b94a8;
  --accent: #35d0e0;
  --accent2: #a76bf0;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 75% -10%, rgba(53, 208, 224, 0.10), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(167, 107, 240, 0.12), transparent 60%),
    linear-gradient(180deg, #0a0f1c, #05070d 72%);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "DejaVu Sans", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: auto;
}

.game {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
}

.board-wrap { position: relative; border-radius: 14px; }

#board {
  display: block;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #080b13;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 60px rgba(53, 208, 224, 0.05);
}

/* ---------- overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(6, 9, 16, 0.74);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 1;
  transition: opacity 0.18s ease;
  z-index: 2;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-card {
  max-width: 88%;
  padding: 18px;
  text-align: center;
}

.overlay-card h1 {
  margin: 0 0 8px;
  font-size: 34px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff, #7fd9e5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.overlay-card p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-line;
}

/* ---------- buttons ---------- */

.btn {
  border: 1px solid rgba(53, 208, 224, 0.5);
  border-radius: 11px;
  padding: 11px 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #d9fbff;
  background: linear-gradient(180deg, rgba(53, 208, 224, 0.26), rgba(53, 208, 224, 0.08));
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 6px 20px rgba(53, 208, 224, 0.14);
}

.btn:hover {
  background: linear-gradient(180deg, rgba(53, 208, 224, 0.38), rgba(53, 208, 224, 0.14));
  box-shadow: 0 8px 26px rgba(53, 208, 224, 0.24);
}

.btn:active { transform: translateY(1px) scale(0.99); }

.btn.ghost {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--muted);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: none;
}

.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }

/* ---------- side panel ---------- */

.panel {
  width: 190px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  backdrop-filter: blur(4px);
}

.box h2 {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.stat span {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat b {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

#score, #best { font-size: 17px; }

.mini { display: flex; gap: 11px; }

.mini .box { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.mini canvas { display: block; margin: 0 auto; }

.controls .row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  padding: 2.5px 0;
}

.controls .row i { font-style: normal; margin-left: auto; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 10.5px;
  text-align: center;
}

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

.touch {
  display: none;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.touch button {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
}

.touch button:active {
  background: rgba(53, 208, 224, 0.22);
  border-color: rgba(53, 208, 224, 0.5);
}

@media (pointer: coarse) {
  .touch { display: flex; }
  .controls { display: none; }
}

@media (max-width: 820px) {
  body { gap: 10px; padding: 10px; }
  .game { flex-direction: column; align-items: center; gap: 10px; }
  .panel { width: min(94vw, 430px); gap: 9px; }
  .box { padding: 9px 10px; }
  .mini .box { padding-bottom: 6px; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 4px 8px; }
  .stat b, #score, #best { font-size: 15px; }
  .stat span { font-size: 9px; }
  .touch { display: flex; }
  .controls { display: none; }
}

@media (max-width: 820px) and (pointer: fine) {
  .touch { display: none; }
}

@media (max-width: 400px) {
  .touch button { width: 46px; height: 46px; font-size: 18px; }
}
