/* ===========================================================
   Nemori — Styles
   Light mode · Teal & sage palette · Header / main / footer layout
   Minimal animations · GPU-accelerated (transform/opacity)
   =========================================================== */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --toffee-brown: #35858E;
  --rosy-taupe: #35858E;
  --powder-blush: #C2D099;
  --petal-frost: #E6EEC9;
  --snow: #F5F8EE;
  --bg-surface: #fff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-color: rgba(53, 133, 142, 0.18);
  --text-primary: #1E3B3E;
  --text-secondary: #35858E;
  --text-muted: #8AA69D;
  --accent: #35858E;
  --success: #5db87e;
  --success-dim: rgba(93, 184, 126, 0.12);
  --danger: #d96060;
  --danger-dim: rgba(217, 96, 96, 0.12);
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
  --header-height: 72px;
}

html { font-size: 16px; }

/* Header (fixed height, top) + main (flexible) + footer (fixed content,
   bottom) stacked in normal document flow — no sidebar, no fixed/absolute
   positioning needed for the page shell itself. */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--snow);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ====== HEADER ====== */
.app-header {
  flex-shrink: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  background: #fff;
  border-bottom: 1px solid var(--border-color);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.app-logo-mark {
  display: block;
  border-radius: var(--radius-sm);
}

.app-logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Hamburger toggle — mobile only, see the .mobile-menu-toggle rule in
   ====== RESPONSIVE ====== below. */
.mobile-menu-toggle {
  display: none;
}

/* ====== MOBILE SLIDE-IN MENU ======
   Desktop always shows every challenge inline (.challenge-row); on mobile
   that's replaced by this menu, reached via the header hamburger. */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30, 59, 62, 0.35);
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-nav-overlay.open {
  display: block;
  opacity: 1;
}

.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: #fff;
  z-index: 1101;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  box-shadow: 4px 0 20px rgba(30, 59, 62, 0.12);
}

.mobile-nav.open {
  transform: translateX(0);
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.mobile-nav-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.mobile-nav-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.mobile-nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-md) 0;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0.75rem var(--space-md);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.mobile-nav-item:hover {
  background: rgba(230, 238, 201, 0.3);
}

.mobile-nav-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.mobile-nav-danger {
  color: var(--danger);
}

.mobile-home-hint {
  display: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-lg);
}

/* ====== DESKTOP PREV/NEXT CHALLENGE PEEKS ======
   Pinned to the left/right edges of the viewport while a challenge's
   morning/waiting/evening/result screen is showing — clicking one jumps
   straight to that challenge. Hidden on Home (all challenges are already
   visible there) and on mobile (see the max-width: 768px override). */
.challenge-peek {
  display: none;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 150px;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: var(--space-md) var(--space-sm);
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  box-shadow: 0 8px 24px rgba(30, 59, 62, 0.08);
  opacity: 0.8;
  z-index: 50;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.challenge-peek.visible { display: flex; }

.challenge-peek:hover {
  opacity: 1;
  box-shadow: 0 12px 28px rgba(30, 59, 62, 0.14);
}

.challenge-peek-left { left: var(--space-xl); }
.challenge-peek-left:hover { transform: translateY(-50%) translateX(-4px); }
.challenge-peek-right { right: var(--space-xl); }
.challenge-peek-right:hover { transform: translateY(-50%) translateX(4px); }

.challenge-peek-arrow {
  font-size: 1.1rem;
  color: var(--rosy-taupe);
  font-weight: 700;
}

.challenge-peek-kicker {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.challenge-peek-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

.challenge-peek-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.challenge-peek-status.live {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.challenge-peek-status.timer-urgent { color: var(--danger); }

/* Below this width there isn't enough clearance between the fixed peeks and
   the centered screen content (max-width: 680px) without overlapping it. */
@media (max-width: 1100px) {
  .challenge-peek { display: none !important; }
}

/* ====== FOOTER ====== */
.app-footer {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  background: #fff;
  border-top: 1px solid var(--border-color);
}

/* The analytics link sits in the footer's centered grid column — true
   center regardless of how wide the actions column ends up. */
.footer-links {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.footer-quick-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: none;
  border: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}

.footer-quick-link:hover {
  background: rgba(230, 238, 201, 0.3);
}

.footer-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
}

.footer-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.footer-stat-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--toffee-brown);
}

.footer-stat-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.footer-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  position: relative;
}

/* Outline only appears on hover for Admin/Debug specifically — everywhere
   else .btn-secondary keeps its normal always-visible border. */
/* .btn-secondary.btn-ghost (two classes) outranks the plain .btn-secondary
   rule further down regardless of source order, which a bare .btn-ghost
   selector could not — same specificity there was losing on file order. */
.btn-secondary.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-secondary.btn-ghost:hover {
  border-color: rgba(53, 133, 142, 0.2);
  background: rgba(53, 133, 142, 0.1);
}

.footer-debug {
  position: relative;
}

.footer-privacy-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-privacy-link:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

/* Anchored above the footer button rather than sliding open below it —
   there's no room below (it's the last thing on the page). */
.settings-panel {
  display: none;
  position: absolute;
  bottom: calc(100% + var(--space-sm));
  right: 0;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm);
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 -4px 16px rgba(30, 59, 62, 0.08);
}

.settings-panel.open {
  display: flex;
}

.btn-settings {
  padding: 0.45rem var(--space-md);
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(230, 238, 201, 0.2);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.btn-settings:hover {
  background: rgba(230, 238, 201, 0.4);
  color: var(--text-primary);
}

/* ====== MAIN CONTENT ====== */
.main-content {
  position: relative;
  flex: 1;
  padding: var(--space-2xl);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* ====== HOME: challenge cards, side by side ====== */
.challenge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
}

.challenge-card {
  flex: 1 1 180px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.challenge-card:hover {
  transform: translateY(-2px);
  border-color: var(--rosy-taupe);
  box-shadow: 0 8px 20px rgba(30, 59, 62, 0.08);
}

.challenge-card-kicker {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.challenge-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.challenge-card-status {
  margin-top: auto;
  padding-top: var(--space-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.challenge-card-status.live {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.challenge-card-status.timer-urgent { color: var(--danger); }

.screen {
  display: none;
  width: 100%;
  max-width: 680px;
}

.screen.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  max-width: 480px;
  margin: var(--space-2xl) auto 0;
}

/* ====== ANALYTICS ====== */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.analytics-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  transition: transform 0.15s ease, background 0.2s ease;
}

.analytics-card:hover {
  background: rgba(230, 238, 201, 0.15);
  transform: translateY(-2px);
}

.analytics-card-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--toffee-brown);
}

.analytics-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.analytics-section {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.analytics-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.btn-back-home {
  display: inline-block;
  margin-bottom: var(--space-md);
  padding: 0;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-back-home:hover {
  color: var(--rosy-taupe);
  text-decoration: underline;
}

/* ====== ANALYTICS PAGE: accuracy/weekly breakdown rows ====== */
.breakdown-list {
  display: flex;
  flex-direction: column;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-color);
}

.breakdown-row:last-child {
  border-bottom: none;
}

.breakdown-type {
  font-weight: 600;
  color: var(--text-primary);
  text-transform: capitalize;
}

.breakdown-value {
  font-weight: 700;
  color: var(--toffee-brown);
  font-variant-numeric: tabular-nums;
}

/* ====== ANALYTICS PAGE: GitHub style activity heatmap ====== */
.heatmap-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  overflow-x: auto;
}

.heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  width: max-content;
}

.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: rgba(53, 133, 142, 0.08);
}

.heatmap-blank { visibility: hidden; }

.heatmap-level-0 { background: rgba(53, 133, 142, 0.08); }
.heatmap-level-1 { background: rgba(53, 133, 142, 0.3); }
.heatmap-level-2 { background: rgba(53, 133, 142, 0.52); }
.heatmap-level-3 { background: rgba(53, 133, 142, 0.74); }
.heatmap-level-4 { background: var(--rosy-taupe); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  align-self: flex-end;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ====== CHALLENGE / MORNING ====== */
.challenge-showcase {
  margin: var(--space-xl) 0;
  padding: var(--space-xl);
  background: rgba(230, 238, 201, 0.2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.challenge-value { font-weight: 700; }
.challenge-pin { font-size: 2.8rem; color: var(--toffee-brown); }
.challenge-words { font-size: 1.5rem; line-height: 1.8; color: var(--toffee-brown); }

/* Facts are full sentences, so they read better left-aligned at body weight */
.challenge-fact {
  text-align: left;
}

/* Vocabulary shows the word plus its definition/synonyms — the learning
   moment, unlike the other types where the display is only what's memorized. */
.challenge-vocabulary {
  text-align: left;
}

.vocab-word {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--toffee-brown);
  margin: 0 0 var(--space-md);
}

.vocab-definition {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0 0 var(--space-sm);
}

.vocab-synonyms {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.fact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.fact-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius-full);
}

/* Two distinct colours so year and subject are easy to tell apart at a glance */
.fact-badge-year {
  background: rgba(53, 133, 142, 0.14);
  color: var(--rosy-taupe);
}

.fact-badge-subject {
  background: rgba(125, 167, 140, 0.16);
  color: #35858E;
}

.fact-body {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.7;
  color: var(--text-primary);
  margin: 0;
}

/* ====== MORNING: LIVE COUNTDOWN + MEMORY TIP ====== */
.timer-hint { color: var(--text-muted); font-size: 0.85rem; margin-top: var(--space-md); }

.morning-timer {
  margin-top: var(--space-lg);
  text-align: center;
}

.morning-timer-value {
  font-family: 'SF Mono', 'Fira Code', 'Roboto Mono', monospace;
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--toffee-brown);
  letter-spacing: 2px;
}

.morning-timer-value.timer-urgent { color: var(--danger); }

.morning-timer-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.morning-tip {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: rgba(230, 238, 201, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: left;
}

.morning-tip-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rosy-taupe);
  margin-bottom: var(--space-xs);
}

.morning-tip-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
  /* Cross-fades to the next tip on rotation — see rotateMorningTip() */
  transition: opacity 0.3s ease;
}

.morning-tip-text.tip-fading { opacity: 0; }

/* ====== WAITING ====== */
.waiting-card { padding-bottom: var(--space-2xl); }

.waiting-animation {
  position: relative;
  width: 80px;
  height: 80px;
  margin: var(--space-xl) auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-ring { display: none; }

.pulse-core {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rosy-taupe);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.6; }
}

.waiting-hint { color: var(--text-muted); font-size: 0.8rem; margin-top: var(--space-lg); }
.waiting-hint strong { color: var(--toffee-brown); }

.waiting-countdown { color: var(--text-secondary); font-size: 0.95rem; margin-top: var(--space-lg); font-variant-numeric: tabular-nums; }
.waiting-countdown.ready { color: var(--toffee-brown); font-weight: 600; }

#btn-start-recall { margin-top: var(--space-lg); }

.evening-deadline { color: var(--text-muted); font-size: 0.85rem; margin-bottom: var(--space-lg); }

/* ====== TIP LISTS (retention on Waiting, recall on Evening) ====== */
.tip-list-block {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  background: rgba(230, 238, 201, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: left;
}

.tip-list-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rosy-taupe);
  margin-bottom: var(--space-sm);
}

.tip-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.tip-list li {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-primary);
  padding-left: var(--space-md);
  position: relative;
}

.tip-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rosy-taupe);
}

/* ====== RECALL INPUTS ====== */
.recall-inputs { margin-bottom: var(--space-xl); }

.pin-input-group {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
}

.pin-input {
  width: 60px;
  height: 72px;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  font-family: inherit;
  background: rgba(230, 238, 201, 0.15);
  border: 2px solid rgba(53, 133, 142, 0.2);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pin-input:focus {
  border-color: var(--rosy-taupe);
  box-shadow: 0 0 0 3px rgba(53, 133, 142, 0.1);
}

.pin-input::-webkit-outer-spin-button,
.pin-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ====== Wordle-style feedback grid (Numbers recall) ======
   One row per attempt (matches STANDARD_FAIL_CAP in app.js), one cell per
   PIN digit. Filled in after each guess: turquoise for a digit that's
   correct and in the right position, light orange for a digit that's in
   the PIN but the wrong position, light blue for a digit that isn't in the
   PIN at all — classic Wordle feedback, applied to digits instead of
   letters. Rows for attempts made before the current page load (e.g. after
   a refresh mid-recall) show as "used" rather than fabricated colors,
   since the actual past guesses aren't stored anywhere to recolor accurately. */
.wordle-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.wordle-row {
  display: flex;
  gap: var(--space-sm);
}

.wordle-cell {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(53, 133, 142, 0.2);
  background: rgba(230, 238, 201, 0.1);
  color: var(--text-primary);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.wordle-cell-correct {
  background: var(--toffee-brown);
  border-color: var(--toffee-brown);
  color: #fff;
}

/* A light, distinct hue rather than a muted gray — gray read too close to
   the "wrong" orange used for absent. --powder-blush is already part of the
   site's defined palette but wasn't actually used anywhere else, so this
   gives "present" its own clear identity without introducing a new color
   or colliding with an existing meaning. */
.wordle-cell-present {
  background: var(--powder-blush);
  border-color: #A9BC72;
  color: var(--text-primary);
}

/* Orange reads as "wrong" more than "neutral" on this palette, so it's used
   for absent (not in the PIN at all) rather than present — the inverse of
   Wordle's own gray-for-absent convention, chosen deliberately for this app. */
.wordle-cell-absent {
  background: #F6C177;
  border-color: #F0AD53;
  color: #5A3D10;
}

.wordle-cell-used {
  background: rgba(138, 166, 157, 0.15);
  border-color: rgba(138, 166, 157, 0.3);
  color: var(--text-muted);
}

.word-input {
  display: block;
  width: 100%;
  padding: 0.85rem var(--space-md);
  margin-bottom: var(--space-md);
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 500;
  background: rgba(230, 238, 201, 0.1);
  border: 2px solid rgba(53, 133, 142, 0.15);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.word-input:focus {
  border-color: var(--rosy-taupe);
  box-shadow: 0 0 0 3px rgba(53, 133, 142, 0.1);
}

.word-input::placeholder { color: var(--text-muted); }

/* ====== VOCABULARY RECALL ====== */
.vocab-recall { margin-bottom: var(--space-xl); }

.vocab-attempts-remaining {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 var(--space-md);
}

.vocab-feedback,
.recall-feedback {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--danger);
  margin: 0 0 var(--space-md);
  min-height: 1.3em;
}

.vocab-hint-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.btn-hint {
  padding: 0.55rem var(--space-md);
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(53, 133, 142, 0.1);
  color: var(--rosy-taupe);
  border: 1px solid rgba(53, 133, 142, 0.2);
}

.btn-hint:hover:not(:disabled) { background: rgba(53, 133, 142, 0.18); }

.btn-hint:disabled {
  opacity: 0.5;
  cursor: default;
}

.vocab-hint-panel {
  padding: 0.75rem var(--space-md);
  margin: 0 0 var(--space-sm);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: rgba(230, 238, 201, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* ====== MULTIPLE CHOICE (facts recall) ====== */
.quiz-block {
  border: none;
  margin-bottom: var(--space-xl);
}

.quiz-question-text {
  display: block;
  padding: 0;
  margin-bottom: var(--space-md);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}

.quiz-option {
  display: block;
  position: relative;
  margin-bottom: var(--space-sm);
  cursor: pointer;
}

/* Visually hidden but still 1px and in flow, so it stays focusable and
   screen-reader accessible — the card is the visible control. */
.quiz-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.quiz-option-card {
  display: block;
  padding: 0.85rem var(--space-md);
  font-size: 0.95rem;
  line-height: 1.55;
  text-align: left;
  background: rgba(230, 238, 201, 0.1);
  border: 2px solid rgba(53, 133, 142, 0.15);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-option:hover .quiz-option-card {
  border-color: rgba(53, 133, 142, 0.4);
}

.quiz-option input[type="radio"]:checked + .quiz-option-card {
  background: rgba(53, 133, 142, 0.12);
  border-color: var(--rosy-taupe);
  font-weight: 600;
}

.quiz-option input[type="radio"]:focus-visible + .quiz-option-card {
  box-shadow: 0 0 0 3px rgba(53, 133, 142, 0.25);
}

/* Unanswered question after a submit attempt */
.quiz-block-error .quiz-question-text {
  color: var(--danger);
}

.quiz-block-error .quiz-question-text::after {
  content: ' · pick an answer';
  font-weight: 500;
  font-size: 0.85rem;
}

.quiz-block-error .quiz-option-card {
  border-color: rgba(217, 96, 96, 0.35);
}

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.85rem 2rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--rosy-taupe);
  color: #fff;
}

.btn-primary:hover { background: #2C6E76; }

.btn-secondary {
  background: rgba(53, 133, 142, 0.1);
  color: var(--rosy-taupe);
  border: 1px solid rgba(53, 133, 142, 0.2);
}

.btn-secondary:hover { background: rgba(53, 133, 142, 0.18); }

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
}

.btn-delete-user {
  color: var(--danger);
  border-color: rgba(217, 96, 96, 0.25);
  background: var(--danger-dim);
}

.btn-delete-user:hover { background: rgba(217, 96, 96, 0.2); }

.btn-danger {
  color: var(--danger);
  border-color: rgba(217, 96, 96, 0.25);
  background: var(--danger-dim);
}

.btn-danger:hover { background: rgba(217, 96, 96, 0.2); }

.account-danger-zone {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-color);
}

.account-danger-zone h4 { color: var(--danger); }

/* ====== RESULT ====== */
.result-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.35rem 1.1rem;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-md);
}

.success-badge { background: var(--success-dim); color: var(--success); }
.failure-badge { background: var(--danger-dim); color: var(--danger); }

.result-title { font-size: 1.8rem; font-weight: 800; margin-bottom: var(--space-sm); }
.result-title.success { color: var(--success); }
.result-title.failure { color: var(--danger); }

.result-message {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: var(--space-xl);
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: rgba(230, 238, 201, 0.2);
  border-radius: var(--radius-md);
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.result-stat-value { font-size: 1.6rem; font-weight: 800; color: var(--rosy-taupe); }
.result-stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }

.result-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ====== CONFETTI ====== */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation: confettiFall 2s linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(-10px); opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  /* Shorter header and tighter page-header/footer spacing — the goal is
     for the Home screen (title + hint text + footer, no challenge cards
     since those only show via the mobile menu) to fit a typical phone
     viewport without scrolling. */
  .app-header { padding: 0 var(--space-md); height: 56px; }
  .main-content { padding: var(--space-lg) var(--space-md); }
  .page-header { margin-bottom: var(--space-md); }

  .mobile-menu-toggle { display: flex; }
  .challenge-row { display: none; }
  .mobile-home-hint { display: block; margin-bottom: var(--space-md); }

  .app-footer {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
  }
  .footer-links { grid-column: 1; flex-direction: column; gap: var(--space-xs); }
  .footer-actions { grid-column: 1; justify-self: center; }
  .footer-stats { justify-content: center; gap: var(--space-md) var(--space-lg); }

  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
  .content-card { padding: var(--space-xl) var(--space-md); }
  .pin-input { width: 52px; height: 62px; font-size: 1.5rem; }
  .wordle-cell { width: 36px; height: 36px; font-size: 1rem; }
}

@media (max-width: 400px) {
  .analytics-card-value { font-size: 1.4rem; }
  .page-title { font-size: 1.3rem; }
}

:focus-visible {
  outline: 2px solid var(--rosy-taupe);
  outline-offset: 2px;
}

::selection {
  background: rgba(194, 208, 153, 0.4);
  color: var(--text-primary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--toffee-brown);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
  background: rgba(53, 133, 142, 0.1);
  color: var(--rosy-taupe);
}

/* Modal Overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  overflow: hidden;
}

.modal-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
  max-height: 75vh;
  overflow-y: auto;
}

.settings-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.settings-group {
  margin-bottom: var(--space-lg);
}

.settings-group h4 {
  font-size: 0.9rem;
  color: var(--toffee-brown);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.slider-control {
  margin-bottom: var(--space-md);
}

.slider-control label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.slider-control label span {
  color: var(--accent);
}

.slider-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.slider-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ====== ADMIN DASHBOARD ====== */
.admin-body {
  display: block;
}

.admin-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
  width: 100%;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.admin-header-actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.admin-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.admin-filter-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.admin-filter-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.admin-filter-field .auth-input {
  width: 100%;
}

.admin-filter-actions {
  display: flex;
  gap: var(--space-sm);
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.admin-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid rgba(53, 133, 142, 0.08);
  color: var(--text-primary);
  white-space: nowrap;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-xl) 0 !important;
  white-space: normal !important;
}

.admin-table-subtle {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.admin-role-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(53, 133, 142, 0.15);
  color: var(--toffee-brown);
}

.admin-role-badge.admin-role-user {
  background: rgba(125, 167, 140, 0.15);
  color: #35858E;
}

/* Create-account form (admin modal) */
#create-user-form .admin-filter-field {
  margin-bottom: var(--space-md);
}

.admin-checkbox-field {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.admin-checkbox-field input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.admin-form-message {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
}

.admin-form-message.error {
  background: var(--danger-dim);
  color: var(--danger);
}

.admin-form-message.success {
  background: rgba(125, 167, 140, 0.15);
  color: #35858E;
}

@media (max-width: 768px) {
  .admin-main { padding: var(--space-xl) var(--space-md); }
}

/* ====== WELCOME TOUR ====== */
.tour-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.tour-overlay.active {
  display: block;
}

.tour-highlight {
  display: none;
  position: fixed;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 9999px rgba(29, 19, 14, 0.6);
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
  pointer-events: none;
  z-index: 2001;
}

.tour-card {
  position: fixed;
  width: 300px;
  max-width: calc(100vw - 2rem);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  padding: var(--space-lg);
  z-index: 2002;
  transition: top 0.25s ease, left 0.25s ease;
}

.tour-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.tour-step-count {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tour-skip {
  background: none;
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}

.tour-skip:hover { color: var(--rosy-taupe); }

.tour-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.tour-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-md);
}

.tour-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
}

.tour-actions .btn {
  flex: 1;
}

.tour-actions .btn:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (max-width: 768px) {
  .tour-card { width: calc(100vw - 2rem); }
}

/* ====== PRACTICE MODE ====== */
.practice-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(53, 133, 142, 0.15);
  color: var(--toffee-brown);
  margin-bottom: var(--space-md);
}

.practice-exit-mid {
  display: block;
  margin: var(--space-xl) auto 0;
}

#practice-result-text { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--space-lg); }
.practice-result-correct { color: var(--toffee-brown); }
.practice-result-wrong { color: var(--danger); }

