/* Tokens ported from lib/ui/theme/sudoku_fog_tokens.dart (light). */
:root {
  --cream: #f4eee3;
  --card: #ffffff;
  --ink: #1c1d24;
  --ink2: #5d574a;
  --ink3: #9a917f;
  --blue: #1f6fe0;
  --blue-soft: #e7f0fd;
  --hard: #d8453f;
  --gold: #e0a01e;
  --line: rgba(28, 29, 36, 0.14);
  --line2: rgba(28, 29, 36, 0.46);
  --peer: rgba(31, 111, 224, 0.06);
  --same: rgba(31, 111, 224, 0.16);
  --wrong-bg: rgba(216, 69, 63, 0.12);
  --hint-bg: rgba(224, 160, 30, 0.14);
  --fog-base: rgba(138, 159, 220, 0.78);
  --fog-edge: rgba(138, 159, 220, 0.32);
  --radius: 14px;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--cream); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  display: flex; justify-content: center;
}

#app { width: 100%; max-width: 460px; padding: 8px 12px 16px; }

/* Header */
.header { display: flex; align-items: center; gap: 14px; padding: 10px 8px; }
.header .title { font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.header .spacer { flex: 1; }
#hearts { color: var(--hard); font-size: 18px; letter-spacing: 2px; }
.timer { display: flex; align-items: center; gap: 4px; color: var(--ink2); font-weight: 700; font-size: 15px; }

/* Board */
.board {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 #e7ded0, 0 8px 20px -12px rgba(40, 34, 20, 0.16);
  padding: 6px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 2px solid var(--line2);
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
}
.cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.cell:nth-child(9n) { border-right: none; }
.grid > .cell:nth-last-child(-n + 9) { border-bottom: none; }
.cell.bdr-r { border-right: 2px solid var(--line2); }
.cell.bdr-b { border-bottom: 2px solid var(--line2); }

.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.wrong { background: var(--wrong-bg); }
.cell.flash { background: var(--wrong-bg); animation: flash .35s ease; }
@keyframes flash { 0%, 100% { background: var(--wrong-bg); } 50% { background: rgba(216,69,63,.35); } }
.cell.sel::after {
  content: ""; position: absolute; inset: 1px;
  border: 2px solid var(--blue); border-radius: 3px; pointer-events: none;
}

.num { font-size: clamp(16px, 4.6vw, 22px); font-weight: 600; color: var(--blue); line-height: 1; }
.num.given { color: var(--ink); font-weight: 700; }
.num.wrongfg { color: var(--hard); }

.notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; padding: 2px; }
.notes span { display: flex; align-items: center; justify-content: center; font-size: clamp(7px, 1.9vw, 9px); color: var(--ink2); line-height: 1; }
.notes span.lit { color: var(--blue); font-weight: 700; }

/* Fog cell — inset:1px overlays so the grid lines stay visible. */
.cell.fog { cursor: default; }
.cell.fog::before {
  content: ""; position: absolute; inset: 1px;
  background-color: var(--fog-base);
  background-image: url("fog.webp");
  background-size: cover; background-position: center;
}
.cell.fog .mist {
  position: absolute; inset: 1px;
  background:
    radial-gradient(72% 64% at 38% 36%, rgba(255,255,255,.7), rgba(255,255,255,.18) 52%, transparent 76%),
    linear-gradient(135deg, var(--fog-edge), rgba(138,159,220,.22));
  animation: drift 2s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translate(0, 0); } to { transform: translate(2px, -1.5px); } }
@media (prefers-reduced-motion: reduce) { .cell.fog .mist { animation: none; } }

/* Action bar */
.actions { display: flex; gap: 8px; padding: 16px 8px 10px; }
.act {
  flex: 1; position: relative; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 6px; border-radius: var(--radius); color: var(--ink2);
  font-size: 11px; font-weight: 600;
}
.act .ic { font-size: 20px; line-height: 1; }
.act.active { background: var(--blue-soft); color: var(--blue); }
.act.disabled { opacity: .4; pointer-events: none; }
.badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  background: var(--gold); color: #fff; font-size: 9px; font-weight: 700;
  border-radius: 999px; padding: 1px 5px; line-height: 1.4;
}

/* Numpad */
.numpad { display: flex; gap: 5px; padding: 0 8px; }
.key {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer; padding: 8px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.key .kd { font-size: clamp(16px, 4.6vw, 20px); font-weight: 700; color: var(--ink); line-height: 1; }
.key .kr { font-size: 10px; color: var(--ink3); line-height: 1; }
.key.sel { background: var(--blue); border-color: var(--blue); }
.key.sel .kd, .key.sel .kr { color: #fff; }
.key.done { opacity: .42; }

/* Overlay */
.overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(20, 18, 12, 0.42); padding: 24px; z-index: 20;
}
.overlay.show { display: flex; }
.overlay .card {
  background: var(--card); border-radius: 20px; max-width: 360px; width: 100%;
  padding: 28px 24px 24px; text-align: center;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.3);
}
.overlay .fox { width: 96px; height: 96px; object-fit: contain; }
.overlay .cloud { font-size: 56px; }
.overlay h2 { margin: 12px 0 6px; font-size: 23px; font-weight: 800; }
.overlay .sub { margin: 0 0 12px; color: var(--ink2); font-size: 14px; }
.overlay .body { margin: 0 0 20px; color: var(--ink2); font-size: 14px; line-height: 1.45; }
.overlay .cta {
  width: 100%; background: var(--blue); color: #fff; border: none; cursor: pointer;
  border-radius: var(--radius); padding: 14px; font-size: 15px; font-weight: 700;
}
.overlay .cta.disabled { background: var(--ink3); cursor: default; pointer-events: none; }
.overlay .row { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.overlay .link { background: none; border: none; color: var(--ink2); cursor: pointer; font-size: 14px; padding: 8px 12px; }

/* Play-page header home link */
.home-link {
  text-decoration: none; color: var(--ink2); font-size: 26px; font-weight: 700;
  line-height: 1; padding: 0 2px; margin-right: -6px;
}

/* ── Landing page (SDD §14) ─────────────────────────────────────────────────── */
body[data-page="landing"] { display: block; }

.lp-top {
  max-width: 760px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
}
.lp-brand { font-size: 19px; font-weight: 800; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 9px; }
.lp-brand-icon { width: 28px; height: 28px; border-radius: 7px; display: block; }
.lp-top .lang-select { margin-left: auto; }
.lang-select {
  appearance: none; -webkit-appearance: none;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 30px 7px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235d574a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.lp { max-width: 760px; margin: 0 auto; padding: 8px 20px 40px; }

.lp-hero { text-align: center; padding: 24px 0 12px; }
.lp-kicker {
  display: inline-block; margin: 0 0 12px; padding: 4px 12px;
  background: var(--blue-soft); color: var(--blue); border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
}
.lp-hero h1 { margin: 0 0 14px; font-size: clamp(28px, 7vw, 44px); font-weight: 800; line-height: 1.12; }
.lp-sub { margin: 0 auto 22px; max-width: 540px; color: var(--ink2); font-size: 17px; line-height: 1.5; }

.lp-cta-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.lp-btn {
  display: inline-block; text-decoration: none; cursor: pointer;
  border-radius: var(--radius); padding: 14px 24px; font-size: 16px; font-weight: 700;
  border: 1px solid transparent;
}
.lp-btn.primary { background: var(--blue); color: #fff; box-shadow: 0 8px 20px -10px rgba(31,111,224,.7); }
.lp-btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.lp-btn.big { padding: 17px 40px; font-size: 18px; }
.lp-btn.disabled {
  background: var(--cream); color: var(--ink3); border-color: var(--line);
  box-shadow: none; cursor: default; pointer-events: none;
}

.lp-hero-img {
  display: block; margin: 28px auto 0; width: 100%; max-width: 300px; height: auto;
  border-radius: 20px; box-shadow: 0 24px 60px -24px rgba(40,34,20,.4);
}

.lp-sec { padding: 30px 0; border-top: 1px solid var(--line); }
.lp-sec h2 { margin: 0 0 14px; font-size: clamp(22px, 5vw, 30px); font-weight: 800; }
.lp-sec p { margin: 0; color: var(--ink2); font-size: 16px; line-height: 1.6; }

.lp-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 16px; }
.lp-steps li { position: relative; padding-left: 48px; counter-increment: step; }
.lp-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-soft); color: var(--blue);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.lp-steps h3 { margin: 4px 0 4px; font-size: 18px; font-weight: 700; }
.lp-steps p { font-size: 15px; }

.lp-feats { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.lp-feats li { position: relative; padding-left: 30px; color: var(--ink); font-size: 16px; line-height: 1.4; }
.lp-feats li::before { content: "✦"; position: absolute; left: 0; color: var(--gold); font-weight: 700; }

.lp-faq { display: grid; gap: 10px; }
.lp-faq details { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.lp-faq summary { cursor: pointer; padding: 14px 0; font-weight: 700; font-size: 16px; list-style: none; }
.lp-faq summary::-webkit-details-marker { display: none; }
.lp-faq summary::after { content: "+"; float: right; color: var(--ink3); font-weight: 700; }
.lp-faq details[open] summary::after { content: "–"; }
.lp-faq p { padding: 0 0 16px; color: var(--ink2); font-size: 15px; line-height: 1.55; }

.lp-final { text-align: center; padding: 36px 0 10px; }

.lp-footer { text-align: center; padding: 28px 20px 40px; color: var(--ink3); font-size: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
