/* Solo play: case sheet (HUD on phones), manila folder, reveal moment, end screen.
   Loaded after officer.css, so equal-specificity rules here win. Only transform/opacity animate. */

.play { padding-top: 0; }
.preview-banner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
  margin-bottom: 16px; padding: 10px 14px; background: var(--res); border: 2px solid var(--ink);
}
.preview-banner a { color: var(--ink); font-weight: 700; }
.play-grid { display: block; min-width: 0; }

/* ---------- Case sheet: phones (< 640px) = slim sticky HUD, 56px ---------- */

.casesheet {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 46px minmax(0, 1fr) auto auto;
  grid-template-areas: "off stage combo score";
  align-items: center; column-gap: 10px;
  height: 56px; margin: 0 -20px 12px; padding: 0 12px;
  background: var(--sheet); border-bottom: 2px solid var(--ink);
  min-width: 0;
}
.cs-officer { grid-area: off; display: flex; align-items: flex-end; height: 54px; overflow: hidden; align-self: end; }
.play .casesheet .officer { --officer-w: 46px; }
.cs-lot { display: none; }
/* the case title stays in the page for screen readers; the folder tab shows it visually */
.cs-id {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.cs-stage { grid-area: stage; margin: 0; font-family: var(--f-display); font-weight: 700; font-size: var(--t-14); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip { display: none; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; gap: 3px; }
.cs-score { grid-area: score; display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.cs-score-label { display: none; font-size: var(--t-14); font-weight: 600; color: var(--ink-2); }
.score-num {
  display: inline-block; font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 125;
  font-size: var(--t-25); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.score-num.is-bump { animation: score-bump 0.35s ease-out 1; }
@keyframes score-bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.combo-wrap { grid-area: combo; display: flex; flex-direction: column; align-items: flex-end; }
.combo-label { display: none; margin: 4px 0 0; font-size: var(--t-16); font-weight: 700; color: var(--ink); }

/* Combo meter: five segments, rising heights */
.combo-head { display: flex; align-items: center; gap: 8px; }
.combo-title { display: none; font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 115; font-size: var(--t-16); letter-spacing: 0.04em; text-transform: uppercase; }
.combo-mult {
  display: inline-block; padding: 0 6px; background: var(--res); border: 1.5px solid var(--ink); border-radius: var(--r-tab);
  font-family: var(--f-display); font-weight: 800; font-size: 0.75rem; line-height: 1.3; rotate: -4deg;
}
.combo { --seg-w: 10px; --seg-h: 8px; --seg-step: 2px; display: inline-flex; align-items: flex-end; gap: 3px; }
.combo i {
  display: block; width: var(--seg-w); border: 2px solid var(--ink); background: var(--sheet);
  transform-origin: 50% 100%;
}
.combo i:nth-child(1) { height: calc(var(--seg-h)); }
.combo i:nth-child(2) { height: calc(var(--seg-h) + var(--seg-step)); }
.combo i:nth-child(3) { height: calc(var(--seg-h) + var(--seg-step) * 2); }
.combo i:nth-child(4) { height: calc(var(--seg-h) + var(--seg-step) * 3); }
.combo i:nth-child(5) { height: calc(var(--seg-h) + var(--seg-step) * 4); }
.combo i.on { background: var(--res); }
.combo.is-hot i.on { background: var(--com); }
.combo i.is-new { animation: combo-pop 0.4s cubic-bezier(0.3, 1.8, 0.5, 1) 1; }
@keyframes combo-pop { from { transform: scaleY(0.2); } to { transform: scaleY(1); } }
.combo.is-cracking i.on { animation: combo-crack 0.5s ease-in 1 forwards; }
.combo.is-cracking i.on:nth-child(2n) { animation-delay: 0.06s; }
.combo.is-cracking i.on:nth-child(3n) { animation-delay: 0.12s; }
@keyframes combo-crack {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  25% { transform: translate(-2px, 0) rotate(-7deg); opacity: 1; }
  45% { transform: translate(2px, 0) rotate(6deg); opacity: 1; }
  100% { transform: translate(0, 14px) rotate(16deg); opacity: 0; }
}

/* Officer speech: a compact toast under the HUD, tail pointing up at the officer's head */
.play .casesheet .officer-bubble.is-on {
  position: fixed; top: 60px; left: 10px; right: auto; z-index: 19;
  max-width: min(80vw, 320px); margin: 0; padding: 8px 12px; box-shadow: 0 2px 0 var(--ink); cursor: pointer;
}
.play .casesheet .officer-bubble.is-on::before,
.play .casesheet .officer-bubble.is-on::after {
  display: block; left: 20px; bottom: auto; top: -9px;
  border: 8px solid transparent; border-top-width: 0; border-bottom-color: var(--ink);
}
.play .casesheet .officer-bubble.is-on::after { top: -6px; border-bottom-color: var(--sheet); }

.strip .lot {
  display: block; width: 14px; height: 14px; border: 1.5px solid var(--ink); background: var(--sheet);
  transition: background-color 0.12s;
}
.strip .lot--todo { border-color: var(--ink-2); border-style: dashed; opacity: 0.7; }
.strip .lot--current { background: #fff; outline: 2px solid var(--ink); outline-offset: 1px; }
.strip .lot--good { background: var(--open); }
.strip .lot--bad { background: var(--com); }
.strip .lot--partial { background: var(--res); }
.strip .lot--done { background: var(--rule); }

/* ---------- Tablet strip (640 - 899px): compact top strip as v1 ---------- */

@media (min-width: 640px) {
  .casesheet {
    grid-template-columns: 60px minmax(0, 1fr) auto;
    grid-template-areas: "off id score" "off strip combo";
    row-gap: 2px; height: auto; margin: 0 0 16px; padding: 8px 14px;
    border: 1.5px solid var(--ink);
  }
  .cs-officer { height: 64px; align-self: center; grid-row: 1 / span 2; }
  .play .casesheet .officer { --officer-w: 56px; }
  .cs-id { grid-area: id; position: static; width: auto; height: auto; margin: 0; overflow: hidden; clip: auto; white-space: normal; }
  .cs-title { font-size: var(--t-16); margin: 0; font-variation-settings: "wdth" 115; }
  .cs-role, .cs-site { display: none; }
  .cs-stage { display: none; }
  .strip { display: flex; grid-area: strip; }
  .strip .lot { width: 14px; height: 14px; }
  .cs-score { flex-direction: row; align-items: baseline; gap: 8px; }
  .cs-score-label { display: inline; }
  .combo-label { display: block; margin: 0 0 0 4px; font-size: var(--t-14); }
  .combo-wrap { flex-direction: row; align-items: center; gap: 8px; }
  .combo-title { display: inline; font-size: var(--t-14); }
  .combo { --seg-w: 14px; --seg-h: 12px; --seg-step: 2px; }
  .play .casesheet .officer-bubble.is-on { top: 90px; left: 20px; max-width: min(34ch, calc(100vw - 40px)); }
}

/* ---------- Desktop (>= 900px): left case sheet column ---------- */

@media (min-width: 900px) {
  .play-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 32px; align-items: start; }
  .casesheet {
    position: sticky; top: 16px; z-index: 1;
    display: flex; flex-direction: column; align-items: stretch; gap: 14px;
    height: auto; margin: 0; padding: 18px;
  }
  .cs-officer { height: auto; overflow: visible; align-self: stretch; grid-row: auto; }
  .play .casesheet .officer { --officer-w: 140px; }
  .cs-lot { display: block; border: 2px solid var(--ink); background: var(--paper); overflow: hidden; }
  .cs-lot > * { max-width: 100%; }
  .cs-title { font-size: var(--t-25); margin-bottom: 6px; }
  .cs-role { display: block; margin: 0 0 2px; font-weight: 600; }
  .cs-site { display: block; margin: 0; font-size: var(--t-14); color: var(--ink-2); }
  .strip { gap: 4px; }
  .strip .lot { width: 18px; height: 18px; }
  .score-num { font-size: var(--t-39); }
  .combo-wrap { flex-direction: column; align-items: flex-start; gap: 6px; }
  .combo-head { gap: 10px; }
  .combo-title { display: inline; font-size: var(--t-20); }
  .combo-mult { font-size: var(--t-16); padding: 0 8px; }
  .combo { --seg-w: 18px; --seg-h: 14px; --seg-step: 2px; gap: 4px; }
  .combo-label { margin: 0; }
  .play .casesheet .officer-bubble.is-on {
    position: relative; top: auto; left: auto; right: auto; z-index: auto; box-shadow: none; cursor: default;
    max-width: min(24ch, 100%); margin: 8% 0 0 8px;
  }
  .play .casesheet .officer-bubble.is-on::before,
  .play .casesheet .officer-bubble.is-on::after {
    left: -11px; bottom: 12px; top: auto; border: 8px solid transparent; border-left-width: 0; border-right-color: var(--ink);
  }
  .play .casesheet .officer-bubble.is-on::after { left: -7px; border-right-color: var(--sheet); }
}

/* ---------- Manila folder around the stage page ---------- */

.folder {
  position: relative; min-width: 0; margin-top: 36px; padding: 10px 8px 12px;
  background: #E2C783 linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 45%);
  border: 2px solid var(--ink); border-radius: 2px 10px 4px 4px;
  scroll-margin-top: 100px;
}
.folder-tab {
  position: absolute; left: 18px; top: -34px; z-index: 2;
  max-width: calc(100% - 56px); height: 36px; padding: 0 16px;
  display: flex; align-items: center;
  background: #E2C783; border: 2px solid var(--ink); border-bottom: 0; border-radius: 8px 8px 0 0;
  font-family: var(--f-display); font-weight: 700; font-size: var(--t-14); font-variation-settings: "wdth" 110;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* back leaf: a second sheet peeking out behind the page */
.folder::after {
  content: ""; position: absolute; z-index: 0; inset: 6px 5px 0 5px;
  background: #F6F0DA; border: 1.5px solid var(--ink); rotate: -0.5deg; pointer-events: none;
}
.stage-sheet { position: relative; z-index: 1; min-width: 0; margin-bottom: 4px; }
.folder-cover {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 16px;
  background: #D9B96A; border: 2px solid var(--ink); border-radius: inherit;
  transform-origin: 0 50%; backface-visibility: hidden; pointer-events: none;
}
.folder-label {
  display: grid; gap: 4px; text-align: center; max-width: 100%;
  padding: 12px 20px; background: #FBF7E8; border: 2px solid var(--ink); transform: rotate(-1.5deg);
}
.folder-label-kicker { font-family: var(--f-display); font-weight: 700; font-size: var(--t-14); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-2); }
.folder-label-title { font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 115; font-size: var(--t-20); line-height: 1.15; }
@media (min-width: 640px) {
  .folder { padding: 18px 18px 22px; scroll-margin-top: 150px; }
}
@media (min-width: 900px) {
  .folder { scroll-margin-top: 60px; }
}

.stage-meta { margin: 0 0 14px; }
.stage-sheet { scroll-margin-top: 16px; }

/* ---------- Reveal moment ---------- */

/* GSAP drives the slam and the shake; switch off the CSS fallbacks so they do not fight it. */
.stage--solo .stamp { animation: none; }
.stage--solo.is-shaking { animation: none; }
.fx-fly.fx-fly--good { color: var(--ok-ink); border-color: var(--open); }
.fx-fly.fx-fly--bad { color: var(--bad-ink); border-color: var(--com); }

.streak-banner {
  display: flex; align-items: center; gap: 10px; flex: 1 1 100%; width: fit-content; max-width: 100%; margin: 0;
  padding: 6px 14px; background: var(--res); border: 2px solid var(--ink); border-radius: var(--r-tab); rotate: -1deg;
  font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 115; font-size: var(--t-20);
}
.streak-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.streak-bars i { display: block; width: 4px; background: var(--ink); }
.streak-bars i:nth-child(1) { height: 7px; }
.streak-bars i:nth-child(2) { height: 11px; }
.streak-bars i:nth-child(3) { height: 16px; }

/* Correct option carries its own small stamp mark */
.stage--solo .opt { position: relative; }
.stage--solo .opt.is-correct { padding-right: 52px; }
.stage--solo .opt.is-correct::after {
  content: "\2713"; content: "\2713" / "";
  position: absolute; top: 50%; right: 12px; margin-top: -16px; width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 3px double var(--ok-ink); border-radius: 50%; color: var(--ok-ink);
  font-weight: 800; font-size: 1rem; line-height: 1; rotate: -12deg; background: rgba(255, 255, 255, 0.7);
  animation: tick-in 0.25s ease-out 0.3s 1 backwards;
}
@keyframes tick-in { from { opacity: 0; scale: 1.8; } to { opacity: 1; scale: 1; } }

/* ---------- Wager ---------- */

.wager { margin: 0; padding: 0; border: 0; min-width: 0; }
.wager legend { padding: 0; margin-bottom: 8px; font-family: var(--f-display); font-weight: 700; font-variation-settings: "wdth" 110; }
.wager-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wager-opt { position: relative; display: block; cursor: pointer; }
.wager-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.wager-face {
  display: grid; gap: 2px; justify-items: start; min-height: 44px; height: 100%; padding: 8px 10px;
  border: 2px solid var(--rule); border-radius: var(--r-btn); background: var(--sheet);
  transition: border-color 0.12s, background-color 0.12s, color 0.12s;
}
.wager-opt:hover .wager-face { border-color: var(--ink); }
.wager-input:checked + .wager-face { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.wager-input:focus-visible + .wager-face { outline: 2px solid var(--pub); outline-offset: 2px; }
.pips { display: inline-flex; gap: 3px; }
.pip { display: block; width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 50%; background: currentColor; }
.wager-name { font-weight: 600; font-size: var(--t-14); line-height: 1.25; }
.wager-mult { font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 125; }
.wager-hint { margin: 8px 0 0; font-size: var(--t-14); color: var(--ink-2); }

/* ---------- End screen ---------- */

.end { padding-top: 8px; }
.end-top { margin-bottom: 32px; min-width: 0; }
.end-hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: center; }
.end-officer { min-width: 0; }
.end .officer { --officer-w: clamp(96px, 28vw, 160px); }
.end .officer-bubble.is-on { max-width: min(24ch, calc(100vw - var(--officer-w) - 72px)); }
.end-score-block { min-width: 0; text-align: center; }
.end-score-block p { margin-left: auto; margin-right: auto; }
.end-score-block .stamp { margin: 14px auto 10px; }
@media (min-width: 720px) {
  .end-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px 40px; }
}
.end-title { font-size: clamp(1.5625rem, 5vw, var(--t-31)); margin-bottom: 0.1em; }
.end-title:focus { outline: none; }
.end-case { margin: 0; color: var(--ink-2); }
.end-score { margin: 12px 0 0; font-size: var(--t-20); }
.end-score-num { display: block; }
.end-score-of { display: block; }
.end-score-num {
  font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 125;
  font-size: clamp(2.5rem, 11vw, var(--t-61)); letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
}
.end-pct, .end-best { margin: 0 0 4px; }
.end-best { font-weight: 600; }
.strip--end { display: flex; margin: 20px 0 0; }
.strip--end .lot { width: 22px; height: 22px; }

.xp { margin-top: 18px; max-width: 520px; }
.xp-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin-bottom: 6px; font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 110; }
.xp-gain { color: var(--ok-ink); font-variant-numeric: tabular-nums; }
.xp-bar { height: 16px; border: 2px solid var(--ink); background: #fff; overflow: hidden; }
.xp-fill { width: 100%; height: 100%; background: var(--open); transform-origin: 0 50%; }
.xp-note { margin: 6px 0 0; font-size: var(--t-14); color: var(--ink-2); }
.rankup { margin-top: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; }
.rankup-kicker { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: var(--t-20); text-transform: uppercase; letter-spacing: 0.12em; }

.new-badges { margin-top: 24px; }
.badge-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.badge-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.badge-row svg { flex: none; }
.badge-row p { margin: 0; }
.badge-row-title { font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 110; }
.badge-row-desc { font-size: var(--t-14); color: var(--ink-2); }

.end-block { margin-top: 36px; }
.review { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.review-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.lot-sq { flex: none; width: 18px; height: 18px; border: 1.5px solid var(--ink); }
.lot-sq--good { background: var(--open); }
.lot-sq--partial { background: var(--res); }
.lot-sq--bad { background: var(--com); }
.review-row .mark { min-width: 7.5rem; }
.review-row--good .mark { color: var(--ok-ink); }
.review-row--partial .mark { color: var(--part-ink); }
.review-row--bad .mark { color: var(--bad-ink); }
.review-title { flex: 1 1 14rem; font-weight: 600; min-width: 0; }
.review-pts { font-family: var(--f-display); font-weight: 800; font-variation-settings: "wdth" 110; font-variant-numeric: tabular-nums; }
.review-row .statutes { flex: 1 1 100%; margin: 0; }
.refl { margin-bottom: 16px; }
.refl-q { font-weight: 600; margin-bottom: 4px; }
.refl-a { background: var(--sheet); border: 1px solid var(--rule); padding: 10px 12px; white-space: pre-wrap; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .score-num.is-bump, .combo i.is-new, .combo.is-cracking i.on, .stage--solo .opt.is-correct::after { animation: none; }
}
