/* Quickwell Play: shared styles for the hub and the three games. Phone first, light/dark, reduced-motion aware. */
:root {
  --bg: #f5f4f0; --ink: #17181c; --muted: #596070; --card: #fff; --line: #e3e1da; --soft: #eeece6;
  --accent: #3b5bdb; --accent-soft: #e6ebfd; --on-accent: #fff;
  --good: #1d7a46; --bad: #c2341f; --warn: #8a5a00; --gold: #b07800;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 6px 20px rgba(20, 20, 30, .06);
  --r: 16px; color-scheme: light;
}
body[data-game="echo"] { --accent: #6246ea; --accent-soft: #ece8fe; }
body[data-game="swift"] { --accent: #b45309; --accent-soft: #fdf0e1; }
body[data-game="linkr"] { --accent: #0f766e; --accent-soft: #dff4f1; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f1115; --ink: #eef0f4; --muted: #a0a8b6; --card: #181b22; --line: #2b303a; --soft: #21252e; --accent: #8aa4ff; --accent-soft: #232b45; --on-accent: #0f1115; --good: #5fd38d; --bad: #ff8a75; --warn: #f0b43c; --gold: #f2c14e; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark; }
  :root:not([data-theme="light"]) body[data-game="echo"] { --accent: #a796ff; --accent-soft: #2a2550; }
  :root:not([data-theme="light"]) body[data-game="swift"] { --accent: #ffad42; --accent-soft: #3a2a14; }
  :root:not([data-theme="light"]) body[data-game="linkr"] { --accent: #3fd6c3; --accent-soft: #123532; }
}
:root[data-theme="dark"] { --bg: #0f1115; --ink: #eef0f4; --muted: #a0a8b6; --card: #181b22; --line: #2b303a; --soft: #21252e; --accent: #8aa4ff; --accent-soft: #232b45; --on-accent: #0f1115; --good: #5fd38d; --bad: #ff8a75; --warn: #f0b43c; --gold: #f2c14e; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark; }
:root[data-theme="dark"] body[data-game="echo"] { --accent: #a796ff; --accent-soft: #2a2550; }
:root[data-theme="dark"] body[data-game="swift"] { --accent: #ffad42; --accent-soft: #3a2a14; }
:root[data-theme="dark"] body[data-game="linkr"] { --accent: #3fd6c3; --accent-soft: #123532; }
/* Brain Pass colour themes (accent only; game colours that carry meaning never change) */
body[data-skin="ocean"] { --accent: #1769c2; --accent-soft: #e2eefb; }
body[data-skin="ember"] { --accent: #c2410c; --accent-soft: #fdeadf; }
body[data-skin="forest"] { --accent: #2f7d32; --accent-soft: #e5f3e5; }
body[data-skin="grape"] { --accent: #8b3fb0; --accent-soft: #f3e6fa; }
body[data-skin="graphite"] { --accent: #3f4652; --accent-soft: #e8eaee; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-skin="ocean"] { --accent: #6cb4ff; --accent-soft: #15304d; }
  :root:not([data-theme="light"]) body[data-skin="ember"] { --accent: #ff9a62; --accent-soft: #3d2416; }
  :root:not([data-theme="light"]) body[data-skin="forest"] { --accent: #7fd67f; --accent-soft: #1b3520; }
  :root:not([data-theme="light"]) body[data-skin="grape"] { --accent: #d79bff; --accent-soft: #33203f; }
  :root:not([data-theme="light"]) body[data-skin="graphite"] { --accent: #c9ced8; --accent-soft: #2a2f38; }
}
:root[data-theme="dark"] body[data-skin="ocean"] { --accent: #6cb4ff; --accent-soft: #15304d; }
:root[data-theme="dark"] body[data-skin="ember"] { --accent: #ff9a62; --accent-soft: #3d2416; }
:root[data-theme="dark"] body[data-skin="forest"] { --accent: #7fd67f; --accent-soft: #1b3520; }
:root[data-theme="dark"] body[data-skin="grape"] { --accent: #d79bff; --accent-soft: #33203f; }
:root[data-theme="dark"] body[data-skin="graphite"] { --accent: #c9ced8; --accent-soft: #2a2f38; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px; padding: 8px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.bar .title { flex: 1; font-weight: 800; letter-spacing: -.01em; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar .title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .title .pill { flex: none; overflow: visible; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; flex: none; }
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 22px; height: 22px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

.wrap { max-width: 600px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: clamp(1.7rem, 7vw, 2.3rem); line-height: 1.1; letter-spacing: -.02em; margin: 8px 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn { font: inherit; font-weight: 700; min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 2px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform .08s ease, filter .15s; touch-action: manipulation; }
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.quiet { background: var(--soft); border-color: var(--soft); color: var(--ink); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.08rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 8px 4px; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; min-height: 44px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.chip { font: inherit; font-size: .92rem; font-weight: 600; min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip .lock { margin-left: 4px; }

/* Level + streak strip */
.meta { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.meta div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.meta b { display: block; font-size: 1.35rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.meta span { font-size: .78rem; color: var(--muted); }
.xpbar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.xpbar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* HUD */
.hud { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.hud .stat { text-align: center; min-width: 64px; }
.hud .stat b { display: block; font-size: 1.4rem; line-height: 1.1; }
.hud .stat span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.status { text-align: center; font-weight: 700; min-height: 1.6em; margin: 6px 0 12px; }
.hearts { letter-spacing: 2px; font-size: 1.2rem; }
.timer { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.timer i { display: block; height: 100%; background: var(--accent); width: 100%; transform-origin: left; }

/* Result */
.result { text-align: center; }
.result .score { font-size: clamp(2.6rem, 14vw, 3.6rem); font-weight: 900; letter-spacing: -.03em; line-height: 1; margin: 6px 0; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-weight: 800; font-size: .85rem; padding: 4px 10px; border-radius: 99px; background: var(--gold); color: #1b1300; margin: 4px; }
pre.share { text-align: left; white-space: pre-wrap; word-break: break-word; font: 15px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--soft); border-radius: 12px; padding: 12px; margin: 12px 0; }

/* Sheets (dialogs) */
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--card); color: var(--ink); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 20px 18px 24px; box-shadow: 0 -8px 40px rgba(0,0,0,.25); animation: rise .22s cubic-bezier(.2,.8,.2,1); position: relative; }
@media (min-width: 640px) { .scrim { align-items: center; } .sheet { border-radius: 22px; } }
.sheet .x { position: absolute; top: 8px; right: 8px; }
.sheet h2 { font-size: 1.35rem; padding-right: 44px; }
.plans { display: grid; gap: 10px; margin: 14px 0; }
.plan { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; min-height: 64px; }
.plan:hover, .plan:focus-visible { border-color: var(--accent); }
.plan.best { border-color: var(--accent); background: var(--accent-soft); }
.plan b { display: block; } .plan small { color: var(--muted); }
.plan .price { font-weight: 800; font-size: 1.1rem; white-space: nowrap; text-align: right; }
ul.perks { padding-left: 20px; margin: 8px 0; } ul.perks li { margin: 3px 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 60; max-width: calc(100vw - 32px); text-align: center; animation: toastin .2s ease; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.levelup { position: fixed; inset: 0; display: grid; place-items: center; z-index: 55; pointer-events: none; }
.levelup div { background: var(--accent); color: var(--on-accent); font-weight: 900; font-size: 1.6rem; padding: 18px 28px; border-radius: 22px; animation: pop .9s cubic-bezier(.2,1.4,.4,1) both; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.confetti { position: fixed; top: 40%; left: 50%; width: 10px; height: 10px; border-radius: 3px; z-index: 56; pointer-events: none; animation: burst 1s cubic-bezier(.1,.7,.3,1) forwards; }

/* Stats */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: 8px; }
.statgrid div { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.statgrid b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.statgrid span { font-size: .8rem; color: var(--muted); }
.chart { position: relative; margin: 12px 0 4px; }
.chart svg { width: 100%; height: 160px; display: block; overflow: visible; }
.chart .tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: .8rem; font-weight: 700; padding: 4px 8px; border-radius: 8px; pointer-events: none; white-space: nowrap; }
table.runs { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.runs th, table.runs td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); }
details { margin-top: 8px; } summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

/* Tutorial */
.steps { display: grid; gap: 10px; margin: 12px 0 16px; padding: 0; list-style: none; counter-reset: s; }
.steps li { display: flex; gap: 12px; align-items: center; background: var(--soft); border-radius: 14px; padding: 10px 12px; }
.steps .ico { font-size: 1.6rem; width: 40px; text-align: center; flex: none; }

/* Settings rows */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); min-height: 56px; }
.setting:first-of-type { border-top: 0; }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch:checked { background: var(--accent); } .switch:checked::after { transform: translateX(20px); }
select { font: inherit; min-height: 44px; padding: 6px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); }

.science { font-size: .88rem; color: var(--muted); border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 24px 0 8px; }
footer.foot { margin-top: 24px; font-size: .88rem; color: var(--muted); }
footer.foot a { color: inherit; }
/* "Also from Quickwell" strip (markup from scripts/xlinks.mjs) */
.qw-also { margin: 24px 0 0; font-size: .88rem; color: var(--muted); }
.qw-also > p { margin: 0 0 8px; font-weight: 700; }
.qw-also ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.qw-also a { display: flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--muted); text-decoration: none; }
.qw-also a:hover { border-color: var(--accent); }
.qw-also b { color: var(--ink); }

/* Motion */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes toastin { from { transform: translate(-50%, 16px); opacity: 0; } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 40% { transform: scale(1.08); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.18); } }
.shake { animation: shake .35s ease; }
.bump { animation: bump .25s ease; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .confetti { display: none; }
}
