:root {
  --bg: #07111f;
  --bg-soft: rgba(255, 255, 255, 0.05);
  --panel: rgba(9, 18, 33, 0.78);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #e8eef7;
  --muted: #9fb0c7;
  --accent: #58d5c9;
  --accent-2: #90f0a8;
  --warn: #ffce63;
  --bad: #7d8da8;
  --good: #47cb8f;
  --radius: 20px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(88, 213, 201, 0.12), transparent 26%),
    radial-gradient(circle at top right, rgba(144, 240, 168, 0.10), transparent 24%),
    linear-gradient(180deg, #07111f 0%, #091728 100%);
  color: var(--text);
}
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.22;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, black 45%, transparent 88%);
}
.app-shell {
  max-width: 860px; margin: 0 auto; padding: 28px 18px 60px;
}
.topbar, .hero-card, .board-wrap, .input-wrap, .clue-wrap, .status-row, .result-card {
  backdrop-filter: blur(16px);
}
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px;
}
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; }
h1 { margin: 6px 0 0; font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 0.98; letter-spacing: -0.05em; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn, .primary-btn, .secondary-btn {
  border: 1px solid var(--panel-border); color: var(--text); cursor: pointer;
}
.icon-btn {
  background: var(--bg-soft); width: 46px; height: 46px; border-radius: 14px; font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.09); }

/* ── Visitor flip counter ─────────────────────────────────────── */
.visitor-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.visitor-label {
  font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.flip-counter {
  display: flex; gap: 4px; align-items: center;
}
.flip-digit {
  width: 28px; height: 38px; border-radius: 6px;
  background: #0b1828; border: 1px solid rgba(88, 213, 201, 0.22);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; font-weight: 700;
  color: var(--accent); position: relative; overflow: hidden;
}
.flip-digit::before {
  content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px;
  background: rgba(88, 213, 201, 0.15);
}
.flip-digit span {
  display: block; animation: flipIn 0.35s ease both;
}
@keyframes flipIn {
  from { transform: rotateX(90deg) translateY(-6px); opacity: 0; }
  to   { transform: rotateX(0deg)  translateY(0);    opacity: 1; }
}
.flip-sep {
  font-family: 'JetBrains Mono', monospace; color: var(--accent); font-size: 1.1rem;
  opacity: 0.5; margin: 0 1px; line-height: 1;
}

/* ── Hero card & handwritten tagline ────────────────────────── */
.hero-card, .board-wrap, .input-wrap, .clue-wrap, .result-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.hero-card { padding: 22px; margin-bottom: 18px; }
.tagline {
  margin: 0; color: #d6e0ef;
  font-family: 'Caveat', cursive;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  line-height: 1.3;
}
.strike-comic {
  position: relative;
  display: inline-block;
  color: rgba(214, 224, 239, 0.55);
}
/* Wobbly hand-drawn strikethrough using SVG via pseudo-element */
.strike-comic::after {
  content: '';
  position: absolute;
  left: -4px; right: -4px;
  top: 52%;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(-3deg) skewX(-5deg);
  opacity: 0.85;
}
.replacement {
  color: var(--accent-2);
  font-weight: 700;
  font-style: italic;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pill {
  display: inline-flex; align-items: center; padding: 8px 12px; border-radius: 999px; font-size: 0.84rem;
  color: var(--muted); background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.07);
  font-family: Inter, sans-serif;
}

/* ── Board ───────────────────────────────────────────────────── */
.board-wrap { padding: 16px; }
.board { display: grid; gap: 10px; }
.board-row { display: grid; gap: 10px; }
.cell {
  min-height: 58px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.03);
  display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.1rem, 3vw, 1.5rem); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  transition: background 0.2s, border-color 0.2s;
}
.cell.pending { border-color: rgba(88, 213, 201, 0.35); box-shadow: inset 0 0 0 1px rgba(88, 213, 201, 0.22); }
.cell.correct { background: rgba(71, 203, 143, 0.18); border-color: rgba(71, 203, 143, 0.45); }
.cell.present { background: rgba(255, 206, 99, 0.16); border-color: rgba(255, 206, 99, 0.45); }
.cell.absent  { background: rgba(125, 141, 168, 0.14); border-color: rgba(125, 141, 168, 0.35); color: #9eabc0; }
/* Ghost hint row — replicates previous row's palette, dimmed */
.cell.hint-correct { background: rgba(71, 203, 143, 0.08);  border-color: rgba(71, 203, 143, 0.28); }
.cell.hint-present { background: rgba(255, 206, 99, 0.07);  border-color: rgba(255, 206, 99, 0.28); }
.cell.hint-absent  { background: rgba(125, 141, 168, 0.07); border-color: rgba(125, 141, 168, 0.2); color: rgba(158,171,192,0.5); }

/* ── Input ───────────────────────────────────────────────────── */
.input-wrap { padding: 16px; margin-top: 18px; }
.guess-box { display: flex; gap: 12px; }
#guessInput {
  width: 100%; padding: 16px 18px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035); color: var(--text); font-size: 1rem; text-transform: uppercase;
}
#guessInput:focus { outline: 1px solid rgba(88,213,201,0.45); }
.primary-btn, .secondary-btn {
  padding: 0 18px; border-radius: 16px; min-height: 54px; font-weight: 700;
}
.primary-btn { background: linear-gradient(135deg, rgba(88,213,201,0.32), rgba(144,240,168,0.25)); }
.secondary-btn { background: rgba(255,255,255,0.04); }
.microcopy { color: var(--muted); font-size: 0.88rem; margin: 12px 2px 0; }

/* ── Clue / Hint area ────────────────────────────────────────── */
.clue-wrap { padding: 16px; margin-top: 18px; display: grid; gap: 14px; }
.clue-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.hint-btn {
  padding: 0 18px; border-radius: 16px; min-height: 48px; font-weight: 700; cursor: pointer;
  background: rgba(88, 213, 201, 0.1); border: 1px solid rgba(88, 213, 201, 0.3); color: var(--accent);
  font-size: 0.92rem;
}
.hint-btn:hover { background: rgba(88, 213, 201, 0.18); }
.hint-btn span, .secondary-btn span { font-size: 0.78rem; opacity: 0.7; margin-left: 4px; }
.clue-card {
  padding: 14px 16px; border-radius: 16px; border: 1px solid rgba(255,206,99,0.28); background: rgba(255,206,99,0.08);
  color: #f3deb0;
}
.hint-card {
  padding: 12px 16px; border-radius: 16px; border: 1px solid rgba(88,213,201,0.25); background: rgba(88,213,201,0.06);
  color: var(--accent); font-size: 0.9rem;
}

/* ── Status row ──────────────────────────────────────────────── */
.status-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px;
}
.status-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 18px; padding: 16px; text-align: center;
}
.status-label { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }
.status-card strong { font-size: 1.2rem; }

/* ── Result card ─────────────────────────────────────────────── */
.result-card { padding: 18px; margin-top: 18px; }
.result-card h3 { margin: 0 0 8px; font-size: 1.6rem; }
.result-card p { color: #d8e2f0; }
.result-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
  margin-top: 26px; color: var(--muted); font-size: 0.88rem;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }
.dot { opacity: 0.5; }
.footer-share-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 1px solid rgba(255,255,255,0.1); color: var(--muted);
  padding: 5px 12px; border-radius: 99px; font-size: 0.82rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.footer-share-btn:hover { background: rgba(88,213,201,0.1); color: var(--accent); border-color: rgba(88,213,201,0.3); }

/* ── Misc ─────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.modal { border: none; padding: 0; background: transparent; color: var(--text); }
.modal::backdrop { background: rgba(3, 8, 18, 0.7); }
.modal-card {
  width: min(92vw, 520px); margin: auto; padding: 22px; border-radius: 24px; background: #0b1424;
  border: 1px solid rgba(255,255,255,0.08); box-shadow: var(--shadow);
}
.modal-card h2 { margin-top: 0; }
.modal-card ul { color: #d7e0ed; line-height: 1.8; padding-left: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0; }
.stats-grid div { padding: 12px; border-radius: 14px; background: rgba(255,255,255,0.04); }
.stats-grid span { display: block; color: var(--muted); font-size: 0.84rem; }
.stats-grid strong { display: block; margin-top: 6px; font-size: 1.2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Cookie bar ──────────────────────────────────────────────── */
#cookieBar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px;
  padding: 14px 20px; background: rgba(9, 18, 33, 0.97);
  border-top: 1px solid rgba(88, 213, 201, 0.2); backdrop-filter: blur(12px);
  font-size: 0.88rem; color: #9fb0c7;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#cookieBar span { max-width: 560px; }
#cookieBar button {
  padding: 8px 20px; border-radius: 12px; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  background: linear-gradient(135deg, rgba(88,213,201,0.32), rgba(144,240,168,0.25));
  border: 1px solid rgba(88, 213, 201, 0.4); color: #e8eef7; white-space: nowrap;
}
#cookieBar button:hover { background: rgba(88, 213, 201, 0.25); }
.cookie-hide { opacity: 0; transform: translateY(12px); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app-shell { padding: 16px 12px 48px; }
  .guess-box { flex-direction: column; }
  .primary-btn, .secondary-btn, .hint-btn { width: 100%; }
  .status-row { grid-template-columns: 1fr; }
  .cell { min-height: 50px; }
  .tagline { font-size: clamp(1.3rem, 5vw, 1.6rem); }
  .flip-digit { width: 24px; height: 32px; font-size: 0.95rem; }
}
