:root {
  --bg: #05060c;
  --bg-2: #0a0d1a;
  --ink: #e8ecff;
  --dim: #6b7398;
  --line: rgba(140, 160, 255, 0.14);
  --accent: #6ef2ff;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1200px 800px at 50% -10%, #131a35 0%, transparent 60%),
    radial-gradient(900px 700px at 90% 110%, #1a1230 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(10px, 2.5vh, 26px) 14px calc(clamp(10px, 2.5vh, 26px) + env(safe-area-inset-bottom));
  gap: clamp(8px, 2vh, 20px);
}

/* ---------- header ---------- */
.head {
  text-align: center;
  flex: 0 0 auto;
}

.title {
  margin: 0;
  font-size: clamp(20px, 4.4vw, 30px);
  font-weight: 700;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: #fff;
  text-shadow: 0 0 18px rgba(110, 242, 255, 0.55), 0 0 46px rgba(110, 242, 255, 0.25);
}

.tagline {
  margin: 6px 0 0;
  font-size: clamp(9px, 2.4vw, 11px);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ---------- board ---------- */
.board-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

#board {
  display: block;
  touch-action: none;
  cursor: pointer;
  border-radius: 18px;
}

/* ---------- overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(closest-side, rgba(5, 6, 12, 0.86), rgba(5, 6, 12, 0.62));
  backdrop-filter: blur(3px);
  animation: fade 0.35s ease both;
  border-radius: 18px;
}

.overlay[hidden] { display: none; }

.overlay-inner { text-align: center; }

.overlay-title {
  margin: 0;
  font-size: clamp(26px, 8vw, 46px);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: #fff;
  text-shadow: 0 0 22px rgba(160, 255, 220, 0.7), 0 0 60px rgba(110, 242, 255, 0.4);
}

.overlay-sub {
  margin: 10px 0 22px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim);
}

/* ---------- footer ---------- */
.foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.6vh, 14px);
}

.controls { display: flex; gap: 10px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(140, 160, 255, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.1s;
}

.btn:hover {
  border-color: rgba(110, 242, 255, 0.55);
  box-shadow: 0 0 20px rgba(110, 242, 255, 0.18);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  border-color: rgba(110, 242, 255, 0.6);
  box-shadow: 0 0 24px rgba(110, 242, 255, 0.22);
}

.btn-ghost { color: var(--dim); }

.meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
  color: var(--dim);
}

#remaining {
  color: var(--ink);
  font-size: 15px;
  min-width: 1.6em;
  text-align: right;
}

.meta-label {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 9px;
}

.sizes { display: flex; gap: 6px; }

.chip {
  appearance: none;
  background: none;
  border: 0;
  color: var(--dim);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.16em;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.18s, color 0.18s;
}

.chip:hover { opacity: 1; }

.chip.is-active {
  opacity: 1;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(110, 242, 255, 0.5);
}

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

@media (prefers-reduced-motion: reduce) {
  .overlay { animation: none; }
}
