/* CAMEL Daily — web daily player.
   Dark-first to match the app's default theme (app_theme.dart: ThemeMode.dark,
   background #16181D). Kept deliberately small; no framework, no web fonts, so
   first paint on mobile web (where shared links open) stays fast. */

:root {
  --bg: #16181d;
  --surface: #1e2128;
  --surface-2: #262a33;
  --line: #333844;
  --ink: #f2f4f8;
  --ink-dim: #9aa3b2;
  --accent: #f5b301;      /* CAMEL amber */
  --accent-ink: #16181d;
  --active: #2f5fea;
  --active-soft: #2f5fea33;
  --good: #34c759;
  --bad: #ff453a;
  --cell: clamp(38px, 15vw, 60px);
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
  max-width: 520px;
  margin: 0 auto;
}

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 10px;
}
.brand { font-weight: 800; letter-spacing: 0.5px; font-size: 20px; }
.brand span { color: var(--accent); }
.meta { display: flex; gap: 8px; }
.pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.timer { min-width: 56px; text-align: center; }
.pill.icon {
  color: var(--ink);
  cursor: pointer;
  width: 30px;
  height: 30px;
  padding: 0;
  font-weight: 700;
  line-height: 1;
  /* Flex-centred so the "?" glyph and the feedback SVG both sit dead centre;
     the glyph alone used to rely on line-height, which the icon cannot. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pill.icon:active { background: var(--surface-2); }

main { width: 100%; }

/* ── Grid ────────────────────────────────────────────────── */
.board { display: flex; flex-direction: column; align-items: center; margin: 8px 0 4px; }
.grid {
  display: grid;
  gap: 3px;
  background: var(--line);
  padding: 3px;
  border-radius: 8px;
}
.cell {
  width: var(--cell);
  height: var(--cell);
  position: relative;
  background: var(--surface);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * 0.5);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  color: var(--ink);
}
.cell.black { background: transparent; cursor: default; }
.cell.in-entry { background: var(--active-soft); }
.cell.active { background: var(--active); color: #fff; }
.cell.wrong { color: var(--bad); }
.cell.locked { color: var(--good); }
/* Candidate digits. Small, dim and centred under the numbering, so a cell
   with notes never reads as a cell with an answer. */
.cell .pencil {
  font-size: calc(var(--cell) * 0.24);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 1px;
  color: var(--ink-dim);
  padding: 0 2px;
  word-break: break-all;
  text-align: center;
}
.cell .num {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: calc(var(--cell) * 0.22);
  font-weight: 600;
  color: var(--ink-dim);
}
.difficulty { color: var(--ink-dim); font-size: 13px; margin: 8px 0 0; }

/* First-visit hint. Deliberately a strip in the flow rather than an overlay:
   it must never cover the grid, because the grid is the thing that sells the
   puzzle. Accent rule on the left so it reads as a note, not as an error. */
.first-hint {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 10px 0 0;
  padding: 8px 10px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.4;
}
.first-hint > span { flex: 1; }
.first-hint a { color: var(--accent); white-space: nowrap; }
.howto-more { margin: 14px 0 0; font-size: 14px; }
.howto-more a { color: var(--accent); }
/* 28px box around a 16px glyph: the visible mark stays small, the tap target
   does not. */
.hint-x {
  background: none;
  border: 0;
  padding: 0;
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--ink-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* ── Clues ───────────────────────────────────────────────── */
.clues { width: 100%; margin-top: 12px; }
.clues h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-dim); margin: 0 0 8px; }
#clue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#clue-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  cursor: pointer;
}
#clue-list li.lit { border-color: var(--accent); }
.how { color: var(--ink-dim); font-size: 13px; line-height: 1.4; margin-top: 10px; }

/* Check's answer. Sits under the actions and is empty until Check is pressed,
   so it costs no space in the default layout. */
.check-status {
  width: 100%;
  min-height: 18px;
  margin: -8px 0 12px;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

/* Glossary terms inside clue text */
.term {
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 3px;
  cursor: help;
}

/* ── Keypad ──────────────────────────────────────────────── */
.keypad {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 14px 0 8px;
}
.keypad button {
  height: 48px;
  font-size: 18px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.keypad button:active { background: var(--active); color: #fff; }
.keypad button.wide { grid-column: span 2; }
/* Fills the rest of the last row beside the 2-wide backspace, so the 5-column
   grid has no ragged gap. */
.keypad button.wide3 { grid-column: span 3; }
/* Pencil mode is a mode, so the button has to look latched rather than just
   pressed — amber fill, matching every other "this is on" in the page. */
.keypad button.toggled {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.keypad button:disabled { opacity: 0.35; cursor: default; }

/* ── Actions ─────────────────────────────────────────────── */
.actions { width: 100%; display: flex; gap: 8px; margin-bottom: 16px; }
.btn {
  flex: 1;
  height: 46px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid var(--line);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink-dim); }

/* ── Result overlay ──────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: #0009;
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
.overlay.hidden { display: none; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  /* Capped and scrollable, like .feedback-card. The result card grew a rating
     block and a note field; on a short phone the Share and CTA buttons at the
     bottom were the first things to go off-screen, which is exactly backwards. */
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}
.card h2 { margin: 0 0 4px; font-size: 24px; }
.result-sub { color: var(--ink-dim); margin: 0 0 14px; font-size: 15px; }
.result-grid {
  font-size: 22px;
  line-height: 1.15;
  margin: 0 0 14px;
  font-family: inherit;
}
.streak { font-size: 15px; margin-bottom: 16px; }
.streak b { color: var(--accent); }
.result-actions { display: flex; flex-direction: column; gap: 8px; }

/* ── Rating ──────────────────────────────────────────────── */
.rating { margin: 0 0 16px; }
.rating-q { color: var(--ink-dim); font-size: 14px; margin: 0 0 6px; }
.stars { display: flex; justify-content: center; gap: 4px; }
/* 40px tap targets around a 26px glyph: five of them have to be separately
   hittable with a thumb. */
.star {
  background: none;
  border: 0;
  padding: 0;
  width: 40px;
  height: 40px;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-dim);
  cursor: pointer;
}
.star.on { color: var(--accent); }
.rating-why { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rating-why textarea {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.rating-why .btn { height: 38px; font-size: 14px; }
.rating-thanks { color: var(--good); font-size: 13px; margin: 8px 0 0; }
.copied { color: var(--good); font-size: 13px; margin: 10px 0 0; }

/* ── Feedback dialog ─────────────────────────────────────── */
/* Left-aligned unlike the other cards: this one is a form, and centred
   labels above inputs read badly. Capped and scrollable so a long message
   on a short phone screen never pushes the buttons off-screen. */
.feedback-card { text-align: left; max-width: 420px; max-height: 88vh; overflow-y: auto; }
.feedback-sub { color: var(--ink-dim); margin: 0 0 16px; font-size: 14px; line-height: 1.45; }
.feedback-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink);
}
.feedback-optional { font-weight: 400; color: var(--ink-dim); }
.feedback-input {
  width: 100%;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  /* Must be >=16px: iOS Safari zooms the whole page when a focused field is
     smaller, which on this page would yank the grid off-screen mid-sentence.
     The viewport's maximum-scale=1 does not reliably suppress that. */
  font-size: 16px;
  margin: 0 0 14px;
}
.feedback-input:focus-visible {
  outline: 2px solid var(--active);
  outline-offset: 1px;
  border-color: var(--active);
}
textarea.feedback-input { resize: vertical; min-height: 96px; line-height: 1.45; }

/* Off-screen rather than display:none — some bots skip hidden inputs. */
.feedback-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.feedback-status { margin: 0 0 12px; font-size: 14px; min-height: 1.2em; }
.feedback-status.ok { color: var(--good); }
.feedback-status.err { color: var(--bad); }
.feedback-actions { display: flex; gap: 8px; }
.hidden { display: none; }

/* How-to overlay */
.howto-list { text-align: left; margin: 0 0 18px; padding-left: 20px; line-height: 1.5; font-size: 15px; }
.howto-list li { margin-bottom: 10px; }
.term-demo { text-decoration: underline dotted var(--accent); text-underline-offset: 3px; }

/* Glossary popup */
.glossary-card { text-align: left; }
.glossary-card h2 { text-transform: capitalize; font-size: 20px; }
.glossary-def { color: var(--ink); font-size: 15px; line-height: 1.5; margin: 0 0 10px; }
.glossary-eg { color: var(--ink-dim); font-size: 13px; margin: 0 0 18px; white-space: pre-line; }
.glossary-card .btn { width: 100%; }

.error {
  margin: 40px 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--bad);
  border-radius: 10px;
  color: var(--ink);
  text-align: center;
}

/* ── Footer ─────────────────────────────────────────────────────────────────
   Deliberately quiet: a report link that competes with the puzzle gets
   clicked by accident, and one that is invisible never gets clicked at all. */
.sitefoot {
  margin: 28px auto 20px;
  padding: 0 16px;
  max-width: 560px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
}
.footlink {
  color: var(--ink-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footlink:hover,
.footlink:focus-visible { color: var(--ink); }
.footsep { margin: 0 8px; opacity: 0.6; }

/* ── About (static, crawlable) ──────────────────────────────────────────────
   Below the puzzle so it never competes with it, but present in the HTML
   rather than injected — the point is that a crawler sees it. */
.about {
  max-width: 560px;
  margin: 32px auto 0;
  padding: 0 16px;
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.6;
}
.about h2 {
  font-size: 15px;
  color: var(--ink);
  margin: 0 0 8px;
}
.about p { margin: 0 0 10px; }
.about a { color: var(--accent); }
