/* Entangle — design tokens taken from thequantuminsider.com (live :root vars, Nov 2026). */
:root {
  --page: #F5F8FA;
  --card: #FFFFFF;
  --ink: #1B2A3A;
  --muted: #8A96AB;
  --slate: #66748E;
  --line: #E4E9F1;
  --navy: #15243F;
  --navy-deep: #040620;
  --teal: #0AA0AB;
  --teal-dark: #08848E;
  --teal-light: #4EC9D3;
  --teal-soft: #DFF3F4;
  --teal-softer: #EFF8F9;
  --cyan: #0ED8E8;

  --lvl0: var(--teal-soft);  --lvl0-ink: var(--navy);
  --lvl1: var(--teal-light); --lvl1-ink: var(--navy-deep);
  --lvl2: var(--teal);       --lvl2-ink: #FFFFFF;
  --lvl3: var(--navy);       --lvl3-ink: #FFFFFF;

  --sans: "Roboto", sans-serif;
  --display: "Archivo", sans-serif;
  --r-md: 14px;
  --r-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(4,6,32,.05);
  --shadow-md: 0 12px 32px rgba(4,6,32,.08);
  --shadow-lg: 0 24px 60px rgba(4,6,32,.12);
  --ease-out: cubic-bezier(.22,1,.36,1);
  --gap: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 400 16px/1.5 var(--sans); color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
main.wrap { max-width: 680px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }

/* Top strip */
.strip { background: var(--navy-deep); color: rgba(255,255,255,.78); font-size: 12px; }
.strip__inner { display: flex; justify-content: space-between; align-items: center; height: 32px; gap: 12px; }
.strip a { color: #fff; margin-left: 10px; }
.strip > div > span:first-child a { margin-left: 0; }
.strip__net { color: rgba(255,255,255,.5); }

/* Header */
.hdr { background: var(--page); border-bottom: 1px solid var(--line); }
.hdr__inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--navy); }
.brand__mark { width: 30px; height: 33px; }
.brand__name { font: 800 11.5px/1.05 var(--display); letter-spacing: .06em; color: var(--navy); }
.hdr__nav { display: flex; align-items: center; gap: 6px; }
.navlink { background: none; border: 0; cursor: pointer; font: 500 13px var(--sans); color: var(--ink); padding: 8px 10px; border-radius: 8px; }
.navlink:hover { color: var(--teal); }

/* Pills (TQI buttons) */
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px var(--sans); letter-spacing: -.01em; color: #fff; background: var(--teal); border: 1px solid var(--teal); border-radius: 32px; padding: 12px 24px; cursor: pointer; transition: background .16s var(--ease-out), color .16s, opacity .16s, transform .16s; }
.pill:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.pill:disabled { opacity: .35; cursor: default; background: var(--teal); }
.pill--sm { font-size: 12px; padding: 10px 18px; border-radius: 24px; margin-left: 6px; }
.pill--ghost { background: var(--card); color: var(--navy); border-color: var(--line); }
.pill--ghost:hover:not(:disabled) { background: var(--teal-softer); color: var(--navy); border-color: var(--teal-soft); }
.pill--ghost:disabled { background: var(--card); }
.pill--dark { background: var(--navy-deep); border-color: rgba(255,255,255,.14); }
.pill--dark:hover { background: var(--navy); border-color: var(--navy); }

/* Hero (dark, like the TQI home hero) */
.hero { background: var(--navy-deep); color: #fff; position: relative; overflow: hidden; padding: 52px 0 120px; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; }
.hero::before { width: 520px; height: 380px; right: -80px; top: -120px; background: rgba(10,160,171,.28); }
.hero::after { width: 420px; height: 300px; left: -140px; bottom: -160px; background: rgba(14,216,232,.12); }
.hero__inner { position: relative; z-index: 1; max-width: 680px; }
.eyebrow { display: flex; gap: 12px; align-items: center; margin: 0 0 16px; font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--teal-light); }
.eyebrow span + span { color: rgba(255,255,255,.55); padding-left: 12px; border-left: 1px solid rgba(255,255,255,.18); }
h1 { font: 900 clamp(38px, 7vw, 50px)/1.12 var(--display); letter-spacing: -1.5px; margin: 0 0 16px; }
h1 i { font-weight: 700; letter-spacing: -.5px; color: var(--teal-light); }
.lede { margin: 0; color: rgba(255,255,255,.78); font-size: 17px; max-width: 520px; }

/* Board card */
.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.board { margin-top: -80px; position: relative; z-index: 2; padding: 22px 22px 18px; }
.solved, .grid { display: grid; gap: var(--gap); }
.solved { margin-bottom: var(--gap); }
.grid { grid-template-columns: repeat(4, 1fr); }

.tile {
  appearance: none; cursor: pointer;
  background: var(--page); color: var(--navy);
  border: 1px solid var(--line); border-radius: var(--r-md);
  min-height: 78px; padding: 6px;
  font: 800 clamp(11.5px, 2.9vw, 15px)/1.15 var(--display);
  text-transform: uppercase; letter-spacing: .01em;
  overflow-wrap: normal; word-break: keep-all; overflow: hidden;
  transition: background .16s var(--ease-out), color .16s, border-color .16s, transform .12s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.tile.brk { overflow-wrap: anywhere; word-break: break-word; }
.tile:hover { background: var(--teal-softer); border-color: var(--teal-soft); }
.tile:active { transform: scale(.97); }
.tile.sel { background: var(--navy); border-color: var(--navy); color: #fff; }
.tile.hop { animation: hop .35s var(--ease-out); }
.grid.shake .tile.sel { animation: shake .4s ease; }
@keyframes hop { 40% { transform: translateY(-6px); } }
@keyframes shake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }

.group { border-radius: var(--r-md); min-height: 78px; padding: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; animation: reveal .32s var(--ease-out); }
.group__label { font: 900 15px var(--display); text-transform: uppercase; letter-spacing: .02em; }
.group__items { font-size: 14px; margin-top: 2px; opacity: .92; }
@keyframes reveal { from { transform: scale(.96); opacity: 0; } }
.lvl0 { background: var(--lvl0); color: var(--lvl0-ink); }
.lvl1 { background: var(--lvl1); color: var(--lvl1-ink); }
.lvl2 { background: var(--lvl2); color: var(--lvl2-ink); }
.lvl3 { background: var(--lvl3); color: var(--lvl3-ink); }

.mistakes { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 20px 0 16px; color: var(--slate); font-size: 14px; }
.dots { display: inline-flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--teal); transition: transform .3s, opacity .3s; }
.dot.gone { background: var(--line); transform: scale(.7); }

.controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.source { text-align: center; margin: 16px 0 0; font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }

/* Toast */
.toast { border: 1px solid rgba(255,255,255,.18); position: fixed; left: 50%; top: 110px; transform: translate(-50%, -8px); background: var(--navy-deep); color: #fff; padding: 10px 18px; border-radius: 24px; font: 600 14px var(--sans); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; box-shadow: var(--shadow-md); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Modals */
.modal { border: 0; border-radius: var(--r-lg); padding: 30px 26px 24px; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow-lg); color: var(--ink); }
.modal--wide { width: min(560px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(4,6,32,.55); }
.modal__x { position: absolute; right: 14px; top: 10px; background: none; border: 0; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.kicker { margin: 0 0 8px; font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--teal); }
h2 { font: 900 30px/1.15 var(--display); letter-spacing: -1px; color: var(--navy); margin: 0 0 14px; }
h2 i { font-weight: 700; color: var(--teal); letter-spacing: -.3px; }
.rules { padding-left: 18px; margin: 0 0 16px; }
.rules li { margin-bottom: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font: 700 10.5px var(--sans); text-transform: uppercase; letter-spacing: 1px; padding: 6px 10px; border-radius: 24px; }

.end__head { text-align: center; }
.end__grid { font-size: 24px; line-height: 1.15; text-align: center; letter-spacing: 2px; margin: 2px 0 14px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 14px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats b { display: block; font: 900 26px var(--display); color: var(--navy); }
.stats span { font: 700 10px var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.stories h3 { font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--slate); margin: 0 0 10px; }
.sgroup { border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 8px; overflow: hidden; }
.sgroup summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; font: 800 13px var(--display); text-transform: uppercase; letter-spacing: .02em; }
.sgroup summary::-webkit-details-marker { display: none; }
.sgroup summary::after { content: "+"; font: 400 20px var(--sans); line-height: 1; }
.sgroup[open] summary::after { content: "–"; }
.sgroup ul { list-style: none; margin: 0; padding: 4px 14px 10px; }
.sgroup li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.35; }
.sgroup li:last-child { border-bottom: 0; }
.sgroup li b { display: block; font: 700 11px var(--sans); color: var(--slate); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 1px; }
.sgroup li a { color: var(--ink); }
.sgroup li a:hover { color: var(--teal); }
.end__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.next { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }
.next b { color: var(--navy); font-variant-numeric: tabular-nums; }

/* Footer */
.foot { margin-top: 48px; background: var(--navy-deep); color: rgba(255,255,255,.6); font-size: 13px; }
.foot__inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 22px 20px; }
.foot a { color: #fff; margin-left: 14px; }
.foot__inner > span:first-child a { margin-left: 0; }

@media (max-width: 640px) {
  .strip__net { display: none; }
  .tile { padding: 4px; }
  .pill--sm { display: none; }
  .hero { padding: 36px 0 104px; }
  .board { padding: 14px 12px 14px; border-radius: 18px; }
  :root { --gap: 6px; }
  .tile, .group { min-height: 68px; border-radius: 11px; }
  .pill { padding: 11px 18px; font-size: 14px; }
  .modal { padding: 26px 18px 18px; }
  .end__grid { font-size: 20px; }
  h2 { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* =====================================================================
   v3: intro, animations, HUD
   ===================================================================== */

/* Hero particle field */
.field { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }

/* Intro panel */
.intro { animation: fadeUp .45s var(--ease-out) both; }
.intro.leaving { animation: fadeOut .26s ease both; }
.intro__head { text-align: center; padding: 8px 6px 0; }
.intro__lede { color: var(--slate); margin: -4px auto 0; max-width: 460px; font-size: 15px; }
.intro__cta { text-align: center; margin-top: 18px; }
.intro__sub { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.intro__streak { margin: 8px 0 0; font: 600 13px var(--sans); color: var(--teal-dark); }
.pill--lg { font-size: 16px; padding: 15px 30px; border-radius: 40px; box-shadow: 0 10px 24px rgba(10,160,171,.28); animation: breathe 2.6s ease-in-out infinite; }
.pill--lg svg { transition: transform .2s var(--ease-out); }
.pill--lg:hover svg { transform: translateX(4px); }
@keyframes breathe { 50% { box-shadow: 0 10px 34px rgba(10,160,171,.5), 0 0 0 6px rgba(10,160,171,.12); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-8px) scale(.98); } }

/* Looping demo: four tiles get selected, then merge into a group */
.demo { position: relative; margin: 18px auto 6px; max-width: 420px; height: 92px; }
.demo__row { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; align-items: center; }
.dt { display: flex; align-items: center; justify-content: center; height: 62px; border-radius: 12px; background: var(--page); border: 1px solid var(--line); font: 800 13px var(--display); text-transform: uppercase; color: var(--navy); animation: dsel 6s infinite var(--ease-out); }
.dt1 { animation-name: dsel1; } .dt2 { animation-name: dsel2; } .dt3 { animation-name: dsel3; }
.demo__bar { position: absolute; left: 0; right: 0; top: 15px; height: 62px; border-radius: 12px; background: var(--teal-soft); color: var(--navy); display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; transform: scale(.92); animation: dbar 6s infinite var(--ease-out); }
.demo__bar b { font: 900 13px var(--display); text-transform: uppercase; letter-spacing: .03em; }
.demo__bar span { font-size: 12px; color: var(--slate); }
.demo__cursor { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: rgba(10,160,171,.35); border: 2px solid var(--teal); top: 52px; left: 10%; animation: dcur 6s infinite var(--ease-out); pointer-events: none; }
@keyframes dsel  { 0%,9% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } 12%,52% { background: var(--navy); color: #fff; opacity: 1; transform: scale(1); } 58%,90% { background: var(--navy); color: #fff; opacity: 0; transform: scale(.88); } 91% { background: var(--page); color: var(--navy); opacity: 0; transform: scale(.96); } 100% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } }
@keyframes dsel1 { 0%,19% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } 22%,52% { background: var(--navy); color: #fff; opacity: 1; transform: scale(1); } 58%,90% { background: var(--navy); color: #fff; opacity: 0; transform: scale(.88); } 91% { background: var(--page); color: var(--navy); opacity: 0; transform: scale(.96); } 100% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } }
@keyframes dsel2 { 0%,29% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } 32%,52% { background: var(--navy); color: #fff; opacity: 1; transform: scale(1); } 58%,90% { background: var(--navy); color: #fff; opacity: 0; transform: scale(.88); } 91% { background: var(--page); color: var(--navy); opacity: 0; transform: scale(.96); } 100% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } }
@keyframes dsel3 { 0%,39% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } 42%,52% { background: var(--navy); color: #fff; opacity: 1; transform: scale(1); } 58%,90% { background: var(--navy); color: #fff; opacity: 0; transform: scale(.88); } 91% { background: var(--page); color: var(--navy); opacity: 0; transform: scale(.96); } 100% { background: var(--page); color: var(--navy); opacity: 1; transform: scale(1); } }
@keyframes dbar  { 0%,54% { opacity: 0; transform: scale(.92); } 62%,88% { opacity: 1; transform: scale(1); } 95%,100% { opacity: 0; transform: scale(.96); } }
@keyframes dcur  { 0% { left: 2%; opacity: 0; } 6% { opacity: 1; } 10% { left: 10%; } 20% { left: 35%; } 30% { left: 60%; } 40% { left: 85%; } 48% { left: 86%; opacity: 1; } 54%,100% { left: 86%; opacity: 0; } }

/* Steps */
.steps { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; line-height: 1.45; color: var(--ink); background: var(--teal-softer); border-radius: 12px; padding: 10px 12px; animation: fadeUp .4s var(--ease-out) both; }
.steps li:nth-child(2) { animation-delay: .06s; } .steps li:nth-child(3) { animation-delay: .12s; } .steps li:nth-child(4) { animation-delay: .18s; }
.steps__n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--teal); color: #fff; font: 800 12px/24px var(--display); text-align: center; }
.steps b { color: var(--navy); }
.steps em { font-style: italic; color: var(--teal-dark); }
.minichips { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 4px; }
.minichips i { width: 18px; height: 10px; border-radius: 3px; display: inline-block; }

/* HUD */
.game { animation: fadeUp .4s var(--ease-out) both; }
.hud { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 12px; font: 600 12px var(--sans); color: var(--slate); letter-spacing: .02em; }
.hud__found { display: flex; align-items: center; gap: 10px; }
.foundbar { display: inline-flex; gap: 4px; }
.foundbar i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); transition: background .4s var(--ease-out), transform .4s var(--ease-out); }
.foundbar i.on { transform: scaleY(1.4); }
.hud__timer { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; color: var(--navy); background: var(--page); border: 1px solid var(--line); padding: 4px 10px; border-radius: 20px; }

/* Playfield + entanglement lines */
.playfield { position: relative; }
.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; overflow: visible; }
.links .link { fill: none; stroke: var(--teal); stroke-width: 2; opacity: .9; stroke-linecap: round; stroke-dasharray: 6 7; animation: flow .7s linear infinite; }
.links .link-glow { fill: none; stroke: rgba(14,216,232,.28); stroke-width: 6; stroke-linecap: round; filter: blur(2px); }
.links .node { fill: var(--cyan); stroke: #fff; stroke-width: 2; filter: drop-shadow(0 0 4px rgba(14,216,232,.9)); }
.links .ready-ring circle { fill: none; stroke: var(--teal-light); stroke-width: 2; animation: ring 1.1s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes flow { to { stroke-dashoffset: -13; } }
@keyframes ring { from { opacity: .9; transform: scale(.6); } to { opacity: 0; transform: scale(2.2); } }

/* Tiles: deal-in, hover lift, selection glow, merge */
.tile { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; text-align: center; will-change: transform; }
.tile > span { display: block; max-width: 100%; }
.tile:hover:not(.sel) { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tile.sel { box-shadow: 0 0 0 3px rgba(10,160,171,.35), 0 10px 22px rgba(21,36,63,.25); }
.tile.deal { animation: deal .5s var(--ease-out) both; }
.tile.merge { transition: transform .18s ease-in, opacity .18s ease-in; transform: scale(.88); opacity: .4; }
@keyframes deal { from { opacity: 0; transform: translateY(14px) rotateX(55deg) scale(.9); } }
.grid { perspective: 900px; }

.group--in { animation: groupIn .55s var(--ease-out) both; position: relative; overflow: hidden; }
.group--in::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%); transform: translateX(-100%); animation: shimmer .9s .15s ease-out both; }
@keyframes groupIn { from { opacity: 0; transform: scale(.94); } 60% { transform: scale(1.02); } }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Submit gets lively when four are picked */
#btnSubmit.ready { animation: readyPulse 1.4s ease-in-out infinite; }
@keyframes readyPulse { 50% { box-shadow: 0 0 0 6px rgba(10,160,171,.18); } }
.pill svg { flex: none; }

/* Mistake dots decohere */
.dot { transition: transform .35s var(--ease-out), background .35s, opacity .35s; }
.dot.gone { animation: decohere .5s var(--ease-out); }
@keyframes decohere { 30% { transform: scale(1.6); background: #8A96AB; } 100% { transform: scale(.7); } }

/* Toast flavours */
.toast.good { background: var(--teal); }
.toast.warn { background: #F2B33D; color: var(--navy-deep); }
.toast.bad { background: #C7354A; }
.toast.on { animation: toastPop .3s var(--ease-out); }
@keyframes toastPop { from { transform: translate(-50%, -12px) scale(.9); } }

/* End screen */
.end__meta { margin: -6px 0 10px; color: var(--slate); font-size: 14px; }
.end__meta b { color: var(--navy); }
.end__grid div { animation: fadeUp .35s var(--ease-out) both; }
.modal[open] { animation: modalIn .38s var(--ease-out); }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }

@media (max-width: 640px) {
  .demo { height: 80px; }
  .dt, .demo__bar { height: 54px; font-size: 11px; }
  .demo__bar { top: 13px; }
  .demo__cursor { top: 45px; }
  .steps li { font-size: 13.5px; }
  .foundbar i { width: 16px; }
}
@media (prefers-reduced-motion: reduce) { .field { display: none; } }

/* =====================================================================
   v4: Sort mode
   ===================================================================== */
.sort { animation: fadeUp .4s var(--ease-out) both; }

/* Mode toggle on the intro */
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--page); border: 1px solid var(--line); border-radius: 16px; padding: 5px; max-width: 380px; margin: 16px auto 0; }
.mode button { border: 0; background: none; border-radius: 12px; padding: 9px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--slate); transition: background .2s var(--ease-out), color .2s, box-shadow .2s; }
.mode button b { font: 800 14px var(--display); text-transform: uppercase; letter-spacing: .03em; }
.mode button small { font: 500 11px var(--sans); }
.mode button.on { background: var(--card); color: var(--navy); box-shadow: var(--shadow-md); }
.mode button.on b { color: var(--teal); }

/* Sort demo: names fly up into a category */
.sdemo { max-width: 420px; margin: 18px auto 6px; display: grid; gap: 14px; }
.sdemo__bucket { border: 2px dashed var(--teal-light); background: var(--teal-softer); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; animation: sbk 6s infinite; }
.sdemo__bucket b { font: 900 13px var(--display); text-transform: uppercase; color: var(--navy); letter-spacing: .03em; }
.sdemo__slots { display: inline-flex; gap: 4px; }
.sdemo__slots i { width: 16px; height: 6px; border-radius: 3px; background: var(--line); }
.sdemo__slots .s0 { animation: sl0 6s infinite; } .sdemo__slots .s1 { animation: sl1 6s infinite; }
.sdemo__slots .s2 { animation: sl2 6s infinite; } .sdemo__slots .s3 { animation: sl3 6s infinite; }
.sdemo__tray { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.st { display: flex; align-items: center; justify-content: center; height: 46px; border-radius: 12px; background: var(--page); border: 1px solid var(--line); font: 800 12.5px var(--display); text-transform: uppercase; color: var(--navy); }
.st0 { animation: st0 6s infinite var(--ease-out); } .st1 { animation: st1 6s infinite var(--ease-out); }
.st2 { animation: st2 6s infinite var(--ease-out); } .st3 { animation: st3 6s infinite var(--ease-out); }
@keyframes st0 { 0%,6%   { transform: none; opacity: 1; background: var(--page); color: var(--navy); } 10% { transform: translateY(-4px); opacity: 1; background: var(--navy); color: #fff; } 16%,92% { transform: translate(150%, -64px) scale(.35); opacity: 0; background: var(--navy); color: #fff; } 100% { transform: none; opacity: 1; background: var(--page); color: var(--navy); } }
@keyframes st1 { 0%,24%  { transform: none; opacity: 1; background: var(--page); color: var(--navy); } 28% { transform: translateY(-4px); opacity: 1; background: var(--navy); color: #fff; } 34%,92% { transform: translate(50%, -64px) scale(.35); opacity: 0; background: var(--navy); color: #fff; } 100% { transform: none; opacity: 1; background: var(--page); color: var(--navy); } }
@keyframes st2 { 0%,42%  { transform: none; opacity: 1; background: var(--page); color: var(--navy); } 46% { transform: translateY(-4px); opacity: 1; background: var(--navy); color: #fff; } 52%,92% { transform: translate(-50%, -64px) scale(.35); opacity: 0; background: var(--navy); color: #fff; } 100% { transform: none; opacity: 1; background: var(--page); color: var(--navy); } }
@keyframes st3 { 0%,60%  { transform: none; opacity: 1; background: var(--page); color: var(--navy); } 64% { transform: translateY(-4px); opacity: 1; background: var(--navy); color: #fff; } 70%,92% { transform: translate(-150%, -64px) scale(.35); opacity: 0; background: var(--navy); color: #fff; } 100% { transform: none; opacity: 1; background: var(--page); color: var(--navy); } }
@keyframes sl0 { 0%,15% { background: var(--line); } 16%,92% { background: var(--teal); } 100% { background: var(--line); } }
@keyframes sl1 { 0%,33% { background: var(--line); } 34%,92% { background: var(--teal); } 100% { background: var(--line); } }
@keyframes sl2 { 0%,51% { background: var(--line); } 52%,92% { background: var(--teal); } 100% { background: var(--line); } }
@keyframes sl3 { 0%,69% { background: var(--line); } 70%,92% { background: var(--teal); } 100% { background: var(--line); } }
@keyframes sbk { 0%,70% { border-style: dashed; background: var(--teal-softer); } 72%,90% { border-style: solid; border-color: var(--teal); background: var(--teal-soft); } 100% { border-style: dashed; } }

/* Sort HUD */
.shud { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 12px; }
.shud__score { display: flex; align-items: baseline; gap: 8px; }
.shud__lbl { font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.shud__score b { font: 900 26px/1 var(--display); color: var(--navy); font-variant-numeric: tabular-nums; min-width: 2ch; }
.combo { font: 800 12px var(--display); text-transform: uppercase; color: #fff; background: linear-gradient(90deg, var(--teal), var(--cyan)); border-radius: 20px; padding: 3px 9px; opacity: 0; transform: scale(.6); transition: opacity .2s, transform .25s var(--ease-out); }
.combo.on { opacity: 1; transform: scale(1); }
.shud__right { display: flex; align-items: center; gap: 12px; }
.dot.life { width: 13px; height: 13px; }

/* Buckets */
.buckets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bucket { appearance: none; text-align: left; cursor: pointer; background: var(--card); border: 2px solid var(--line); border-radius: var(--r-md); padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 124px; font: inherit; color: inherit; transition: border-color .2s, box-shadow .2s, transform .2s var(--ease-out), background .2s; }
.bucket__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 11px; }
.bucket__label { font: 900 12.5px/1.2 var(--display); text-transform: uppercase; letter-spacing: .02em; }
.bucket__count { display: inline-flex; gap: 3px; flex: none; }
.bucket__count i { width: 12px; height: 5px; border-radius: 3px; background: currentColor; opacity: .25; transition: opacity .3s; }
.bucket__count i.on { opacity: 1; }
.bucket__body { flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; padding: 9px; position: relative; }
.bucket__drop { position: absolute; inset: 8px; border: 1.5px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; font: 600 12px var(--sans); color: var(--muted); opacity: 0; transition: opacity .2s; pointer-events: none; }
.bucket.target { border-color: var(--teal-light); }
.bucket.target:not(.has) .bucket__drop { opacity: 1; border-color: var(--teal-light); color: var(--teal); }
.bucket.target { animation: targetPulse 1.4s ease-in-out infinite; }
@keyframes targetPulse { 50% { box-shadow: 0 0 0 4px rgba(10,160,171,.14); } }
.bucket.over { border-color: var(--teal); background: var(--teal-softer); transform: scale(1.03); box-shadow: var(--shadow-md); animation: none; }
.bucket.full { cursor: default; border-color: var(--lc); }
.bucket.full.target { animation: none; border-color: var(--lc); }
.bucket.full .bucket__head::after { content: "✓"; font: 900 14px var(--display); margin-left: 6px; }
.bucket.justdone { animation: done .7s var(--ease-out); }
@keyframes done { 30% { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(10,160,171,.25); } }
.bucket.nope { animation: nope .5s ease; }
@keyframes nope { 0%,100% { border-color: var(--line); } 20%,60% { border-color: #C7354A; background: #FCEEF0; transform: translateX(-4px); } 40%,80% { transform: translateX(4px); } }
.hintglow { animation: hintGlow 1s ease-in-out infinite !important; }
@keyframes hintGlow { 50% { box-shadow: 0 0 0 5px rgba(242,179,61,.5); border-color: #F2B33D; } }

.pchip { font: 700 12px var(--sans); color: var(--navy); background: var(--teal-softer); border: 1px solid var(--teal-soft); border-radius: 8px; padding: 4px 8px; white-space: nowrap; }
.pchip.revealed { background: #F7F7F7; border-color: var(--line); color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(199,53,74,.5); }

/* Fact line */
.fact { margin: 12px 0 4px; min-height: 52px; display: flex; flex-direction: column; justify-content: center; gap: 4px; background: var(--page); border-radius: 12px; padding: 9px 12px; border-left: 3px solid var(--teal); font-size: 13.5px; line-height: 1.4; }
.fact__empty { color: var(--muted); }
.fact__tag { align-self: flex-start; font: 700 9.5px var(--sans); text-transform: uppercase; letter-spacing: 1px; padding: 2px 7px; border-radius: 10px; }
.fact__text b { color: var(--navy); margin-right: 4px; }
.fact__text a { white-space: nowrap; font-weight: 600; }

/* Tray */
.tray__hint { text-align: center; font: 600 13px var(--sans); color: var(--slate); margin: 12px 0 8px; transition: color .2s; }
.tray__hint.active { color: var(--teal-dark); }
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; min-height: 48px; margin-bottom: 16px; }
.chip-t { appearance: none; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; background: var(--page); border: 1px solid var(--line); color: var(--navy); border-radius: 12px; padding: 10px 14px; font: 800 13px var(--display); text-transform: uppercase; letter-spacing: .01em; transition: background .16s, color .16s, box-shadow .2s, transform .16s var(--ease-out), opacity .2s; }
.chip-t:hover { background: var(--teal-softer); border-color: var(--teal-soft); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.chip-t.picked { background: var(--navy); border-color: var(--navy); color: #fff; transform: translateY(-3px); box-shadow: 0 0 0 3px rgba(10,160,171,.35), 0 10px 22px rgba(21,36,63,.25); }
.chip-t.dragging { opacity: .25; }
.chip-t.deal { animation: deal .45s var(--ease-out) both; }
.chip-t.ghost { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; background: var(--navy); color: #fff; box-shadow: var(--shadow-lg); cursor: grabbing; transition: none; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; border-radius: 10px; background: var(--teal); color: #fff; font: 700 11px var(--sans); padding: 0 6px; }
.pill:disabled .badge { background: var(--muted); }

.floatpts { position: fixed; z-index: 70; pointer-events: none; font: 900 18px var(--display); color: var(--teal); text-shadow: 0 2px 8px rgba(10,160,171,.35); }

/* Sort end screen */
.scorecard { background: var(--page); border-radius: 14px; padding: 12px 16px; margin: 4px 0 12px; }
.scorecard__total { display: flex; justify-content: space-between; align-items: baseline; }
.scorecard__total span { font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.scorecard__total b { font: 900 34px var(--display); color: var(--teal); }
.scorecard__rows { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line); }
.scorecard__rows li { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; color: var(--slate); }
.scorecard__rows b { color: var(--navy); }

@media (max-width: 640px) {
  .buckets { gap: 7px; }
  .bucket { min-height: 108px; }
  .bucket__head { padding: 7px 8px; flex-direction: column; align-items: flex-start; gap: 4px; }
  .bucket__label { font-size: 11px; }
  .bucket__body { padding: 6px; gap: 4px; }
  .pchip { font-size: 10.5px; padding: 3px 6px; }
  .chip-t { padding: 9px 11px; font-size: 12px; }
  .shud__score b { font-size: 22px; }
  .st { height: 40px; font-size: 11px; }
  .fact { font-size: 12.5px; }
}

/* =====================================================================
   v5: end screen redesign + Platform CTA; always light (fixes dark-mode dialogs)
   ===================================================================== */
:root { color-scheme: light; }
.modal { background: var(--card); color: var(--ink); padding: 0; overflow-x: hidden; }
.modal > form .modal__x { z-index: 5; }
#helpBody { padding: 30px 26px 24px; }
#endBody { padding: 0 0 22px; }
#endBody > *:not(.banner) { margin-left: 22px; margin-right: 22px; }

/* Result banner */
.banner { position: relative; text-align: center; padding: 30px 24px 22px; color: #fff; overflow: hidden; }
.banner--won { background: radial-gradient(120% 140% at 80% 0%, #19C6D2 0%, var(--teal) 40%, var(--teal-dark) 100%); }
.banner--lost { background: radial-gradient(120% 140% at 80% 0%, #24406B 0%, var(--navy) 45%, var(--navy-deep) 100%); }
.banner::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 15% 110%, rgba(255,255,255,.14), transparent 45%); pointer-events: none; }
.banner__kicker { margin: 0 0 6px; font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: rgba(255,255,255,.75); }
.banner h2 { color: #fff; margin: 0 0 6px; font-size: 32px; }
.banner h2 i { color: #fff; opacity: .92; }
.banner--lost h2 i { color: var(--teal-light); opacity: 1; }
.banner__meta { margin: 0; color: rgba(255,255,255,.85); font-size: 14.5px; }
.banner__meta b { color: #fff; }
.banner__score { margin: 14px auto 0; display: inline-flex; flex-direction: column; align-items: center; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: 16px; padding: 8px 22px 10px; position: relative; z-index: 1; }
.banner__score span { font: 700 10px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: rgba(255,255,255,.75); }
.banner__score b { font: 900 38px/1.05 var(--display); color: #fff; letter-spacing: -1px; }
.banner__score small { font-size: 11.5px; color: rgba(255,255,255,.8); }
.modal__x { color: rgba(255,255,255,.85); }
#dlgHelp .modal__x { color: var(--muted); }

.end__trail { text-align: center; font-size: 20px; line-height: 1.2; letter-spacing: 2px; margin-top: 16px !important; }
.end__trail div { animation: fadeUp .35s var(--ease-out) both; }

/* Platform CTA */
.pcta { position: relative; overflow: hidden; margin-top: 18px !important; background: var(--navy-deep); color: #fff; border-radius: 18px; padding: 20px 20px 18px; box-shadow: 0 18px 40px rgba(4,6,32,.28); }
.pcta__glow { position: absolute; width: 320px; height: 220px; right: -90px; top: -110px; background: rgba(10,160,171,.45); filter: blur(60px); border-radius: 50%; pointer-events: none; }
.pcta > *:not(.pcta__glow) { position: relative; }
.pcta__eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font: 700 10.5px var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--teal-light); }
.pcta__badge { letter-spacing: 1px; font-size: 9.5px; color: var(--navy-deep); background: linear-gradient(90deg, #F2B33D, #FFD27A); border-radius: 20px; padding: 3px 8px; }
.pcta h3 { font: 900 22px/1.2 var(--display); letter-spacing: -.5px; margin: 0 0 8px; color: #fff; }
.pcta h3 i { font-weight: 700; color: var(--teal-light); }
.pcta__lede { margin: 0 0 14px; color: rgba(255,255,255,.78); font-size: 14px; line-height: 1.5; }
.pcta__stats { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pcta__stats li { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: 8px 10px; }
.pcta__stats b { display: block; font: 900 18px var(--display); color: #fff; }
.pcta__stats span { font-size: 11.5px; color: rgba(255,255,255,.65); }
.pcta__actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pill--cta { font-size: 15px; padding: 13px 22px; box-shadow: 0 10px 26px rgba(10,160,171,.45); animation: breathe 2.6s ease-in-out infinite; }
.pill--cta svg { transition: transform .2s var(--ease-out); }
.pill--cta:hover svg { transform: translateX(4px); }
.pcta__link { color: #fff; font: 600 14px var(--sans); border-bottom: 1px solid rgba(255,255,255,.35); padding-bottom: 1px; }
.pcta__link:hover { color: var(--teal-light); border-color: var(--teal-light); }

/* Stories with marks */
.stories { margin-top: 4px; }
.sgroup summary { gap: 10px; }
.sgroup summary > span:first-child { flex: 1; }
.sgroup__n { font: 700 11px var(--sans); background: rgba(255,255,255,.35); border-radius: 10px; padding: 2px 8px; }
.sgroup li { display: flex; gap: 10px; align-items: flex-start; }
.sgroup li .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font: 800 11px var(--sans); margin-top: 2px; }
.sgroup li.ok .mark { background: var(--teal-soft); color: var(--teal-dark); }
.sgroup li.miss .mark { background: #FCEEF0; color: #C7354A; }
.sgroup li div { min-width: 0; }

/* Soft CTAs */
.fact__platform { align-self: flex-start; font: 600 12px var(--sans); color: var(--teal-dark); border-bottom: 1px dashed rgba(10,160,171,.5); margin-top: 2px; }
.intro__powered { display: inline-block; margin-top: 14px; font-size: 12.5px; color: var(--slate); }
.intro__powered b { color: var(--teal-dark); }
.intro__powered:hover b { text-decoration: underline; }

@media (max-width: 640px) {
  #endBody > *:not(.banner) { margin-left: 16px; margin-right: 16px; }
  .banner { padding: 26px 18px 18px; }
  .banner h2 { font-size: 26px; }
  .pcta { padding: 18px 16px 16px; }
  .pcta h3 { font-size: 19px; }
  .pcta__stats b { font-size: 16px; }
  #helpBody { padding: 26px 18px 18px; }
}
#endBody > .kicker:first-child { padding-top: 28px; }

/* Real TQI logo */
.brand__logo { display: block; height: 40px; width: auto; }
.foot__brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.foot__brand img { display: block; height: 32px; width: auto; }
.foot__brand a { margin-left: 0 !important; }
@media (max-width: 640px) { .brand__logo { height: 32px; } .foot__brand img { height: 28px; } }
