/* Daam: the kirana bill. Tokens per PLAN.md section 6. */

:root {
  --paper: #F3F0E7;
  --paper-2: #E9E4D6;
  --slip: #FBFAF5;
  --rule: #D6CFBD;
  --ink: #1B1A17;
  --ink-2: #5F5C53;
  --stamp: #2F3E9E;
  --on-stamp: #FBFAF5;
  --cta: var(--stamp); --on-cta: var(--on-stamp);
  --copper: #A8572E;
  --copper-text: #94491F;
  --sahi: #2E7D4F;
  --haldi: #C9961A;
  --door: #C8682B;
  --arre: #C2362B;
  --key-shadow: #CFC7B2;
  --shadow: rgba(40, 30, 10, .08);

  --mono: "IBM Plex Mono", "Plex Fallback", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ink-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.45' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 -2.4 1.75'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141412; --paper-2: #26241F; --slip: #201F1B; --rule: #3A3731;
    --ink: #ECE8DC; --ink-2: #A29E92; --stamp: #8C9BFF; --on-stamp: #141412; --cta: var(--ink); --on-cta: var(--paper);
    --copper: #D08A5C; --copper-text: #D08A5C;
    --sahi: #4FA872; --haldi: #E2B23C; --door: #E5844A; --arre: #E2584C;
    --key-shadow: #0B0B0A; --shadow: rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"], .night {
  --paper: #141412; --paper-2: #26241F; --slip: #201F1B; --rule: #3A3731;
  --ink: #ECE8DC; --ink-2: #A29E92; --stamp: #8C9BFF; --on-stamp: #141412; --cta: var(--ink); --on-cta: var(--paper);
  --copper: #D08A5C; --copper-text: #D08A5C;
  --sahi: #4FA872; --haldi: #E2B23C; --door: #E5844A; --arre: #E2584C;
  --key-shadow: #0B0B0A; --shadow: rgba(0, 0, 0, .4);
  color-scheme: dark;
}

@font-face { font-family: "Plex Fallback"; src: local("Roboto Mono"), local("Menlo"), local("Courier New"); size-adjust: 100%; ascent-override: 102.5%; descent-override: 27.5%; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background-color .45s var(--ease), color .45s var(--ease);
}
/* Thermal grain, 3% */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.app {
  max-width: 440px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
}
.top {
  flex: none;
  height: 52px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.brand { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); text-decoration: none; justify-self: start; }
.coin { width: 22px; height: 22px; fill: var(--copper); }
.wordmark {
  font-family: var(--serif);
  font-weight: 650;
  font-size: 23px;
  letter-spacing: -.02em;
  line-height: 1;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  transform: translateY(-1px);
}
.meta {
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.actions { justify-self: end; display: flex; gap: 2px; margin-right: -8px; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 2px;
}
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .dot { fill: var(--ink); }
.icon-btn:active { transform: scale(.92); }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Receipt (shared object) ---------- */
.slip-wrap { filter: drop-shadow(0 1px 1.5px var(--shadow)); }
.slip {
  --z: 5px;
  background: var(--slip);
  padding: 14px 16px calc(14px + var(--z));
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--z)) 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--z)) 100%;
  transition: background-color .45s var(--ease);
}
.cap {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.rule { border: 0; border-top: 1px dashed var(--rule); margin: 8px 0; }

/* ---------- Play ---------- */
.play { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.play .slip-wrap { flex: 1; min-height: 0; display: flex; }
.play .slip { position: relative; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; }
.play .slip::-webkit-scrollbar { display: none; }

.rc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ladder { display: flex; gap: 4px; }
.ladder i {
  width: 10px; height: 10px;
  border: 1px solid var(--rule);
  display: block;
  transition: background-color .18s, border-color .18s;
}
.ladder i.cur { border-color: var(--ink); }
.ladder i.drop { animation: drop .18s var(--spring) both; }
.ladder i[data-b="0"], .blocks i[data-b="0"] { background: var(--sahi); border-color: var(--sahi); }
.ladder i[data-b="1"], .blocks i[data-b="1"] { background: var(--haldi); border-color: var(--haldi); }
.ladder i[data-b="2"], .blocks i[data-b="2"] { background: var(--door); border-color: var(--door); }
.ladder i[data-b="3"], .blocks i[data-b="3"] { background: var(--arre); border-color: var(--arre); }
@keyframes drop { from { transform: translateY(-8px) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

.theme-line { margin-top: 4px; font-size: 13px; color: var(--ink); }

.lines { list-style: none; margin: 0; padding: 0; }
.ln {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto 26px 8px;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  padding: 2px 0;
  opacity: .88;
}
.ln-n { color: var(--ink-2); }
.ln-name { display: flex; min-width: 0; gap: 4px; }
.ln-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 100%; }
.ln-name::after { content: ""; flex: 1; border-bottom: 1px dotted var(--ink-2); opacity: .5; transform: translateY(-3px); min-width: 8px; }
.ln-price { font-weight: 600; white-space: nowrap; }
.ln-pts { text-align: right; color: var(--ink-2); }
.ln-b { width: 8px; height: 8px; align-self: center; }
.ln-b[data-b="0"] { background: var(--sahi); } .ln-b[data-b="1"] { background: var(--haldi); }
.ln-b[data-b="2"] { background: var(--door); } .ln-b[data-b="3"] { background: var(--arre); }
.ln.pending { opacity: .7; }
.ln.pending .ln-price { letter-spacing: .02em; }
.ln.cur { opacity: 1; }
.ln.cur .ln-n { color: var(--stamp); font-weight: 600; }
.ln.cur .ln-name span { color: var(--ink); }
.ln.guessed .ln-price { color: var(--ink); font-weight: 600; }
.ln-price.print { animation: print .18s steps(6) both; }
@keyframes print { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.ln.pending .ln-name span { color: var(--ink-2); }
.ln.pending .ln-price { color: var(--ink-2); font-weight: 400; }
.ln.pending .ln-b { border: 1px solid var(--rule); width: 8px; height: 8px; }
.ln.pending.cur .ln-name span { color: var(--ink); }
.ln.pending.guessed .ln-price { color: var(--ink); font-weight: 600; letter-spacing: 0; }
.ln.new { animation: feed .24s var(--ease) both; }
@keyframes feed { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: .88; } }

.card {
  margin-top: auto;
  padding-top: 10px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.card.enter { animation: cardIn .32s var(--ease) both; }
@keyframes cardIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.pic {
  width: 64px; height: 64px;
  background: var(--paper-2);
  display: grid; place-items: center;
  border-radius: 2px;
  transition: background-color .45s var(--ease);
}
.pic svg { width: 38px; height: 38px; fill: none; stroke: var(--stamp); stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.item-name:focus { outline: none; }
.spec .nw { white-space: nowrap; }
.item-name { margin: 3px 0 0; font-size: 18px; font-weight: 600; line-height: 1.22; letter-spacing: 0; text-wrap: balance; }
.about { margin: 6px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--ink); }
.info {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; margin-left: 4px; padding: 0; vertical-align: 3px;
  border: 1.5px solid var(--ink-2); border-radius: 50%; background: transparent; color: var(--ink-2);
  font: italic 700 11px/1 Georgia, serif; cursor: pointer;
}
.info::after { content: ''; position: absolute; inset: -12px; } /* bigger tap target */
.info[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.spec { margin-top: 4px; font-size: 11px; line-height: 1.45; color: var(--ink-2); letter-spacing: .02em; }
.sticker {
  margin-top: 8px;
  display: inline-flex; align-items: baseline; gap: 6px;
  border: 1.5px solid var(--arre);
  border-radius: 6px;
  padding: 4px 9px 5px;
  transform: rotate(-1.5deg);
  transform-origin: left center;
  font-size: 10px;
  letter-spacing: .06em;
  color: var(--arre);
  text-transform: uppercase;
}
.sticker b { text-transform: none; font-size: 14px; letter-spacing: 0; font-weight: 600; color: var(--ink); min-width: 4ch; }
.sticker b.blank { color: var(--ink-2); opacity: .8; }
.sticker.filled { animation: thunk .34s var(--spring); }
@keyframes thunk { 0% { transform: rotate(-1.5deg) scale(1.12); } 100% { transform: rotate(-1.5deg) scale(1); } }

/* ---------- Panel ---------- */
.panel { flex: none; display: flex; flex-direction: column; }
.entry { padding: 2px 2px 0; container-type: inline-size; }
.display {
  height: 52px;
  display: flex; align-items: baseline; gap: 0;
  font-size: clamp(20px, calc(100cqw / var(--len, 8) / .6), 40px); font-weight: 600; line-height: 52px;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
}
.display .rs { font-weight: 500; color: var(--ink-2); margin-right: .3em; }
.display .val { display: inline-flex; }
.display .val span { display: inline-block; }
.display .val span.in { animation: digitIn .14s var(--spring) both; }
@keyframes digitIn { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }
.display .ph { color: var(--ink-2); opacity: .45; font-weight: 500; }
.display .unit { font-size: .5em; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-left: .5em; }
.caret {
  width: 2px; height: 34px; background: var(--stamp);
  align-self: center; margin-left: 3px; height: .85em;
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.words { display: block; min-height: 18px; font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.words.warn { color: var(--arre); }
.shake { animation: shake .3s linear; }
@keyframes shake { 0%, 100% { transform: none; } 12.5%, 62.5% { transform: translateX(-6px); } 37.5%, 87.5% { transform: translateX(6px); } }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.chip {
  height: 40px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  transition: background-color .12s, color .12s;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.key {
  height: clamp(44px, 5.9dvh, 56px);
  border: 0;
  border-radius: 2px;
  background: var(--paper-2);
  box-shadow: 0 3px 0 var(--key-shadow);
  font-size: 25px;
  font-weight: 500;
  display: grid; place-items: center;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background-color .45s var(--ease);
}
.key.down { transform: translateY(3px) scale(.96); box-shadow: 0 0 0 var(--key-shadow); transition-duration: .06s; }
.key svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.key.dim { color: var(--ink-2); }

.cta {
  margin-top: 14px;
  height: 56px;
  width: 100%;
  border: 0;
  border-radius: 2px;
  background: var(--stamp);
  color: var(--on-cta);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: opacity .15s, transform .12s var(--ease), background-color .45s var(--ease);
}
a.cta { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.cta:disabled { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--rule); cursor: default; }
.cta:not(:disabled):active { transform: scale(.985); }
.cta .amt { font-weight: 500; letter-spacing: 0; opacity: .85; text-transform: none; }

/* ---------- Reveal ---------- */
.reveal { display: flex; flex-direction: column; flex: 1; }
.reveal.enter { animation: fadeUp .22s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rv-top { display: flex; justify-content: space-between; align-items: baseline; }
.price {
  height: 58px;
  display: flex; align-items: center;
  font-size: 44px; font-weight: 600; letter-spacing: 0;
  line-height: 1;
  overflow: hidden;
}
.odo { display: inline-flex; align-items: center; height: 1.25em; line-height: 1.25em; overflow: hidden; }
.odo .col { display: inline-block; height: 1.25em; overflow: hidden; }
.odo .strip { display: flex; flex-direction: column; transition: transform var(--dur, .7s) cubic-bezier(.16, .84, .3, 1); }
.odo .strip span { height: 1.25em; line-height: 1.25em; }
.odo .sep { display: inline-block; }
.odo .suf { font-size: .5em; font-weight: 500; color: var(--ink-2); margin-left: .25em; align-self: flex-end; line-height: 1.6; letter-spacing: 0; }

.tape { position: relative; height: 46px; margin-top: 8px; }
.tape-line { position: absolute; left: 0; right: 0; top: 14px; border-top: 1px solid var(--ink); }
.tick { position: absolute; top: 9px; width: 1px; height: 11px; background: var(--ink-2); transform: translateX(-.5px); }
.tick.minor { top: 11px; height: 7px; background: var(--rule); }
.tick-l { position: absolute; top: 25px; font-size: 9.5px; color: var(--ink-2); transform: translateX(-50%); letter-spacing: .04em; white-space: nowrap; }
.tick-l.edge-l { transform: none; }
.tick-l.edge-r { transform: translateX(-100%); }
.notch { position: absolute; top: 4px; width: 3px; height: 21px; background: var(--stamp); transform: translateX(-1.5px); }
.marker {
  position: absolute; top: 0; left: 50%;
  width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 9px solid var(--ink);
  transform: translateX(-6px);
  opacity: 0;
  transition: left .42s var(--ease), opacity .12s;
}
.rv-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 12px; gap: 12px; }
.gap-l { font-size: 15px; font-weight: 600; }
.gap-l small { display: block; font-size: 10.5px; font-weight: 400; color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }
.gap-l .sub { display: inline-block; margin-left: 6px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--arre); border: 1px solid var(--arre); padding: 0 4px; transform: rotate(-2deg); }
.score { text-align: right; }
.score .pts { font-size: 38px; font-weight: 600; line-height: 1; letter-spacing: 0; }
.score .pts small { font-size: 13px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.bandw { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: .04em; color: var(--ink); margin-top: 3px; }
.bandw i { width: 9px; height: 9px; display: block; }
.bandw i[data-b="0"] { background: var(--sahi); } .bandw i[data-b="1"] { background: var(--haldi); }
.bandw i[data-b="2"] { background: var(--door); } .bandw i[data-b="3"] { background: var(--arre); }
.pakka {
  display: inline-block; margin-right: 8px; vertical-align: middle;
  text-transform: uppercase;
  -webkit-mask-image: var(--ink-mask); mask-image: var(--ink-mask);
  font-family: var(--serif); font-weight: 650; font-size: 11px; letter-spacing: .1em;
  color: var(--stamp); border: 1.5px solid var(--stamp); padding: 1px 6px;
  transform: rotate(-6deg);
  animation: pakkaIn .5s var(--ease) both;
}
.fine { margin-top: 12px; font-size: 11px; color: var(--ink-2); line-height: 1.5; }
.fine p { margin: 0; }
.fine .fact { color: var(--ink); font-size: 12px; margin-bottom: 3px; }
.fine button { background: none; border: 0; padding: 12px 0; margin: -12px 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; font-size: 11px; }
.reveal .fine { margin-top: auto; padding: 14px 0 14px; }
.reveal .cta { margin-top: 0; }

/* ---------- Result ---------- */
.result { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 0 0; display: flex; flex-direction: column; scrollbar-width: none; }
.result::-webkit-scrollbar { display: none; }
.result .slip { padding-top: 20px; }
.bill-head { text-align: center; }
.bill-head .coin { width: 26px; height: 26px; }
.bill-shop:focus { outline: none; }
.bill-shop { font-family: var(--serif); font-weight: 650; font-size: 20px; letter-spacing: .14em; margin: 0; font-variation-settings: "opsz" 144, "SOFT" 50; }
.bill-sub { margin-top: 2px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) auto; font-size: 10.5px; letter-spacing: .08em; color: var(--ink-2); text-transform: uppercase; }
.rl { padding: 7px 0; }
.rl + .rl { border-top: 1px dotted var(--rule); }
.rl-1 { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px; font-size: 12.5px; font-weight: 600; align-items: baseline; }
.rl-1 .n { color: var(--ink-2); font-weight: 400; }
.rl-1 .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-1 .s { display: inline-flex; align-items: center; gap: 6px; }
.rl-1 .s i { width: 8px; height: 8px; display: block; }
.rl-2 { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 4px; white-space: nowrap; font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.rl-2 span b { color: var(--ink); font-weight: 500; }
.total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.tv { text-align: right; }
.tv .k { font-size: 11px; letter-spacing: .14em; color: var(--ink-2); }
.tv .v { font-size: 48px; font-weight: 600; letter-spacing: 0; line-height: 1.05; }
.tv .v small { font-size: 16px; color: var(--ink-2); font-weight: 500; letter-spacing: 0; }
.stamp {
  font-family: var(--serif); font-weight: 650; font-size: 16px; letter-spacing: .08em; line-height: 1.15;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  text-transform: uppercase;
  color: var(--stamp);
  border: 2.5px solid var(--stamp);
  border-radius: 3px;
  padding: 6px 10px 5px;
  max-width: 58%;
  text-align: center;
  transform: rotate(-4deg);
  -webkit-mask-image: var(--ink-mask);
          mask-image: var(--ink-mask);
}
.stamp.go { animation: stampIn .5s var(--ease) .3s both; }
@keyframes stampIn {
  0% { opacity: 0; transform: rotate(-4deg) scale(1.25); }
  55% { opacity: 1; transform: rotate(-4deg) scale(.98); }
  100% { opacity: 1; transform: rotate(-4deg) scale(1); }
}
@keyframes pakkaIn {
  0% { opacity: 0; transform: rotate(-6deg) scale(1.3); }
  60% { opacity: 1; transform: rotate(-6deg) scale(.97); }
  100% { opacity: 1; transform: rotate(-6deg) scale(1); }
}
.fx { opacity: 0; transform: translateY(4px); transition: opacity .22s var(--ease), transform .22s var(--ease); }
.fx.on { opacity: 1; transform: none; }
.meta { text-align: center; line-height: 1.25; }
.meta-1 { color: var(--ink); font-weight: 600; font-size: 11px; letter-spacing: .1em; }
.meta-2 { font-size: 10px; letter-spacing: .06em; }
.blocks-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.blocks { display: flex; gap: 5px; }
.blocks i { width: 20px; height: 20px; display: block; }
.blocks i.go { animation: drop .2s var(--spring) both; }
.dir { font-size: 11.5px; color: var(--ink-2); }
.thanks { text-align: center; margin-top: 14px; }
.barcode {
  height: 18px; margin: 10px auto 0; width: 72%;
  background: repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 3px, var(--ink) 3px 5px, transparent 5px 6px, var(--ink) 6px 7px, transparent 7px 10px, var(--ink) 10px 13px, transparent 13px 14px);
  opacity: .85;
}
.practice-mark { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 44px; font-weight: 600; letter-spacing: .2em; color: var(--ink); opacity: .05; pointer-events: none; }
.result .slip { position: relative; }

.share { margin-top: 22px; }
.bubble {
  position: relative;
  background: var(--paper-2);
  border-radius: 8px 8px 8px 2px;
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  transition: background-color .45s var(--ease);
}
.bubble b { font-weight: 600; }
.share-bar {
  position: sticky; bottom: 0; z-index: 2;
  margin-top: 12px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--paper) 14px);
}
.share-bar .cta { margin-top: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.ghost {
  height: 46px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
}
.ghost:active { transform: scale(.985); }
.next { margin-top: 22px; text-align: center; }
.next .clock { font-size: 26px; font-weight: 600; letter-spacing: .02em; margin-top: 2px; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px; margin-top: 14px; }
.links button { background: none; border: 0; padding: 12px 6px; font-size: 12px; white-space: nowrap; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); }
.tear { animation: tear .26s var(--ease) both; }
@keyframes tear { from { transform: translateY(-12px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 18, 12, .34); z-index: 20; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 440px; margin: 0 auto;
  max-height: 88dvh;
  display: flex; flex-direction: column;
  animation: rise .24s var(--ease) both;
  filter: drop-shadow(0 -1px 2px var(--shadow));
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-inner {
  --z: 5px;
  scrollbar-width: none;
  background: var(--slip);
  overflow-y: auto;
  padding: calc(18px + var(--z)) 20px calc(22px + env(safe-area-inset-bottom));
  -webkit-mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--z)) 100%;
          mask: conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--z)) 100%;
}
.sheet h2 { font-family: var(--serif); font-weight: 650; font-size: 24px; margin: 0; letter-spacing: 0; font-variation-settings: "opsz" 144, "SOFT" 50; }
.sheet h3 { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); font-weight: 500; margin: 20px 0 8px; }
.sheet p { margin: 8px 0 0; font-size: 13px; line-height: 1.55; }
.sheet .muted { color: var(--ink-2); font-size: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.close { width: 44px; height: 44px; margin-right: -10px; background: none; border: 0; display: grid; place-items: center; }
.close svg { width: 20px; height: 20px; stroke: var(--ink); stroke-width: 1.5; fill: none; stroke-linecap: round; }
.ex { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; font-size: 12.5px; padding: 6px 0; border-top: 1px dotted var(--rule); }
.ex:first-of-type { border-top: 0; }
.ex .pts { font-weight: 600; width: 3ch; text-align: right; }
.ex i, .bt i { width: 10px; height: 10px; display: block; }
.bt { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; padding: 5px 0; }
.bt span:last-child { color: var(--ink-2); }
[data-b="0"].sw { background: var(--sahi); } [data-b="1"].sw { background: var(--haldi); }
[data-b="2"].sw { background: var(--door); } [data-b="3"].sw { background: var(--arre); }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--paper-2); padding: 10px 10px 9px; border-radius: 2px; }
.stat b { display: block; font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: 0; }
.stat b.cu { color: var(--copper-text); }
.stat span { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-2); }
.chutti { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.chutti svg { width: 16px; height: 16px; }
.hist { display: grid; gap: 6px; }
.hrow { display: grid; grid-template-columns: 150px 1fr 24px; gap: 8px; align-items: center; font-size: 11px; }
.hrow .bar { height: 10px; background: var(--ink); min-width: 2px; transition: width .4s var(--ease); }
.hrow .bar.zero { background: var(--rule); }
.hrow span:last-child { text-align: right; color: var(--ink-2); }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px dotted var(--rule); font-size: 13px; }
.toggle:first-of-type { border-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; }
.seg button { background: none; border: 0; height: 36px; padding: 0 10px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 40;
  transform: translate(-50%, 16px);
  background: var(--ink); color: var(--paper);
  font-size: 12.5px; padding: 10px 14px; border-radius: 2px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .22s var(--ease);
  white-space: nowrap;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Short screens ---------- */
@media (max-height: 700px) {
  .top { height: 46px; }
  .pic { width: 52px; height: 52px; }
  .pic svg { width: 32px; height: 32px; }
  .card { grid-template-columns: 52px minmax(0, 1fr); gap: 12px; }
  .item-name { font-size: 16.5px; }
  .display { height: 46px; line-height: 46px; font-size: 34px; }
  .chips { margin-top: 6px; }
  .keys { gap: 6px; margin-top: 8px; }
  .cta { height: 50px; margin-top: 10px; }
  .play { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .1s !important; animation-delay: 0s !important; transition-duration: .1s !important; }
  .caret { animation: none; }
}
:root[data-motion="fast"] *, :root[data-motion="fast"] *::before { animation-duration: .1s !important; animation-delay: 0s !important; transition-duration: .1s !important; }

.rl-2 .g { color: var(--ink); }
.rl-2 span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }

.sheet-inner::-webkit-scrollbar { display: none; }
.result > .slip-wrap, .result > .share { flex: none; }
.next { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.pakka.sm { font-size: 9px; padding: 0 4px; margin-right: 6px; }
:root[data-theme="dark"] .pic, .night .pic { background: var(--paper); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pic { background: var(--paper); } }

/* stats sheet */
.hero { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--rule); }
.hero b { font-size: 56px; line-height: .95; font-weight: 600; color: var(--copper-text); }
.hero .unit { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin-left: 8px; }
.hero .coins { display: flex; gap: 6px; align-items: center; }
.hero .coins svg { width: 18px; height: 18px; }
.srows { list-style: none; margin: 8px 0 0; padding: 0; }
.srows .ln { opacity: 1; font-size: 13px; padding: 5px 0; grid-template-columns: minmax(0, 1fr) auto; }

/* very short screens (320x568 and friends) */
@media (max-height: 600px) {
  .top { height: 40px; }
  .lines .pending:not(.cur), .theme-line { display: none; }
  .pic { width: 44px; height: 44px; }
  .pic svg { width: 28px; height: 28px; }
  .card { grid-template-columns: 44px minmax(0, 1fr); padding-top: 6px; gap: 10px; }
  .item-name { font-size: 15px; }
  .sticker { margin-top: 6px; }
  .display { height: 40px; line-height: 40px; }
  .words { min-height: 16px; }
  .chips { margin-top: 4px; }
  .keys { gap: 6px; margin-top: 6px; }
  .cta { height: 46px; margin-top: 8px; }
  .price { height: 46px; font-size: 36px; }
  .play { gap: 8px; }
}

/* ---------- v2 additions ---------- */
html { touch-action: manipulation; overscroll-behavior-y: none; }
.key { touch-action: none; }
.key, .chip, .cta, .icon-btn, .seg button, .ghost, .links button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:root[data-motion="fast"] .caret { animation: none; }
/* Only show lines already played; upcoming items stay hidden until their turn */
.lines .pending:not(.guessed) { display: none; }
.lines:not(:has(> li:not(.pending), > li.guessed)) { display: none; }
.bill-head .coin { fill: var(--ink); display: block; margin: 0 auto 6px; }

.boot { margin: auto; padding: 48px 24px; text-align: center; max-width: 34ch; display: grid; gap: 12px; justify-items: center; }
.boot-h { font-family: var(--serif); font-weight: 650; font-size: 26px; margin: 0; outline: none; }
.boot p { margin: 0; color: var(--ink-2); }
.boot .cta { margin-top: 8px; width: auto; padding: 0 22px; }

.archive { list-style: none; margin: 8px 0 0; padding: 0; display: grid; }
.arc { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 1px dashed var(--rule); cursor: pointer; font-family: var(--mono); color: var(--ink); }
.arc:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
.arc-n { color: var(--ink-2); font-size: 13px; }
.arc-t { display: grid; gap: 2px; min-width: 0; }
.arc-t b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arc-t small { color: var(--ink-2); font-size: 12px; }
.arc-s { font-weight: 600; font-size: 14px; }
/* With upcoming lines hidden, the receipt hugs its content and the keypad stays at the bottom */
.play .slip-wrap { flex: 0 1 auto; }
.play .card { margin-top: 14px; }
.play > .panel { margin-top: auto; }

/* ---------- Results: crowd stats panel (charts come from charts.js / charts.css) ---------- */
.stats-panel {
  margin-top: 22px;
  padding: 16px 16px 14px;
  display: grid; gap: 20px;
  background: var(--slip);
  border-radius: 2px;
  box-shadow: 0 1px 2px var(--shadow);
  transition: background-color .45s var(--ease);
}
.sp-head { display: flex; align-items: baseline; gap: 10px; }
.sp-h { flex: 1; margin: 0; font-family: var(--serif); font-weight: 650; font-size: 19px; line-height: 1.1; font-variation-settings: "opsz" 144, "SOFT" 50; }
.sp-tag { flex: none; align-self: center; font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 2px; padding: 2px 5px; }
.sp-t { margin: 0 0 8px; font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.sp-items { display: grid; gap: 12px; }
.sp-items .sp-t { margin-bottom: -4px; }
.sp-board-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sp-board-h .sp-t { margin: 0; }
.sp-tabs { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; }
.sp-tabs button { background: none; border: 0; height: 32px; padding: 0 10px; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; -webkit-user-select: none; user-select: none; }
.sp-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.sp-list { min-height: 40px; }
.sp-load { display: grid; gap: 12px; padding: 4px 0 6px; }
@media (hover: hover) and (pointer: fine) {
  .sp-tabs button { transition: background-color .15s var(--ease), color .15s var(--ease); }
  .sp-tabs button:not([aria-selected="true"]):hover { background: var(--paper-2); }
}
@media (min-width: 900px) {
  .stats-panel { padding: 20px 22px 18px; gap: 22px; }
  .sp-h { font-size: 21px; }
}
