/* HardDonate: a fictional bureau rendered as paper on a desk.
   Type scale: 1.25 ratio (major third) from 16 px. Spacing: 4 px base, steps 4 8 12 16 24 32 48 64.
   Shadows come from one light source at the top left; blur and offset grow with elevation h: offset = 0.4 h, blur = 1.6 h. */
:root {
  --paper: #F4EFE3;
  --paper-2: #ECE5D4;
  --paper-3: #E4DBC6;
  --pink-copy: #EFDCD6;
  --yellow-copy: #EFE5C4;
  --desk: #CBC1AD;
  --desk-2: #B7AB94;
  --ink: #1E3563;
  --ink-2: #3B4F7E;
  --ink-soft: rgba(30, 53, 99, .62);
  --ink-faint: rgba(30, 53, 99, .14);
  --rule: rgba(30, 53, 99, .11);
  --red: #B8322B;
  --red-ink: rgba(184, 50, 43, .9);
  --red-wash: rgba(184, 50, 43, .12);
  --margin: rgba(184, 50, 43, .32);
  --gold: #A87B1F;
  --ok: #3E6B4F;
  --board: #17150F;
  --led: #FF5A3C;
  --cat: #E9D3B4;
  --sky: #E8E4D6;
  --hill: #C9CFB2;
  --hill-2: #AEB893;
  --locked: rgba(30, 53, 99, .3);
  --tj-coral: #F2683C;
  --tj-coral-d: #D9522A;
  --tj-cream: #FBF7F0;
  --tj-cream-2: #F4EFE6;
  --tj-ink: #1A1714;
  --mono: "Courier Prime", "IBM Plex Sans Thai", ui-monospace, monospace;
  --serif: "Trirong", "IBM Plex Sans Thai", serif;
  --display: "Kanit", "IBM Plex Sans Thai", sans-serif;
  --ui: "IBM Plex Sans Thai", system-ui, sans-serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --shadow-1: 0 0.4px 1.6px rgba(46, 34, 14, .18), 0 1px 2px rgba(46, 34, 14, .08);
  --shadow-4: 0 1.6px 6.4px rgba(46, 34, 14, .16), 0 6px 14px -6px rgba(46, 34, 14, .22);
  --shadow-12: 0 4.8px 19px rgba(46, 34, 14, .14), 0 22px 40px -22px rgba(46, 34, 14, .36);
  --grain: url("../assets/paper.webp");
  --desk-tex: url("../assets/desk.webp");
  --ink-mask: url("../assets/ink-mask.webp");
  /* One layer scale for the whole page. Decorative layers (confetti, tear) never take pointer events.
     The HUD (timer, sound toggles, give-up) sits above every modal so it is never covered. */
  --z-desk: 0;
  --z-paper: 10;
  --z-stamp: 20;
  --z-dodging-button: 30;
  --z-stamp-over: 35; /* a stamp that lands on the dodging button itself */
  --z-toast: 50;
  --z-modal: 60;
  --z-confetti: 70;
  --z-hud: 75;
  --z-easter: 80;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; overflow-x: clip;
  background-color: var(--desk);
  background-image: radial-gradient(120% 90% at 30% 0%, rgba(255, 250, 236, .38), rgba(255, 250, 236, 0) 60%), var(--desk-tex);
  background-size: auto, 512px 512px;
  color: var(--ink); font: 400 16px/1.6 var(--ui);
  font-feature-settings: "zero" 0; font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
body.is-booting .app { visibility: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, .rv-title, .rv-pitch, .intro-sub, .fake-title, .crown-card h2 { text-wrap: balance; }
p, dd, li, figcaption, .clerk-bubble span { text-wrap: pretty; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 40px; font-size: 20px; }
[hidden] { display: none !important; }

/* ---------- letterhead ---------- */
.letterhead {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: var(--s5);
  padding: var(--s3) clamp(16px, 4vw, 48px);
  background: var(--paper) var(--grain); background-size: 512px; background-blend-mode: multiply;
  border-bottom: 3px double var(--ink);
  box-shadow: var(--shadow-4);
  position: relative; z-index: var(--z-hud);
}
.bureau { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.seal { width: 54px; height: 54px; flex: none; transform: rotate(-8deg); }
.seal-ink { stroke: var(--red); fill: var(--red); opacity: .9; }
.seal-ring { font: 600 10.4px var(--ui); letter-spacing: .06em; stroke: none; }
.seal-hd { font: 800 15px var(--display); stroke: none; letter-spacing: .04em; }
.bureau-th { margin: 0; font: 700 clamp(15px, 1.7vw, 19px)/1.25 var(--serif); }
.bureau-en { margin: 0; font: 400 12px/1.3 var(--mono); color: var(--ink-soft); letter-spacing: .04em; }
.clockbox { display: flex; align-items: center; gap: var(--s2); }
.wallclock { width: 44px; height: 44px; padding: 0; border: 0; background: none; border-radius: 50%; }
.wallclock svg { width: 44px; height: 44px; display: block; }
.wc-face { fill: #fffdf6; stroke: var(--ink); stroke-width: 2.4; }
.wc-ticks path { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.wc-min { stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.wc-sec { stroke: var(--red); stroke-width: 1.3; stroke-linecap: round; }
.wallclock-sec, .wallclock-min { transform-origin: 24px 24px; transform-box: view-box; }
.wc-pin { fill: var(--red); }
.wallclock.is-back svg { animation: back-wobble .4s ease-in-out infinite alternate; }
@keyframes back-wobble { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
.clock-label { display: block; font: 400 11px/1 var(--ui); color: var(--ink-soft); }
.clock { display: block; font: 600 20px/1.2 var(--mono); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.toggles { display: flex; gap: var(--s2); }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border: 1.5px solid var(--ink); border-radius: 999px; background: transparent; font-size: 13px;
}
.toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toggle[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }

/* ---------- tabs ---------- */
.tabsnav { max-width: 1180px; margin: 0 auto; padding: var(--s5) clamp(16px, 4vw, 48px) 0; }
.tabs { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0 0 0 40px; overflow: hidden; }
.tab {
  flex: 1 1 0; min-width: 0; display: flex; align-items: baseline; gap: 6px;
  padding: 7px 10px 9px; border-radius: 8px 8px 0 0;
  background: var(--paper-3); color: var(--ink-soft);
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: inset 0 -6px 8px -8px rgba(0, 0, 0, .3);
  transform: translateY(4px);
}
.tab-no { font: 600 12px var(--mono); }
.tab-name { overflow: hidden; text-overflow: ellipsis; }
.tab--now { background: var(--paper); color: var(--ink); transform: none; font-weight: 600; box-shadow: none; }
.tab--done { background: #e9e1cd; }
.tab--done .tab-no { color: var(--red); }
.tab--done .tab-no::after { content: " ผ่าน"; font: 600 10px var(--ui); }
.tabs-mobile { display: none; margin: 0; font: 600 14px var(--mono); }

/* ---------- desk layout ---------- */
.desk {
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(24px, 4vw, 56px); align-items: start;
  padding: 0 clamp(16px, 4vw, 48px) 140px;
}
.stack { position: relative; min-width: 0; }
.sheet {
  border-radius: 2px;
  background-color: var(--paper);
  background-image: var(--grain);
  background-size: 512px 512px;
  background-blend-mode: multiply;
}
.sheet-back { position: absolute; inset: 0; box-shadow: var(--shadow-4); }
.sheet-back--1 { background-color: var(--pink-copy); transform: rotate(1.2deg) translate(6px, 6px); }
.sheet-back--2 { background-color: var(--yellow-copy); transform: rotate(-1.4deg) translate(-8px, 10px); }
.sheet-front {
  position: relative; min-height: 640px;
  padding: 56px clamp(20px, 5vw, 56px) 64px clamp(60px, 9vw, 92px);
  box-shadow: var(--shadow-12);
  transform: rotate(-.35deg);
  background-image:
    linear-gradient(90deg, transparent calc(clamp(44px, 7vw, 66px) - 1px), var(--margin) calc(clamp(44px, 7vw, 66px) - 1px), var(--margin) clamp(44px, 7vw, 66px), transparent clamp(44px, 7vw, 66px)),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px),
    var(--grain);
  background-size: auto, auto, 512px 512px;
  background-position: 0 0, 0 120px, 0 0;
  background-repeat: no-repeat, repeat-y, repeat;
}
.sheet-front::before {
  content: ""; position: absolute; left: clamp(14px, 2.4vw, 24px); top: 0; bottom: 0; width: 18px; pointer-events: none;
  background:
    radial-gradient(circle at 9px 9px, var(--desk) 6.5px, rgba(0,0,0,.25) 7.5px, transparent 8.5px) 0 14% / 18px 18px no-repeat,
    radial-gradient(circle at 9px 9px, var(--desk) 6.5px, rgba(0,0,0,.25) 7.5px, transparent 8.5px) 0 50% / 18px 18px no-repeat,
    radial-gradient(circle at 9px 9px, var(--desk) 6.5px, rgba(0,0,0,.25) 7.5px, transparent 8.5px) 0 86% / 18px 18px no-repeat;
}
.clip { position: absolute; left: clamp(110px, 14vw, 150px); top: -28px; width: 30px; height: 82px; z-index: var(--z-paper); transform: rotate(4deg); filter: drop-shadow(1px 2px 1px rgba(0,0,0,.18)); }
.formno { position: absolute; right: clamp(16px, 4vw, 40px); top: 18px; display: flex; gap: 6px; align-items: baseline; font: 400 12px var(--ui); color: var(--ink-soft); }
.formno b { font: 600 13px var(--mono); color: var(--ink); border-bottom: 1px dotted var(--ink); padding: 0 4px; }
.stage { position: relative; z-index: var(--z-paper); will-change: transform, opacity; }

.coffee { position: absolute; right: -26px; bottom: -40px; width: 110px; height: 110px; z-index: var(--z-stamp); cursor: grab; touch-action: none; mix-blend-mode: multiply; }
.coffee svg { width: 100%; height: 100%; }
.coffee:active { cursor: grabbing; }
.coffee-note { position: absolute; right: -18px; bottom: -22px; width: 96px; font: 400 10.5px/1.35 var(--mono); color: var(--ink-soft); opacity: 0; transform: rotate(-4deg); transition: opacity .3s; z-index: var(--z-paper); }
.coffee-note.is-shown { opacity: 1; }

/* ---------- side panel ---------- */
.side { display: grid; gap: var(--s5); position: sticky; top: 16px; }
.qboard {
  background: var(--board); color: var(--led); border-radius: 10px; padding: 14px 16px 12px;
  box-shadow: var(--shadow-12), inset 0 0 0 2px #2c281f, inset 0 12px 20px rgba(255,255,255,.04);
  position: relative; overflow: hidden; cursor: default;
}
.qboard::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(180deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); pointer-events: none; }
.qboard-cap { margin: 0; font: 600 12px/1.4 var(--ui); color: #f2c0a8; }
.qboard-num { margin: 0; position: relative; font: 600 64px/1 var(--mono); letter-spacing: .06em; font-variant-numeric: tabular-nums; text-shadow: 0 0 12px rgba(255, 90, 60, .55); }
.qboard-ghost { position: absolute; left: 0; top: 0; opacity: .07; text-shadow: none; }
.qboard-ch { margin: 4px 0 0; font: 400 12px var(--mono); color: #c98b76; }
.qboard.is-flash { animation: qflash .9s steps(2, jump-none) 3; }
@keyframes qflash { 50% { color: #ffd166; } }
.hands67 { position: absolute; right: 10px; top: 10px; display: flex; align-items: center; gap: 2px; opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
.hands67.is-on { opacity: 1; transform: none; }
.hand { width: 26px; height: 26px; fill: #ffd166; }
.hand--r { transform: scaleX(-1); }
.hands67-t { font: 800 16px var(--display); color: #ffd166; }
.hands67.is-on .hand--l { animation: bob .44s ease-in-out infinite alternate; }
.hands67.is-on .hand--r { animation: bob .44s ease-in-out infinite alternate-reverse; }
@keyframes bob { from { translate: 0 -5px; } to { translate: 0 5px; } }

.memo { background: #fffdf5 var(--grain); background-size: 512px; background-blend-mode: multiply; padding: 14px 16px; box-shadow: var(--shadow-4); transform: rotate(.8deg); border-top: 12px solid #f3e6b3; }
.memo-k { margin: 0; font: 400 12px var(--ui); color: var(--ink-soft); }
.memo-who { margin: 0 0 8px; font: 700 18px var(--serif); }
.memo-who span { display: block; font: 400 12px var(--ui); color: var(--ink-soft); }
.memo-amt { margin: 0; font: 600 32px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.memo-note { margin: 2px 0 0; font: 400 12px var(--ui); color: var(--red); }

.clerk { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: start; }
.clerk-face { width: 56px; height: 56px; }
.cf-head { fill: #e8c9a6; stroke: var(--ink); stroke-width: 2; }
.cf-hair { fill: var(--ink); }
.cf-glass { fill: rgba(255,255,255,.4); stroke: var(--ink); stroke-width: 2; }
.cf-line { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; fill: none; }
.cf-body { fill: var(--ink-2); }
.clerk-bubble { margin: 0; position: relative; background: #fffdf6; border: 1.5px solid var(--ink); border-radius: 10px; padding: 8px 12px; font: 400 14px/1.5 var(--ui); }
.clerk-bubble::before { content: ""; position: absolute; left: -8px; top: 16px; width: 12px; height: 12px; background: #fffdf6; border-left: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(45deg); }
.clerk-k { display: block; font: 600 11px var(--mono); color: var(--ink-soft); }
.clerk.is-new .clerk-bubble { animation: pop-in .5s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes pop-in { from { transform: scale(.94); opacity: .3; } }

.notice { position: relative; background: #fbf8ee; padding: 18px 16px 14px; box-shadow: var(--shadow-4); transform: rotate(-1.4deg); font-family: var(--mono); }
.pin { position: absolute; left: 50%; top: 6px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff8b7a, #b8322b 60%, #7d1a14); box-shadow: 1px 2px 2px rgba(0,0,0,.3); }
.notice-k { margin: 0; font: 600 12px var(--mono); letter-spacing: .2em; color: var(--red); }
.notice-t { margin: 4px 0 0; font: 400 13px/1.5 var(--mono), var(--ui); }
.bundle, .inkpad { margin: 0; }
.bundle svg, .inkpad svg { width: 100%; height: auto; display: block; }
.bundle-t { font: 600 13px var(--mono); fill: #6b4f1d; }
.inkpad { width: 70%; justify-self: end; }

/* ---------- typography inside forms ---------- */
.st-head { margin-bottom: var(--s5); max-width: 40em; }
.st-kicker { margin: 0 0 var(--s1); font: 600 12px/1.4 var(--mono); letter-spacing: .14em; color: var(--red); text-transform: uppercase; }
.st-head h2, .intro-title { margin: 0; font: 700 clamp(26px, 3.4vw, 36px)/1.2 var(--serif); letter-spacing: -.005em; }
.st-head h2:focus { outline: none; }
.st-lede { margin: var(--s2) 0 0; font: 400 clamp(16px, 1.6vw, 18px)/1.6 var(--serif); color: var(--ink-2); }
.st-status { min-height: 1.6em; margin: var(--s4) 0 0; font: 400 15px/1.5 var(--mono); }
.fine { margin: var(--s4) 0 0; font: 400 12.5px/1.6 var(--ui); color: var(--ink-soft); }
.linkish { border: 0; background: none; padding: 8px 0; font: 600 15px var(--ui); color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 6px;
  font: 600 16px var(--ui); letter-spacing: .01em; text-decoration: none;
  transition: transform .12s, box-shadow .12s, background-color .15s;
  touch-action: manipulation;
}
.btn-ink { background: var(--ink); color: #f6f1e4; border: 0; box-shadow: 0 2px 0 #0e1d3d, var(--shadow-4); }
.btn-ink:hover { background: #24407a; }
.btn-ink:active { transform: translateY(2px); box-shadow: 0 0 0 #0e1d3d, var(--shadow-1); }
.btn-ink:disabled { opacity: .55; cursor: progress; }
.btn-ghost { background: rgba(255,255,255,.35); color: var(--ink); border: 1.5px solid var(--ink); }
.btn-ghost:hover { background: rgba(255,255,255,.7); }
.btn-ghost:active { transform: translateY(1px); }
.btn-big { min-height: 56px; padding: 0 28px; font-size: 18px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-fake { border-style: dashed; opacity: .75; }

/* ---------- intro ---------- */
.intro-title { display: grid; gap: 2px; }
.intro-hd { font: 800 clamp(36px, 12.2vw, 92px)/.95 var(--display); letter-spacing: -.02em; color: var(--ink); }
.intro-sub { font: 700 clamp(17px, 5.2vw, 28px)/1.3 var(--serif); color: var(--red); }
.intro-lede { margin: var(--s5) 0; max-width: 34em; font: 400 clamp(16px, 1.7vw, 19px)/1.7 var(--serif); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s6); margin: 0 0 var(--s6); max-width: 36em; }
.kv div { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px dotted var(--ink-soft); }
.kv dt { font: 400 12px var(--ui); color: var(--ink-soft); }
.kv dd { margin: 0; font: 600 16px var(--mono); }
.intro-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s5); }

/* ---------- stamps ---------- */
.stamp {
  position: absolute; z-index: var(--z-stamp); pointer-events: none;
  transform: translate(-50%, -50%) rotate(var(--rot));
  color: var(--red-ink); mix-blend-mode: multiply;
  -webkit-mask-image: var(--ink-mask); mask-image: var(--ink-mask);
  -webkit-mask-size: 300px; mask-size: 300px;
  -webkit-mask-position: var(--ink-x) var(--ink-y); mask-position: var(--ink-x) var(--ink-y);
}
.stamp-face {
  display: grid; justify-items: center; gap: 2px;
  border: .12em solid currentColor; border-radius: .18em;
  padding: .16em .5em .12em; box-shadow: inset 0 0 0 .05em currentColor, inset 0 0 0 .1em transparent;
  outline: .05em solid currentColor; outline-offset: .07em;
  white-space: nowrap;
}
.stamp-text { font: 800 1em/1.05 var(--display); letter-spacing: .02em; }
.stamp-sub { font: 600 .32em/1.2 var(--ui); letter-spacing: .02em; }
.arena > .stamp { z-index: var(--z-stamp-over); }
.stamp--sm { font-size: 22px; }
.stamp--md { font-size: 38px; }
.stamp--lg { font-size: 56px; }
.stamp--xl { font-size: clamp(56px, 11vw, 120px); }
.stamp--round .stamp-face { border-radius: 50%; aspect-ratio: 1; align-content: center; padding: .5em; }
.stamp--gold { color: #A87B1F; mix-blend-mode: normal; }
.stamp--gold .stamp-face { background: linear-gradient(110deg, #c99a2e, #f6de8d 38%, #b8862a 52%, #f0d27a 70%, #a87b1f); -webkit-background-clip: text; background-clip: text; color: transparent; border-color: #b8862a; outline-color: #c99a2e; }
.stamp--gold .stamp-text, .stamp--gold .stamp-sub { color: transparent; }

/* ---------- stage 1: queue ---------- */
.dispenser { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s6); }
.dispenser-body { position: relative; width: min(100%, 260px); }
.dispenser-art { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 10px rgba(46,34,14,.25)); }
.dsp-t1 { font: 700 15px var(--ui); fill: var(--red); }
.dsp-t2 { font: 400 8px var(--mono); fill: var(--ink-soft); letter-spacing: .1em; }
.ticket-slot { position: absolute; left: 22%; right: 22%; top: 72%; height: 220px; overflow: hidden; }
.ticket {
  position: absolute; left: 4%; right: 4%; top: 0; display: grid; gap: 2px; justify-items: center; text-align: center;
  padding: 12px 8px 16px; background: #fffef9; box-shadow: var(--shadow-4);
  background-image: radial-gradient(circle at 50% 100%, var(--desk) 4px, transparent 4.5px);
  background-size: 12px 8px; background-repeat: repeat-x; background-position: 0 100%;
}
.ticket-top { font: 400 10px var(--mono); color: var(--ink-soft); }
.ticket-label { font: 400 11px var(--ui); }
.ticket-num { font: 600 40px/1 var(--mono); letter-spacing: .04em; }
.ticket-meta { font: 400 10px/1.4 var(--ui); color: var(--ink-soft); }
.dispenser .btn { margin-top: 60px; }

/* ---------- stage 2: form ---------- */
.dform { display: grid; gap: var(--s5); max-width: 40em; }
.field { position: relative; display: grid; gap: 4px; padding: 4px 0 6px; }
.field label:first-child, .flabel { font: 600 15px var(--ui); display: flex; align-items: baseline; gap: 8px; }
.fno { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid var(--ink); border-radius: 50%; font: 600 11px var(--mono); flex: none; }
.field input[type="text"] {
  width: 100%; min-height: 44px; padding: 6px 2px; border: 0; border-bottom: 1.5px dotted var(--ink);
  background: transparent; font: 400 18px var(--mono); color: var(--ink); border-radius: 0;
}
.field input[type="text"]:focus { outline: none; border-bottom-style: solid; background: rgba(255,255,255,.35); }
.field input[type="text"]:focus-visible { box-shadow: 0 2px 0 var(--ink); }
.rule { margin: 0; font: 400 13px/1.5 var(--ui); color: var(--ink-soft); }
.msg { margin: 0; min-height: 1.4em; font: 400 13px/1.5 var(--mono); color: var(--red); }
.field.is-ok .msg { color: var(--ok); }
.field.is-ok > label:first-child .fno, .field.is-ok .flabel .fno { background: var(--ink); color: var(--paper); }
.field.is-bad input[type="text"] { border-bottom-color: var(--red); }
.field.is-relaxed .rule { text-decoration: line-through; text-decoration-color: var(--red); }
.count { font: 600 12px var(--mono); padding: 0 6px; border: 1px solid var(--ink-faint); border-radius: 4px; }
.pw-rules { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.pw-rules li { font: 400 13px/1.5 var(--ui); padding-left: 22px; position: relative; }
.pw-rules li::before { content: ""; position: absolute; left: 2px; top: .45em; width: 11px; height: 11px; border: 1.5px solid currentColor; border-radius: 2px; }
.pw-rules li.ok { color: var(--ok); }
.pw-rules li.ok::after { content: ""; position: absolute; left: 5px; top: .35em; width: 5px; height: 9px; border: solid var(--ok); border-width: 0 2px 2px 0; transform: rotate(40deg); }
.pw-rules li.no { color: var(--red); }
.pw-rules li.is-new { animation: type-in .4s steps(8, end); }
@keyframes type-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.pw-rules em { font-style: normal; color: var(--ink-soft); }
.birth-out { margin: 0; font: 600 15px var(--mono); }
input[type="range"] { width: 100%; accent-color: var(--ink); min-height: 32px; }
.check { display: inline-flex; align-items: center; gap: 8px; font: 400 14px var(--ui); min-height: 36px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.check.is-locked { opacity: .55; cursor: not-allowed; }
.sigpad { position: relative; border-bottom: 1.5px solid var(--ink); background: rgba(255,255,255,.28); max-width: 560px; }
.sigpad canvas { display: block; width: 100%; height: auto; aspect-ratio: 560 / 150; touch-action: none; cursor: crosshair; }
.sigpad--receipt canvas { aspect-ratio: 560 / 140; }
.sig-x { position: absolute; left: 8px; bottom: 6px; font: 600 18px var(--mono); color: var(--ink-soft); pointer-events: none; }
.terms { height: 6.4em; overflow-y: auto; padding: 8px 10px; border: 1.5px solid var(--ink-faint); background: rgba(255,255,255,.4); font: 400 12.5px/1.6 var(--mono); }
.terms p { margin: 0 0 6px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); }
.copies { font: 400 13px var(--mono); color: var(--ink-soft); }

/* ---------- stage 3: fees ---------- */
.ledger { max-width: 40em; }
.ledger-total { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: 12px 0; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.ledger-total span { font: 600 15px var(--ui); }
.ledger-total b { font: 600 clamp(30px, 5vw, 44px)/1 var(--mono); font-variant-numeric: tabular-nums; }
.ledger-rows { list-style: none; margin: 0; padding: 8px 0; min-height: 200px; }
.ledger-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; padding: 4px 0; font: 400 15px/1.5 var(--mono); }
.lr-label { white-space: normal; }
.lr-dots { border-bottom: 1.5px dotted var(--ink-soft); transform: translateY(-4px); min-width: 12px; }
.lr-amt { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--red); opacity: 0; transition: opacity .15s; }
.ledger-row.is-in .lr-amt { opacity: 1; }
.ledger-row.is-refund .lr-amt { color: var(--ok); }
.ledger-row.is-67 .lr-label { background: linear-gradient(transparent 60%, rgba(255, 209, 102, .55) 60%); }
.ledger-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }

/* ---------- stage 4: captcha ---------- */
.cap { max-width: 460px; background: #fdfbf6; border: 1.5px solid var(--ink); box-shadow: var(--shadow-4); position: relative; }
.cap::before { content: ""; position: absolute; left: 0; right: 0; top: -7px; height: 7px; background: radial-gradient(circle at 6px 7px, transparent 3.5px, #fdfbf6 4px) 0 0 / 12px 7px repeat-x; }
.cap-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; background: var(--ink); color: #f4efe3; }
.cap-title { font: 600 14px var(--ui); }
.cap-count { font: 600 14px var(--mono); font-variant-numeric: tabular-nums; }
.cap-count b { display: inline-block; }
.cap-body { position: relative; padding: 14px; min-height: 280px; }
.cap-q { margin: 0 0 12px; font: 400 16px var(--ui); }
.cap-q b { font-weight: 700; color: var(--red); }
.cap-msg { min-height: 3em; margin: 0; padding: 0 14px 12px; font: 400 14px/1.5 var(--mono); color: var(--red); }
.cap-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cap-hint { margin: 8px 0 0; font: 400 12px var(--ui); color: var(--ink-soft); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile { position: relative; aspect-ratio: 1; padding: 6px; border: 1.5px solid var(--ink-faint); background: #fffef9; border-radius: 3px; transition: transform .12s; }
.tile svg { width: 100%; height: 100%; display: block; }
.tile[aria-pressed="true"] { border-color: var(--ink); transform: scale(.9); background: #eef1f7; }
.tile[aria-pressed="true"]::after { content: ""; position: absolute; left: 6px; top: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10 L9 14 L15 6' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100%; }
.tiles67 .tile { display: grid; place-items: center; }
.t67 span { font: 800 34px var(--display); color: var(--ink); }
.t67.s2 span { font-family: var(--serif); transform: rotate(-8deg); color: var(--red); }
.t67.s3 span { font-family: var(--mono); font-size: 28px; }
.t67.s4 span { transform: scale(1.4) rotate(4deg); }
.t67.s5 span { letter-spacing: .3em; font-size: 26px; }
.t67.s6 span { font-style: italic; color: var(--red); }
.t67.s7 span { font-size: 18px; opacity: .7; }
.t67.s8 span { font: 700 20px var(--ui); }
.t67.s9 span { transform: rotate(180deg) scaleX(-1); }
.catwrap { position: relative; width: min(100%, 240px); margin: 0 auto; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, #fffef9 60%, #f1ead8); border: 1.5px dashed var(--ink-faint); touch-action: none; cursor: grab; }
.cat { width: 100%; height: 100%; display: block; }
.cat-guide { position: absolute; left: 50%; top: 4px; width: 2px; height: 14px; background: var(--red); margin-left: -1px; }
.robot-track { position: relative; min-height: 64px; }
.robot { position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 12px; padding: 14px 18px; border: 1.5px solid var(--ink-faint); background: #fffef9; border-radius: 4px; font: 400 16px var(--ui); cursor: pointer; white-space: nowrap; }
.robot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.robot-box { width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 3px; background: #fff; display: grid; place-items: center; }
.robot input:checked + .robot-box::after { content: ""; width: 8px; height: 15px; border: solid var(--ok); border-width: 0 3px 3px 0; transform: rotate(40deg) translate(-1px, -2px); }
.robot input:focus-visible + .robot-box { outline: 3px solid var(--ink); outline-offset: 3px; }
.robot-ask { margin-top: 14px; padding: 12px; border-left: 3px solid var(--red); background: var(--red-wash); }
.robot-ask p { margin: 0; font: 600 16px var(--ui); }
.puz { width: 100%; height: auto; display: block; border: 1.5px solid var(--ink-faint); }
.puz-range { margin-top: 10px; }
.shy-face { font: 600 11px var(--ui); fill: var(--red); }
.garble { position: relative; height: 96px; display: grid; place-items: center; background: repeating-linear-gradient(-45deg, #f6f1e4 0 6px, #efe8d6 6px 12px); border: 1.5px solid var(--ink-faint); overflow: hidden; }
.garble-noise { position: absolute; inset: 0; width: 100%; height: 100%; }
.garble-text { position: relative; font: 700 clamp(26px, 7.4vw, 38px) var(--serif); color: var(--ink); letter-spacing: .04em; filter: url(#rough); }
.gl { display: inline-block; animation: wob 1.4s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -0.23s); }
@keyframes wob { from { transform: translateY(-4px) rotate(-9deg) skewX(8deg); } to { transform: translateY(5px) rotate(7deg) skewX(-6deg); } }
.garble-form { display: flex; gap: 8px; margin-top: 12px; }
.garble-form input { flex: 1; min-width: 0; min-height: 46px; padding: 0 10px; border: 1.5px solid var(--ink); background: #fff; font: 400 18px var(--ui); border-radius: 4px; }
.circles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.circ { aspect-ratio: 1; padding: 6px; border: 1.5px solid var(--ink-faint); background: #fffef9; border-radius: 4px; }
.circ svg { width: 100%; height: 100%; }
.circ.is-wrong { border-color: var(--red); }
.circ.is-right { border-color: var(--ok); background: #eef4ef; }
.holdbtn { position: relative; display: grid; place-items: center; width: 170px; height: 170px; margin: 0 auto; border: 0; border-radius: 50%; background: #fffef9; box-shadow: var(--shadow-4); touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.holdbtn svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hold-track { fill: none; stroke: var(--ink-faint); stroke-width: 9; }
.hold-fill { fill: none; stroke: var(--red); stroke-width: 9; stroke-linecap: round; }
.holdbtn span { position: relative; font: 600 18px var(--mono); }
.holdbtn:active { transform: scale(.97); }

/* ---------- stage 5: the button ---------- */
.arena { position: relative; height: clamp(360px, 58vh, 560px); border: 1.5px dashed var(--ink-faint); border-radius: 6px; background: rgba(255,255,255,.18); touch-action: manipulation; }
.arena-hint { position: absolute; left: 14px; right: 14px; top: 10px; margin: 0; font: 400 14px/1.5 var(--mono); color: var(--ink-2); z-index: var(--z-paper); }
.dodge {
  position: absolute; left: 0; top: 0; z-index: var(--z-dodging-button);
  display: inline-flex; align-items: center; gap: 6px; min-height: 52px; padding: 0 22px;
  border: 0; border-radius: 8px; background: var(--red); color: #fff7f0;
  font: 700 17px var(--ui); white-space: nowrap; will-change: transform;
  box-shadow: 0 3px 0 #7d1a14, var(--shadow-4);
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.dodge--cancel { background: #e8e1d0; color: var(--ink); box-shadow: 0 3px 0 #b9ae95, var(--shadow-4); }
.dodge.is-dot { padding: 0; min-height: 0; width: 52px; height: 52px; border-radius: 50%; }
.dodge.is-dot .dodge-label { opacity: 0; font-size: 0; }
.dodge.is-hidden { visibility: hidden; }
.dodge.is-peek { box-shadow: 0 3px 0 #7d1a14; }
.dodge.is-calm { background: var(--ok); box-shadow: 0 3px 0 #233f2d, var(--shadow-4); }
.dodge-zz { display: none; font: 600 12px var(--mono); }
.dodge.is-sleep { background: #6d7891; box-shadow: 0 3px 0 #3c455b, var(--shadow-1); }
.dodge.is-sleep .dodge-zz { display: inline; animation: zz 2.2s ease-in-out infinite; }
.dodge.is-sleep .dodge-label { opacity: .75; }
@keyframes zz { 0% { opacity: 0; translate: 0 6px; } 40% { opacity: 1; } 100% { opacity: 0; translate: 4px -10px; } }
.dodge.is-awake { background: #e3a21a; color: var(--tj-ink); }
.dodge.is-tired { background: #9a5a50; box-shadow: 0 1px 0 #5b2f29, var(--shadow-1); }
.decoy {
  position: absolute; z-index: var(--z-dodging-button); transform: translate(-50%, -50%); min-height: 52px; padding: 0 20px; border: 0; border-radius: 8px;
  background: var(--red); color: #fff7f0; font: 700 17px var(--ui); white-space: nowrap; box-shadow: 0 3px 0 #7d1a14, var(--shadow-4);
}
.decoy--real { background: #c7564f; font: 400 15px var(--serif); letter-spacing: .1em; border-radius: 2px 14px 4px 9px; rotate: -3deg; box-shadow: 1px 2px 0 #7d1a14; filter: url(#rough) saturate(.7); opacity: .9; }
.decoy.is-popped { opacity: 0; transform: translate(-50%, -50%) scale(.3); transition: opacity .2s, transform .2s; }

/* the fake success */
.fake { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: rgba(251, 247, 236, .94); }
.fake-card { position: relative; width: min(100%, 520px); padding: 40px 28px; text-align: center; background: #fff; border-radius: 18px; box-shadow: var(--shadow-12); }
.fake-check { width: 96px; height: 96px; color: var(--ok); }
.fake-kicker { margin: 8px 0 0; font: 600 14px var(--ui); color: var(--ok); }
.fake-title { margin: 4px 0; font: 800 clamp(36px, 7vw, 54px)/1.1 var(--display); color: var(--tj-ink); }
.fake-title:focus { outline: none; }
.fake-sub { margin: 0; font: 400 16px var(--ui); color: #5a5650; }
.fake-after { margin: 20px 0 16px; font: 400 16px/1.6 var(--ui); }
.fake.is-busted .fake-check { color: #b9b2a3; }
.fake.is-busted .fake-kicker { color: var(--red); }

/* ---------- stage 6: slip ---------- */
.intray { max-width: 40em; }
.intray-tray { height: 18px; margin-bottom: -4px; background: linear-gradient(#8e7a58, #6e5c3f); border-radius: 4px 4px 0 0; display: flex; justify-content: center; align-items: center; }
.intray-tray span { font: 600 10px var(--mono); color: #f4e9cf; letter-spacing: .2em; }
.slip-view { min-height: 240px; display: grid; place-items: center; padding: 16px; background: rgba(110, 92, 63, .12); border: 1.5px dashed var(--ink-faint); }
.slip-empty { font: 400 14px var(--mono); color: var(--ink-soft); }
.slip-doc { position: relative; margin: 0; width: clamp(160px, 46vw, 200px); }
.slip-img { position: relative; display: block; overflow: hidden; background: #fff; box-shadow: var(--shadow-4); }
.slip-doc img { display: block; width: 100%; height: auto; }
.scanline { position: absolute; left: 0; right: 0; top: 0; height: 18px; background: linear-gradient(transparent, rgba(80, 200, 140, .55), transparent); animation: scan 1.1s linear 1 forwards; }
@keyframes scan { from { transform: translateY(-20px); } to { transform: translateY(260px); opacity: 0; } }
.slip-doc.v-blur .slip-img img { filter: blur(2.6px); }
.slip-doc.v-sharp img { filter: contrast(2.4) saturate(0) brightness(1.08); }
.slip-doc.v-too img { filter: drop-shadow(0 0 0 #000) hue-rotate(10deg); outline: 6px double var(--ink); outline-offset: -10px; }
.slip-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }
.file-btn { position: relative; overflow: hidden; }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.file-btn:focus-within { outline: 3px solid var(--ink); outline-offset: 3px; }
.loading { margin-top: var(--s6); max-width: 30em; padding: 20px; background: #fffef9; border: 1.5px solid var(--ink); box-shadow: var(--shadow-4); }
.loading-t { margin: 0 0 10px; font: 600 15px var(--ui); }
.loading-bar { height: 14px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; background: #f1ead8; }
.loading-bar span { display: block; height: 100%; background: repeating-linear-gradient(-45deg, var(--ink) 0 8px, var(--ink-2) 8px 16px); transform-origin: left; transform: scaleX(0); }
.loading-pct { margin: 8px 0 0; font: 600 22px var(--mono); font-variant-numeric: tabular-nums; }
.loading-ask p { margin: 12px 0 0; font: 400 15px var(--ui); }

/* ---------- stage 7: receipt ---------- */
.printer { position: relative; width: min(100%, 340px); }
.printer-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 22px; background: linear-gradient(#4b4f5a, #2f323a); color: #c9ccd3; border-radius: 10px 10px 4px 4px; font: 400 12px var(--mono); box-shadow: var(--shadow-4); }
.printer-led { width: 8px; height: 8px; border-radius: 50%; background: #5bd38a; box-shadow: 0 0 6px #5bd38a; }
.printer-mouth { height: 10px; margin: -16px 18px 0; background: #121318; border-radius: 3px; position: relative; z-index: var(--z-paper); }
.receipt-clip { margin: -4px 26px 0; overflow: hidden; }
.receipt { padding: 16px 14px 22px; background: #fffef8; box-shadow: var(--shadow-4); font: 400 13px/1.55 var(--mono); color: #2a2a2a;
  background-image: radial-gradient(circle at 50% 100%, var(--paper) 5px, transparent 5.5px); background-size: 14px 10px; background-repeat: repeat-x; background-position: 0 100%; position: relative; }
.rl { animation: feed .28s ease-out; }
@keyframes feed { from { opacity: 0; transform: translateY(-6px); } }
.rl-c { text-align: center; }
.rl-b { font-weight: 600; font-size: 14px; }
.rl-s { font-size: 11px; color: #666; }
.rl-hr { border-top: 1.5px dashed #999; margin: 6px 0; height: 0; }
.rl-kv { display: flex; justify-content: space-between; gap: 12px; }
.rl-kv.rl-b { font-size: 16px; }
.barcode { display: block; height: 44px; margin: 8px 0; background: repeating-linear-gradient(90deg, #222 0 2px, transparent 2px 4px, #222 4px 7px, transparent 7px 8px, #222 8px 9px, transparent 9px 12px); }
.signoff { margin-top: var(--s6); max-width: 560px; }
.signoff-t { margin: 0 0 6px; font: 700 20px var(--serif); }
.pen { position: absolute; right: 10px; top: -18px; width: 110px; height: auto; transform-origin: 80% 50%; filter: drop-shadow(1px 3px 2px rgba(0,0,0,.25)); }
.final { margin-top: var(--s6); }

/* ---------- give up coupon ----------
   It hangs from a pin and swings like a pendulum: T = 2 pi sqrt(L / g) with L = 0.25 m gives T = 1.0 s. */
.giveup {
  position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: var(--z-hud);
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 10px 14px 8px;
  background: #fffdf4; border: 1.5px dashed var(--ink); border-radius: 3px; color: var(--ink);
  font: 600 14px var(--ui); box-shadow: var(--shadow-4); transform-origin: 50% -8px;
  opacity: 0; translate: 0 20px; transition: opacity .3s, translate .4s cubic-bezier(.3, 1.4, .5, 1);
}
.giveup.is-in { opacity: 1; translate: 0 0; animation: swing 1s ease-in-out infinite alternate; }
.giveup:hover { animation-play-state: paused; background: #fff6e4; }
@keyframes swing { from { rotate: -2.6deg; } to { rotate: 2.6deg; } }
.giveup-pin { position: absolute; left: 50%; top: -6px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #9ab0d8, var(--ink) 65%); }
.giveup-sc { width: 16px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.giveup-k { font: 400 11px var(--ui); color: var(--ink-soft); }

/* rush mode (easter egg) */
body.is-rush .letterhead { background-color: #f6d9cf; }
body.is-rush .letterhead::after { content: "โหมดราชการด่วนพิเศษ"; position: absolute; left: 50%; top: 100%; translate: -50% 6px; padding: 4px 14px; background: var(--red); color: #fff; font: 800 15px var(--display); letter-spacing: .06em; border-radius: 3px; }
body.is-rush .stage { animation: jitter .12s steps(2) infinite; }
@keyframes jitter { 50% { translate: 1px 0; } }

/* ---------- context menu, toasts, modal ---------- */
.ctx { position: fixed; z-index: var(--z-easter); min-width: 220px; padding: 6px; background: #fffef9; border: 1.5px solid var(--ink); box-shadow: var(--shadow-12); border-radius: 4px; }
.ctx-t { margin: 0; padding: 6px 10px 8px; font: 700 13px var(--ui); color: var(--red); border-bottom: 1px dotted var(--ink-soft); }
.ctx button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; font: 400 14px var(--ui); border-radius: 3px; }
.ctx button:hover, .ctx button:focus-visible { background: var(--ink); color: #fff; outline: none; }
.toasts { position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); translate: -50% 0; z-index: var(--z-toast); display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast { padding: 10px 14px; background: var(--ink); color: #f4efe3; border-radius: 6px; font: 400 14px/1.45 var(--ui); box-shadow: var(--shadow-12); }
.toast--gold { background: linear-gradient(110deg, #8a6416, #c99a2e 40%, #a87b1f); color: #fffaf0; font-weight: 600; }
.toast--egg { background: #3b3127; }
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: rgba(23, 21, 15, .5); }
.modal-card { position: relative; width: min(100%, 560px); max-height: 88vh; overflow: auto; padding: 28px 24px; background: var(--paper) var(--grain); background-size: 512px; background-blend-mode: multiply; box-shadow: var(--shadow-12); }
.modal-card h2 { margin: 0; font: 700 28px var(--serif); }
.modal-card h2:focus { outline: none; }
.modal-lede { margin: 6px 0 16px; font: 400 14px var(--ui); color: var(--ink-soft); }
.modal-x { position: absolute; right: 12px; top: 12px; min-height: 36px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 999px; background: transparent; font: 600 13px var(--ui); }

/* the ledger board */
.ledger-board { background: #fffdf5; border: 1.5px solid var(--ink); box-shadow: var(--shadow-4); }
.lb-head, .lb-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 14px; }
.lb-head { background: var(--ink); color: #f4efe3; font: 600 12px var(--ui); }
.lb-rows { list-style: none; margin: 0; padding: 0; }
.lb-row { position: relative; border-bottom: 1px dotted var(--ink-faint); font: 400 15px var(--ui); will-change: transform; }
.lb-rank { font: 600 15px var(--mono); }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-time { font: 600 15px var(--mono); font-variant-numeric: tabular-nums; }
.lb-row.is-top { background: linear-gradient(90deg, rgba(232, 194, 90, .28), transparent 70%); }
.lb-row.is-top .lb-rank { color: var(--gold); }
.lb-row.is-mine { box-shadow: inset 4px 0 0 var(--red); }
.lb-row.is-flash { animation: goldflash 1.4s ease-out; }
@keyframes goldflash { 0% { background-color: rgba(246, 222, 141, .95); } 100% { background-color: transparent; } }
.lb-newstamp { position: absolute; right: 90px; top: 50%; translate: 0 -50%; rotate: -8deg; padding: 0 6px; border: 2px solid var(--red); color: var(--red); font: 800 12px var(--display); border-radius: 3px; }
.lb-state { margin: 0; padding: 14px; font: 400 14px var(--mono); color: var(--ink-soft); }

.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: var(--z-confetti); }

/* ---------- tear ---------- */
.tear { position: fixed; inset: 0; z-index: var(--z-confetti); pointer-events: none; filter: drop-shadow(0 0 1px rgba(255, 255, 255, .9)) drop-shadow(3px 6px 8px rgba(0, 0, 0, .28)); will-change: transform; }
.tear-inner { position: absolute; inset: 0; overflow: hidden; background-color: var(--desk); background-image: var(--desk-tex); background-size: 512px; }

/* ================= REVEAL: Tipjai ================= */
.reveal { position: relative; min-height: 100vh; background: var(--tj-cream); color: var(--tj-ink); font-family: var(--ui); overflow-x: clip; }
.reveal::before { content: ""; position: absolute; inset: 0; background: var(--grain); background-size: 512px; opacity: .35; mix-blend-mode: multiply; pointer-events: none; }
.reveal > * { position: relative; }
.rv-onair { display: flex; align-items: center; gap: 10px; padding: 10px clamp(16px, 4vw, 48px); background: var(--tj-ink); color: var(--tj-cream); font: 800 14px var(--display); letter-spacing: .12em; }
.rv-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 8px #ff3b30; animation: blink 1s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rv-onair-t { font: 600 13px var(--ui); letter-spacing: 0; color: #f7a27e; }
.rv-hero { max-width: 1120px; margin: 0 auto; padding: clamp(32px, 6vw, 72px) clamp(16px, 4vw, 48px) 40px; display: grid; grid-template-columns: minmax(0, 1fr) clamp(180px, 22vw, 260px); gap: 8px 40px; }
.rv-hero > * { grid-column: 1; }
.rv-kicker { margin: 0; font: 600 15px/1.5 var(--ui); color: #7a6f63; max-width: 40em; }
.rv-title { margin: 8px 0 0; display: grid; font: 800 italic clamp(42px, 8.4vw, 104px)/.98 var(--display); letter-spacing: -.02em; }
.rv-title:focus { outline: none; }
.rv-title span:nth-child(2) { color: var(--tj-coral); }
.rv-pitch { margin: 18px 0 0; font: 800 clamp(28px, 4.4vw, 52px)/1.1 var(--display); }
.rv-pitch::after { content: ""; display: block; width: min(100%, 12em); height: .22em; margin-top: .12em; background: var(--tj-coral); border-radius: 999px; transform: rotate(-1.2deg); }
.rv-brand { display: flex; align-items: center; gap: 14px; margin-top: 26px; }
.rv-brand img { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 6px 16px rgba(242, 104, 60, .35); }
.rv-brand b { display: block; font: 800 36px/1 var(--display); }
.rv-brand span { font: 400 16px var(--ui); color: #7a6f63; }
.rv-lede { margin: 18px 0 0; max-width: 32em; font: 400 clamp(18px, 2vw, 22px)/1.6 var(--ui); }
.rv-ctas { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 26px; }
.rv-ctas--center { justify-content: center; }
.rv-cta { display: inline-flex; align-items: center; min-height: 64px; padding: 0 34px; border-radius: 999px; background: var(--tj-coral); color: #fff; font: 800 clamp(20px, 2.4vw, 26px) var(--display); text-decoration: none; box-shadow: 0 5px 0 var(--tj-coral-d), 0 14px 28px -10px rgba(217, 82, 42, .6); transition: transform .12s, box-shadow .12s; }
.rv-cta:hover { transform: translateY(-2px); }
.rv-cta:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--tj-coral-d); }
.rv-cta2 { color: var(--tj-ink); font: 600 17px var(--ui); text-underline-offset: 5px; }
.rv-phone { margin: 10px 0 0; font: 400 13px var(--ui); color: #7a6f63; }
.rv-burst { grid-column: 2 !important; grid-row: 1 / span 6; align-self: start; position: relative; width: 100%; aspect-ratio: 1; margin-top: 40px; rotate: 9deg; }
.rv-burst svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: #FFD23F; stroke: var(--tj-ink); stroke-width: 2.5; filter: drop-shadow(4px 6px 0 rgba(26, 23, 20, .85)); }
.rv-burst-t { position: absolute; inset: 18%; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.rv-burst-t span { font: 800 clamp(13px, 1.4vw, 16px) var(--display); }
.rv-burst-t s { font: 600 clamp(16px, 1.8vw, 20px) var(--ui); color: #6b5a3e; text-decoration-color: var(--red); text-decoration-thickness: 3px; }
.rv-burst-t b { font: 800 italic clamp(40px, 5vw, 60px)/1 var(--display); color: var(--red); }
.rv-burst-t small { font: 400 11px var(--ui); }
.reveal section { max-width: 1120px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 48px); }
/* sections below the fold skip layout until they come near the viewport */
.reveal section { content-visibility: auto; contain-intrinsic-size: auto 900px; }
.reveal h2 { margin: 0 0 18px; font: 800 clamp(26px, 3.4vw, 40px)/1.15 var(--display); }
.rv-bars { display: grid; gap: 12px; }
.rv-bar { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.rv-bar-l { font: 600 15px var(--ui); }
.rv-bar-fill { height: 30px; border-radius: 6px; width: var(--w); background: #1E3563; }
.rv-bar--tj .rv-bar-fill { background: var(--tj-coral); min-width: 8px; }
.rv-bar b { font: 700 16px var(--ui); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rv-note { margin: 10px 0 0; font: 400 13px var(--ui); color: #7a6f63; }
.ba { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--tj-ink); border-radius: 16px; overflow: hidden; }
.ba-col { padding: 22px 24px; }
.ba-col--before { background: var(--paper) var(--grain); background-size: 512px; background-blend-mode: multiply; color: var(--ink); font-family: var(--mono); }
.ba-col--after { background: var(--tj-coral); color: #fff; }
.ba-tag { margin: 0 0 12px; font: 800 20px var(--display); }
.ba-col--before .ba-tag::after { content: "ไม่แนะนำ"; margin-left: 10px; padding: 0 6px; border: 2px solid var(--red); color: var(--red); font-size: 12px; rotate: -6deg; display: inline-block; }
.ba dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; }
.ba dt { font: 600 13px var(--ui); opacity: .75; padding-top: 2px; }
.ba dd { margin: 0; font-size: 15px; line-height: 1.5; }
.ba-col--before dd { text-decoration: line-through; text-decoration-color: rgba(184, 50, 43, .7); text-decoration-thickness: 2px; }
.ba-col--after dd { font: 600 16px/1.5 var(--ui); }
.rv-facts ol { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 0; }
.rv-facts li { display: grid; grid-template-columns: clamp(110px, 16vw, 180px) 1fr; gap: 18px; align-items: baseline; padding: 18px 0; border-top: 2px solid var(--tj-ink); }
.rv-facts li:last-child { border-bottom: 2px solid var(--tj-ink); }
.rv-facts b { font: 800 clamp(40px, 6vw, 72px)/1 var(--display); color: var(--tj-coral); }
.rv-facts span { font: 400 clamp(17px, 1.8vw, 21px)/1.5 var(--ui); }
.rv-small { text-align: center; margin: 14px 0 0; font: 400 14px var(--ui); color: #7a6f63; }
.rv-sub { margin: -8px 0 16px; font: 400 15px var(--ui); color: #7a6f63; }
.honours-new, .honours-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 18px; }
.honour { margin: 0; text-align: center; }
.badge-svg { width: 110px; height: 110px; display: block; margin: 0 auto 6px; }
.badge-svg.is-earned { -webkit-mask-image: var(--ink-mask); mask-image: var(--ink-mask); -webkit-mask-size: 240px; mask-size: 240px; }
.honour.is-new { opacity: 0; }
.honour.is-new.is-landed { opacity: 1; }
.honour figcaption b { display: block; font: 600 14px/1.35 var(--ui); }
.honour figcaption span { font: 400 12px/1.4 var(--ui); color: #7a6f63; }
.honour.is-locked figcaption b { color: #9a9086; }
.badge-q { font: 800 40px var(--display); }
.badge-67 { font: 800 44px var(--display); }
.badge-mini { font: 600 9px var(--mono); letter-spacing: .1em; }
.honours-book { margin-top: 24px; }
.honours-book summary { cursor: pointer; font: 700 17px var(--ui); padding: 10px 0; }
.honours-book .honours-grid { margin-top: 12px; }
.sign { margin-bottom: 18px; }
.sign-form label { display: block; font: 700 18px var(--ui); margin-bottom: 8px; }
.sign-row { display: flex; gap: 10px; max-width: 520px; }
.sign-row input { flex: 1; min-width: 0; min-height: 50px; padding: 0 14px; border: 2px solid var(--tj-ink); border-radius: 10px; background: #fff; font: 400 18px var(--ui); }
.sign-msg { min-height: 1.5em; margin: 8px 0 0; font: 400 14px var(--ui); color: var(--red); }
.sign-note { font: 400 15px var(--ui); color: #7a6f63; }
.sign-done { position: relative; margin: 0; padding: 12px 0; font: 600 17px var(--ui); }
.sign-form { position: relative; }
.btn-tj { background: var(--tj-coral); color: #fff; border: 0; box-shadow: 0 3px 0 var(--tj-coral-d); border-radius: 10px; }
.btn-tj:active { transform: translateY(2px); box-shadow: none; }
.btn-tj-ghost { background: transparent; color: var(--tj-ink); border: 2px solid var(--tj-ink); border-radius: 10px; }
.share-wrap { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 28px; align-items: start; }
#share { width: 100%; height: auto; display: block; box-shadow: 0 18px 40px -16px rgba(26, 23, 20, .45); rotate: -1.4deg; border-radius: 4px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 10px; align-content: start; }
.rv-foot { max-width: 1120px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 48px) 48px; display: flex; gap: 14px; align-items: flex-start; border-top: 1px solid rgba(26, 23, 20, .15); }
.rv-foot img { border-radius: 10px; flex: none; }
.rv-foot p { margin: 0; font: 400 13px/1.6 var(--ui); color: #7a6f63; }
.rv-foot a { color: var(--tj-ink); }

/* share bar: a row of bureau stamps carrying the real marks */
.share-side { display: grid; gap: 14px; align-content: start; }
.sharebar-k { margin: 0; justify-self: start; padding: 2px 10px; border: 3px double var(--red); color: var(--red); font: 800 18px var(--display); rotate: -2deg; letter-spacing: .02em; }
.sharebar { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.sharebar--center { max-width: 640px; margin: 0 auto 14px; }
.sb { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border: 2px dashed rgba(26, 23, 20, .55); border-radius: 6px; background: #fffdf8; color: var(--tj-ink); font: 600 15px var(--ui); text-decoration: none; cursor: pointer; transition: transform .12s, border-color .15s, background-color .15s; }
.sb svg { flex: none; width: 24px; height: 24px; }
.sb:hover { border-style: solid; background: #fff; transform: rotate(-1deg); }
.sb:active { transform: translateY(2px); }
.sb--native { background: var(--tj-coral); color: #fff; border: 2px solid var(--tj-coral-d); }
.sb.is-pressed { animation: sbpress .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes sbpress { from { transform: scale(.9); } }
.crown .sharebar-k { justify-self: center; margin: 0 auto 10px; display: table; }

/* coronation */
.crown { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: rgba(23, 21, 15, .72); overflow: auto; }
.crown-card { position: relative; width: min(100%, 860px); padding: 28px 22px 22px; background: var(--paper) var(--grain); background-size: 512px; background-blend-mode: multiply; text-align: center; box-shadow: var(--shadow-12); border: 3px double var(--gold); }
.crown-k { margin: 0; font: 600 13px var(--mono); color: var(--gold); letter-spacing: .14em; }
.crown-card h2 { margin: 4px 0 14px; font: 800 clamp(30px, 5vw, 48px) var(--display); }
.crown-card h2:focus { outline: none; }
#cert { width: 100%; height: auto; display: block; margin-bottom: 14px; box-shadow: var(--shadow-4); }
.crown .share-actions { justify-content: center; }

/* Courier Prime's space is 0.6 em wide; in Thai sentences set in the typewriter face that reads gappy, so word spacing comes down to about 0.3 em. */
.terms, .st-status, .notice-t, .msg, .cap-msg, .ledger-row, .arena-hint, .copies, .clerk-k, .formno, .bureau-en, .birth-out, .loading-pct, .slip-empty, .receipt, .lb-state, .ba-col--before, .coffee-note, .ticket-top, .qboard-ch, .st-kicker, .crown-k, .bundle-t { word-spacing: -0.3em; }
.sb span { white-space: nowrap; }
.ba-tag { word-spacing: normal; }

/* ---------- responsive ---------- */
@media (min-width: 1600px) {
  .desk, .tabsnav { max-width: 1440px; }
  .desk { grid-template-columns: minmax(0, 1fr) 360px; }
  .sheet-front { min-height: 720px; }
  body { font-size: 17px; }
}
@media (min-width: 2200px) {
  .desk, .tabsnav { max-width: 1680px; }
  .desk { grid-template-columns: minmax(0, 1fr) 420px; }
  body { font-size: 18px; }
}
@media (max-width: 1100px) {
  .desk { grid-template-columns: minmax(0, 1fr) 260px; }
}
@media (max-width: 900px) {
  .letterhead { grid-template-columns: 1fr auto; grid-template-areas: "b t" "c c"; row-gap: 8px; }
  .bureau { grid-area: b; } .toggles { grid-area: t; } .clockbox { grid-area: c; justify-self: start; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; grid-template-columns: 1fr 1fr; order: -1; gap: 12px; }
  .qboard-num { font-size: 44px; }
  .clerk { grid-column: 1 / -1; }
  .notice, .bundle, .inkpad { display: none; }
  .tabs { display: none; }
  .tabs-mobile { display: block; padding: 0 0 8px; }
  .tabsnav { padding-top: 14px; }
  .rv-hero { grid-template-columns: minmax(0, 1fr); }
  .rv-burst { grid-column: 1 !important; grid-row: auto; width: min(220px, 60vw); justify-self: end; margin-top: 8px; }
  .ba { grid-template-columns: 1fr; }
  .share-wrap { grid-template-columns: 1fr; }
  #share { max-width: 360px; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .letterhead { padding: 10px 14px; gap: 10px; }
  .seal { width: 42px; height: 42px; }
  .bureau-en { display: none; }
  .bureau-th { font-size: 14px; }
  .toggle span { display: none; }
  .toggle { width: 40px; padding: 0; justify-content: center; }
  .desk { padding: 0 12px 120px; gap: 16px; }
  .tabsnav { padding: 12px 12px 0; }
  .sheet-front { padding: 48px 16px 56px 46px; transform: none; min-height: 520px; }
  .sheet-back--1 { transform: rotate(.5deg) translate(-2px, 4px); }
  .sheet-back--2 { transform: rotate(-.4deg) translate(2px, 6px); }
  .sheet-front::before { left: 10px; transform: scale(.8); transform-origin: left; }
  .clip { left: 58px; top: -12px; width: 20px; height: 54px; }
  .formno { right: 12px; top: 14px; font-size: 11px; }
  .side { grid-template-columns: 1fr 1fr; gap: 10px; }
  .qboard { padding: 8px 10px 6px; }
  .qboard-num { font-size: clamp(26px, 8.6vw, 34px); }
  .qboard-ch { display: none; }
  .hand { width: 18px; height: 18px; }
  .memo { padding: 8px 10px; border-top-width: 8px; }
  .memo-k:first-child, .memo-who { display: none; }
  .memo-amt { font-size: clamp(20px, 6.4vw, 24px); }
  .memo-note { font-size: 11px; }
  .clerk { grid-template-columns: 32px 1fr; gap: 8px; }
  .clerk-face { width: 32px; height: 32px; }
  .clerk-k { display: none; }
  .clerk-bubble { font-size: 12.5px; padding: 6px 10px; }
  .clerk-bubble::before { top: 10px; }
  .wallclock, .wallclock svg { width: 32px; height: 32px; }
  .clock-label { display: none; }
  .clock { font-size: 17px; }
  .kv { grid-template-columns: 1fr; }
  .coffee { width: 76px; height: 76px; right: 0; bottom: -30px; }
  .coffee-note { right: 2px; bottom: -18px; width: 72px; font-size: 9px; }
  .dispenser { gap: 16px; }
  .dispenser .btn { margin-top: 140px; }
  .arena { height: clamp(380px, 62vh, 520px); }
  .rv-bar { grid-template-columns: 1fr auto; }
  .rv-bar-fill { grid-column: 1 / -1; grid-row: 2; }
  .rv-facts li { grid-template-columns: 1fr; gap: 4px; }
  .lb-head, .lb-row { grid-template-columns: 36px minmax(0, 1fr) auto; padding: 8px 10px; }
  .lb-newstamp { right: 70px; }
  .giveup-k { display: none; }
  .giveup { left: auto; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); padding: 8px 12px 6px; min-height: 44px; }
}
@media (max-width: 360px) {
  .bureau-th { font-size: 13px; }
  .stamp--md { font-size: 30px; }
  .stamp--lg { font-size: 42px; }
  .robot { padding: 12px; font-size: 15px; }
  .rv-cta { padding: 0 22px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .side { position: static; }
  .arena { height: 340px; }
  .letterhead { position: relative; }
}

/* Reduced motion: decoration stops; the dodging button still dodges (it hops instead of gliding, handled in JS). */
@media (prefers-reduced-motion: reduce) {
  .giveup.is-in, .gl, .hands67.is-on .hand, .rv-dot, .wallclock.is-back svg, body.is-rush .stage, .dodge.is-sleep .dodge-zz { animation: none !important; }
  .scanline { animation: none; display: none; }
  .rl, .clerk.is-new .clerk-bubble, .pw-rules li.is-new { animation: none; }
  .giveup { transition: none; }
}
