/* ============================================================
   Recall — Daily Cognitive Check-in
   Calm, clinical-but-friendly dark theme. Teal + indigo accents,
   deliberately distinct from the other apps' palettes.
   ============================================================ */

:root {
  --bg:        #0b1020;
  --bg-soft:   #131a30;
  --card:      #1a2240;
  --card-2:    #202a4d;
  --line:      #2b365e;
  --ink:       #eaf0ff;
  --ink-dim:   #a7b2d6;
  --ink-faint: #6b78a3;
  --teal:      #2dd4bf;
  --teal-deep: #0f9d8f;
  --indigo:    #818cf8;
  --indigo-deep:#4f57c4;
  --good:      #34d399;
  --warn:      #fbbf24;
  --bad:       #fb7185;
  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 18px 40px rgba(0,0,0,.45);
  --grad:      linear-gradient(135deg, var(--teal), var(--indigo));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2450 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hidden { display: none !important; }

/* ── Screens ─────────────────────────────────────── */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom));
  animation: fade .35s ease both;
}
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Splash ──────────────────────────────────────── */
.splash-inner { width: 100%; max-width: 440px; text-align: center; }

.brand {
  display: inline-flex; align-items: center; gap: 12px;
  margin: 0 0 6px; font-size: 44px; font-weight: 800; letter-spacing: -.02em;
}
.brand-mark {
  width: 52px; height: 52px; overflow: hidden;
  display: grid; place-items: center; border-radius: 15px;
  background: var(--grad); box-shadow: 0 10px 24px rgba(45,212,191,.28);
}
.brand-mark svg { width: 46px; height: 46px; display: block; }
.brand-word {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--ink-dim); margin: 0 0 26px; font-size: 16px; }

.streak-strip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 999px; margin-bottom: 22px; font-size: 14px; color: var(--ink-dim);
}
.streak-strip strong { color: var(--ink); }
.streak-badge { font-size: 16px; }

/* ── Buttons ─────────────────────────────────────── */
.btn-primary {
  appearance: none; border: 0; cursor: pointer;
  display: block; width: 100%; max-width: 340px; margin: 0 auto;
  padding: 17px 24px; border-radius: var(--radius);
  font-size: 17px; font-weight: 700; color: #06202a;
  background: var(--grad); box-shadow: 0 12px 28px rgba(45,212,191,.30);
  transition: transform .12s ease, box-shadow .2s ease;
}
.btn-primary:active { transform: translateY(1px) scale(.99); box-shadow: 0 6px 16px rgba(45,212,191,.25); }

.btn-ghost {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--ink-faint); font-size: 15px; padding: 14px; margin-top: 10px;
  text-decoration: underline; text-underline-offset: 3px;
}
.btn-ghost:active { color: var(--ink-dim); }

/* ── Icon action row ─────────────────────────────── */
.icon-action-row {
  display: flex; justify-content: center; gap: 10px; margin-top: 26px; flex-wrap: wrap;
}
.icon-action {
  appearance: none; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink-dim); padding: 12px 14px; min-width: 74px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; transition: background .15s ease, color .15s ease, transform .1s ease;
}
.icon-action:active { transform: translateY(1px); background: var(--card-2); color: var(--ink); }
.icon-action-glyph svg { width: 22px; height: 22px; }

app-switcher { display: block; margin-top: 26px; }

.splash-footer { margin-top: 22px; color: var(--ink-faint); font-size: 12px; }

/* ── Flow screens (alert / encode / recall / result) ── */
.flow-inner { width: 100%; max-width: 460px; text-align: center; }
.flow-kicker {
  text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700;
  color: var(--teal); margin: 0 0 12px;
}
.flow-title { font-size: 26px; font-weight: 800; margin: 0 0 10px; letter-spacing: -.01em; }
.flow-sub { color: var(--ink-dim); margin: 0 auto 26px; font-size: 15px; line-height: 1.5; max-width: 380px; }

/* Alertness scale */
.alert-scale { display: flex; gap: 10px; justify-content: center; margin-bottom: 8px; }
.alert-dot {
  appearance: none; cursor: pointer; flex: 1; max-width: 76px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.alert-dot span { font-size: 20px; font-weight: 800; }
.alert-dot small { color: var(--ink-faint); font-size: 11px; min-height: 13px; }
.alert-dot:active, .alert-dot.sel { transform: translateY(-2px); border-color: var(--teal); background: var(--card-2); }

/* Word grids (encode + recall) */
.word-grid {
  list-style: none; padding: 0; margin: 0 0 22px;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.word-grid li {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 10px; font-size: 17px; font-weight: 600; letter-spacing: .01em;
}
.word-grid.selectable li { cursor: pointer; transition: transform .1s ease, border-color .15s ease, background .15s ease; }
.word-grid.selectable li:active { transform: scale(.98); }
.word-grid.selectable li.picked {
  border-color: var(--teal); background: linear-gradient(135deg, rgba(45,212,191,.18), rgba(129,140,248,.18)); color: #fff;
}
.encode-timer { color: var(--ink-dim); font-size: 15px; margin-bottom: 20px; }
.encode-timer span { color: var(--teal); font-weight: 800; font-size: 20px; }

/* ── Round screens ───────────────────────────────── */
.round { justify-content: flex-start; }
.round-head {
  width: 100%; max-width: 460px; display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; padding-top: 6px;
}
.round-tag { color: var(--ink-dim); font-size: 13px; font-weight: 600; }
.round-lives { letter-spacing: 3px; font-size: 15px; }
.round-timer {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; color: var(--teal);
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; min-width: 56px; text-align: center;
}
.round-timer.low { color: var(--bad); border-color: var(--bad); }
/* Header pins to the top; the body centres in the space that's left so the
   grid / symbols sit around the visual middle instead of leaving a large empty
   lower half on tall phones. */
.round-body { width: 100%; max-width: 460px; text-align: center; margin: auto 0; }
.round-instruction { font-size: 19px; font-weight: 700; margin: 0 0 26px; min-height: 26px; }
.round-span { color: var(--ink-faint); font-size: 14px; margin-top: 26px; }
.round-span strong { color: var(--ink); }

/* Tile grid (visual working memory) */
.grid-wrap { display: grid; place-items: center; }
.tile-grid { display: grid; gap: 10px; touch-action: manipulation; }
.tile {
  width: 100%; aspect-ratio: 1; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
  transition: transform .1s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  cursor: pointer;
}
.tile.lit { background: var(--grad); border-color: transparent; box-shadow: 0 8px 22px rgba(45,212,191,.4); }
.tile.picked { background: var(--card-2); border-color: var(--indigo); }
.tile.correct { background: var(--good); border-color: transparent; }
.tile.wrong { background: var(--bad); border-color: transparent; animation: shake .3s; }
.tile.idle { pointer-events: none; }
.tile:active { transform: scale(.94); }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

/* Processing speed */
.symbol-pair {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin: 2vh auto 6vh; min-height: 120px;
}
.symbol {
  font-size: 68px; width: 118px; height: 118px; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
}
.symbol-vs { color: var(--ink-faint); font-size: 15px; }
.speed-buttons { display: flex; gap: 12px; }
.btn-answer {
  appearance: none; border: 0; cursor: pointer; flex: 1;
  padding: 20px; border-radius: var(--radius); font-size: 18px; font-weight: 800; color: #06202a;
  transition: transform .08s ease, filter .15s ease;
}
.btn-answer:active { transform: translateY(2px); }
.btn-yes { background: var(--good); }
.btn-no  { background: linear-gradient(135deg, #fbbf24, #fb7185); }
.btn-answer.flash-ok  { animation: pulse .3s; }
.btn-answer.flash-bad { animation: shake .3s; }
@keyframes pulse { 0%{filter:brightness(1)} 50%{filter:brightness(1.4)} 100%{filter:brightness(1)} }

/* ── Results: headline score, level, streak, badges ─ */
.score-hero { text-align: center; margin-bottom: 18px; }
.score-num {
  font-size: 72px; font-weight: 800; line-height: 1; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.score-unit { font-size: 14px; color: var(--ink-faint); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.score-rank { font-size: 20px; font-weight: 800; color: var(--ink); margin-top: 10px; }
.score-best { font-size: 14px; color: var(--teal); margin-top: 4px; font-weight: 600; }

.level-block { margin: 0 auto 16px; max-width: 340px; }
.level-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.level-label { font-weight: 700; font-size: 14px; }
.level-next { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.level-bar { height: 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.level-fill { height: 100%; width: 0; border-radius: 999px; background: var(--grad); transition: width .9s cubic-bezier(.2,.8,.2,1); }

.result-streak {
  text-align: center; font-size: 14px; color: var(--ink-dim);
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 14px; margin-bottom: 16px;
}
.result-streak strong { color: var(--ink); }

.new-badges {
  background: linear-gradient(135deg, rgba(45,212,191,.12), rgba(129,140,248,.12));
  border: 1px solid var(--indigo-deep); border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
}
.new-badges-head { text-align: center; font-weight: 800; font-size: 14px; margin-bottom: 10px; }
.new-badges-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.badge-chip {
  display: flex; align-items: center; gap: 8px; background: var(--card-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px 7px 10px;
  animation: badgePop .5s cubic-bezier(.2,1.4,.4,1) both;
}
.badge-emoji { font-size: 20px; }
.badge-cname { font-size: 13px; font-weight: 700; }
@keyframes badgePop { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: scale(1); } }
.badge-more {
  appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
  color: var(--teal); background: none; border: 1px dashed var(--line);
  border-radius: 999px; padding: 7px 14px;
  animation: badgePop .5s cubic-bezier(.2,1.4,.4,1) both;
}
.badge-more:active { transform: scale(.96); }

/* ── Results: domain breakdown ─────────────────────── */
.result-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.result-card {
  position: relative; appearance: none; cursor: pointer; font: inherit; color: inherit; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 8px 14px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.result-card:active { transform: scale(.97); }
@media (hover: hover) { .result-card:hover { border-color: var(--teal); background: var(--card-2); } }
.rc-info { position: absolute; top: 7px; right: 9px; font-size: 12px; color: var(--ink-faint); }
.cards-hint { text-align: center; font-size: 12px; color: var(--ink-faint); margin: 0 0 20px; }
.rc-icon { font-size: 22px; }
.rc-val {
  font-size: 28px; font-weight: 800;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.rc-tag { font-size: 11px; font-weight: 700; color: var(--teal); }
.rc-label { font-size: 11px; color: var(--ink-faint); line-height: 1.3; }

/* ── Confetti ──────────────────────────────────────── */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; border-radius: 2px; opacity: .95;
  animation-name: confettiFall; animation-timing-function: linear; animation-fill-mode: forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(680deg); opacity: 1; }
}

/* ── Badges collection modal ───────────────────────── */
.badges-count { font-size: 14px; color: var(--ink-faint); font-weight: 600; }
.badges-level { margin-bottom: 16px; }
.bl-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.bl-level { font-weight: 800; }
.bl-xp { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.bl-bar { height: 10px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); overflow: hidden; }
.bl-fill { height: 100%; border-radius: 999px; background: var(--grad); }
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.badge {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.badge.earned { border-color: var(--teal); background: linear-gradient(135deg, rgba(45,212,191,.10), rgba(129,140,248,.10)); }
.badge.locked { opacity: .55; }
.badge-ico { font-size: 26px; line-height: 1; }
.badge-t { font-size: 11.5px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.badge-d { font-size: 10px; color: var(--ink-faint); line-height: 1.25; }

/* ── Score detail modal ────────────────────────────── */
.sd-blurb { color: var(--ink-dim); font-size: 15px; line-height: 1.5; margin: 0 0 18px; }
.sd-range { margin-bottom: 18px; }
/* Extra bottom gap reserves a lane for the marker's floating value label, so
   it never collides with "Best N" even when today's score is at the far edge. */
.sd-range-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--ink-dim); margin-bottom: 32px; }
.sd-range-head strong { color: var(--ink); font-size: 16px; }
.sd-best { color: var(--teal); font-weight: 600; }
.sd-track {
  position: relative; height: 12px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--line); margin-bottom: 6px;
}
.sd-band { position: absolute; top: 0; bottom: 0; background: rgba(45,212,191,.22); border-radius: 999px; }
.sd-marker {
  position: absolute; top: 50%; width: 4px; height: 22px; border-radius: 3px;
  background: var(--grad); transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(11,16,32,.9); transition: left .5s cubic-bezier(.2,.8,.2,1);
}
.sd-marker-val {
  position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 800; color: var(--ink); white-space: nowrap;
}
.sd-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.sd-typical { font-size: 13px; color: var(--ink-dim); line-height: 1.5; margin: 12px 0 0; }
.sd-how { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 18px; }
.sd-how-head { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--teal); font-weight: 700; margin-bottom: 8px; }
.sd-how p { margin: 0; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }

.result-note {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 14px; color: var(--ink-dim); line-height: 1.5; margin-bottom: 20px; text-align: left;
}
.result-note.warm { border-color: var(--indigo-deep); }
.result-note strong { color: var(--ink); }

.trend-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.trend-head { text-align: left; font-weight: 700; font-size: 14px; margin-bottom: 10px; color: var(--ink-dim); }
.trend-head small { color: var(--ink-faint); font-weight: 500; }
.sparkline { width: 100%; height: 80px; display: block; }
.sparkline path { fill: none; stroke: var(--teal); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sparkline .area { fill: rgba(45,212,191,.12); stroke: none; }
.sparkline circle { fill: var(--indigo); }

/* ── Modals ──────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4,8,20,.72); backdrop-filter: blur(6px);
  animation: fade .2s ease both;
}
.modal-card {
  position: relative; width: 100%; max-width: 420px; max-height: 86dvh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; box-shadow: var(--shadow); text-align: left;
}
.modal-card h3 { margin: 0 0 14px; font-size: 21px; }
.modal-card p { color: var(--ink-dim); font-size: 15px; line-height: 1.6; margin: 0 0 14px; }
.modal-card .fineprint { font-size: 13px; color: var(--ink-faint); border-top: 1px solid var(--line); padding-top: 12px; }
.modal-card .btn-primary { margin-top: 6px; }
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: var(--bg-soft); color: var(--ink-dim);
  font-size: 15px; cursor: pointer;
}
.modal-close:active { background: var(--card-2); }

/* History rows */
.hist-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist-row:last-child { border-bottom: 0; }
.hist-date { color: var(--ink-dim); }
.hist-scores { display: flex; gap: 12px; font-variant-numeric: tabular-nums; }
.hist-scores span { color: var(--ink); }
.hist-warm { font-size: 11px; color: var(--warn); margin-left: 6px; }
.hist-empty { color: var(--ink-faint); font-size: 14px; text-align: center; padding: 20px 0; }

/* ── Toast ───────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 200;
  background: var(--card-2); border: 1px solid var(--line); color: var(--ink);
  padding: 12px 20px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  animation: toastIn .25s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 360px) {
  .brand { font-size: 38px; }
  .symbol { font-size: 56px; width: 100px; height: 100px; }
}
