/* India-Crossword — production styles.
   Design system carried over from the reference prototype (theme: Modern Minimal). */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }

:root {
  --bg: #fbfaf6;
  --paper: #ffffff;
  --ink: #181613;
  --ink-2: #4b463f;
  --ink-3: #8a8478;
  --rule: #e8e4da;
  --rule-strong: #1a1815;
  --accent: #5b7a5a;
  --accent-soft: #e6ede4;
  --accent-ink: #2f4a32;
  --highlight: #fff2b8;
  --cursor: #ffd84a;
  --error: #c8553d;
  --good: #5b7a5a;
  --correct: #2563d6;        /* confirmed-correct letters (locked) */

  --font-display: 'Domine', 'Tiro Devanagari Hindi', Georgia, serif;
  --font-body: 'Inter Tight', 'Noto Sans Devanagari', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-deva: 'Noto Sans Devanagari', system-ui, sans-serif;

  --radius: 4px;
  --radius-lg: 8px;
}

body {
  background: var(--bg);
  overscroll-behavior: none;
}

.app {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ── Masthead ─────────────────────────────────────────── */
.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding: 18px 32px 14px;
  border-bottom: 1.5px solid var(--rule-strong);
  background: var(--paper);
  gap: 12px;
  flex: 0 0 auto;
}
.masthead .left, .masthead .right {
  display: flex; gap: 16px; align-items: center;
  font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
  font-family: var(--font-mono);
}
.masthead .right { justify-content: flex-end; }
.masthead .title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 36px;
  letter-spacing: -0.01em;
  line-height: 0.95;
  text-align: center;
  color: var(--ink);
  white-space: nowrap;
}
.masthead .sub {
  font-family: var(--font-display);
  font-style: italic;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 4px;
}
.masthead .pip {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; vertical-align: middle;
}

/* ── Screens ──────────────────────────────────────────── */
main { flex: 1; min-height: 0; display: flex; position: relative; }
.screen {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  animation: screen-in .32s cubic-bezier(.2,.7,.3,1);
}
.screen.active { display: flex; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ── Home ─────────────────────────────────────────────── */
.home-wrap {
  flex: 1;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  background: var(--bg);
  overflow: auto;
  min-height: 0;
}
.home-hero {
  padding: 48px 52px 40px;
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 30px;
}
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 4.6vw, 60px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 14px 0 20px;
  color: var(--ink);
  font-weight: 700;
  text-wrap: balance;
}
.home-hero h1 em { font-style: italic; color: var(--accent); }
.home-hero .lede {
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 44ch;
  margin: 0;
}
.cta {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink);
  color: var(--paper);
  padding: 14px 22px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: transform .15s cubic-bezier(.2,.7,.3,1), background .15s;
}
.cta:hover { background: var(--accent-ink); transform: translateY(-1px); }
.cta:active { transform: translateY(0) scale(.99); }
.cta .arrow { font-size: 18px; transition: transform .18s; }
.cta:hover .arrow { transform: translateX(3px); }
.cta-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cta-secondary {
  background: transparent;
  color: var(--ink);
  padding: 13px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-size: 14px;
  transition: background .15s;
}
.cta-secondary:hover { background: var(--paper); }

.section-h {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.section-h::after { content: ''; flex: 1; height: 1px; background: var(--rule); }

/* Level selector — secondary segmented control (Easy / Medium / Hard) */
.level-select { display: flex; flex-direction: column; gap: 9px; margin-top: 30px; }
.level-label {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
}
.mode-bar {
  display: inline-flex;
  align-self: flex-start;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
}
.mode-opt {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 18px;
  background: var(--paper);
  border: none;
  border-right: 1px solid var(--rule);
  text-align: center;
  transition: background .15s;
}
.mode-opt:last-child { border-right: none; }
.mode-opt:hover { background: var(--bg); }
.mode-opt.active { background: var(--ink); }
.mode-opt.active:hover { background: var(--ink); }
.mode-opt.active .mode-name, .mode-opt.active .mode-size { color: var(--paper); }
.mode-name { font-family: var(--font-body); font-weight: 600; font-size: 13px; color: var(--ink); line-height: 1.1; }
.mode-size { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.06em; color: var(--ink-3); }

.cta-row { margin-top: 28px; }
.btn-text {
  color: var(--ink-2);
  font-size: 14px;
  padding: 13px 6px;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  transition: color .15s, border-color .15s;
}
.btn-text:hover { color: var(--ink); border-color: var(--ink-3); }
.small-meta { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); }

.home-side {
  padding: 48px 48px 40px;
  display: flex; flex-direction: column; gap: 28px;
  overflow: auto;
}
.streak-strip { display: flex; gap: 8px; margin-top: 8px; }
.streak-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.sd-day {
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 0.08em;
  color: var(--ink-3);
}
.streak-box {
  width: 22px; height: 22px;
  border-radius: var(--radius);
  background: var(--rule);
  transition: background .2s;
}
.streak-box.done { background: var(--accent); }
.streak-box.today { outline: 2px solid var(--ink); outline-offset: 2px; }
.sd-time {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  min-height: 11px;
  letter-spacing: -0.02em;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-top: 18px;
}
.stat { padding: 18px 0; border-right: 1px solid var(--rule); }
.stat:last-child { border-right: none; padding-left: 20px; }
.stat .num {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin-top: 6px;
}

.archive-list { display: flex; flex-direction: column; }
.archive-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 4px;
  border-top: 1px solid var(--rule);
  cursor: pointer;
  transition: background .15s;
  border-radius: var(--radius);
}
.archive-row:hover { background: var(--paper); }
.archive-row:last-child { border-bottom: 1px solid var(--rule); }
.archive-row .dno { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.08em; }
.archive-row .title { font-family: var(--font-display); font-size: 16px; color: var(--ink); font-weight: 600; }
.archive-row .meta {
  font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--ink-3); margin-top: 2px;
}
.archive-row .check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--rule-strong);
  display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 12px;
  transition: background .2s, border-color .2s, color .2s;
}
.archive-row.done .check { background: var(--accent); border-color: var(--accent); color: var(--paper); }

/* ── Puzzle screen ────────────────────────────────────── */
#screen-puzzle { overflow: hidden; }
.puzzle-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  flex: 0 0 auto;
  position: relative;
  z-index: 30;
}
.puzzle-toolbar .group { display: flex; align-items: center; gap: 10px; }
.tb-btn {
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em;
  text-transform: uppercase; transition: background .12s, color .12s;
  display: flex; align-items: center; gap: 6px;
  position: relative;
}
.tb-btn:hover { background: var(--bg); color: var(--ink); }
.tb-btn:disabled { opacity: .35; cursor: default; }
.tb-btn:disabled:hover { background: transparent; color: var(--ink-2); }
.tb-btn.timer { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; min-width: 86px; justify-content: center; }
.tb-btn.active { color: var(--accent-ink); }
.tb-dot {
  width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid var(--ink-3);
  background: transparent;
  transition: background .15s, border-color .15s;
}
.tb-btn.active .tb-dot { background: var(--accent); border-color: var(--accent); }

/* Toolbar dropdown */
.tb-menu-wrap { position: relative; }
.tb-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.06);
  padding: 5px;
  min-width: 168px;
  z-index: 60;
  display: none;
  animation: menu-in .16s cubic-bezier(.2,.7,.3,1);
  text-transform: none;
}
.tb-menu.open { display: block; }
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-5px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.tb-menu button {
  display: block; width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
  color: var(--ink);
  text-align: left;
  letter-spacing: 0;
  transition: background .12s;
}
.tb-menu button:hover { background: var(--bg); }
.tb-menu hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 4px; }
.tb-menu .danger { color: var(--error); }

.puzzle-wrap {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(360px, 1.25fr) minmax(190px, 0.8fr);
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.grid-pane {
  padding: 22px 28px 28px;
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
  position: relative;
}
.current-clue {
  width: 100%;
  max-width: 620px;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  margin-bottom: 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  flex: 0 0 auto;
  min-height: 54px;
}
.current-clue .num-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
}
.current-clue .clue-text {
  font-family: var(--font-display);
  font-size: 16.5px;
  color: var(--ink);
  line-height: 1.3;
  flex: 1;
}
.current-clue .nav { display: flex; gap: 4px; }
.current-clue .nav button {
  width: 30px; height: 30px;
  border: 1px solid var(--rule); background: var(--paper);
  border-radius: var(--radius); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background .12s, color .12s;
}
.current-clue .nav button:hover { background: var(--bg); color: var(--ink); }

.grid-shell {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}
.clear-wrong-cta {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--error);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.01em;
  padding: 11px 20px;
  border-radius: var(--radius);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--error) 28%, transparent);
  transition: transform .15s cubic-bezier(.2,.7,.3,1), background .15s, box-shadow .15s;
  animation: cta-pop .22s cubic-bezier(.2,.8,.3,1.2);
}
.clear-wrong-cta::before { content: '✕'; font-size: 12px; font-weight: 700; }
.clear-wrong-cta:hover { background: #b0472f; transform: translateY(-1px); box-shadow: 0 6px 20px color-mix(in srgb, var(--error) 36%, transparent); }
.clear-wrong-cta:active { transform: translateY(0) scale(.98); }
.clear-wrong-cta[hidden] { display: none; }
@keyframes cta-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.crossword-grid {
  border: 1.5px solid var(--rule-strong);
  background: var(--rule-strong);
  display: grid;
  gap: 1px;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.cell {
  background: var(--paper);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: background .12s;
}
.cell.block { background: var(--rule-strong); cursor: default; }
.cell .num {
  position: absolute; top: 1px; left: 3px;
  font-family: var(--font-mono);
  font-size: var(--num-size, 9.5px);
  color: var(--ink-2);
  line-height: 1;
  pointer-events: none;
}
.cell .letter {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-size: var(--letter-size, 20px);
  line-height: 1;
  padding-top: 12%;
  pointer-events: none;
}
.lang-hi .cell .letter {
  font-family: var(--font-deva);
  font-weight: 600;
  padding-top: 6%;
}
.cell .letter.pop { animation: letter-pop .18s cubic-bezier(.2,.9,.3,1.4); }
@keyframes letter-pop {
  0% { transform: scale(.55); opacity: .4; }
  100% { transform: scale(1); opacity: 1; }
}
.cell.in-word { background: var(--highlight); }
.cell.focused { background: var(--cursor); }
.cell.wrong .letter { color: var(--error); }
.cell.wrong::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to top right,
    transparent calc(50% - 1px), var(--error) calc(50% - 1px),
    var(--error) calc(50% + 0.5px), transparent calc(50% + 0.5px));
  opacity: .85;
  pointer-events: none;
}
.cell.revealed::after {
  content: '';
  position: absolute; bottom: 7%; right: 7%;
  width: 9%; height: 9%;
  min-width: 4px; min-height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
/* Confirmed-correct (via Check) — letters turn blue and lock */
.cell.locked { cursor: default; }
.cell.locked .letter { color: var(--correct); font-weight: 700; }
.cell.locked.focused { background: var(--cursor); }
.lang-hi .cell.locked .letter { color: var(--correct); }
.cell.win {
  animation: cell-wave .55s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: var(--wave-delay, 0s);
}
@keyframes cell-wave {
  0% { background: var(--paper); }
  45% { background: var(--accent); }
  100% { background: var(--accent-soft); }
}
.cell.win .letter { animation: letter-wave .55s cubic-bezier(.2,.7,.3,1) both; animation-delay: var(--wave-delay, 0s); }
@keyframes letter-wave {
  0% { transform: none; }
  45% { transform: translateY(-14%) scale(1.12); color: var(--paper); }
  100% { transform: none; }
}

/* ── Clue lists (side columns: Across left, Down right) ─── */
.clue-side {
  display: flex; flex-direction: column;
  overflow: hidden;
  padding: 22px 20px 18px;
  background: var(--paper);
  min-height: 0;
}
#side-across { border-right: 1px solid var(--rule); }
#side-down { border-left: 1px solid var(--rule); }
.clue-side h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule-strong);
  font-weight: 700;
}
.clue-list {
  list-style: none;
  margin: 0; padding: 0 0 12px;
  overflow-y: auto;
  flex: 1;
  font-size: 14px;
  scrollbar-width: thin;
  min-height: 0;
}
.clue-list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.35;
  color: var(--ink-2);
  align-items: baseline;
  transition: background .12s;
}
.clue-list li:hover { background: var(--bg); color: var(--ink); }
.clue-list li.active { background: var(--highlight); color: var(--ink); }
.clue-list li.active.this { background: var(--cursor); }
.clue-list li.done { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); text-decoration-thickness: 1px; }
.clue-list .n {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  letter-spacing: 0.04em;
}

/* ── On-screen keyboards ──────────────────────────────── */
.kbd {
  width: 100%;
  background: var(--bg);
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom, 0px));
  display: none;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--rule);
  flex: 0 0 auto;
  z-index: 20;
}
.kbd.visible { display: flex; }
.kbd-row { display: flex; gap: 5px; justify-content: center; }
.kbd button {
  flex: 1;
  max-width: 38px;
  height: 46px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 5px;
  font-family: var(--font-body);
  font-size: 16px; font-weight: 600;
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  transition: transform .08s, background .12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.kbd button:active { background: var(--accent-soft); transform: scale(.94); }
.kbd button.wide { max-width: 64px; font-size: 18px; }
.kbd.deva button { font-family: var(--font-deva); font-size: 17px; max-width: 44px; }

/* Hindi akshar bank shown on desktop too */
.akshar-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
  padding-top: 2px;
}

/* ── Overlays & modals ────────────────────────────────── */
.veil {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 40;
}
.veil.open { display: flex; animation: veil-in .25s ease; }
@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }
.veil-card { text-align: center; padding: 24px; }
.veil-card .big {
  font-family: var(--font-display);
  font-size: 44px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--ink); margin-bottom: 8px;
}
.veil-card .sub-t { color: var(--ink-2); font-size: 15px; margin-bottom: 24px; font-variant-numeric: tabular-nums; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(24, 22, 19, 0.4);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.open { display: flex; animation: veil-in .2s ease; }
.modal {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  max-height: 86dvh;
  overflow: auto;
  padding: 30px 32px 26px;
  box-shadow: 0 24px 70px rgba(0,0,0,.18);
  animation: modal-in .26s cubic-bezier(.2,.8,.3,1.1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal h2 {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  margin: 0 0 14px; color: var(--ink);
}
.modal p { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); margin: 0 0 12px; }
.modal ul { margin: 0 0 14px; padding-left: 18px; font-size: 14px; line-height: 1.7; color: var(--ink-2); }
.modal .key {
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--rule-strong);
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink);
  white-space: nowrap;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .cta { flex: 1; justify-content: center; }
.modal-actions .cta-secondary { flex: 1; text-align: center; }

/* ── Completion ───────────────────────────────────────── */
.complete-wrap {
  flex: 1;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--bg);
  overflow: auto;
  position: relative;
}
.complete-left {
  padding: 48px 52px;
  display: flex; flex-direction: column; justify-content: center;
  border-right: 1px solid var(--rule);
  gap: 0;
}
.confetti-row { display: flex; gap: 8px; margin-bottom: 26px; }
.confetti-row span { width: 14px; height: 14px; background: var(--accent); animation: conf-pop .5s cubic-bezier(.2,.9,.3,1.4) both; }
.confetti-row span:nth-child(2n) { background: var(--ink); }
.confetti-row span:nth-child(3n) { background: var(--cursor); }
.confetti-row span:nth-child(1) { animation-delay: .05s; }
.confetti-row span:nth-child(2) { animation-delay: .1s; }
.confetti-row span:nth-child(3) { animation-delay: .15s; }
.confetti-row span:nth-child(4) { animation-delay: .2s; }
.confetti-row span:nth-child(5) { animation-delay: .25s; }
.confetti-row span:nth-child(6) { animation-delay: .3s; }
.confetti-row span:nth-child(7) { animation-delay: .35s; }
.confetti-row span:nth-child(8) { animation-delay: .4s; }
.confetti-row span:nth-child(9) { animation-delay: .45s; }
.confetti-row span:nth-child(10) { animation-delay: .5s; }
@keyframes conf-pop { from { transform: scale(0) rotate(45deg); } to { transform: none; } }
.complete-left h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 5vw, 64px);
  letter-spacing: -0.025em;
  line-height: 0.98;
  margin: 0 0 18px;
  font-weight: 700;
  color: var(--ink);
}
.complete-left .lede {
  font-size: 17px;
  color: var(--ink-2);
  line-height: 1.55;
  max-width: 42ch;
  margin: 0 0 30px;
}
.share-card {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  padding: 24px 28px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  max-width: 440px;
}
.share-card .top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.share-card .big-time {
  font-family: var(--font-display);
  font-size: 52px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 8px;
}
.share-card .caption { font-size: 13.5px; color: var(--ink-2); margin-bottom: 16px; }
.share-grid {
  display: grid;
  gap: 1px;
  background: var(--rule);
  padding: 1px;
  width: 200px;
}
.share-grid .pixel { aspect-ratio: 1; background: var(--accent-soft); }
.share-grid .pixel.b { background: var(--ink); }
.share-grid .pixel.g { background: var(--accent); }
.view-solved {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  display: inline-flex; align-items: center; gap: 7px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--rule-strong);
  transition: gap .15s, color .15s, border-color .15s;
}
.view-solved::after { content: '→'; font-size: 13px; transition: transform .18s; }
.view-solved:hover { gap: 10px; color: var(--ink); border-color: var(--ink); }
.view-solved:hover::after { transform: translateX(2px); }
.share-actions { display: flex; gap: 10px; flex-wrap: wrap; max-width: 440px; }
.share-btn {
  flex: 1;
  min-width: 130px;
  background: var(--ink);
  color: var(--paper);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .15s;
}
.share-btn:hover { background: var(--accent-ink); transform: translateY(-1px); }
.share-btn.outline { background: transparent; color: var(--ink); border: 1px solid var(--rule-strong); }
.share-btn.outline:hover { background: var(--paper); }

.complete-right {
  padding: 48px 48px;
  display: flex; flex-direction: column; gap: 28px;
  overflow: auto;
}
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 18px 20px;
  border-radius: var(--radius);
}
.stat-card .big {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat-card .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin-top: 8px;
}
.stat-card .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.fact-list { display: flex; flex-direction: column; gap: 0; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); }
.fact {
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: baseline;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.fact + .fact { border-top: 1px solid var(--rule); }
.fact .ans {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 3px 7px;
  border-radius: 3px;
  text-transform: uppercase;
}
.lang-hi .fact .ans { font-family: var(--font-deva); text-transform: none; }

/* Falling confetti */
.confetti-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -16px;
  width: 9px; height: 14px;
  animation: conf-fall linear both;
}
@keyframes conf-fall {
  0% { transform: translateY(-20px) rotate(0) rotateY(0); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(105vh) rotate(560deg) rotateY(960deg); opacity: 0; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 100px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s cubic-bezier(.2,.7,.3,1);
  z-index: 300;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive: mobile ───────────────────────────────── */
@media (max-width: 880px) {
  .masthead { padding: 10px 14px 8px; grid-template-columns: auto 1fr auto; align-items: center; }
  .masthead .left { display: none; }
  .masthead .title { font-size: 21px; text-align: left; }
  .masthead .sub { display: none; }
  .masthead .center { justify-self: start; }
  .masthead .right { gap: 8px; }
  .masthead .right .mono-extra { display: none; }

  .home-wrap { grid-template-columns: 1fr; overflow: auto; }
  .home-hero { padding: 26px 20px 24px; border-right: none; border-bottom: 1px solid var(--rule); gap: 22px; }
  .home-hero h1 { font-size: 34px; }
  .home-hero .lede { font-size: 15px; }
  .home-side { padding: 24px 20px 40px; gap: 24px; }

  .puzzle-wrap { display: flex; flex-direction: column; min-height: 0; }
  .grid-pane { padding: 10px 10px 8px; border-right: none; flex: 1; min-height: 0; }
  .grid-shell { justify-content: center; gap: 10px; }
  .clear-wrong-cta { padding: 10px 16px; font-size: 13px; }
  #tb-issue { display: none; }
  .current-clue { margin-bottom: 10px; padding: 8px 12px; min-height: 46px; max-width: none; }
  .current-clue .clue-text { font-size: 14px; }
  .current-clue .num-tag { font-size: 10px; padding: 3px 6px; }
  .clue-side { display: none; }
  .puzzle-toolbar { padding: 7px 5px; font-size: 10px; }
  .puzzle-toolbar .group { gap: 1px; }
  .tb-btn { padding: 5px 5px; font-size: 10px; gap: 4px; }
  .tb-btn.timer { min-width: 58px; }
  #btn-auto { padding-left: 3px; padding-right: 3px; }

  .complete-wrap { grid-template-columns: 1fr; }
  .complete-left { padding: 30px 20px; border-right: none; border-bottom: 1px solid var(--rule); }
  .complete-left h1 { font-size: 40px; }
  .complete-right { padding: 24px 20px 44px; gap: 22px; }
  .share-card { padding: 20px 22px; }
  .share-card .big-time { font-size: 42px; }

  .modal { padding: 24px 22px 20px; }
  .modal h2 { font-size: 24px; }
  .veil-card .big { font-size: 34px; }

  .kbd button { height: 44px; max-width: 36px; font-size: 15px; }
  .kbd.deva button { max-width: 42px; }
}

@media (max-width: 380px) {
  .kbd button { height: 42px; font-size: 14px; }
  .masthead .title { font-size: 18px; }
}

/* Subtle scrollbars */
.clue-list::-webkit-scrollbar { width: 8px; }
.clue-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.clue-list::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* Focus rings for accessibility */
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
