/* =========================================================
   Daily Games — Shared Stylesheet
   Mobile-first. Calm palette. Light + dark theme.
   System fonts only (no Google Fonts).
   ========================================================= */

:root {
  --bg:        #FAF8F3;
  --surface:   #FFFFFF;
  --text:      #2C2C2C;
  --muted:     #777777;
  --border:    #E5E1D6;
  --accent:    #6AAA64;   /* calm green - success */
  --warn:      #C9B458;   /* warm yellow - close  */
  --bad:       #C46A6A;   /* muted red - far      */
  --shadow:    0 2px 8px rgba(0,0,0,0.04);
  --radius:    14px;
}

[data-theme="dark"] {
  --bg:        #1A1A1A;
  --surface:   #242424;
  --text:      #F5F5F5;
  --muted:     #9A9A9A;
  --border:    #333333;
  --shadow:    0 2px 8px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}
.topbar .controls { display: flex; gap: 6px; align-items: center; }
.topbar-link {
  color: var(--text);
  text-decoration: none;
  padding: 0 12px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.topbar-link:hover {
  background: var(--surface);
  border-color: var(--border);
  text-decoration: none;
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn:active { transform: scale(0.95); }

/* ---------- Layout ---------- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}
.center-text { text-align: center; }
h1 { font-size: 1.6rem; margin: 0 0 6px; }
h2 { font-size: 1.2rem; margin: 0 0 8px; }
.tagline { color: var(--muted); margin: 0 0 28px; font-size: 0.95rem; }
.puzzle-num { color: var(--muted); font-size: 0.9rem; margin-bottom: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  min-height: 48px;
  padding: 12px 22px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease, background 0.2s ease;
}
.btn:hover    { opacity: 0.92; }
.btn:active   { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

/* ---------- Homepage cards ---------- */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 8px;
}
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .cards { grid-template-columns: 1fr 1fr 1fr; } }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
  text-decoration: none;
}
.card .emoji { font-size: 2rem; display: block; margin-bottom: 8px; }
.card .name  { font-weight: 600; margin-bottom: 4px; }
.card .desc  { color: var(--muted); font-size: 0.9rem; min-height: 36px; }
.card .state { margin-top: 10px; font-size: 0.88rem; color: var(--accent); font-weight: 600; }
.card .state.todo { color: var(--muted); }

/* ---------- Footer ---------- */
footer {
  margin-top: 40px;
  padding: 20px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Result panel (shared across games) ---------- */
.result {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.result h3 { margin: 0 0 8px; font-size: 1.1rem; }
.result .emoji-grid {
  font-size: 1.4rem;
  letter-spacing: 4px;
  margin: 10px 0;
  line-height: 1.4;
}
.countdown {
  display: inline-block;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  color: var(--muted);
}

/* ---------- Stats mini ---------- */
.stats-mini {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 12px 0 4px;
  flex-wrap: wrap;
}
.stat { text-align: center; min-width: 60px; }
.stat .num { font-size: 1.4rem; font-weight: 600; display: block; }
.stat .lbl { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Color Match ---------- */
.color-target, .color-guess {
  width: 100%;
  max-width: 320px;
  height: 110px;
  border-radius: var(--radius);
  margin: 8px auto;
  border: 1px solid var(--border);
}
.color-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
.color-pair label { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sliders { max-width: 360px; margin: 18px auto 8px; }
.slider-row { display: grid; grid-template-columns: 30px 1fr 40px; align-items: center; gap: 10px; margin: 10px 0; }
.slider-row .lbl { font-weight: 600; }
.slider-row .val { color: var(--muted); text-align: right; }
input[type="range"] { width: 100%; }

/* ---------- Daily Maze ---------- */
.maze-wrap { display: flex; justify-content: center; margin: 14px 0; }
#mazeCanvas {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  width: 100%;
  max-width: 380px;
  height: auto;
  touch-action: none;
}
.maze-controls {
  display: grid;
  grid-template-columns: 60px 60px 60px;
  gap: 8px;
  justify-content: center;
  margin: 14px auto;
}
.maze-controls .btn { min-height: 54px; padding: 8px; font-size: 1.3rem; }
.maze-controls .spacer { visibility: hidden; }
.maze-status { text-align: center; color: var(--muted); margin: 4px 0; }

/* ---------- Sum Path ---------- */
.numble-target {
  text-align: center;
  font-size: 1rem;
  color: var(--muted);
  margin: 8px 0;
}
.numble-target .big { font-size: 2.2rem; color: var(--text); display: block; font-weight: 700; }
.numble-sum { text-align: center; margin: 8px 0; color: var(--muted); }
.numble-sum .big {
  font-size: 1.6rem;
  color: var(--text);
  font-weight: 700;
  transition: color 0.2s ease;
}
.numble-sum .big.over { color: #C46A6A; }
.numble-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 320px;
  margin: 14px auto;
}
.numble-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, transform 0.1s ease;
}
.numble-cell.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.numble-cell.disabled { opacity: 0.4; cursor: not-allowed; }
.numble-cell.invalid {
  background: #C46A6A;
  color: #fff;
  border-color: #C46A6A;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.numble-cell.hint {
  background: #B6E2B0;
  color: #2C2C2C;
  border-color: #6AAA64;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* --- Win modal (shared across all games on a win) --- */
.win-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: winModalFade 0.2s ease;
}
.win-modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px 22px;
  text-align: center;
  min-width: 260px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: winModalPop 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.win-modal-emoji  { font-size: 3rem; line-height: 1; }
.win-modal h3     { margin: 12px 0 6px; font-size: 1.35rem; }
.win-modal-sub    { color: var(--muted); margin-bottom: 16px; }
.win-modal .btn   { margin-top: 4px; }
@keyframes winModalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes winModalPop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* ==========================================================
   === Word Hunt styles ====================================
   6 × 5 tile board + on-screen keyboard. Fixed indicator
   colours (green / yellow / gray) so they read the same in
   both light and dark themes.
   ========================================================== */

.wordle-board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  max-width: 330px;
  margin: 14px auto;
}
.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.wordle-tile {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  user-select: none;
  transition: transform 0.15s ease, background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.wordle-tile.filled  { border-color: var(--muted); transform: scale(1.04); }
.wordle-tile.flip    { transform: rotateX(0); }
.wordle-tile.correct { background: #6AAA64; border-color: #6AAA64; color: #FFF; }
.wordle-tile.present { background: #C9B458; border-color: #C9B458; color: #FFF; }
.wordle-tile.absent  { background: #787C7E; border-color: #787C7E; color: #FFF; }

.wordle-row.shake { animation: wordleShake 0.4s ease-in-out; }
@keyframes wordleShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

.wordle-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 520px;
  margin: 22px auto;
  padding: 0 6px;
}
.wordle-kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.wordle-key {
  flex: 1;
  min-height: 52px;
  min-width: 28px;
  max-width: 44px;
  background: var(--border);
  color: var(--text);
  border: 0;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.08s ease;
}
.wordle-key.wide   { max-width: 70px; flex: 1.5; font-size: 0.78rem; }
.wordle-key.correct { background: #6AAA64; color: #FFF; }
.wordle-key.present { background: #C9B458; color: #FFF; }
.wordle-key.absent  { background: #787C7E; color: #FFF; }
.wordle-key:active  { transform: scale(0.94); }

/* Dark-mode base — but only for keys that haven't been graded yet.
   Without the :not() guards, this rule has the same specificity as
   .wordle-key.correct / .present / .absent and (being later in the file)
   would override their colours, hiding the guess feedback in dark mode. */
[data-theme="dark"] .wordle-key:not(.correct):not(.present):not(.absent) {
  background: #4a4a4a;
  color: var(--text);
}

.wordle-answer {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 4px;
  margin: 4px 0 8px;
  color: var(--accent);
}

/* Word Hunt's share grid is multi-line — let .emoji-grid show line breaks. */
.result .emoji-grid { white-space: pre-line; }

/* ==========================================================
   === Cookie consent banner + privacy choices modal =======
   Sticky bottom banner on first visit, plus a centred modal
   for per-category opt-in/out. Both built and managed from
   shared.js.
   ========================================================== */

.cookie-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  z-index: 95;
  font-size: 0.92rem;
  animation: cookieSlide 0.28s ease;
}
@keyframes cookieSlide {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.cookie-banner-text { flex: 1 1 280px; min-width: 0; line-height: 1.5; }
.cookie-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cookie-btn {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.cookie-btn:hover { background: var(--surface); }
.cookie-btn.cookie-accept {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.cookie-btn.cookie-accept:hover { opacity: 0.92; }

.consent-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 105;
  padding: 16px;
  animation: winModalFade 0.2s ease;
}
.consent-modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: winModalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.consent-modal h3 { margin: 0 0 6px; }
.consent-modal-sub { color: var(--muted); margin: 0 0 14px; }
.consent-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.consent-row:last-of-type { border-bottom: 0; }
.consent-row input[type="checkbox"] {
  margin-top: 4px;
  transform: scale(1.15);
  cursor: pointer;
  accent-color: var(--accent);
}
.consent-row-desc { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.consent-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* --- Confetti burst (shared celebration helper in shared.js) --- */
.confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 80;
}
.confetti-piece {
  position: absolute;
  top: 50%; left: 50%;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  animation: confetti-burst 1.2s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes confetti-burst {
  0%   { transform: translate(-50%, -50%) rotate(0deg) scale(0.4);   opacity: 1; }
  20%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); opacity: 0; }
}
.numble-actions { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.numble-tries { text-align: center; color: var(--muted); margin: 8px 0; }

/* ---------- Pattern Find ---------- */
.pattern-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  font-size: 2.4rem;
  margin: 18px 0;
  flex-wrap: wrap;
}
.pattern-slot {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.pattern-slot.q { color: var(--muted); }
.pattern-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 320px;
  margin: 14px auto;
}
.pattern-options .opt {
  font-size: 2rem;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  min-height: 64px;
}
.pattern-options .opt:hover { background: var(--bg); }
.pattern-options .opt:active { transform: scale(0.97); }
.pattern-progress { text-align: center; color: var(--muted); margin: 8px 0; }

/* ---------- Echo Tap ---------- */
.seq-pads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 320px;
  margin: 18px auto;
}
.seq-pad {
  height: 100px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s ease, transform 0.08s ease;
}
.seq-pad.active { opacity: 1; transform: scale(1.03); }
.seq-pad:disabled { cursor: not-allowed; }
.seq-pad.red    { background: #D96A6A; }
.seq-pad.blue   { background: #6A8CD9; }
.seq-pad.green  { background: #6AAA64; }
.seq-pad.yellow { background: #D9C36A; }
.seq-status { text-align: center; color: var(--muted); margin: 10px 0; min-height: 24px; }
.seq-level { text-align: center; font-size: 1.1rem; margin: 8px 0; font-weight: 600; }

/* ---------- About ---------- */
.prose { line-height: 1.65; }
.prose p { margin: 0 0 14px; }

/* ==========================================================
   === Color Trick styles ==================================
   Stroop-effect game. Big coloured word inside a timer ring,
   four solid-colour buttons below.
   ========================================================== */

.strooply-progress {
  max-width: 360px;
  margin: 6px auto 4px;
}
.strooply-progress-label {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.strooply-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.strooply-progress-bar > div {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.strooply-question {
  text-align: center;
  color: var(--muted);
  margin: 14px 0 8px;
  font-size: 0.95rem;
}
.strooply-question em { font-style: normal; color: var(--text); font-weight: 600; }

/* Stage = SVG ring + word, both centred and overlaid */
.strooply-stage {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 10px auto;
  border-radius: 50%;
  transition: box-shadow 0.2s ease;
}
.strooply-stage.correct { box-shadow: 0 0 0 4px var(--accent); }
.strooply-stage.wrong   { box-shadow: 0 0 0 4px #C46A6A; }

.strooply-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  /* Start the ring at 12 o'clock and deplete clockwise */
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.strooply-word {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 1px;
  user-select: none;
  text-transform: uppercase;
  transition: transform 0.15s ease, color 0.15s ease;
}
@media (min-width: 640px) {
  .strooply-stage { width: 320px; height: 320px; }
  .strooply-word  { font-size: 84px; }
}
/* "Start" / "Resume" state — the word IS the button */
.strooply-word.strooply-start {
  cursor: pointer;
  color: var(--accent);
  letter-spacing: 4px;
  font-size: 44px;
  animation: strooplyPulse 1.8s ease-in-out infinite;
}
.strooply-word.strooply-start:hover  { transform: scale(1.06); }
.strooply-word.strooply-start:active { transform: scale(0.96); }
.strooply-word.strooply-start:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 8px;
}
@media (min-width: 640px) {
  .strooply-word.strooply-start { font-size: 56px; }
}
@keyframes strooplyPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* 2x2 colour buttons on mobile, single row on wider screens */
.strooply-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 320px;
  margin: 18px auto 8px;
}
@media (min-width: 640px) {
  .strooply-options {
    grid-template-columns: repeat(4, 1fr);
    max-width: 520px;
  }
}
.strooply-btn {
  height: 72px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  opacity: 0.92;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.strooply-btn:hover:not(:disabled)  { opacity: 1; }
.strooply-btn:active:not(:disabled) { transform: scale(0.96); }
.strooply-btn:disabled              { opacity: 0.55; cursor: not-allowed; }

/* "New personal best!" badge inside the result panel */
.best-badge {
  display: inline-block;
  margin: 4px 0 10px;
  padding: 4px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
}
