:root {
  --primary: #0020a5; --primary-2: #253cc0; --secondary: #4648d4;
  --ink: #1b2240; --ink-2: #4a5272; --ink-3: #7d849e;
  --desk: #dbe7e6; --desk-line: #bcd2d3; --slip: #fcfcf7; --slip-edge: #e6e6dc;
  --stamp: #4b3fc4; --chit: #fff3a8; --pen: #1d3fa8;
  --good: #1f8a5b; --bad: #c0283d; --warn: #d9822b;
  --radius-slip: 6px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif; color: var(--ink); background-color: var(--desk);
  /* security-paper guilloche */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='48'%3E%3Cg fill='none' stroke='%23bcd2d3' stroke-width='1'%3E%3Cpath d='M0 24 C20 4 60 4 80 24 S140 44 160 24'/%3E%3Cpath d='M0 24 C20 44 60 44 80 24 S140 4 160 24'/%3E%3Cpath d='M0 12 C40 -4 40 28 80 12 S120 -4 160 12' opacity='.6'/%3E%3Cpath d='M0 36 C40 52 40 20 80 36 S120 52 160 36' opacity='.6'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button, a.btn { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 3px; }

#stage { max-width: 440px; margin: 0 auto; min-height: 100dvh; position: relative; }
.screen { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }

h1, h2, .stamp, .btn, .lbl, .when b, .who b { font-family: 'Plus Jakarta Sans', Inter, sans-serif; }

/* ---------- slips (the cards) ---------- */
.slip {
  background: var(--slip); border-radius: var(--radius-slip); position: relative;
  box-shadow: 0 1px 0 var(--slip-edge), 0 10px 24px -14px rgba(27, 34, 64, .45), 0 2px 6px -3px rgba(27, 34, 64, .2);
  padding: 22px 18px 18px;
}
.slip::before { /* perforated top edge */
  content: ''; position: absolute; left: 10px; right: 10px; top: 8px; height: 4px;
  background: radial-gradient(circle, var(--desk) 1.6px, transparent 1.9px) 0 0 / 9px 4px repeat-x; opacity: .9;
}
.form-no { position: absolute; top: 16px; right: 16px; font-size: 11px; color: var(--ink-3); letter-spacing: .02em; }

/* ---------- title ---------- */
.brandbar { display: flex; justify-content: space-between; align-items: center; padding: 4px 2px; }
.logo { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; color: var(--primary); font-size: 17px; }
.exam-tag { font-size: 12px; color: var(--ink-2); background: rgba(255, 255, 255, .6); padding: 4px 8px; border-radius: 99px; }
.title-wrap { padding-top: 6px; }
.title-slip { padding: 34px 22px 18px; touch-action: none; cursor: grab; user-select: none; }
.title-slip h1 { font-size: clamp(46px, 14vw, 62px); line-height: .92; margin: 6px 0 14px; letter-spacing: -0.03em; font-weight: 800; color: var(--primary); }
.pitch { font-size: 16px; line-height: 1.5; margin: 0 0 16px; color: var(--ink-2); max-width: 34ch; }
.title-cast { display: flex; gap: 6px; margin-bottom: 8px; }
.title-cast .photo { width: 44px; height: 53px; }
.drag-hint { text-align: center; font-size: 13px; color: var(--ink-3); margin: 10px 0 0; }
.drag-hint .arrow { display: inline-block; animation: nudge 1.6s ease-in-out infinite; }
.drag-hint .arrow:first-child { animation-direction: reverse; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
.title-actions { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.goal-box { background: rgba(0, 32, 165, .06); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.4; color: var(--ink-2); display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.goal-box b { color: var(--primary); font-size: 14px; }
.goal-box em { font-style: normal; font-weight: 700; color: var(--ink); }
.found-line { text-align: center; font-size: 13px; color: var(--ink-2); margin: 2px 0 0; min-height: 1em; }

.btn { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 10px 16px; border-radius: 10px; border: 0; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 3px 0 #00157a; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #00157a; }
.btn.ghost { background: rgba(255, 255, 255, .75); color: var(--primary); box-shadow: inset 0 0 0 2px rgba(0, 32, 165, .18); }
.btn.quiet { background: transparent; color: var(--primary); box-shadow: inset 0 0 0 2px rgba(0, 32, 165, .25); }

/* ---------- stamps ---------- */
.stamp {
  position: absolute; z-index: 3; pointer-events: none; color: var(--stamp); border: 3px solid var(--stamp);
  box-shadow: inset 0 0 0 2px var(--slip), inset 0 0 0 4px var(--stamp);
  padding: 7px 12px; border-radius: 6px; font-weight: 800; font-size: 19px; line-height: 1.1; text-transform: uppercase;
  letter-spacing: .02em; opacity: 0; max-width: 78%; text-align: center; background: rgba(252, 252, 247, .5);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.85' numOctaves='2' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.45'/%3E%3C/filter%3E%3Crect width='120' height='60' filter='url(%23n)'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.85' numOctaves='2' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.45'/%3E%3C/filter%3E%3Crect width='120' height='60' filter='url(%23n)'/%3E%3C/svg%3E");
}
.st-L { top: 62%; right: 14px; transform: rotate(9deg); transform-origin: right center; }
.st-R { top: 62%; left: 14px; transform: rotate(-9deg); transform-origin: left center; }
.title-slip .st-L, .title-slip .st-R { top: 46%; font-size: 26px; }

/* ---------- HUD ---------- */
.hud { display: flex; flex-direction: column; gap: 8px; }
.prog-top { display: flex; align-items: center; gap: 8px; }
.prog-top b { font: 800 17px 'Plus Jakarta Sans', sans-serif; color: var(--primary); white-space: nowrap; }
.prog-month { font-size: 12px; color: var(--ink-2); flex: 1; line-height: 1.2; }
.prog-month.warn { color: #a65a12; font-weight: 600; }
.prog-bar { --months: 4; position: relative; height: 6px; border-radius: 99px; background: rgba(27, 34, 64, .12); margin-top: 6px; overflow: hidden;
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(100% / var(--months) - 2px), var(--desk) 0 calc(100% / var(--months))); }
.prog-bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--primary); border-radius: 99px; transition: width .4s ease; }
.hud-btns { display: flex; gap: 6px; flex: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .75); color: var(--primary); font: 800 16px 'Plus Jakarta Sans', sans-serif; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0, 32, 165, .15); }
.icon-btn[aria-pressed="false"] { opacity: .5; }

.meters { display: flex; flex-direction: column; gap: 5px; background: rgba(252, 252, 247, .72); border-radius: 10px; padding: 7px 10px; box-shadow: inset 0 0 0 1px rgba(27, 34, 64, .08); }
.meter { position: relative; display: grid; grid-template-columns: 92px 1fr 28px; align-items: center; gap: 8px; }
.meter .lbl { display: flex; flex-direction: column; line-height: 1.05; }
.meter .lbl b { font: 800 13px 'Plus Jakarta Sans', sans-serif; color: var(--ink); }
.meter .lbl small { font-size: 10px; color: var(--ink-3); white-space: nowrap; }
.meter .bar { position: relative; height: 12px; border-radius: 99px; background: rgba(27, 34, 64, .1); overflow: hidden; }
.meter .zone { position: absolute; top: 0; bottom: 0; width: 20%; left: 0; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(192, 40, 61, .55) 0 2px, rgba(192, 40, 61, .12) 2px 5px); box-shadow: inset -2px 0 0 var(--bad); }
.meter.hi .zone { left: auto; right: 0; width: 25%; box-shadow: inset 2px 0 0 var(--bad); }
.meter .fill { position: absolute; inset: 0 auto 0 0; width: 50%; background: var(--ink); border-radius: 99px; z-index: 2; opacity: .85; }
.meter .num { font: 800 15px 'Plus Jakarta Sans', sans-serif; text-align: right; font-variant-numeric: tabular-nums; }
.meter .dot { position: absolute; left: -7px; top: 50%; width: 0; height: 0; margin-top: 0; border-radius: 50%; background: var(--secondary); transition: width .12s, height .12s, margin .12s; }
.meter .dot.s1 { width: 6px; height: 6px; margin-top: -3px; left: -8px; }
.meter .dot.s2 { width: 10px; height: 10px; margin-top: -5px; left: -10px; }
.meter.flash-up .num { animation: glowUp .5s; } .meter.flash-down .num { animation: glowDown .5s; }
.meter.danger .fill { background: var(--bad); opacity: 1; animation: throb 1s ease-in-out infinite; }
.meter.danger .num, .meter.danger .lbl small { color: var(--bad); }
.meter.danger .lbl small { font-weight: 700; }
@keyframes glowUp { 40% { transform: scale(1.35); color: var(--good); } }
@keyframes glowDown { 40% { transform: scale(1.35); color: var(--bad); } }
@keyframes throb { 50% { opacity: .65; } }

/* ---------- table + card ---------- */
.table { position: relative; height: min(400px, 56dvh); min-height: 350px; margin-top: 2px; }
.slip.under { position: absolute; inset: 10px 6px 0; padding: 0; }
.slip.under.u1 { transform: rotate(-2.2deg) translateY(6px); }
.slip.under.u2 { transform: rotate(1.6deg) translateY(3px); }
#card-host { position: absolute; inset: 0; }
.card { position: absolute; inset: 0; display: flex; flex-direction: column; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; will-change: transform; padding-top: 28px; }
.card.dragging { cursor: grabbing; }
.card.enter { animation: enter .32s cubic-bezier(.2, .9, .3, 1.2); }
.card.slam { animation: slam .5s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes enter { from { transform: translateY(18px) scale(.94); opacity: .2; } }
@keyframes slam { 0% { transform: translateY(-40px) scale(1.08) rotate(-3deg); opacity: 0; } 55% { transform: translateY(4px) scale(.99) rotate(1deg); opacity: 1; } 70% { transform: translateX(-6px) rotate(-1deg); } 85% { transform: translateX(4px); } }

.head { display: flex; gap: 14px; align-items: center; }
.photo { width: 78px; height: 95px; flex: none; background: #fff; padding: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transform: rotate(-2deg); position: relative; }
.photo svg { display: block; width: 100%; height: 100%; }
.photo::after { /* staple */ content: ''; position: absolute; top: -4px; left: 50%; width: 22px; height: 6px; margin-left: -11px; border: 2px solid #9aa0ad; border-bottom: 0; border-radius: 2px 2px 0 0; transform: rotate(4deg); }
.who b { display: block; font-size: 19px; font-weight: 800; line-height: 1.15; }
.who span { font-size: 13px; color: var(--ink-2); }
.card .text { font-size: 21px; line-height: 1.42; margin: 18px 0 0; font-weight: 500; text-wrap: pretty; }
.card .exam { margin-top: auto; font-size: 11px; color: var(--ink-3); display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px dashed var(--slip-edge); }
.card .hint { color: var(--ink-2); font-size: 12px; }
.term { text-decoration: underline dotted rgba(70, 72, 212, .7); text-underline-offset: 3px; cursor: help; }

/* the stapled chit: your own words, come back */
.chit {
  position: relative; align-self: flex-start; margin: 14px 0 0 -4px; padding: 10px 14px 8px; background: var(--chit);
  font-family: Kalam, cursive; color: var(--pen); font-size: 17px; line-height: 1.25; transform: rotate(-3deg); max-width: 92%;
  box-shadow: 0 4px 10px -6px rgba(0, 0, 0, .45); clip-path: polygon(0 3%, 6% 0, 14% 4%, 24% 1%, 37% 4%, 52% 0, 66% 3%, 80% 0, 92% 4%, 100% 1%, 100% 100%, 0 100%);
}
.chit small { display: block; font-size: 14px; opacity: .8; }
.chit::before { content: ''; position: absolute; top: 4px; left: 18px; width: 20px; height: 5px; border: 2px solid #8d93a1; border-bottom: 0; transform: rotate(-8deg); }
.card.slam .chit { animation: chitIn .6s .25s both cubic-bezier(.2, .9, .3, 1.4); }
@keyframes chitIn { from { transform: rotate(14deg) translateY(-30px) scale(1.2); opacity: 0; } }

/* banner: month change */
.banner { position: absolute; inset: 30px 18px; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; background: var(--slip); border-radius: var(--radius-slip); box-shadow: 0 14px 30px -14px rgba(27, 34, 64, .55); padding: 20px; animation: enter .35s; }
.cal { width: 132px; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 0 #c9ccd6, 0 6px 14px -6px rgba(0, 0, 0, .3); background: #fff; }
.cal-top { display: block; background: var(--bad); color: #fff; font: 700 13px 'Plus Jakarta Sans', sans-serif; padding: 6px 0; }
.cal b { display: block; font: 800 30px 'Plus Jakarta Sans', sans-serif; padding: 14px 0 16px; color: var(--ink); }
.banner p { margin: 0; font-size: 17px; line-height: 1.4; font-weight: 600; max-width: 26ch; }
.banner .banner-sub { font-size: 14px; color: var(--ink-2); font-weight: 500; line-height: 1.8; }
.banner .banner-sub .chip { display: inline-block; margin-top: 4px; }
.banner.tear .cal { animation: tear .5s ease-in forwards; }
@keyframes tear { to { transform: translateY(40px) rotate(18deg); opacity: 0; } }

.below { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; min-height: 52px; margin-top: 6px; }
.note { margin: 0; font-size: 14px; line-height: 1.4; color: var(--ink-2); flex: 1; transition: opacity .3s; }
.note b { color: var(--ink); }
.streak { flex: none; font: 700 13px 'Plus Jakarta Sans', sans-serif; padding: 6px 10px; border-radius: 99px; background: rgba(255, 255, 255, .7); color: var(--ink-2); opacity: 0; transition: opacity .2s; }
.streak.on { opacity: 1; }
.streak.hot { background: var(--primary); color: #fff; }
.streak.squash { animation: squash .35s; }
.streak.pulse { animation: pulse .5s; }
@keyframes squash { 30% { transform: scale(1.3, .6); } }
@keyframes pulse { 40% { transform: scale(1.3); } }

.tip { position: fixed; z-index: 20; max-width: 240px; background: var(--ink); color: #fff; font-size: 13px; line-height: 1.4; padding: 8px 10px; border-radius: 8px; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .5); }

.referral { position: fixed; left: 50%; top: 38%; z-index: 30; transform: translateX(-50%); background: var(--primary); color: #fff; font: 800 16px 'Plus Jakarta Sans', sans-serif; padding: 10px 16px; border-radius: 10px; animation: refer 1.4s ease-out forwards; white-space: nowrap; pointer-events: none; }
.referral small { display: block; font: 500 12px Inter, sans-serif; opacity: .9; }
@keyframes refer { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -24px); } }

.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-7px) rotate(-.6deg); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

/* outcome beat: verdict, what happened, chips that fly into the bars */
.beat { position: absolute; inset: 16px 8px; overflow-y: auto; overscroll-behavior: contain; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: safe center; text-align: center; gap: 8px;
  background: var(--slip); border-radius: var(--radius-slip); box-shadow: 0 14px 30px -14px rgba(27, 34, 64, .55); padding: 20px 18px; animation: beatIn .22s cubic-bezier(.2, .9, .3, 1.3); cursor: pointer; border-top: 6px solid var(--ink-3); }
.beat.v-good { border-top-color: var(--good); } .beat.v-bad { border-top-color: var(--bad); } .beat.v-trap { border-top-color: var(--warn); }
.beat.out { animation: beatOut .16s ease-in forwards; }
@keyframes beatIn { from { transform: scale(.9); opacity: 0; } }
@keyframes beatOut { to { transform: translateY(-10px); opacity: 0; } }
.verdict { font: 800 22px 'Plus Jakarta Sans', sans-serif; text-transform: uppercase; letter-spacing: .02em; padding: 6px 14px; border: 3px solid currentColor; border-radius: 6px; transform: rotate(-3deg); color: var(--ink-2); animation: stampSlam .35s cubic-bezier(.3, 1.6, .5, 1) both; }
.verdict.v-good { color: var(--good); } .verdict.v-bad { color: var(--bad); } .verdict.v-trap { color: #a65a12; }
.beat-then { margin: 4px 0 0; font-size: 16px; line-height: 1.4; font-weight: 600; max-width: 28ch; }
.beat-then:empty, .beat-why:empty, .beat-extra:empty { display: none; }
.beat-why { margin: 0; font-size: 14px; line-height: 1.4; color: var(--ink-2); max-width: 30ch; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip { font: 800 14px 'Plus Jakarta Sans', sans-serif; padding: 5px 10px; border-radius: 99px; white-space: nowrap; animation: beatIn .25s both; }
.chip:nth-child(2) { animation-delay: .06s; } .chip:nth-child(3) { animation-delay: .12s; }
.chip.up { background: rgba(31, 138, 91, .14); color: var(--good); }
.chip.down { background: rgba(192, 40, 61, .12); color: var(--bad); }
.chip.flat { background: rgba(27, 34, 64, .08); color: var(--ink-2); }
.chip.ghost { position: fixed; z-index: 30; margin: 0; pointer-events: none; animation: none; }
.beat-extra { margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; align-items: center; max-width: 32ch; }
.beat-extra b { color: var(--primary); }
.beat-skip { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.beat:has(.beat-extra:not(:empty)) .beat-skip { display: none; }

/* ---------- end ---------- */
.end-slip { padding-top: 34px; overflow: hidden; }
.end-head { display: flex; gap: 14px; align-items: flex-start; }
.photo.big { width: 84px; height: 102px; }
.end-when { margin: 4px 0 6px; font-size: 13px; color: var(--ink-2); }
.end-line { margin: 0; font-size: 16px; line-height: 1.45; font-weight: 500; }
.end-stamp { position: relative; display: block; margin: 18px auto 8px; font-size: clamp(24px, 8vw, 32px); opacity: 1; transform: rotate(-6deg); max-width: 92%; }
.end-stamp.slam { animation: stampSlam .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes stampSlam { 0% { transform: rotate(-6deg) scale(2.4); opacity: 0; } 60% { transform: rotate(-6deg) scale(.94); opacity: 1; } 100% { transform: rotate(-6deg) scale(1); } }
.score { border-top: 1px dashed var(--slip-edge); margin-top: 14px; padding-top: 12px; }
.score h3 { margin: 0 0 6px; font: 800 14px 'Plus Jakarta Sans', sans-serif; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.end-why { margin: 0 0 10px; font-size: 15px; line-height: 1.45; font-weight: 600; }
.end-meters { display: flex; flex-direction: column; gap: 5px; }
.meter.mini { grid-template-columns: 56px 1fr 28px; }
.end-best { margin: 10px 0 0; font-size: 13px; line-height: 1.4; color: var(--primary); font-weight: 600; }
.end-best:empty { display: none; }
.strip-key { margin: 6px 0 0; font-size: 11px; color: var(--ink-3); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.strip-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: #d6d8e0; }
.strip-key i.g { background: var(--good); } .strip-key i.b { background: var(--bad); } .strip-key i.t { background: var(--warn); }
.strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.strip i { width: 14px; height: 14px; border-radius: 3px; background: #d6d8e0; }
.strip i.g { background: var(--good); } .strip i.b { background: var(--bad); } .strip i.t { background: var(--warn); }
.end-stats { font-size: 13px; color: var(--ink-2); margin: 10px 0 0; line-height: 1.4; }
.end-stats b { color: var(--ink); }
.new-ending { position: absolute; top: 12px; left: 16px; font: 800 12px 'Plus Jakarta Sans', sans-serif; color: #fff; background: var(--secondary); padding: 4px 8px; border-radius: 99px; animation: pulse .6s .5s; }
.end-actions { display: flex; flex-direction: column; gap: 10px; }
.share-msg { margin: 0; text-align: center; font-size: 13px; color: var(--good); min-height: 1em; }
.debrief h2, .found h2 { font-size: 18px; margin: 10px 0 8px; font-weight: 800; }
.debrief ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.debrief li { background: var(--slip); border-radius: 8px; padding: 12px 14px; box-shadow: 0 1px 3px rgba(27, 34, 64, .15); border-left: 4px solid var(--bad); }
.debrief li.trap { border-left-color: var(--warn); }
.debrief li.clean { border-left-color: var(--good); }
.debrief .d-top { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.debrief .d-top .photo { width: 34px; height: 41px; padding: 2px; }
.debrief .d-top .photo::after { display: none; }
.debrief .d-who { font-size: 13px; color: var(--ink-2); }
.debrief .d-said { font-family: Kalam, cursive; color: var(--pen); font-size: 16px; display: block; line-height: 1.2; }
.debrief .d-rule { margin: 0; font-size: 15px; line-height: 1.45; font-weight: 600; }
.debrief .d-src { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.debrief .d-tag { font: 700 11px 'Plus Jakarta Sans', sans-serif; color: var(--bad); }
.debrief li.trap .d-tag { color: #a65a12; }
.found-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.found-grid li { font: 700 12px 'Plus Jakarta Sans', sans-serif; text-align: center; padding: 10px 4px; border-radius: 8px; border: 2px dashed rgba(27, 34, 64, .2); color: var(--ink-3); line-height: 1.2; min-height: 48px; display: flex; align-items: center; justify-content: center; }
.found-grid li.got { border: 2px solid var(--stamp); color: var(--stamp); background: rgba(252, 252, 247, .7); }
.found-grid li.this { background: var(--stamp); color: #fff; }
.fine { font-size: 12px; color: var(--ink-3); text-align: center; margin: 8px 0 20px; line-height: 1.5; }

/* overlay */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(27, 34, 64, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.how-slip { max-width: 400px; width: 100%; }
.how-slip h2 { margin: 4px 0 10px; font-size: 22px; font-weight: 800; color: var(--primary); }
.how-slip ul { margin: 0 0 16px; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.45; }
.how-slip .btn { width: 100%; }

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 25; }

/* narrow debug (?w=360) and very small phones */
@media (max-width: 370px) {
  .card .text { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- layout rules (docs/DESIGN.md "Layout rules", docs/DESKTOP.md) ----------
   Play and end are fixed-height shells: the page never scrolls, the card table keeps its size between the question
   and the outcome beat, and the dock (choices, then Next) sits at the bottom edge on phones, beside the card on desktop. */
#screen-title, #screen-play, #screen-end { height: 100dvh; min-height: 0; overflow: hidden; }
.rail-slot:empty { display: none; }
.title-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.title-actions { flex: none; }
#screen-play { gap: 8px; }
.play-grid { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.table { flex: 1 1 auto; height: auto; min-height: 0; max-height: 480px; margin-top: 0; }
.play-side { flex: none; display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.below { min-height: 0; height: 40px; margin: 0; overflow: hidden; align-items: center; }
.note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; }
.dock { position: relative; flex: none; height: 56px; }
.dk { position: absolute; inset: 0; display: flex; gap: 10px; }
.dk .btn { flex: 1; min-height: 0; height: 100%; }
.choose { gap: 8px; padding: 6px 12px; font-size: 15px; line-height: 1.2; background: var(--slip); color: var(--ink); box-shadow: inset 0 0 0 2px rgba(0, 32, 165, .22), 0 3px 0 rgba(0, 21, 122, .18); }
.choose span:not(.arr) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.choose .arr { flex: none; color: var(--primary); font-size: 18px; }
.choose:active { transform: translateY(2px); }
.choose:disabled { opacity: .5; cursor: default; }
.keys { display: none; margin: 0; font-size: 12px; color: var(--ink-3); }
.beat-chip { margin: 4px 0 0; }
.streak:empty { display: none; }
.beat-chip:empty, .banner-strip:empty { display: none; }
.banner { overflow-y: auto; justify-content: safe center; }
.banner > *, .beat > * { flex-shrink: 0; } /* scroll inside the box instead of squashing the calendar */
.banner-strip { align-self: stretch; }
.card { overflow: hidden; }

#screen-end { gap: 0; padding-bottom: 0; }
.end-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }
.end-left, .end-right { display: flex; flex-direction: column; gap: 12px; }
.end-slip { flex: none; }
.end-promo:empty { display: none; }
.end-actions { flex: none; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--desk); box-shadow: 0 -8px 18px -10px rgba(27, 34, 64, .35); gap: 6px; }
.share-msg:empty { display: none; }
.fine { margin-bottom: 4px; }

/* short phones: smaller card type and hud so the table keeps room */
@media (max-height: 700px) {
  .screen { padding-top: 8px; }
  .hud { gap: 6px; }
  .meters { gap: 3px; padding: 5px 10px; }
  .meter .bar { height: 10px; }
  .card .text { font-size: 17px; margin-top: 10px; }
  .photo { width: 58px; height: 71px; }
  .who b { font-size: 17px; }
  .chit { font-size: 15px; margin-top: 8px; }
  .title-slip { padding: 26px 18px 14px; }
  .title-slip h1 { font-size: 44px; margin-bottom: 8px; }
  .pitch { font-size: 14px; margin-bottom: 10px; }
  .title-cast, .drag-hint { display: none; }
  .dock { height: 52px; }
  .banner { inset: 16px 10px; gap: 8px; padding: 14px; }
  .cal { width: 104px; }
  .cal-top { padding: 3px 0; font-size: 12px; }
  .cal b { font-size: 22px; padding: 6px 0 8px; }
  .banner p { font-size: 15px; }
  .banner .banner-sub { font-size: 13px; line-height: 1.5; }
}

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

/* desktop (1024+): HUD across the top, the card on the left, the dock + promo rail beside it */
@media (min-width: 1024px) {
  #stage { max-width: 1180px; }
  #screen-play { --side: 360px; --tw: min(500px, calc(100vw - 72px - var(--side))); padding: 18px 24px 20px; gap: 16px; }
  .hud { width: calc(var(--tw) + 24px + var(--side)); margin: 0 auto; flex-direction: row; align-items: center; gap: 24px; }
  .prog { flex: 0 0 var(--tw); }
  .meters { flex: 1; min-width: 0; }
  .play-grid { display: grid; grid-template-columns: var(--tw) var(--side); grid-template-rows: minmax(0, 1fr); gap: 24px; justify-content: center; }
  .table { height: 100%; max-height: 580px; }
  .play-side { margin: 0; gap: 12px; padding-top: 10px; }
  .below { height: auto; min-height: 44px; align-items: flex-start; }
  .note { font-size: 14px; -webkit-line-clamp: 4; }
  .dock { height: 64px; }
  .choose { font-size: 16px; }
  #screen-title { display: grid; grid-template-columns: minmax(0, 520px) 360px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "brand brand" "slip actions"; gap: 16px 40px; justify-content: center; align-content: center; padding: 24px; }
  .brandbar { grid-area: brand; }
  .title-wrap { grid-area: slip; }
  .title-actions { grid-area: actions; align-self: center; }
  #screen-end { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 520px); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "left right" "actions right"; gap: 14px 32px; justify-content: center; padding: 24px; }
  .end-scroll { display: contents; }
  .end-left { grid-area: left; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 4px 4px 0; }
  .end-right { grid-area: right; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: rgba(252, 252, 247, .7); border-radius: 14px; padding: 6px 16px 10px; }
  .end-actions { grid-area: actions; margin: 0; padding: 0; background: none; box-shadow: none; }
}
@media (min-width: 1024px) and (hover: hover) { .keys { display: block; } }
