/* =========================================================
   Next Move · game.css
   Premium financial-game surface: dark, glassy, chart-first.
   Palette matches the other Playtrade mini-games.
   ========================================================= */

:root {
  --bg: #0b0d11;
  --card: #15181d;
  --card-2: #1e2227;
  --line: #2d2f34;
  --text: #f7f8fa;
  --muted: #9ba1a8;
  --muted-2: #6f7680;
  --green: #22a180;
  --green-2: #07d8a2;
  --gain: #1fc47a;
  --loss: #f2456f;
  --orange: #ff9100;
  --gold: #ffc700;
  --blue: #87bfff;
  --violet: #b39ddb;
  --glass: rgba(18, 21, 26, .72);
  --glass-2: rgba(24, 28, 34, .82);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --r: 16px;
  --safe-t: max(10px, env(safe-area-inset-top));
  --safe-b: max(10px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; touch-action: manipulation; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}

button { font-family: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--green-2); outline-offset: 2px; border-radius: 8px; }

/* Result flashes: colour plus an icon in the feedback card, never colour alone */
body.flash-good::after, body.flash-bad::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 40;
  animation: flashOut .42s ease-out forwards;
}
body.flash-good::after { background: radial-gradient(ellipse at center, rgba(31,196,122,.16), transparent 70%); }
body.flash-bad::after { background: radial-gradient(ellipse at center, rgba(242,69,111,.18), transparent 70%); }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }

/* ---------- brand ---------- */
.brandbar {
  position: fixed; top: var(--safe-t); left: 16px; z-index: 30;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.brandbar .logo { display: flex; color: #fff; }
.brandbar .logo svg { height: 20px; width: auto; }
.brandbar .sep { width: 1px; height: 15px; background: rgba(255,255,255,.22); }
.brandbar .pt { font-size: 11px; font-weight: 800; letter-spacing: .5px; color: var(--green-2); }

/* =========================================================
   Play screen
   ========================================================= */
#play {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  height: 100%; width: min(1180px, 100%); margin: 0 auto;
  padding: calc(var(--safe-t) + 34px) 16px var(--safe-b);
  gap: 10px;
}

/* ---------- HUD ---------- */
.hud {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  height: 52px; padding: 0 14px; flex: 0 0 auto;
  background: var(--glass); border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
/* Explicit columns: the timer is hidden between scenarios, and without
   this the right-hand group would slide into the middle column. */
.hud-left { grid-column: 1; display: flex; align-items: center; gap: 14px; min-width: 0; }
.timer { grid-column: 2; }
.hud-right { grid-column: 3; display: flex; align-items: center; gap: 10px; justify-content: flex-end; }

.lives { display: flex; gap: 4px; }
.lives .heart { font-style: normal; font-size: 16px; line-height: 1; color: var(--loss); transition: color .25s, transform .25s; }
.lives .heart.gone { color: rgba(255,255,255,.16); }
.lives .heart.breaking { animation: heartBreak .6s ease-out; }
@keyframes heartBreak {
  0% { transform: scale(1.35); color: #fff; }
  40% { transform: scale(.85) rotate(-12deg); color: var(--loss); }
  100% { transform: scale(1); }
}

.streak { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.streak .s-icon { font-size: 13px; filter: grayscale(1) opacity(.5); }
.streak.on { color: var(--orange); }
.streak.on .s-icon { filter: none; }
.streak.hot { color: var(--gold); }
.streak.hot .s-icon { animation: streakPulse 1.4s ease-in-out infinite; }
.streak .s-mult { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: rgba(255,199,0,.16); color: var(--gold); }
@keyframes streakPulse { 50% { transform: scale(1.22); } }

.timer { position: relative; width: 42px; height: 42px; display: grid; place-items: center; justify-self: center; }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 3; }
.timer .t-track { stroke: rgba(255,255,255,.1); }
.timer .t-arc { stroke: var(--green-2); stroke-linecap: round; stroke-dasharray: 100.5; transition: stroke-dashoffset .1s linear, stroke .3s; }
.timer span { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.urgent .t-arc { stroke: var(--loss); }
.timer.urgent span { color: var(--loss); animation: urgent .6s ease-in-out infinite; }
@keyframes urgent { 50% { transform: scale(1.14); } }

.score-box { text-align: right; line-height: 1.05; }
.score-box b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-box small { display: block; font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--muted-2); }
.lvl-chip { font-size: 10px; font-weight: 800; letter-spacing: .6px; padding: 4px 8px; border-radius: 7px; background: rgba(7,216,162,.13); color: var(--green-2); white-space: nowrap; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04);
  display: grid; place-items: center; transition: background .15s, opacity .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.off { opacity: .42; }

/* ---------- stage ---------- */
.stage { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }

.chart-panel {
  flex: 1 1 auto; min-height: 0; position: relative;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(23,27,33,.9), rgba(15,18,22,.92));
  border: 1px solid rgba(255,255,255,.09); border-radius: var(--r);
  box-shadow: 0 24px 60px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05);
  overflow: hidden;
  transform-style: preserve-3d;
}
/* the "camera" settling as the next chart arrives */
.chart-panel.entering { animation: panelIn .42s cubic-bezier(.2,.9,.3,1.05); }
@keyframes panelIn {
  from { opacity: 0; transform: perspective(1400px) rotateX(5deg) translateY(14px) scale(.985); }
  to { opacity: 1; transform: perspective(1400px) rotateX(0) translateY(0) scale(1); }
}
.chart-panel.shake { animation: panelShake .4s ease-out; }
@keyframes panelShake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } 100% { transform: none; }
}

.chart-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px 6px; flex: 0 0 auto;
}
.chart-head .sym { font-size: 15px; font-weight: 800; letter-spacing: .3px; }
.chart-head .tf { font-size: 11px; font-weight: 700; color: var(--muted); padding: 2px 6px; border-radius: 5px; background: rgba(255,255,255,.06); }
.chip { font-size: 10px; font-weight: 800; letter-spacing: .5px; padding: 3px 7px; border-radius: 6px; text-transform: uppercase; }
.chip.diff { background: rgba(255,255,255,.07); color: var(--muted); }
.chip.diff.d2 { color: var(--blue); background: rgba(135,191,255,.12); }
.chip.diff.d3 { color: var(--orange); background: rgba(255,145,0,.12); }
.chip.diff.d4 { color: var(--loss); background: rgba(242,69,111,.14); }
.chip.cat { background: rgba(255,255,255,.06); }
.chart-head .spacer { flex: 1; }
.chart-head .prompt { font-size: 12px; font-weight: 700; color: var(--muted); }
.chart-head .sim {
  font-size: 9px; font-weight: 800; letter-spacing: .7px; color: var(--muted-2);
  border: 1px solid rgba(255,255,255,.1); padding: 2px 6px; border-radius: 5px;
}

#chart { flex: 1 1 auto; width: 100%; min-height: 0; display: block; }

.hints { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 12px 10px; flex: 0 0 auto; }
.hint {
  font-size: 11px; font-weight: 600; color: #cfd4da;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07);
  padding: 4px 9px; border-radius: 8px;
}
.hint b { display: inline-block; margin-right: 6px; font-weight: 800; color: var(--muted-2); text-transform: uppercase; font-size: 9px; letter-spacing: .5px; }
.hint.insight { background: rgba(7,216,162,.1); border-color: rgba(7,216,162,.25); color: #d6fff2; }
.hint.insight b { color: var(--green-2); }

.progress-note { font-size: 11px; font-weight: 700; color: var(--muted-2); letter-spacing: .3px; }

/* ---------- feedback ---------- */
.feedback {
  flex: 0 0 auto; position: relative; overflow: hidden;
  background: var(--glass-2); border: 1px solid var(--line); border-left-width: 4px;
  border-radius: 13px; padding: 11px 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fbIn .28s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes fbIn { from { opacity: 0; transform: translateY(10px); } }
.feedback.right { border-left-color: var(--gain); }
.feedback.wrong { border-left-color: var(--loss); }

.fb-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.fb-verdict { font-size: 16px; font-weight: 900; letter-spacing: .3px; }
.feedback.right .fb-verdict { color: var(--gain); }
.feedback.wrong .fb-verdict { color: var(--loss); }
.fb-points { font-size: 15px; font-weight: 800; color: var(--gain); font-variant-numeric: tabular-nums; }
.fb-actual { font-size: 13px; color: var(--muted); }
.fb-actual b { color: var(--text); font-weight: 800; }
.fb-move { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.fb-why { margin: 7px 0 0; font-size: 13.5px; line-height: 1.52; color: #d9dde1; }
.fb-myth { margin: 7px 0 0; font-size: 12px; line-height: 1.5; color: #c8cdd3; padding-left: 10px; border-left: 2px solid rgba(255,199,0,.4); }
.fb-myth b { color: var(--gold); font-weight: 800; margin-right: 6px; }
.fb-foot { display: flex; align-items: center; gap: 10px; margin-top: 9px; flex-wrap: wrap; }
.fb-concept { font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--c, var(--green-2)); border: 1px solid currentColor; padding: 3px 8px; border-radius: 6px; opacity: .9; }
/* Naming the pattern and whether it had actually confirmed is half the lesson. */
.fb-pattern { font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--c, #9ba1a8); background: color-mix(in srgb, var(--c, #9ba1a8) 14%, transparent); padding: 3px 8px; border-radius: 6px; }
@supports not (color: color-mix(in srgb, red 50%, transparent)) { .fb-pattern { background: rgba(255,255,255,.08); } }
.fb-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
/* Shown when the card is waiting rather than counting down — a miss is
   the moment to read, so nothing hurries the player along. */
.fb-wait { font-size: 11px; font-weight: 700; color: var(--muted-2); }
/* The track has to be visible, or the draining bar reads as a line that
   has been cut off rather than a countdown with distance left to run.
   The bar always runs to completion — nothing interrupts it, because a
   countdown that stops early is indistinguishable from a broken one. */
.fb-bar {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: rgba(255,255,255,.16);
}
/* Duration arrives inline as --dwell so the reduced-motion override below
   can re-assert it; a bare inline animation-duration loses to !important. */
.fb-bar i { display: block; height: 100%; background: var(--green-2); width: 100%; transform-origin: left; animation: fbBar var(--dwell, 3s) linear forwards; }
@keyframes fbBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- controls ---------- */
.controls { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }

.powerups { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.pu {
  display: flex; align-items: center; gap: 5px; padding: 5px 10px;
  border-radius: 9px; border: 1px solid rgba(255,255,255,.11);
  background: rgba(255,255,255,.04); font-size: 12px; font-weight: 700;
  transition: background .15s, border-color .15s, transform .1s;
}
.pu:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.pu:active:not(:disabled) { transform: scale(.95); }
.pu:disabled { opacity: .35; cursor: not-allowed; }
.pu.armed { border-color: var(--green-2); background: rgba(7,216,162,.15); color: #d6fff2; }
.pu-i { font-size: 13px; }
.pu-n { font-size: 10px; font-weight: 800; color: var(--muted); }

.answers { display: flex; justify-content: center; gap: 10px; }
.answers button {
  position: relative; flex: 0 1 186px; min-height: 56px; padding: 9px 14px;
  border-radius: 13px; border: 2px solid rgba(255,255,255,.12);
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 15px; font-weight: 900; letter-spacing: .5px;
  transition: transform .1s, border-color .15s, background .15s, opacity .2s;
}
/* NO TRADE carries the longest label, so it gets a little more room. */
.answers button[data-a="NO_TRADE"] { flex-basis: 200px; }
.answers button small { font-size: 10px; font-weight: 600; letter-spacing: .1px; color: var(--muted); }
.answers button .a-icon { font-size: 15px; margin-right: 5px; }
.answers button:active:not(:disabled) { transform: scale(.97); }
.answers button[data-a="UP"] { color: var(--gain); }
.answers button[data-a="DOWN"] { color: var(--loss); }
.answers button[data-a="NO_TRADE"] { color: #d7dbe0; }
.answers button[data-a="UP"]:hover:not(:disabled) { border-color: var(--gain); background: rgba(31,196,122,.16); }
.answers button[data-a="DOWN"]:hover:not(:disabled) { border-color: var(--loss); background: rgba(242,69,111,.16); }
.answers button[data-a="NO_TRADE"]:hover:not(:disabled) { border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.1); }
.answers button:disabled { cursor: not-allowed; }
.answers.locked button { opacity: .38; }
.answers.locked button.picked { opacity: 1; border-color: currentColor; background: rgba(255,255,255,.08); }
/* The result is marked with a glyph as well as colour (spec §51) */
.answers.locked button.is-correct { opacity: 1; border-color: var(--gain); background: rgba(31,196,122,.2); }
.answers.locked button.is-correct::after {
  content: '✓'; position: absolute; top: 5px; right: 8px; font-size: 13px; color: var(--gain);
}
.answers.locked button.picked:not(.is-correct)::after {
  content: '✕'; position: absolute; top: 5px; right: 8px; font-size: 13px; color: var(--loss);
}
.answers button.disabled-5050 { opacity: .16; text-decoration: line-through; }

.keyhint { text-align: center; font-size: 10.5px; color: var(--muted-2); font-weight: 600; }
.keyhint kbd {
  font-family: inherit; font-size: 10px; font-weight: 700; padding: 1px 5px; margin: 0 1px;
  border: 1px solid rgba(255,255,255,.14); border-radius: 4px; background: rgba(255,255,255,.05);
}

/* ---------- start countdown ---------- */
#countdown {
  position: fixed; inset: 0; z-index: 48;
  display: grid; place-items: center; text-align: center; pointer-events: none;
}
#countdown .n {
  display: block; line-height: 1; color: #fff;
  font: 900 min(22vw, 132px)/1 var(--font);
  text-shadow: 0 0 44px rgba(7,216,162,.55), 0 8px 40px rgba(0,0,0,.6);
  animation: cdPop .82s ease-out forwards;
}
#countdown .n.go { color: var(--green-2); font-size: min(17vw, 104px); letter-spacing: -2px; }
@keyframes cdPop {
  0% { transform: scale(1.75); opacity: 0; }
  22% { transform: scale(1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}
/* The controls sit under the count, so they are fresh for the first chart. */
#countdown .cd-keys {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 104px);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px;
  width: max-content; max-width: calc(100% - 24px);
  padding: 6px 14px; border-radius: 999px;
  background: rgba(10,12,15,.5); border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font: 600 12.5px var(--font); color: rgba(255,255,255,.66);
}
#countdown .cd-keys b { color: var(--text); font-weight: 800; }
#countdown .cd-keys kbd {
  font-family: inherit; font-size: 11px; font-weight: 700; padding: 2px 6px; margin: 0 1px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 5px; background: rgba(255,255,255,.07);
}
/* Reduced motion: keep the number readable instead of animating it away. */
body.reduced-motion #countdown .n { animation: none; opacity: 1; }

/* ---------- transient ---------- */
#pops { position: fixed; inset: 0; pointer-events: none; z-index: 45; }
.pop {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: 26px; font-weight: 900; white-space: nowrap;
  text-shadow: 0 3px 16px rgba(0,0,0,.8); animation: popRise 1.2s ease-out forwards;
}
.pop.good { color: var(--gain); }
.pop.bad { color: var(--loss); }
.pop.info { color: #fff; }
@keyframes popRise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -110%) scale(1); }
}

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-t) + 60px); z-index: 46;
  display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none;
  width: min(420px, calc(100% - 32px));
}
.toast {
  display: flex; flex-direction: column; gap: 1px; width: 100%;
  padding: 8px 13px; border-radius: 11px;
  background: rgba(20,24,30,.94); border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1.1);
}
.toast.out { animation: toastOut .4s ease-in forwards; }
.toast b { font-size: 12.5px; font-weight: 800; }
.toast span { font-size: 11px; color: var(--muted); }
.toast.good { border-color: rgba(31,196,122,.4); }
.toast.good b { color: var(--gain); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* =========================================================
   Overlays
   ========================================================= */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px 16px;
  background: rgba(8,10,13,.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  overflow-y: auto; overscroll-behavior: contain;
}
.card {
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: linear-gradient(180deg, rgba(26,30,37,.97), rgba(17,20,25,.98));
  border: 1px solid rgba(255,255,255,.1); border-radius: 20px;
  padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
  animation: cardIn .34s cubic-bezier(.2,.9,.3,1.05);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.card.wide { width: min(680px, 100%); }

.title { font-size: clamp(30px, 6vw, 44px); font-weight: 900; letter-spacing: -1.2px; margin: 0; line-height: 1; }
.title em { font-style: normal; color: var(--green-2); }
.tagline { margin: 8px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.kicker { font-size: 10px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--green-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; min-height: 48px; width: 100%;
  border-radius: 12px; border: none; background: var(--green-2); color: #04211a;
  font-size: 14px; font-weight: 800; letter-spacing: .3px;
  transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn.big { font-size: 15px; min-height: 54px; }
.btn.small { width: auto; min-height: 36px; padding: 8px 15px; font-size: 12.5px; border-radius: 9px; }
.btn.ghost { background: rgba(255,255,255,.07); color: var(--text); border: 1px solid rgba(255,255,255,.13); }
.btn.ghost:hover { background: rgba(255,255,255,.13); }
.link-btn { background: none; border: none; padding: 6px 2px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

/* ---------- home ---------- */

/* The three answers, explained once. */
.legend {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 20px 0 6px; padding: 16px 0;
  border-top: 1px solid rgba(255,255,255,.08); border-bottom: 1px solid rgba(255,255,255,.08);
}
.lg { text-align: center; min-width: 0; }
.lg svg { display: block; width: 52px; height: 17px; margin: 0 auto 8px; overflow: visible; }
.lg svg polyline { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.lg.down svg polyline { stroke: var(--loss); }
.lg.flat svg polyline { stroke: #9ba1a8; }
.lg.up svg polyline { stroke: var(--gain); }
.lg b { display: block; font-size: 12.5px; font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
.lg .lg-i { font-size: 9px; vertical-align: 1px; }
.lg.down b { color: var(--loss); }
.lg.flat b { color: #c3c8ce; }
.lg.up b { color: var(--gain); }
/* Direct child only — the arrow lives in a span inside <b> and must stay inline. */
.lg > span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); font-weight: 600; }

.section-label {
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted-2); margin: 18px 0 9px;
}

/* Two mode cards, radio-style. */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode {
  position: relative; text-align: left; padding: 14px 15px;
  border-radius: 14px; border: 2px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.035);
  transition: border-color .15s, background .15s, transform .1s;
}
.mode:hover { background: rgba(255,255,255,.07); }
.mode:active { transform: scale(.99); }
.mode .radio {
  position: absolute; top: 13px; right: 13px; width: 17px; height: 17px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.28); transition: border-color .15s;
}
.mode .k {
  display: block; font-size: 10.5px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); padding-right: 22px;
}
.mode b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.3px; margin: 3px 0 4px; }
.mode .m-desc { display: block; font-size: 11.5px; line-height: 1.45; color: var(--muted); font-weight: 600; }

.mode.practice[aria-checked="true"] { border-color: var(--green-2); background: rgba(7,216,162,.1); }
.mode.practice[aria-checked="true"] .k { color: var(--green-2); }
.mode.practice[aria-checked="true"] .radio { border-color: var(--green-2); box-shadow: inset 0 0 0 3.5px var(--green-2); }
.mode.survival[aria-checked="true"] { border-color: var(--orange); background: rgba(255,145,0,.09); }
.mode.survival[aria-checked="true"] .k { color: var(--orange); }
.mode.survival[aria-checked="true"] .radio { border-color: var(--orange); box-shadow: inset 0 0 0 3.5px var(--orange); }

.menu-controls {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px;
  margin: 16px 0 14px; font-size: 11.5px; font-weight: 600; color: var(--muted-2);
}
.menu-controls kbd {
  font-family: inherit; font-size: 10.5px; font-weight: 700; padding: 2px 6px;
  border: 1px solid rgba(255,255,255,.14); border-radius: 5px; background: rgba(255,255,255,.05);
  color: var(--muted);
}
.menu-controls .sep { opacity: .5; margin: 0 2px; }

.home-stats-inline { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); font-weight: 600; min-width: 0; }
.lvl-pill { font-size: 10px; font-weight: 800; letter-spacing: .6px; padding: 3px 7px; border-radius: 6px; background: rgba(7,216,162,.14); color: var(--green-2); flex: 0 0 auto; }
/* Collapsible explainer. */
.how { margin-top: 16px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(255,255,255,.03); }
.how summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 15px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 800;
}
.how summary::-webkit-details-marker { display: none; }
.how summary svg { width: 16px; height: 16px; color: var(--muted); transition: transform .2s; flex: 0 0 auto; }
.how[open] summary svg { transform: rotate(180deg); }
.how-body { padding: 0 15px 14px; }
.how-body p { margin: 0 0 9px; font-size: 12.5px; line-height: 1.6; color: #cfd4da; }
.how-body p:last-child { margin-bottom: 0; }
.how-body b { color: var(--text); font-weight: 800; }
.how-lead { color: #d9dde1 !important; }
.how-note { color: var(--muted-2) !important; font-size: 11.5px !important; margin-top: 12px !important; }

.how-answers { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.how-a {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border-radius: 10px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07);
}
.how-a b { font-size: 12.5px; font-weight: 800; white-space: nowrap; }
.how-a span { font-size: 12px; color: var(--muted); flex: 1; min-width: 150px; }
.how-a.down b { color: var(--loss); }
.how-a.up b { color: var(--gain); }
.how-a.flat b { color: #d7dbe0; }

.how-rules { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.how-rules li { font-size: 12px; line-height: 1.55; color: var(--muted); padding-left: 11px; position: relative; }
.how-rules li::before { content: ''; position: absolute; left: 0; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--green-2); opacity: .7; }
.how-rules b { display: inline-block; min-width: 74px; color: var(--text); font-weight: 800; }

.xp-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 5px; }
.xp-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--green-2)); border-radius: 3px; transition: width .6s cubic-bezier(.2,.9,.3,1); }
.home-foot { margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.fineprint { font-size: 10px; color: var(--muted-2); line-height: 1.5; margin: 14px 0 0; font-weight: 600; }

/* ---------- onboarding ---------- */
.ob-list { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.ob-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.ob-row .ob-k { font-size: 17px; font-weight: 900; width: 26px; text-align: center; flex: 0 0 auto; }
.ob-row.up .ob-k { color: var(--gain); }
.ob-row.down .ob-k { color: var(--loss); }
.ob-row.nt .ob-k { color: #d7dbe0; }
.ob-row b { display: block; font-size: 13px; font-weight: 800; }
.ob-row span { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ---------- chapters ---------- */
.chapter-list { display: flex; flex-direction: column; gap: 7px; margin: 16px 0; }
.chapter {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 13px; border-radius: 11px;
  border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.035);
  transition: background .15s, border-color .15s;
}
.chapter:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.2); }
.ch-n { width: 24px; height: 24px; flex: 0 0 auto; border-radius: 7px; display: grid; place-items: center; background: rgba(7,216,162,.14); color: var(--green-2); font-size: 11px; font-weight: 900; }
.ch-body { flex: 1; min-width: 0; }
.ch-body b { display: block; font-size: 13px; font-weight: 800; }
.ch-body small { font-size: 11px; color: var(--muted); }
.ch-meta { font-size: 10px; font-weight: 700; color: var(--muted-2); text-align: right; flex: 0 0 auto; }
.ch-meta em { display: block; font-style: normal; font-size: 13px; font-weight: 800; color: var(--green-2); }

/* ---------- result screen ---------- */
/* A game-over screen, not a dashboard: label, headline, score, three
   stats, everything analytical behind one disclosure. */
.over { text-align: center; }

.over-label {
  display: block; font-size: 10px; font-weight: 800; letter-spacing: 1.6px;
  text-transform: uppercase; color: var(--muted-2);
}
.over-title {
  margin: 8px 0 0; font-size: clamp(24px, 5vw, 32px); font-weight: 800;
  letter-spacing: -.6px; line-height: 1.15;
}

.over-score { margin-top: 22px; }
.over-score b {
  display: block; font-size: clamp(52px, 12vw, 72px); font-weight: 900;
  letter-spacing: -2.5px; line-height: 1; font-variant-numeric: tabular-nums;
}
.over-score span {
  display: block; margin-top: 6px; font-size: 10px; font-weight: 800;
  letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted-2);
}

.over-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.over-badge {
  font-size: 10px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase;
  padding: 5px 11px; border-radius: 7px;
}
.over-badge.best { color: var(--gold); background: rgba(255,199,0,.13); border: 1px solid rgba(255,199,0,.3); }
.over-badge.level { color: var(--green-2); background: rgba(7,216,162,.12); border: 1px solid rgba(7,216,162,.3); }

.over-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 24px; }
.over-stats div {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-radius: 13px; padding: 14px 8px;
}
.over-stats b { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.over-stats span {
  display: block; margin-top: 3px; font-size: 9.5px; font-weight: 700;
  letter-spacing: .7px; text-transform: uppercase; color: var(--muted-2);
}

/* ---- collapsed breakdown ---- */
.over-more {
  margin-top: 14px; text-align: left;
  border: 1px solid rgba(255,255,255,.09); border-radius: 13px; background: rgba(255,255,255,.03);
}
.over-more summary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 15px; cursor: pointer; list-style: none;
  font-size: 12.5px; font-weight: 800; color: var(--muted);
}
.over-more summary::-webkit-details-marker { display: none; }
.over-more summary:hover { color: var(--text); }
.over-more summary svg { width: 15px; height: 15px; transition: transform .2s; flex: 0 0 auto; }
.over-more[open] summary svg { transform: rotate(180deg); }
.over-more-body { padding: 2px 15px 15px; }

.sk-list { display: flex; flex-direction: column; gap: 7px; }
.sk { display: grid; grid-template-columns: 1fr 76px 52px; align-items: center; gap: 10px; }
.sk-name { font-size: 12px; font-weight: 700; }
.sk-bar { height: 4px; border-radius: 3px; background: rgba(255,255,255,.09); overflow: hidden; }
.sk-bar i { display: block; height: 100%; border-radius: 3px; background: var(--muted); }
.sk-bar i.good { background: var(--gain); }
.sk-bar i.mid { background: var(--gold); }
.sk-bar i.low { background: var(--loss); }
.sk-pct { font-size: 12px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.sk-pct em { display: block; font-style: normal; font-size: 9.5px; font-weight: 600; color: var(--muted-2); }

.over-insights {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 15px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08);
}
.over-insights span {
  display: block; font-size: 9.5px; font-weight: 800; letter-spacing: .9px;
  text-transform: uppercase; color: var(--muted-2); margin-bottom: 3px;
}
.over-insights b { font-size: 13px; font-weight: 800; color: var(--gain); }
.over-insights b.warn { color: var(--orange); }
.over-tip { margin: 12px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); }

.over-ach { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.over-ach span {
  font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--gold); background: rgba(255,199,0,.1);
  border: 1px solid rgba(255,199,0,.26); padding: 4px 9px; border-radius: 6px;
}

.over-actions { margin-top: 22px; }
.over-links {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px;
}
.over-links .sep { color: var(--muted-2); opacity: .6; }
.over .fineprint { text-align: center; }

/* ---------- paused ---------- */
.pause-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 760px) {
  #play { padding: calc(var(--safe-t) + 30px) 10px var(--safe-b); gap: 8px; }
  .hud { height: 46px; padding: 0 10px; gap: 8px; border-radius: 12px; }
  .score-box b { font-size: 16px; }
  .score-box small { display: none; }
  .lvl-chip { display: none; }
  .timer { width: 36px; height: 36px; }
  .timer span { font-size: 11.5px; }
  .hud-left { gap: 9px; }
  .hud-right { gap: 7px; }
  .icon-btn { width: 29px; height: 29px; }
  .chart-head { padding: 8px 10px 4px; gap: 6px; }
  .chart-head .sym { font-size: 13px; }
  .chart-head .prompt { display: none; }
  .chart-head .sim { display: none; }
  .hints { padding: 5px 10px 8px; gap: 5px; }
  .hint { font-size: 10px; padding: 3px 7px; }
  .answers { gap: 7px; }
  .answers button,
  .answers button[data-a="NO_TRADE"] { flex: 1 1 0; min-height: 54px; font-size: 13.5px; border-radius: 12px; padding: 8px 6px; }
  .answers button small { font-size: 9px; }
  .fb-why { font-size: 12.5px; }
  .fb-move { margin-left: 0; width: 100%; }
  .keyhint { display: none; }
  .card { padding: 20px 18px; border-radius: 17px; }
  .over-score b { letter-spacing: -1.6px; }
  .over-stats { gap: 7px; }
  .over-stats div { padding: 12px 5px; border-radius: 11px; }
  .over-stats b { font-size: 19px; }
  .sk { grid-template-columns: 1fr 52px 46px; }
  .brandbar { left: 10px; }
  .brandbar .logo svg { height: 17px; }
}

@media (max-width: 380px) {
  .answers button,
  .answers button[data-a="NO_TRADE"] { font-size: 12px; min-height: 50px; }
  .answers button small { display: none; }
  .over-insights { grid-template-columns: 1fr; gap: 12px; }
}

/* Short landscape phones: give the chart every pixel it can get */
@media (max-height: 560px) and (orientation: landscape) {
  .hints { display: none; }
  .powerups { display: none; }
  .keyhint { display: none; }
  .answers button,
  .answers button[data-a="NO_TRADE"] { min-height: 46px; }
  .fb-why { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}
/* The feedback countdown is a progress indicator, not decoration. Collapsing
   it to .01ms empties the bar the instant it appears, which looks broken and
   tells the player nothing about how long they have. It keeps its duration,
   set inline from the dwell. */
@media (prefers-reduced-motion: reduce) {
  .fb-bar i { animation-duration: var(--dwell, 3s) !important; }
}
body.reduced-motion .fb-bar i { animation-duration: var(--dwell, 3s) !important; }


/* =========================================================
   Arena embedding — the game inside the Playtrade player.
   Only what the shell needs; the game's own look is unchanged.
   ========================================================= */
html.direct-start #home,
html.direct-start #onboard { display: none !important; }
/* The attract loop on the join screen is watch-only: no chrome, no panels, no pointer */
html.is-preview .brandbar,
html.is-preview .hud,
html.is-preview .powerups,
html.is-preview .keyhint,
html.is-preview .overlay,
/* streak, power-up and achievement toasts: noise in a watch-only loop */
html.is-preview #toasts { display: none !important; }
html.is-preview #answers { pointer-events: none; opacity: .92; }
/* Compact answer buttons: the sub-labels are unreadable at preview size and only make the
   row tall, so the loop shows the three calls alone */
html.is-preview .answers button small { display: none; }
html.is-preview .answers button {
  min-height: 38px;
  padding: 6px 10px;
  gap: 0;
  font-size: 10.5px;
}
html.is-preview .answers button > span { white-space: nowrap; }
html.is-preview .answers button .a-icon { font-size: 12.5px; margin-right: 4px; }
/* the corner glyph crowds the short labels once the buttons are compact; in a watch-only
   loop the picked button's border and fill already mark the result */
html.is-preview .answers.locked button.is-correct::after,
html.is-preview .answers.locked button.picked:not(.is-correct)::after { content: none; }
/* The preview box is only 240px tall on phones. The reveal panel is flex: 0 0 auto, so its
   prose cannot shrink and it overflows the stage onto the answer buttons. Keep the verdict
   line, drop the prose, and clip the stage so nothing can spill whatever the height. */
html.is-preview .stage { overflow: hidden; }
@media (max-height: 380px) {
  /* In a 240px preview there is no room for the reveal panel beside the chart and the
     answers; the ✓/✕ on the answer button already carries the result. */
  html.is-preview .feedback { display: none; }
}
/* #play reserves 34px for the brand bar, which the preview hides — give it to the chart */
html.is-preview #play { padding-top: calc(var(--safe-t) + 10px); }
html.is-preview body { overflow: hidden; }
/* Inside the player the game already fills the frame, so it keeps its own brand bar out */
html.is-embedded .brandbar { display: none; }
/* …and gives back most of the space #play was reserving for it, so the HUD does not float
   far below the player's own header */
html.is-embedded #play { padding-top: calc(var(--safe-t) + 16px); }
