:root {
  --purple: #7c3aed;
  --purple-dark: #6d28d9;
  --bg: #0f1024;
  --bg-2: #1a1840;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f4f3ff;
  --muted: #b8b5d8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(140% 120% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 10px)
    calc(env(safe-area-inset-right) + 12px)
    calc(env(safe-area-inset-bottom) + 12px)
    calc(env(safe-area-inset-left) + 12px);
  gap: 10px;
}

/* ── HUD ───────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 8px 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.stat.combo {
  margin-left: auto;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.stat strong {
  font-size: 18px;
  font-weight: 800;
}

.stat.lives strong {
  color: #ff7a90;
  letter-spacing: 1px;
}

.icon-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn.muted {
  opacity: 0.45;
}

/* ── Prompt ────────────────────────────────────── */
.prompt-wrap {
  text-align: center;
}

.rule-banner {
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 16px;
  border-radius: 999px;
  background: var(--purple);
  color: #fff;
  transition: background 0.2s, transform 0.2s;
}
.rule-banner.ink {
  background: #0ea5e9;
}
.rule-banner.flip {
  animation: pop 0.35s ease;
}

.prompt-word {
  font-size: clamp(44px, 14vw, 76px);
  font-weight: 900;
  line-height: 1.05;
  margin-top: 6px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}

/* ── Timer ─────────────────────────────────────── */
.timer-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.timer-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #fbbf24, #f87171);
  transform-origin: left center;
}

/* ── Board ─────────────────────────────────────── */
.board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ── Overlays ──────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 24, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 18px;
  padding: 16px;
  z-index: 5;
}
.overlay.hidden {
  display: none;
}

.overlay-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 26px 22px;
}

.logo-emoji {
  font-size: 52px;
}

.overlay-card h1 {
  font-size: 30px;
  font-weight: 900;
  margin: 6px 0 2px;
}

.tagline {
  color: var(--muted);
  margin-bottom: 14px;
}

.how-to {
  list-style: none;
  text-align: left;
  font-size: 14px;
  color: var(--muted);
  margin: 0 auto 18px;
  display: grid;
  gap: 8px;
  max-width: 280px;
}
.how-to b {
  color: var(--text);
}

.primary-btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  background: var(--purple);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.primary-btn:hover {
  background: var(--purple-dark);
}
.primary-btn:active {
  transform: scale(0.97);
}

.ghost-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.ghost-link:hover {
  color: var(--text);
}

.final-stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 14px 0;
}
.final-stats div {
  display: flex;
  flex-direction: column;
}
.final-stats strong {
  font-size: 26px;
  font-weight: 900;
}

.new-best {
  color: #fbbf24;
  font-weight: 800;
  margin-bottom: 12px;
}
.new-best.hidden {
  display: none;
}

@keyframes pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
