/* Higher or Lower: BFSI edition. Play surface = a banknote field: deep blue guilloche, slips with a gold security thread. */
:root {
  --brand: #0020a5;
  --brand-2: #253cc0;
  --sec: #4648d4;
  --field: #0a1a86;
  --field-deep: #06125e;
  --line: rgba(160, 180, 255, .13);
  --slip: #f5f7fc;
  --ink: #0e1546;
  --muted: #56608f;
  --thread: #d6a21e;
  --up: #11855a;
  --down: #c3352d;
  --radius-card: 18px;
  --radius-btn: 12px;
  --head: 'Plus Jakarta Sans', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body);
  color: #fff;
  background-color: var(--field-deep);
  background-image:
    repeating-radial-gradient(circle at 18% 12%, transparent 0 13px, var(--line) 13px 14px),
    repeating-radial-gradient(circle at 92% 88%, transparent 0 17px, var(--line) 17px 18px),
    linear-gradient(170deg, var(--brand) 0%, var(--field) 45%, var(--field-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body.forced-w #stage { max-width: var(--force-w); }
#stage { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: 0 16px; }
.rail-slot:empty { display: none; }
[hidden] { display: none !important; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--thread); outline-offset: 3px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: var(--radius-btn); border: 0; cursor: pointer; font-family: var(--head); font-weight: 700; font-size: 16px; text-decoration: none; transition: transform .08s ease, background .15s; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn-primary { background: #fff; color: var(--brand); }
.btn-primary:hover { background: #e9edff; }
.btn-quiet { background: transparent; color: #cfd7ff; border: 1px solid rgba(207, 215, 255, .35); min-height: 40px; font-size: 14px; }
.btn-signup { background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, .6); }
.btn-signup.lead { background: var(--thread); color: var(--ink); border-color: var(--thread); }
.small { font-size: 13px; color: #b9c3f5; line-height: 1.5; }

/* ---------- title ---------- */
.scr-title { min-height: 100dvh; padding: 16px 0; display: flex; flex-direction: column; justify-content: center; gap: 28px; max-width: 460px; margin: 0 auto; }
.title-cards { position: relative; height: clamp(150px, 26dvh, 210px); }
.tcard { position: absolute; width: 62%; padding: 18px 18px 20px 24px; border-radius: var(--radius-card); background: var(--slip); color: var(--ink); box-shadow: 0 18px 40px rgba(2, 8, 50, .45); display: flex; flex-direction: column; gap: 8px; }
.tcard::before { content: ''; position: absolute; left: 10px; top: 14px; bottom: 14px; width: 3px; border-radius: 2px; background: repeating-linear-gradient(180deg, var(--thread) 0 7px, transparent 7px 11px); }
.tcard-a { left: 0; top: 0; transform: rotate(-4deg); }
.tcard-b { right: 0; top: 84px; transform: rotate(3deg); animation: nudge 2.6s ease-in-out infinite; }
.t-lab { font-size: 13px; color: var(--muted); font-weight: 600; }
.t-val { font-family: var(--head); font-weight: 800; font-size: 40px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tcard-b .t-val { color: var(--brand); }
@keyframes nudge { 0%, 100% { transform: rotate(3deg) translateY(0); } 30% { transform: rotate(2deg) translateY(-12px); } 60% { transform: rotate(4deg) translateY(10px); } }
.panel { display: flex; flex-direction: column; gap: 12px; }
.kicker { margin: 0; font-size: 13px; font-weight: 600; color: var(--thread); }
h1 { margin: 0; font-family: var(--head); font-weight: 800; font-size: clamp(40px, 11vw, 60px); line-height: .95; letter-spacing: -.035em; }
.goal { margin: 4px 0 0; font-size: 19px; font-weight: 600; line-height: 1.35; }
.sub { margin: 0 0 8px; color: #c5ceff; font-size: 15px; line-height: 1.5; }
.row-btns { display: flex; gap: 8px; }

/* ---------- HUD ---------- */
/* play: a fixed-height shell, never a page scroll. Layout rules: docs/DESKTOP.md */
.scr-play { position: relative; display: flex; flex-direction: column; gap: 8px; height: 100dvh; overflow: hidden; padding: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom)); margin: 0 auto; }
.play-grid { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 10px; }
.play-main { flex: none; }
.play-side { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 12px; }
.dock { position: relative; flex: 1 1 200px; min-height: 190px; }
.dk { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.dk[hidden] { display: none !important; }
.dk-foot { display: flex; flex-direction: column; gap: 8px; }
.keys { display: none; margin: 0; font-size: 12.5px; color: #b9c3f5; text-align: center; }
.rv-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; outline: none; display: flex; flex-direction: column; gap: 6px; }
.rv-meta { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.rv-meta span:empty { display: none; }
.note-hint { margin: 0; font-size: 13px; color: #dbe1ff; text-align: center; }
.note-hint:empty { display: none; }
.hud { flex: none; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.chain { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 4px 10px; border-radius: 12px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(214, 162, 30, .5); }
.chain-n { font-family: var(--head); font-weight: 800; font-size: 28px; line-height: 1.05; color: var(--thread); font-variant-numeric: tabular-nums; display: inline-block; }
.chain-l { font-size: 11px; color: #c5ceff; }
.hud-mid p { margin: 0; }
.level { font-family: var(--head); font-weight: 700; font-size: 15px; }
.theme { font-size: 13px; color: #b9c3f5; display: inline-block; transform-origin: left center; }
.hud-right { display: flex; align-items: center; gap: 8px; }
[hidden].hot { display: none; }
.hot { font-size: 12px; font-weight: 700; color: var(--ink); background: var(--thread); padding: 4px 9px; border-radius: 999px; display: inline-block; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(207, 215, 255, .35); background: transparent; cursor: pointer; position: relative; }
.icon-btn::before { content: ''; position: absolute; inset: 11px; background: #cfd7ff; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05A4.5 4.5 0 0 0 16.5 12z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05A4.5 4.5 0 0 0 16.5 12z'/%3E%3C/svg%3E") center/contain no-repeat; }
.icon-btn.off::after { content: ''; position: absolute; left: 8px; right: 8px; top: 19px; height: 2px; background: #cfd7ff; transform: rotate(-45deg); }
.clock.off { visibility: hidden; }
.clock { flex: none; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.clock-fill { height: 100%; background: var(--thread); transform-origin: left; }
.clock.low .clock-fill { background: #ff7a6b; }

/* ---------- board ---------- */
.board { display: flex; flex-direction: column; gap: 6px; }
.card { position: relative; background: var(--slip); color: var(--ink); border-radius: var(--radius-card); padding: 12px 16px 12px 30px; box-shadow: 0 14px 34px rgba(2, 8, 50, .42); }
.card::before { content: ''; position: absolute; left: 13px; top: 16px; bottom: 16px; width: 3px; border-radius: 2px; background: repeating-linear-gradient(180deg, var(--thread) 0 7px, transparent 7px 11px); }
.card p { margin: 0; }
.c-lab { font-family: var(--head); font-weight: 700; font-size: 16px; line-height: 1.25; height: 2.5em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.c-val { font-family: var(--head); font-weight: 800; font-size: clamp(30px, min(11vw, 6.4dvh), 56px); line-height: 1.1; letter-spacing: -.025em; margin: 6px 0 4px !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-val.hidden-val { color: var(--brand); }
.c-val.rolling { color: var(--sec); }
.c-meta { font-size: 12.5px; line-height: 1.3; height: 1.3em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); padding-right: 74px; }
.card-known { background: #e7ebf8; }
.seam { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.seam::before, .seam::after { content: ''; flex: 1; height: 1px; background: rgba(214, 162, 30, .55); }
.ask { margin: 0; font-family: var(--head); font-weight: 700; font-size: 15px; text-align: center; max-width: 80%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drag-zone { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.dir { align-self: center; line-height: 16px; font-family: var(--head); font-weight: 800; font-size: 12px; color: #fff; opacity: .35; padding: 2px 12px; border-radius: 999px; transition: opacity .1s, background .1s; display: flex; align-items: center; gap: 6px; }
.dir-up::before { content: ''; border: 6px solid transparent; border-bottom-color: currentColor; border-top: 0; }
.dir-down::before { content: ''; border: 6px solid transparent; border-top-color: currentColor; border-bottom: 0; }
.dir.armed { opacity: 1 !important; background: rgba(255, 255, 255, .16); }
.card-new { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .25s cubic-bezier(.2, 1.4, .4, 1), box-shadow .2s, background .2s; }
.card-new.dragging { cursor: grabbing; box-shadow: 0 24px 50px rgba(2, 8, 50, .55); }
.card-new.right { background: #e5f6ee; }
.card-new.right .c-val { color: var(--up); }
.card-new.wrong { background: #fbe9e7; }
.card-new.wrong .c-val { color: var(--down); }
.verdict { position: absolute; right: 12px; bottom: 10px; font-family: var(--head); font-weight: 800; font-size: 13px; padding: 4px 10px; border-radius: 999px; color: #fff; background: var(--ink); }
.card-new.right .verdict { background: var(--up); }
.card-new.wrong .verdict { background: var(--down); }
.card-new.enter { animation: deal .36s cubic-bezier(.2, 1.3, .4, 1); }
.card-known.enter-l { animation: deal-l .36s ease-out; }
.card-new.gone, .card-known.gone { transition: transform .2s ease-in, opacity .2s; opacity: 0; }
.card-new.gone { transform: translateY(-40px) scale(.97); }
@keyframes deal { from { transform: translateY(60px) rotate(2deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes deal-l { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-call:disabled { opacity: .45; cursor: default; }
.btn-call { min-height: 54px; font-size: 17px; background: rgba(255, 255, 255, .1); color: #fff; border: 1.5px solid rgba(255, 255, 255, .45); }
.btn-call svg { width: 16px; height: 16px; fill: currentColor; }
.btn-call:hover { background: rgba(255, 255, 255, .18); }
.note { background: rgba(4, 10, 60, .72); border: 1px solid rgba(214, 162, 30, .35); border-radius: 14px; padding: 12px 14px; }
.note p { margin: 0; }
.note-gap { font-family: var(--head); font-weight: 700; font-size: 15px; color: var(--thread); }
.note-take { font-size: 15px; line-height: 1.45; }
.note-src { font-size: 12px; color: #aab5ee; }
.hint { margin: 0; text-align: center; font-size: 14.5px; line-height: 1.4; color: #dbe1ff; }
.hint.tut { background: var(--thread); color: var(--ink); font-weight: 600; padding: 8px 11px; border-radius: 9px; }

.pop { position: absolute; left: 30px; top: 56px; font-family: var(--head); font-weight: 800; font-size: 26px; color: var(--thread); opacity: 0; pointer-events: none; }
.pop.go { animation: pop .8s ease-out; }
@keyframes pop { 0% { opacity: 0; transform: translateY(6px) scale(.7); } 20% { opacity: 1; transform: translateY(0) scale(1.15); } 100% { opacity: 0; transform: translateY(-34px) scale(1); } }
.bump { animation: bump .32s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }
.banner { position: absolute; left: 0; right: 0; top: 38%; margin: 0 auto; max-width: 340px; text-align: center; background: var(--thread); color: var(--ink); font-family: var(--head); font-weight: 800; font-size: 18px; line-height: 1.3; padding: 14px 18px; border-radius: 14px; box-shadow: 0 18px 40px rgba(2, 8, 50, .5); animation: banner 2.2s ease both; z-index: 5; pointer-events: none; }
@keyframes banner { 0% { opacity: 0; transform: scale(.85); } 12%, 85% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }
.freeze * { animation-play-state: paused !important; }
.shake { animation: shake .38s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(5px); } 30%, 50%, 70% { transform: translateX(-9px); } 40%, 60% { transform: translateX(9px); } }

/* ---------- end ---------- */
.scr-end { padding: 20px 0 130px; display: flex; flex-direction: column; gap: 12px; }
.end-left { display: flex; flex-direction: column; gap: 10px; }
.end-big { margin: 0; display: flex; align-items: baseline; gap: 12px; }
#end-n { font-family: var(--head); font-weight: 800; font-size: 88px; line-height: 1; letter-spacing: -.04em; color: var(--thread); font-variant-numeric: tabular-nums; }
.end-unit { font-family: var(--head); font-weight: 700; font-size: 22px; }
#end-best:empty, .end-promo:empty { display: none; }
.best-stamp { display: inline-block; font-family: var(--head); font-weight: 800; font-size: 18px; color: var(--thread); border: 3px solid var(--thread); border-radius: 8px; padding: 2px 12px; transform: rotate(-5deg); animation: stamp .4s cubic-bezier(.2, 1.6, .4, 1) .5s both; }
@keyframes stamp { from { transform: rotate(-5deg) scale(2.2); opacity: 0; } to { transform: rotate(-5deg) scale(1); opacity: 1; } }
.end-panel { display: flex; flex-direction: column; gap: 12px; }
.miss, .learned { background: var(--slip); color: var(--ink); border-radius: 14px; padding: 14px 16px; }
.miss:empty, .learned:empty { display: none; }
.miss-h { margin: 0 0 8px; font-family: var(--head); font-weight: 700; font-size: 14px; color: var(--muted); }
.miss-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 6px 0; border-top: 1px solid #dfe3f3; font-size: 14px; }
.miss-row b { font-family: var(--head); font-size: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.miss-row b.up { color: var(--up); }
.miss-row b.down { color: var(--down); }
.miss-take { margin: 8px 0 0; font-size: 14px; line-height: 1.45; }
.learned ul { margin: 0; padding-left: 18px; }
.learned li { font-size: 14px; line-height: 1.45; margin: 6px 0; }
.learned li b { font-weight: 600; }
.asof { margin: 0; }
/* phones: Share / Play again live in a fixed bottom bar, always in reach */
.end-actions { position: fixed; z-index: 5; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 520px); padding: 10px 16px max(10px, env(safe-area-inset-bottom)); background: var(--field-deep); box-shadow: 0 -6px 18px rgba(0, 0, 30, .4); }
.end-actions .row-btns .btn { flex: 1; padding: 0 10px; }
.btn-share { background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, .6); }
.end-actions .small { margin: 6px 0 0; text-align: center; max-height: 3em; overflow: hidden; }
.end-actions .small:empty { display: none; }

/* ---------- tablets: the same single column, a little wider ---------- */
@media (min-width: 600px) and (max-width: 1023px) {
  #stage { max-width: 600px; }
  .end-actions { width: min(100%, 600px); }
}

/* ---------- desktop (1024+): board left (cards side by side), dock + promo rail right ---------- */
@media (min-width: 1024px) {
  #stage { max-width: 1240px; padding: 0 24px; }
  .scr-play { --side: 320px; --pw: min(760px, calc(100vw - 72px - var(--side))); padding: 14px 0 16px; }
  .hud, .clock { width: calc(var(--pw) + 24px + var(--side)); margin: 0 auto; }
  .play-grid { display: grid; grid-template-columns: var(--pw) var(--side); gap: 24px; justify-content: center; align-items: stretch; }
  .play-main { align-self: center; }
  .board { display: grid; grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1fr); align-items: center; gap: 12px; }
  .seam { flex-direction: column; height: 100%; justify-content: center; }
  .seam::before, .seam::after { width: 1px; height: auto; flex: 1; }
  .ask { max-width: none; white-space: normal; }
  .card { height: 230px; display: flex; flex-direction: column; justify-content: center; padding: 18px 18px 18px 30px; }
  .c-lab { font-size: 17px; }
  .c-val { font-size: clamp(32px, 3vw, 44px); }
  .c-meta { white-space: normal; height: 2.6em; padding-right: 0; }
  .verdict { position: static; align-self: flex-start; margin-top: 8px; }
  .card .verdict[hidden] { display: inline-block !important; visibility: hidden; } /* reserve its line: the value never shifts */
  .dock { flex: 1 1 auto; min-height: 0; }
  .dk-call { padding: 16px; border-radius: 14px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .16); }
  .note { padding: 16px; }
  .hint { text-align: left; font-size: 16px; }
  .scr-title { flex-direction: row; align-items: center; justify-content: center; gap: 56px; max-width: none; }
  .title-cards { flex: 0 1 460px; height: 260px; }
  .scr-title .panel { flex: 0 0 380px; }
  .scr-end {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "left panel" "actions panel" ". panel"; gap: 0 32px; height: 100dvh; padding: 24px 0; max-width: 1120px; margin: 0 auto;
  }
  .end-left { grid-area: left; }
  .end-actions { grid-area: actions; position: static; transform: none; width: auto; padding: 12px 0 0; background: none; box-shadow: none; }
  .end-panel { grid-area: panel; min-height: 0; overflow-y: auto; }
}
@media (min-width: 1024px) and (hover: hover) { .keys { display: block; text-align: left; } }
@media (min-width: 1280px) { .scr-play { --side: 360px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
