:root {
  --laminate: #DDE6E6; --laminate-deep: #C9D6D6; --paper: #FFFDF7; --ink: #1B2A2F; --ink-soft: #4C5F66;
  --rn: #1F7A74; --lpn: #3D5A80; --uap: #B8860B; --float: #6B4C9A; --coral: #D1495B; --hi: #F2E05C; --ok: #2E8B57;
  --font: 'Atkinson Hyperlegible', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --col: 420px; --badge-h: 76px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #CFDBDB; color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { overflow: hidden; }
button { font: inherit; color: inherit; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }

.stage { position: fixed; inset: 0; margin: 0 auto; width: min(100vw, var(--col)); max-width: 100%;
  background: linear-gradient(180deg, #E6EDED 0%, var(--laminate) 40%, var(--laminate-deep) 100%);
  box-shadow: 0 0 0 1px rgba(27,42,47,.08), 0 0 60px rgba(27,42,47,.12); touch-action: none; overflow: hidden; }
.stage.is-narrow { width: 360px; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); gap: 16px; opacity: 1; transition: opacity .22s ease; }
.screen[hidden] { display: none; }
.screen.is-leaving { opacity: 0; pointer-events: none; }

/* ---------- printer ---------- */
.printer { position: relative; width: 100%; height: 54px; border-radius: 10px 10px 4px 4px; flex: none;
  background: linear-gradient(180deg, #F3F6F6, #D6E0E0); box-shadow: inset 0 -3px 0 rgba(27,42,47,.15), 0 2px 0 rgba(255,255,255,.6); }
.printer__slot { position: absolute; left: 12%; right: 12%; bottom: 6px; height: 7px; border-radius: 4px; background: #2A3B41; box-shadow: inset 0 2px 3px rgba(0,0,0,.6); }
.printer__count { position: absolute; right: 12px; top: 10px; font-size: 13px; color: var(--ink-soft); }
.printer__level { position: absolute; left: 12px; top: 10px; font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.printer.is-buzz { animation: buzz .12s linear; }
@keyframes buzz { 25% { transform: translateX(-1px); } 75% { transform: translateX(1px); } }

/* ---------- slips ---------- */
.slip { position: relative; width: 100%; max-width: 340px; background: var(--paper); color: var(--ink); border-radius: 3px; padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(27,42,47,.18), 0 6px 14px rgba(27,42,47,.12); font-size: 20px; line-height: 1.3;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 100%);
}
.slip::before { content: ''; position: absolute; left: 0; right: 0; top: -6px; height: 6px;
  background: linear-gradient(135deg, transparent 50%, var(--paper) 50%) 0 0/8px 6px repeat-x; }
.slip__room { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: .02em; }
.slip h1 { font-size: 38px; line-height: 1; margin: 4px 0 10px; }
.slip h2 { font-size: 26px; line-height: 1.1; margin: 2px 0 8px; }
.slip p { font-size: 17px; color: var(--ink-soft); }
.slip--title { margin-top: -10px; transform: translateY(-70px) scale(.96); opacity: 0; animation: print .55s cubic-bezier(.2,.9,.25,1.15) .15s forwards; }
@keyframes print { to { transform: none; opacity: 1; } }
.slip--note, .slip--level { margin-top: 24px; }

/* play slip: draggable with two faces */
.pslip { position: absolute; left: 50%; top: 50%; width: min(300px, 86%); margin-left: calc(min(300px, 86%) / -2); margin-top: -70px;
  min-height: 132px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transform-style: preserve-3d; will-change: transform;
  transition: transform .28s cubic-bezier(.2,.9,.25,1.1); }
.pslip.is-dragging { cursor: grabbing; transition: none; z-index: 5; }
.pslip.is-landing { transition: transform .18s cubic-bezier(.34,1.56,.64,1); }
.pslip.is-refused { transition: transform .32s ease-in-out; }
.pslip.is-printing { transition: transform .28s cubic-bezier(.2,.9,.25,1.1), opacity .2s; }
.pslip__face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--paper); border-radius: 3px; padding: 14px 16px 16px;
  box-shadow: 0 1px 2px rgba(27,42,47,.18), 0 6px 14px rgba(27,42,47,.12); display: flex; flex-direction: column; gap: 8px; }
.pslip__face::before { content: ''; position: absolute; left: 0; right: 0; top: -6px; height: 6px;
  background: linear-gradient(135deg, transparent 50%, var(--paper) 50%) 0 0/8px 6px repeat-x; }
.pslip__face--back { transform: rotateY(180deg); background: #FBF7EA; }
.pslip__meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-soft); }
.pslip__text { font-size: 19px; line-height: 1.28; font-weight: 400; }
.pslip__rule { font-size: 17px; line-height: 1.3; font-weight: 700; }
.pslip__rulehead { font-size: 13px; color: var(--ink-soft); }
.pslip.is-flipped { transform: rotateY(180deg); }
.pslip.is-static { transition: opacity .12s; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1; color: #fff; background: var(--ok); }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.chip--alert { background: var(--coral); }
.chip--alert::before { border-radius: 1px; transform: rotate(45deg); }
.chip.is-flash { animation: chipflash .6s steps(2) infinite; }
@keyframes chipflash { 50% { filter: brightness(1.35); } }
.chip.is-zoom { animation: chipzoom .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes chipzoom { from { transform: scale(2.2); } }
.stamp { position: absolute; right: 10px; bottom: 8px; padding: 2px 10px; border: 3px solid currentColor; border-radius: 6px; font-weight: 700; font-size: 22px; letter-spacing: .04em;
  transform: rotate(-8deg) scale(1); opacity: .9; -webkit-text-stroke: .4px currentColor; mix-blend-mode: multiply; pointer-events: none;
  animation: slam .12s cubic-bezier(.2,.9,.25,1.3); }
@keyframes slam { from { transform: rotate(-8deg) scale(2.2); opacity: 0; } }
.stamp--RN { color: var(--rn); } .stamp--LPN { color: var(--lpn); } .stamp--UAP { color: var(--uap); } .stamp--FLOAT { color: var(--float); }
.stamp--miss { color: var(--coral); }

/* ---------- counter ---------- */
.counter { position: relative; flex: 1; width: 100%; min-height: 200px; perspective: 900px; border-radius: 6px;
  background: repeating-linear-gradient(90deg, transparent 0 38px, rgba(27,42,47,.03) 38px 40px); }
.counter.is-shake { animation: shake .3s linear; }
@keyframes shake { 20% { transform: translate(-3px, 1px) rotate(-.4deg); } 40% { transform: translate(3px, -1px) rotate(.4deg); } 60% { transform: translate(-2px, 0); } 80% { transform: translate(2px, 1px); } }
.counter.is-coral::after { content: ''; position: absolute; inset: 0; border-radius: 6px; box-shadow: inset 0 0 0 3px var(--coral); animation: fadeout .5s forwards; pointer-events: none; }
@keyframes fadeout { to { opacity: 0; } }
.streak-stripe { position: absolute; left: 0; bottom: 0; height: 6px; width: 0; background: var(--hi); border-radius: 3px; transition: width .24s ease-out; }
.hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: 90%; text-align: center; font-size: 15px; color: var(--ink-soft);
  background: rgba(255,253,247,.9); padding: 6px 10px; border-radius: 6px; pointer-events: none; }
.pops { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.pop { position: absolute; font-weight: 700; font-size: 22px; color: var(--rn); transform: translate(-50%, -50%); animation: pop .7s ease-out forwards; text-shadow: 0 1px 0 #fff; }
.pop--streak { color: #9A8A00; font-size: 18px; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.6); opacity: 0; } 20% { transform: translate(-50%, -60%) scale(1.25); opacity: 1; } 100% { transform: translate(-50%, -140%) scale(1); opacity: 0; } }

/* ---------- badges ---------- */
.badges { display: flex; gap: 10px; width: 100%; flex: none; padding-top: 18px; position: relative; }
.badges::before { content: ''; position: absolute; left: 6%; right: 6%; top: 0; height: 14px; border-top: 2px solid rgba(27,42,47,.2); border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.badge { flex: 1; min-width: 56px; height: var(--badge-h); border: 0; border-radius: 10px; color: #fff; background: var(--c); position: relative; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 3px 0 rgba(0,0,0,.22), 0 6px 12px rgba(27,42,47,.16); transition: transform .12s, filter .2s; padding: 4px; }
.badge::before { content: ''; position: absolute; top: -12px; left: 50%; width: 2px; height: 14px; margin-left: -1px; background: rgba(27,42,47,.3); }
.badge__clip { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); width: 26px; height: 10px; border-radius: 3px; background: #F6F8F8; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.badge svg { width: 24px; height: 24px; }
.badge__label { font-weight: 700; font-size: 15px; line-height: 1; }
.badge__tag { position: absolute; bottom: -18px; font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.badge--RN { --c: var(--rn); } .badge--LPN { --c: var(--lpn); } .badge--UAP { --c: var(--uap); } .badge--FLOAT { --c: var(--float); }
.badge.is-over { transform: translateY(-4px) scale(1.06); filter: brightness(1.12); }
.badge.is-pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); box-shadow: 0 3px 0 rgba(0,0,0,.22), 0 0 0 6px rgba(242,224,92,.55); } }
.badge.is-hit { animation: squash .28s cubic-bezier(.34,1.56,.64,1); }
@keyframes squash { 30% { transform: scale(1.12, .88); } 60% { transform: scale(.96, 1.06); } }
.badge.is-hit .badge__clip { animation: clipflash .3s; }
@keyframes clipflash { 0%, 40% { background: #fff; box-shadow: 0 0 10px #fff; } }
.badge.is-wrong { filter: grayscale(1) brightness(.9); animation: badgeshake .3s linear; }
@keyframes badgeshake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.badge:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.badges.has-tag { padding-bottom: 20px; }

.badges--deco { position: absolute; left: 16px; right: 16px; top: 250px; width: auto; pointer-events: none; opacity: .9; }
.badges--deco .badge { animation: sway 4s ease-in-out infinite; transform-origin: 50% -14px; }
.badges--deco .badge:nth-child(2) { animation-delay: -1.3s; } .badges--deco .badge:nth-child(3) { animation-delay: -2.6s; }
@keyframes sway { 50% { transform: rotate(1.6deg); } }
.menu { position: relative; z-index: 1; }
/* ---------- HUD ---------- */
.hud { width: 100%; display: flex; justify-content: space-between; align-items: center; flex: none; min-height: 36px; }
.hud__clock { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 60px; }
.hud__clock.is-low { color: var(--coral); }
.hud__clock.is-tick { animation: tick 1s; }
@keyframes tick { 0% { transform: scale(1.08); } }
.hud__score { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.hud__score.is-bump { animation: bump .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes bump { 30% { transform: scale(1.25); } }
.hud__mult { font-size: 14px; background: var(--hi); color: var(--ink); padding: 3px 8px; border-radius: 999px; }
.hud__mult.is-up { animation: bump .35s cubic-bezier(.34,1.56,.64,1); }
.hud__mult.is-down { animation: sag .2s; opacity: .75; }
@keyframes sag { 50% { transform: scale(.88); } }

/* ---------- buttons / menus ---------- */
.menu { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 300px; margin-top: auto; }
.btn { min-height: 48px; padding: 10px 18px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); font-weight: 700; font-size: 17px; cursor: pointer; transition: transform .06s; box-shadow: 0 2px 0 var(--ink); }
.btn:active, .btn.is-press { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.btn--primary { background: var(--rn); color: #fff; border-color: var(--rn); box-shadow: 0 2px 0 #145450; }
.btn--ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-soft); }
.btn--small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn:focus-visible { outline: 3px solid var(--hi); outline-offset: 2px; }

/* ---------- how to play ---------- */
.howto { width: 100%; display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 10px; }
.howto__slide { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 8px; }
.howto__slide .slip { font-size: 17px; }
.howto__slide .slip p { font-size: 15px; }
.howto__step { font-size: 14px; color: var(--ink-soft); display: flex; gap: 8px; align-items: center; }
.howto__step .chip { flex: none; }
.minibadge { display: inline-block; padding: 2px 8px; border-radius: 6px; color: #fff; font-weight: 700; font-size: 13px; background: var(--c); }

/* ---------- debrief ---------- */
.screen--debrief { gap: 10px; overflow-y: auto; }
.debrief__title { font-size: 26px; margin-top: 4px; }
.debrief__tally { display: flex; align-items: baseline; gap: 12px; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.debrief__tally span:last-child { font-size: 16px; color: var(--ink-soft); font-weight: 400; }
.stacks { display: flex; gap: 8px; width: 100%; justify-content: center; }
.stack { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stack__head { font-weight: 700; font-size: 13px; color: var(--c); }
.stack__pile { position: relative; width: 100%; height: 70px; }
.stack__card { position: absolute; left: 10%; right: 10%; top: 0; height: 56px; background: var(--paper); border-radius: 3px; border-left: 4px solid var(--ok); box-shadow: 0 1px 2px rgba(27,42,47,.2);
  transform: translateY(40px) rotate(0); opacity: 0; animation: fan .3s ease-out forwards; cursor: pointer; border-width: 0 0 0 4px; padding: 0; font-size: 11px; text-align: left; overflow: hidden; color: var(--ink); }
.stack__card.is-wrong { border-left-color: var(--coral); }
.stack__card span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; max-height: 44px; padding: 5px 6px; line-height: 1.2; }
@keyframes fan { to { transform: translateY(var(--y)) rotate(var(--r)); opacity: 1; } }
.misses { width: 100%; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.misses li { background: var(--paper); border-left: 4px solid var(--coral); padding: 6px 10px; border-radius: 3px; line-height: 1.3; }
.misses li.is-ok { border-left-color: var(--ok); }
.misses li b { display: block; font-size: 13px; }
.misses li i { font-style: normal; color: var(--ink-soft); }

/* ---------- end ---------- */
.end-slip { text-align: center; }
.end-slip h2 { font-size: 48px; }
.end-rows { display: flex; flex-direction: column; gap: 4px; font-size: 15px; margin: 8px 0; }
.end-rows li { display: flex; justify-content: space-between; color: var(--ink-soft); }
.end-rows li b { color: var(--ink); font-variant-numeric: tabular-nums; }
.best-stamp { font-weight: 700; color: var(--coral); border: 3px solid var(--coral); border-radius: 6px; padding: 4px 12px; transform: rotate(-6deg); font-size: 18px; display: inline-block;
  text-decoration: underline wavy var(--hi); animation: slam .14s cubic-bezier(.2,.9,.25,1.3); }
.best-stamp--inline { margin-top: 8px; }
.best-stamp[hidden] { display: none; }

/* ---------- particles ---------- */
.particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; width: 8px; height: 12px; border-radius: 1px; will-change: transform; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) { :root { --rm: 1; } }
.stage.is-nomotion *, .stage.is-nomotion *::before, .stage.is-nomotion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .12s !important; transition-property: opacity !important; }
.stage.is-nomotion .badge.is-pulse { outline: 4px solid var(--hi); animation: none; }
.stage.is-nomotion .slip--title { transform: none; opacity: 1; }

@media (min-aspect-ratio: 1/1) and (min-width: 700px) {
  .stage { border-radius: 14px; top: 12px; bottom: 12px; }
}
