/* Brain Stroll by New Roots Brain Camp: calm, large, high-contrast styles.
   Colors from newrootsbraincamp.com (navy #183960 / #304254, gold #f4d76b / #f9e5af).
   Ink and primary are the darker navies so body text and buttons meet WCAG AA at the large type sizes.
   Gold is used as an accent, never as body text. Base size scales with Settings > Text size. */
:root {
  --bg: #f8f4ea; --card: #ffffff; --ink: #183960; --muted: #3d5270; --line: #e0d6c2;
  --primary: #183960; --primary-ink: #ffffff; --primary-soft: #e8eef4;
  --accent: #c49a1a; --accent-soft: #f9e5af;
  --good: #2e7d4f; --good-soft: #e2f3e8; --bad: #b03a2e; --bad-soft: #fbe6e3; --warn: #8a5a00;
  --memory: #6d4a8c; --word: #2c628f; --attention: #a2541a; --math: #2f6f4f; --pattern: #9b3658;
  --radius: 18px; --tap: 60px; --shadow: 0 1px 2px rgba(24,57,96,.06), 0 4px 14px rgba(24,57,96,.07);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
html.ts-1 { font-size: 18px; } html.ts-2 { font-size: 20px; } html.ts-3 { font-size: 23px; }
html.hc { --bg: #ffffff; --ink: #000000; --muted: #222222; --line: #000000; --primary: #0c2240; --card: #ffffff; --primary-soft: #e6eef6; }
html.hc .card, html.hc .btn, html.hc .tile, html.hc .choice { border-width: 2px; border-color: #000; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: .2rem 0 .6rem; }
h2 { font-size: 1.25rem; line-height: 1.25; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .25rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: calc(.55rem + var(--safe-t)) 1rem .55rem; background: rgba(248,244,234,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
html.hc .topbar { background: #fff; }
/* Header: logo + stacked title. Use block/flex-column so the two names never run together,
   even if an older cached stylesheet is missing a rule. Cache-bust: ?v=1.1.1 on the link. */
.brand { display: flex; align-items: center; gap: .55rem; min-height: 44px; min-width: 0; color: var(--ink); font-weight: 400; font-size: 1rem; text-decoration: none; }
.brand-logo-link { flex: 0 0 40px; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; text-decoration: none; }
.brand img { width: 40px; height: 40px; object-fit: contain; display: block; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-width: 0; line-height: 1.15; }
.brand-name { display: block; font-weight: 750; font-size: 1.05rem; color: var(--ink); text-decoration: none; line-height: 1.2; }
.brand-by { display: block; font-size: .68rem; font-weight: 600; color: var(--muted); text-decoration: none; line-height: 1.25; letter-spacing: .01em; }
html.hc .brand-by { color: var(--muted); }
.brand-logo-link:hover, .brand-by:hover { opacity: .85; }
.topbar-right { display: flex; align-items: center; gap: .4rem; font-weight: 650; }
.view { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 1rem 1rem calc(6.2rem + var(--safe-b)); outline: none; }
.app.playing .tabbar { display: none; } .app.playing .view { padding-bottom: calc(1.5rem + var(--safe-b)); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 650; }
.tabbar svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--primary); }
.tabbar a.on span { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1rem; box-shadow: var(--shadow); }
.card.soft { background: var(--primary-soft); border-color: #c5d0dc; box-shadow: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap); padding: .7rem 1.3rem; border-radius: 16px; border: 1.5px solid var(--primary); background: #fff; color: var(--primary); font-weight: 700; font-size: 1.05rem; text-decoration: none; cursor: pointer; touch-action: manipulation; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.block { display: flex; width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; min-height: 48px; padding: .4rem .7rem; }
.btn.small { min-height: 48px; font-size: .92rem; padding: .4rem .9rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .tile:focus-visible, .choice:focus-visible, a:focus-visible, .cell:focus-visible { outline: 3px solid #f2b84b; outline-offset: 2px; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; } .row > .btn { flex: 1 1 0; }
.stack > * + * { margin-top: .7rem; }

.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: .6rem; }
.hello .date { color: var(--muted); font-weight: 600; }
.streak { display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-soft); border: 1px solid #e4c56e; color: #5c4300; font-weight: 750; padding: .3rem .75rem; border-radius: 999px; white-space: nowrap; }
.workout-list { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.workout-list li { display: flex; align-items: center; gap: .8rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.workout-list li:last-child { border-bottom: 0; }
.check { flex: 0 0 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; color: #fff; }
.check.done { background: var(--good); border-color: var(--good); }
.meter { height: 14px; border-radius: 99px; background: #ece6da; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }

.cat-grid { display: grid; gap: .8rem; }
.cat { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; border-radius: var(--radius); color: #fff; text-decoration: none; min-height: 84px; box-shadow: var(--shadow); }
.cat .ic { flex: 0 0 52px; height: 52px; border-radius: 14px; background: rgba(255,255,255,.18); display: grid; place-items: center; }
.cat .ic svg { width: 32px; height: 32px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cat h3 { font-size: 1.1rem; margin: 0; } .cat p { margin: 0; font-size: .88rem; opacity: .95; }
.c-memory { background: var(--memory); } .c-word { background: var(--word); } .c-attention { background: var(--attention); } .c-math { background: var(--math); } .c-pattern { background: var(--pattern); }
.t-memory { color: var(--memory); } .t-word { color: var(--word); } .t-attention { color: var(--attention); } .t-math { color: var(--math); } .t-pattern { color: var(--pattern); }
.game-card { display: flex; align-items: center; gap: .9rem; text-decoration: none; color: var(--ink); }
.game-card .gi { flex: 0 0 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.3rem; }
.game-card .meta { flex: 1; } .game-card .meta p { margin: 0; color: var(--muted); font-size: .9rem; }
.game-card .lvl { font-size: .8rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.chip { display: inline-block; padding: .15rem .65rem; border-radius: 99px; font-size: .8rem; font-weight: 750; color: #fff; }

/* Game frame */
.gbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: -.2rem 0 .6rem; }
.gbar .count { font-weight: 750; font-size: 1rem; }
.clock { height: 10px; border-radius: 99px; background: #ece6da; overflow: hidden; margin: 0 0 .8rem; }
.clock > i { display: block; height: 100%; width: 100%; background: var(--attention); transform-origin: left; }
.prompt { font-size: 1.2rem; font-weight: 700; text-align: center; margin: .3rem 0 .9rem; min-height: 1.6em; }
.feedback { text-align: center; font-weight: 750; font-size: 1.1rem; min-height: 1.7em; margin: .5rem 0; }
.feedback.good { color: var(--good); } .feedback.bad { color: var(--bad); }
.stage { user-select: none; -webkit-user-select: none; }
.choices { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .75rem; }
.choice { min-height: 76px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; font-size: 1.5rem; font-weight: 750; cursor: pointer; touch-action: manipulation; display: flex; align-items: center; justify-content: center; gap: .5rem; padding: .4rem; }
.choice.right { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.choice.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.big-q { text-align: center; font-size: 2.6rem; font-weight: 800; letter-spacing: .02em; margin: .6rem 0 1rem; font-variant-numeric: tabular-nums; }
.seq { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; margin: .5rem 0 1.1rem; }
.seq span { min-width: 3.1rem; padding: .45rem .5rem; border-radius: 12px; background: #fff; border: 1.5px solid var(--line); font-size: 1.45rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.seq span.q { background: var(--primary-soft); color: var(--primary); border-style: dashed; border-color: var(--primary); }

/* Memory cards */
.cards { display: grid; gap: .55rem; }
.mcard { aspect-ratio: 1 / 1.08; border-radius: 14px; border: 1.5px solid #b9aed0; background: var(--memory); cursor: pointer; display: grid; place-items: center; padding: 10%; touch-action: manipulation; transition: transform .25s; }
.mcard .face { display: none; width: 100%; height: 100%; }
.mcard.up, .mcard.matched { background: #fff; border-color: var(--line); }
.mcard.up .face, .mcard.matched .face { display: block; }
.mcard.matched { opacity: .55; cursor: default; }
.mcard .back { width: 38%; height: 38%; border-radius: 50%; border: 3px solid rgba(255,255,255,.45); }
.mcard.up .back, .mcard.matched .back { display: none; }
@media (prefers-reduced-motion: no-preference) { html:not(.rm) .mcard.up { transform: rotateY(0deg) scale(1.02); } }

/* Sequence tiles */
.pads { display: grid; gap: .7rem; margin: 0 auto; max-width: 420px; }
.pad { aspect-ratio: 1; border-radius: 20px; border: 3px solid transparent; cursor: pointer; display: grid; place-items: center; touch-action: manipulation; opacity: .42; transition: opacity .12s, transform .12s; }
.pad svg { width: 44%; height: 44%; }
.pad.lit { opacity: 1; transform: scale(1.04); border-color: #1d2327; }
.pads.input .pad { opacity: .72; } .pads.input .pad:active { opacity: 1; }

/* Word tiles */
.slots, .letters { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; margin: .4rem 0 1rem; }
.slot, .ltr { width: 3.1rem; height: 3.5rem; border-radius: 12px; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; text-transform: uppercase; }
.slot { border: 2px dashed #9fb7b4; background: #fff; }
.slot.filled { border-style: solid; border-color: var(--word); cursor: pointer; }
.ltr { border: 1.5px solid #9db6cc; background: #eef4f9; color: #123e60; cursor: pointer; touch-action: manipulation; }
.ltr.used { visibility: hidden; }
.clue { text-align: center; font-size: 1.05rem; color: var(--muted); margin-bottom: .3rem; }
.clue b { color: var(--word); }
.shake { animation: shake .35s; } @keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
html.rm .shake { animation: none; }

/* Word search */
.ws { display: grid; gap: 3px; margin: 0 auto .8rem; max-width: 460px; touch-action: manipulation; }
.cell { aspect-ratio: 1; border-radius: 8px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; text-transform: uppercase; cursor: pointer; padding: 0; }
.cell.start { background: #fff0c9; border-color: #c99a2e; }
.cell.found { background: #d8ebf7; border-color: #7aa7c9; color: #123e60; }
.cell.hint { box-shadow: inset 0 0 0 3px #c99a2e; }
.wlist { display: flex; flex-wrap: wrap; gap: .4rem .5rem; justify-content: center; list-style: none; padding: 0; margin: 0 0 .6rem; }
.wlist li { padding: .2rem .65rem; border-radius: 99px; background: #fff; border: 1px solid var(--line); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.wlist li.found { text-decoration: line-through; color: var(--muted); background: #eef4f9; }

/* Attention */
.react { width: 100%; aspect-ratio: 1 / .95; max-height: 56vh; border-radius: 28px; border: 0; display: grid; place-items: center; font-size: 1.9rem; font-weight: 850; color: #fff; cursor: pointer; touch-action: manipulation; background: #7b858b; }
.react.go { background: #2e7d4f; } .react.nogo { background: #2c628f; } .react.early { background: #b03a2e; }
.stroop-word { text-align: center; font-size: 3.4rem; font-weight: 900; letter-spacing: .04em; margin: .4rem 0 .2rem; }
.rule { text-align: center; font-weight: 750; margin-bottom: 1rem; }
.rule b { background: #fff4dc; padding: .05rem .4rem; border-radius: 6px; }
.swatch { width: 1.3rem; height: 1.3rem; border-radius: 50%; border: 2px solid rgba(0,0,0,.25); flex: 0 0 auto; }
.choice.color { font-size: 1.15rem; }

/* Pattern */
.grid-odd { display: grid; gap: .55rem; margin: 0 auto; max-width: 440px; }
.tile { aspect-ratio: 1; border-radius: 14px; background: #fff; border: 1.5px solid var(--line); display: grid; place-items: center; padding: 14%; cursor: pointer; touch-action: manipulation; }
.tile svg { width: 100%; height: 100%; }
.tile.right { background: var(--good-soft); border-color: var(--good); } .tile.wrong { background: var(--bad-soft); border-color: var(--bad); }
.prow { display: grid; gap: .4rem; margin: .4rem 0 1.1rem; }
.prow .tile { cursor: default; padding: 12%; }
.prow .tile.q { border: 2px dashed var(--pattern); background: #fbeff3; color: var(--pattern); font-size: 1.8rem; font-weight: 800; }
.choices.shapes .choice { min-height: 0; aspect-ratio: 1.25; padding: 16%; }
.choices.shapes .choice svg { height: 100%; width: auto; max-width: 100%; }

/* Results */
.score-ring { width: 9.5rem; height: 9.5rem; margin: .4rem auto .8rem; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--p) * 1%), #e8e1d4 0); }
.score-ring > div { width: 7.6rem; height: 7.6rem; border-radius: 50%; background: var(--card); display: grid; place-items: center; text-align: center; }
.score-ring b { display: block; font-size: 2.6rem; line-height: 1; }
.score-ring span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center; }
.stats3 b { display: block; font-size: 1.35rem; } .stats3 span { font-size: .8rem; color: var(--muted); font-weight: 650; }

/* Progress */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-top: .5rem; }
.bars i { flex: 1; background: var(--primary); border-radius: 6px 6px 2px 2px; min-height: 4px; }
.bars i.zero { background: #e8e1d4; }
.bar-labels { display: flex; gap: 6px; font-size: .7rem; color: var(--muted); font-weight: 650; } .bar-labels span { flex: 1; text-align: center; }
.catrow { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.catrow:last-child { border-bottom: 0; }
.catrow .meter { grid-column: 1 / -1; height: 12px; }

/* Settings */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .lbl { flex: 1; } .setting .lbl small { display: block; color: var(--muted); font-size: .82rem; }
.switch { position: relative; width: 68px; height: 40px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: #b9b3a8; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 32px; height: 32px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--primary); } .switch input:checked + i::after { transform: translateX(28px); }
.switch input:focus-visible + i { outline: 3px solid #f2b84b; outline-offset: 2px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-top: .5rem; }
.seg button { min-height: 56px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-weight: 750; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.disclaimer { font-size: .85rem; color: var(--muted); border-left: 4px solid #d9cbb0; padding: .2rem 0 .2rem .8rem; margin: 1rem 0; }

.toast { position: fixed; left: 50%; bottom: calc(5.4rem + var(--safe-b)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: #1d2327; color: #fff; padding: .7rem 1.1rem; border-radius: 14px; font-weight: 650; max-width: 90vw; text-align: center; transition: opacity .25s, transform .25s; z-index: 9; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.legal h2 { font-size: 1.1rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (min-width: 700px) { .cat-grid { grid-template-columns: 1fr 1fr; } }
.tile svg, .choice svg, .mcard svg, .pad svg { overflow: visible; }
.celebrate { text-align: center; }
.celebrate .big { font-size: 3rem; line-height: 1; margin: .3rem 0; color: var(--primary); }
.intro-list { padding-left: 1.2rem; margin: .4rem 0 1rem; } .intro-list li { margin: .35rem 0; }
.lvl-pill { display: inline-block; padding: .2rem .7rem; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 750; font-size: .85rem; }
.flame { width: 1.05em; height: 1.05em; }
.field { width: 100%; min-height: 60px; padding: .6rem .9rem; border-radius: 14px; border: 1.5px solid #9aa3a8; background: #fff; font-size: 1.1rem; }
.field:focus { outline: 3px solid #f2b84b; outline-offset: 1px; border-color: var(--primary); }
.field.code { font-size: 1.8rem; letter-spacing: .35em; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.btn.apple { background: #000; color: #fff; border-color: #000; }
.btn.apple svg { margin-top: -3px; }
.or { text-align: center; color: var(--muted); font-weight: 650; margin: .9rem 0 .7rem; }
label { display: block; }

.from-nr { display: flex; align-items: center; gap: .85rem; text-align: left; margin: .4rem 0 1rem; }
.from-nr img { flex: 0 0 56px; width: 56px; height: 56px; object-fit: contain; }
.from-nr span { flex: 1; }
.welcome-mark { width: 96px; height: 96px; object-fit: contain; margin: .5rem auto .2rem; display: block; }
.disclaimer { font-size: .88rem; color: var(--muted); }
