/* 로또 환생 계산기
   Layout: a lottery slip you mark with a marker, then a thermal receipt that prints the result.
   Paper objects stay paper-colored in both themes; the counter around them follows the theme. */
:root {
  --slip: #d8435d;          /* red-pink print of the paper slip */
  --ink: #17191c;           /* marker / receipt print */
  --paper: #fbfbf8;
  --paper-line: #c9c9c2;
  --y: #f2b705; --b: #3fa7dc; --r: #e8555a; --g: #8d9196; --gr: #79b33a;  /* broadcast ball colors */
  /* light theme: a sunny lotto-yellow counter instead of grey */
  --bg: #f4cf47; --muted: #5a4a14; --line: rgba(23, 25, 28, 0.2);
}

.ball {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  font-family: var(--body); font-weight: 600; font-size: 16px; color: #fff;
  background: var(--c, #555);
  box-shadow: inset -3px -4px 0 rgba(0, 0, 0, 0.14);
}
.ball.c1 { --c: var(--y); } .ball.c2 { --c: var(--b); } .ball.c3 { --c: var(--r); } .ball.c4 { --c: var(--g); } .ball.c5 { --c: var(--gr); }

.actions { display: grid; gap: 10px; margin-top: 22px; }

/* ---------- intro ---------- */
.slip-head {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 10px; margin-top: 8px;
  background: var(--slip); color: #fff;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
}
.intro-title { font-size: clamp(32px, 9.6vw, 44px); margin-top: 22px; }
.intro-title em { font-style: normal; color: var(--slip); }

/* ---------- slip (pick) ---------- */
.slip { background: var(--paper); color: var(--ink); margin: 8px 0 14px; padding-bottom: 12px; box-shadow: 0 1px 0 var(--paper-line), 0 10px 24px rgba(0, 0, 0, 0.12); }
.slip .slip-head { margin-top: 0; }
.slip-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 12px 12px 0; }
.slip-tabs button {
  position: relative; height: 40px; border: 1.5px solid var(--slip); background: transparent; color: var(--slip);
  font-family: var(--display); font-size: 18px; cursor: pointer; border-radius: 2px;
}
.slip-tabs button[aria-selected="true"] { background: var(--slip); color: #fff; }
.slip-tabs button .st { position: absolute; right: 3px; top: 1px; font-family: var(--body); font-size: 10px; font-weight: 600; }
.slip-tabs button:focus-visible, .slip-grid button:focus-visible, .check:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.slip-body { display: grid; grid-template-columns: 1fr 58px; gap: 10px; padding: 12px 12px 0; }
.slip-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px 4px; }
.slip-grid button {
  aspect-ratio: 3 / 4; max-width: 100%; padding: 0; cursor: pointer;
  border: 1.2px solid var(--slip); border-radius: 3px; background: transparent;
  color: var(--slip); font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.slip-grid button.is-on {
  /* a hand-drawn marker fill */
  background: var(--ink); color: var(--paper); border-color: var(--ink);
  border-radius: 40% 46% 42% 48% / 46% 40% 48% 42%;
}
.slip-grid.is-auto button:not(.is-auto-on) { opacity: 0.45; }
.slip-grid button.is-auto-on { background: var(--slip); border-color: var(--slip); color: #fff; border-radius: 40% 46% 42% 48% / 46% 40% 48% 42%; }
.slip-side { display: flex; flex-direction: column; gap: 8px; }
.check {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0;
  background: none; border: 0; color: var(--slip); font-size: 12px; font-weight: 600; cursor: pointer;
}
.check .box { width: 26px; height: 32px; border: 1.2px solid var(--slip); border-radius: 3px; }
.check[aria-pressed="true"] .box { background: var(--ink); border-color: var(--ink); border-radius: 40% 46% 42% 48% / 46% 40% 48% 42%; }
.slip-note { margin: 12px 12px 0; font-size: 13px; color: var(--slip); font-weight: 600; }
.run-btn { margin-top: 16px; }

/* ---------- run ---------- */
.run-head { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.era {
  display: inline-block; padding: 4px 10px; border: 2px solid var(--slip); color: var(--slip);
  font-family: var(--display); font-size: 15px; transform: rotate(-2deg);
}
.skip { background: none; border: 0; color: var(--muted); font-size: 14px; text-decoration: underline; cursor: pointer; padding: 8px 0; }
.counter { display: grid; gap: 2px; margin-top: 20px; padding: 18px 16px 16px; background: var(--paper); color: var(--ink); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12); }
.counter-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: #6b6f75; }
.counter-num { font-family: var(--mono); font-weight: 600; font-size: clamp(38px, 12vw, 56px); line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter-sub { font-weight: 600; font-size: 17px; }
.run-draw { display: flex; gap: 6px; margin-top: 18px; min-height: 40px; flex-wrap: wrap; }
.run-draw .plus { align-self: center; color: var(--muted); font-weight: 700; }
.tiers { width: 100%; margin-top: 18px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tiers th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 0 0 4px; }
.tiers td { font-family: var(--mono); font-size: 20px; font-weight: 600; padding: 6px 0; border-top: 1.5px solid var(--fg); }
.run-spent { margin-top: 12px; color: var(--muted); }
.run-spent b { color: var(--fg); font-family: var(--mono); }
.jackpot .counter-num { color: var(--slip); }

/* ---------- result ---------- */
.detail { margin-top: 26px; padding: 16px; background: var(--paper); color: var(--ink); font-size: 14px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12); }
.detail h3 { margin: 0 0 10px; font-family: var(--display); font-weight: 400; font-size: 20px; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; padding-top: 10px; border-top: 1px dashed #8b8f95; }
.detail dt { color: #5d6268; }
.detail dd { margin: 0; text-align: right; font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 0; }
.detail p { color: #5d6268; margin: 14px 0 0; padding-top: 10px; border-top: 1px dashed #8b8f95; }

@media (max-width: 360px) {
  .ball { width: 34px; height: 34px; font-size: 14px; }
  .slip-body { grid-template-columns: 1fr 48px; }
}
.slip-note { display: grid; gap: 2px; font-family: var(--mono); font-size: 12.5px; color: #5d6268; white-space: pre; overflow-x: auto; }
.slip-note .on { color: var(--slip); }
.counter-odds { font-family: var(--mono); font-size: 13px; color: #6b6f75; margin-top: 4px; }
.friend-bar { display: grid; gap: 10px; padding: 6px 0 14px; }
.friend-bar p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- color pass (11-08: Robin wanted more color than black & white) ---------- */
.k-btn:not(.is-ghost) { background: var(--slip); color: #fff; box-shadow: 0 3px 0 #9e2a3f; }
.k-btn:not(.is-ghost):active { box-shadow: none; }
.k-top .k-brand { color: var(--fg); }
.intro-title em { color: var(--slip); background: linear-gradient(transparent 62%, rgba(255, 255, 255, 0.55) 62%); }
.era { background: var(--slip); color: #fff; border-color: var(--slip); }
.counter-quip { font-weight: 600; font-size: 15px; color: var(--slip); min-height: 1.5em; }
.ball.blank { --c: #c9c9c2; color: #fff; }
.tiers th:nth-child(1) { color: var(--r); } .tiers th:nth-child(2) { color: var(--b); }
.tiers th:nth-child(3) { color: var(--gr); } .tiers th:nth-child(4) { color: var(--fg); }
.tiers td:nth-child(1) { border-top-color: var(--r); } .tiers td:nth-child(2) { border-top-color: var(--b); }
.tiers td:nth-child(3) { border-top-color: var(--gr); } .tiers td:nth-child(4) { border-top-color: var(--slip); }
.tiers td { border-top-width: 4px; }
.detail .roast { margin: -4px 0 12px; padding: 0; border: 0; color: var(--slip); font-weight: 600; font-size: 15px; }

/* ---------- result: one object per item (11-08 v2) ---------- */
.detail { background: none; box-shadow: none; padding: 0; color: var(--fg); display: grid; gap: 16px; }
.detail .tile p, .detail .fine { border-top: 0; padding-top: 0; }
.tile { position: relative; overflow: hidden; padding: 18px; background: var(--paper); color: var(--ink); }
.t-k { display: block; font-size: 12.5px; font-weight: 600; color: #6b6f75; }
.t-big { margin: 2px 0 0; font-family: var(--display); font-size: 42px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.t-big span { font-size: 22px; margin-left: 4px; }
.t-big b { font-weight: 400; }
.detail .t-cap { margin: 10px 0 0; font-size: 14px; color: #4d5157; }
.t-cap b { color: inherit; }
.fine { margin: 0; font-size: 12.5px; color: var(--muted); }

/* verdict: a sticker with a speech bubble */
.t-type { background: #fff; transform: rotate(-0.8deg); margin: 4px 6px 4px 0; border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); }
.t-type h3 { margin: 2px 0 0; font-family: var(--display); font-weight: 400; font-size: 32px; line-height: 1.2; color: var(--slip); }
.bubble { position: relative; display: inline-block; margin: 12px 0 0; padding: 8px 12px; background: var(--y); color: var(--ink); font-weight: 700; border-radius: 14px; }
.bubble::before { content: ""; position: absolute; left: 16px; top: -10px; width: 16px; height: 11px; background: var(--y); clip-path: polygon(0 100%, 30% 0, 100% 100%); }
.t-type { overflow: visible; }

/* graveyard at night */
.t-grave { background: linear-gradient(#232a43, #39446a 78%, #4a6b3a 78%); color: #f2f0e6; padding-bottom: 14px; }
.t-grave .t-k { color: #aab3d4; }
.t-grave .t-cap { color: #e2e5f0 !important; }
.t-grave .moon { position: absolute; right: 22px; top: 18px; width: 38px; height: 38px; border-radius: 50%; background: #fff5c2; box-shadow: -9px 0 0 0 #232a43 inset, 0 0 24px rgba(255, 245, 194, .45); }
.yard { display: flex; flex-wrap: wrap; gap: calc(var(--s) * .25) calc(var(--s) * .3); margin-top: 12px; padding: 10px 0 8px; border-bottom: 6px solid #4a6b3a; }
/* a Korean grave: a grass mound (봉분) with a small stone in front */
.yard i { position: relative; width: var(--s); height: calc(var(--s) * .9); }
.yard i::before {             /* the grass mound behind */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 52%;
  border-radius: 50% 50% 6% 6% / 100% 100% 6% 6%;
  background: radial-gradient(ellipse at 40% 25%, #a9cf7d 0 18%, #7aa452 48%, #557d3b 100%);
}
.yard i::after {              /* the gravestone standing in front of it, taller than the mound */
  content: ""; position: absolute; left: 50%; bottom: 0; width: 30%; height: 92%; margin-left: -15%;
  background: linear-gradient(90deg, #eceef2 0 70%, #b9bdc6 70%); border-radius: 40% 40% 2px 2px / 22% 22% 2px 2px;
  box-shadow: 0 0 0 1px rgba(20, 24, 40, .35);
}
/* this life: a person still standing, holding a lotto slip */
.yard .me { position: relative; width: var(--s); height: calc(var(--s) * .9); }
.yard .me::before { content: ""; position: absolute; left: 50%; top: -8%; width: 30%; aspect-ratio: 1; margin-left: -15%; border-radius: 50%; background: #ffd9b3; box-shadow: 0 -2px 0 0 #2b2b2b; }
.yard .me::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 44%; height: 66%; margin-left: -22%; border-radius: 40% 40% 4px 4px; background: var(--slip);
  box-shadow: calc(var(--s) * .3) calc(var(--s) * -.12) 0 calc(var(--s) * -.12) #fff; }

/* tear-off calendar (일력) */
.t-cal { background: none; padding: 0; overflow: visible; }
.t-cal .rings { position: relative; z-index: 2; display: flex; justify-content: space-around; height: 26px; background: var(--slip); border-radius: 6px 6px 0 0; padding: 0 30px; }
.t-cal .rings i { width: 10px; height: 22px; margin-top: -10px; border-radius: 5px; background: #8d9196; box-shadow: inset -2px 0 0 rgba(0,0,0,.25); }
.t-cal .sheets { position: absolute; left: 0; right: 0; top: 26px; height: 80px; z-index: 3; pointer-events: none; }
.t-cal .sheets i { position: absolute; inset: 0; background: #fbfbf8; transform-origin: 50% 0; opacity: 0; border-bottom: 1px solid #ddd; }
.t-cal .page { position: relative; padding: 16px 18px 18px; background: var(--paper); text-align: left; box-shadow: 0 4px 0 #e2e0d8, 0 8px 0 #cfcdc4; }
.cal-year { margin: 2px 0 0; font-family: var(--display); font-size: 36px; line-height: 1.2; }
.cal-year b { font-weight: 400; }
.cal-gj { display: flex; align-items: center; gap: 12px; margin: 10px 0 0; padding: 10px 12px; background: #fff4c7; border-radius: 10px; }
.cal-gj .emo { font-size: 46px; line-height: 1; }
.cal-gj b { display: block; font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.1; color: var(--slip); }
.cal-gj small { font-size: 15px; font-weight: 700; }

/* bankbook */
.t-bank { background: repeating-linear-gradient(#eef6ea 0 31px, #d3e4cc 31px 32px); border: 1px solid #c2d7b9; }
.t-bank .t-k { color: #4f7a43; }
.t-bank table { width: 100%; margin-top: 10px; border-collapse: collapse; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.t-bank th { text-align: left; font-family: var(--body); font-size: 11.5px; color: #4f7a43; font-weight: 600; padding: 4px 0; border-bottom: 2px solid #4f7a43; }
.t-bank td { padding: 7px 0; vertical-align: top; }
.t-bank td:nth-child(n+2), .t-bank th:nth-child(n+2) { text-align: right; }
.t-bank .out { color: var(--r); font-weight: 600; } .t-bank .in { color: #2b7bb9; font-weight: 600; }
.t-bank .sum td { border-top: 2px solid #4f7a43; font-family: var(--display); font-size: 22px; padding-top: 10px; }
.bank-stamp { position: absolute; right: 18px; top: 12px; padding: 2px 10px; border: 3px solid currentColor; border-radius: 6px; font-family: var(--display); font-size: 22px; transform: rotate(12deg); }
.bank-stamp.loss { color: var(--r); } .bank-stamp.gain { color: #2b7bb9; }

/* chicken heap */
.t-chicken { background: #ffe7c2; }
.t-chicken .t-k { color: #9a5a17; }
.heap { position: relative; height: 178px; margin-top: 4px; overflow: hidden; }
.heap i, .heap .roll { position: absolute; left: 50%; bottom: 4px; width: 26px; height: 34px; margin-left: -13px; transform: translate(var(--x), calc(-1 * var(--y))) rotate(var(--r)); }
.heap i::before, .heap .roll::before { content: ""; position: absolute; left: 1px; top: 0; width: 24px; height: 22px; border-radius: 50% 50% 46% 46%; background: #d98c3a; box-shadow: inset -4px -3px 0 rgba(0,0,0,.14), inset 3px 3px 0 rgba(255,255,255,.25); }
.heap i::after, .heap .roll::after { content: ""; position: absolute; left: 10px; top: 19px; width: 6px; height: 14px; border-radius: 3px; background: #f6ecdc; box-shadow: 0 0 0 1px #d8c9ae; }
.heap::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: #c98a3d; border-radius: 3px; }
.heap .roll { opacity: 0; transform: translate(0, -150px); }

/* prize stickers */
.t-tiers { background: #fff; }
.stickers { list-style: none; margin: 14px 0 4px; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.stickers li { display: grid; justify-items: center; align-content: center; aspect-ratio: 1; border-radius: 50%; color: #fff; min-width: 0; box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.stickers li:nth-child(odd) { transform: rotate(-7deg); } .stickers li:nth-child(even) { transform: rotate(6deg) translateY(4px); }
.stickers em { font-style: normal; font-family: var(--display); font-size: 13px; line-height: 1; }
.stickers b { font-family: var(--mono); font-size: 13px; font-weight: 700; line-height: 1.3; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
.stickers small { font-size: 10px; line-height: 1; opacity: .85; }
.stickers .r1 { background: var(--slip); } .stickers .r2 { background: #e0a400; } .stickers .r3 { background: var(--b); }
.stickers .r4 { background: var(--gr); } .stickers .r5 { background: var(--g); }

/* the queue of 100 */
.t-queue { background: #efe9ff; }
.t-queue .t-k { color: #5b45a8; }
.queue { display: grid; grid-template-columns: repeat(20, 1fr); gap: 7px 3px; margin-top: 14px; }
.queue i { position: relative; height: 16px; }
.queue i::before { content: ""; position: absolute; left: 50%; top: 0; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--pc, #b9b3cf); }
.queue i::after { content: ""; position: absolute; left: 50%; top: 7px; width: 10px; height: 9px; margin-left: -5px; border-radius: 5px 5px 1px 1px; background: var(--pc, #b9b3cf); }
.queue i.done { --pc: #8f7bd6; }
.queue i.me { --pc: var(--slip); z-index: 1; }
.queue i.me { transform: scale(1.7); }

/* the winning slip */
.t-games { background: #fff; border-top: 8px solid var(--slip); }
.winrow { display: flex; gap: 4px; align-items: center; margin-top: 10px; }
.winrow .plus { color: #6b6f75; font-weight: 700; }
.winrow .ball { width: 34px; height: 34px; font-size: 14px; }
.games { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.games li { display: grid; grid-template-columns: 38px 1fr 30px; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; }
.games li.win { background: #ffe680; }
.games .g { font-family: var(--display); font-size: 17px; line-height: 1; display: grid; }
.games .g small { font-family: var(--body); font-size: 10px; color: #6b6f75; }
.games .bs { display: flex; gap: 3px; min-width: 0; }
.games .ball { width: 30px; height: 30px; font-size: 13px; }
.games .r { font-weight: 700; font-size: 13px; color: var(--slip); text-align: right; }
.ball.dim { background: color-mix(in srgb, var(--c) 22%, #fff); color: var(--ink); box-shadow: none; }

/* ---------- intro machine ---------- */
.machine-wrap { display: grid; justify-items: center; margin: 14px 0 0; }
.machine { width: 330px; max-width: 100%; height: auto; aspect-ratio: 330 / 352; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .tile { opacity: 0; translate: 0 22px; transition: opacity .45s ease-out, translate .5s cubic-bezier(.2,1.3,.4,1); }
  .tile.in { opacity: 1; translate: 0 0; }

  .t-type.in h3 { animation: stampin .5s .15s cubic-bezier(.2,1.4,.4,1) both; }
  @keyframes stampin { from { transform: scale(1.9) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
  .t-type.in .bubble { animation: popin .4s .6s cubic-bezier(.2,1.6,.4,1) both; transform-origin: 20px 0; }
  @keyframes popin { from { transform: scale(0); } }

  /* gravestones rise out of the ground */
  .yard i { transform: translateY(140%); opacity: 0; transition: transform .45s cubic-bezier(.2,1.5,.4,1), opacity .2s; transition-delay: calc(var(--i) * 6ms + .2s); }
  .t-grave.in .yard i { transform: none; opacity: 1; }
  .yard .me { opacity: 0; transition: opacity .3s; transition-delay: calc(var(--i) * 6ms + .4s); }
  .t-grave.in .yard .me { opacity: 1; animation: wobble .6s 2.2s ease-in-out 3; }
  @keyframes wobble { 25% { rotate: -8deg; } 75% { rotate: 8deg; } }

  /* calendar sheets get torn off */
  .t-cal.in .sheets i { animation: tear .7s cubic-bezier(.5,0,.8,.6) both; }
  .t-cal.in .sheets i:nth-child(2) { animation-delay: .25s; } .t-cal.in .sheets i:nth-child(3) { animation-delay: .5s; }
  @keyframes tear { 0% { opacity: 1; transform: none; } 30% { opacity: 1; transform: rotateX(-30deg) rotate(-4deg); } 100% { opacity: 0; transform: translate(60px, 160px) rotate(28deg); } }
  .t-cal.in .emo { animation: hop .6s 1s cubic-bezier(.3,1.6,.5,1) 2 both; display: inline-block; }
  @keyframes hop { 40% { transform: translateY(-14px) rotate(-8deg); } }

  /* bankbook: the stamp lands last */
  .t-bank .bank-stamp { opacity: 0; }
  .t-bank.in .bank-stamp { animation: thud .35s .9s cubic-bezier(.2,1.4,.4,1) both; }
  @keyframes thud { from { opacity: 0; transform: rotate(12deg) scale(2.4); } to { opacity: 1; transform: rotate(12deg); } }
  .t-bank tr { opacity: 0; transition: opacity .3s; }
  .t-bank.in tr { opacity: 1; } .t-bank.in tr:nth-child(2) { transition-delay: .15s; } .t-bank.in tr:nth-child(3) { transition-delay: .35s; } .t-bank.in tr:nth-child(4) { transition-delay: .6s; }

  /* chicken heap: legs drop onto the pile, then a few keep tumbling off the top */
  .heap i { opacity: 0; transform: translate(var(--x), -200px) rotate(0deg); transition: transform .5s cubic-bezier(.3,1.35,.5,1), opacity .1s; transition-delay: calc(var(--k) * 35ms); }
  .t-chicken.in .heap i { opacity: 1; transform: translate(var(--x), calc(-1 * var(--y))) rotate(var(--r)); }
  .t-chicken.in .heap .roll { animation: slideL 2.4s 1.6s cubic-bezier(.45,0,.7,1) infinite; }
  .t-chicken.in .heap .roll.r { animation-name: slideR; animation-delay: 2.4s; }
  .t-chicken.in .heap .roll.l2 { animation-delay: 3.3s; animation-duration: 2.8s; }
  @keyframes slideL { 0% { opacity: 0; transform: translate(0, -170px) rotate(0); } 10% { opacity: 1; transform: translate(0, -158px) rotate(0); }
    80% { opacity: 1; transform: translate(-128px, -6px) rotate(-540deg); } 100% { opacity: 0; transform: translate(-150px, -6px) rotate(-600deg); } }
  @keyframes slideR { 0% { opacity: 0; transform: translate(0, -170px) rotate(0); } 10% { opacity: 1; transform: translate(0, -158px) rotate(0); }
    80% { opacity: 1; transform: translate(128px, -6px) rotate(540deg); } 100% { opacity: 0; transform: translate(150px, -6px) rotate(600deg); } }

  /* stickers slap on */
  .stickers li { scale: 0; transition: scale .4s cubic-bezier(.2,1.7,.4,1); }
  .t-tiers.in .stickers li { scale: 1; }
  .stickers li:nth-child(2) { transition-delay: .1s; } .stickers li:nth-child(3) { transition-delay: .2s; }
  .stickers li:nth-child(4) { transition-delay: .3s; } .stickers li:nth-child(5) { transition-delay: .4s; }

  /* the queue walks in, I jump */
  .queue i { opacity: 0; translate: -30px 0; transition: opacity .3s, translate .4s ease-out; transition-delay: calc(var(--i) * 10ms); }
  .t-queue.in .queue i { opacity: 1; translate: 0 0; }
  .t-queue.in .queue i.me { animation: jump .5s 1.4s ease-out 4; }
  @keyframes jump { 50% { translate: 0 -8px; } }

  /* receipt comes out of a printer slot */
  .k-result-img.printing { animation: print 1.5s steps(14, end) both, settle .35s 1.5s ease-out; }
  @keyframes print { from { clip-path: inset(0 0 100% 0); transform: translateY(-14px); } to { clip-path: inset(0); transform: none; } }
  @keyframes settle { 40% { transform: rotate(-1.2deg) translateY(3px); } }

  /* run */
  .run-draw .ball.pop { animation: pop .16s ease-out; }
  @keyframes pop { from { transform: scale(.6) translateY(-6px); } }
  .counter-quip.bump { animation: bump .4s cubic-bezier(.2,1.6,.4,1); }
  @keyframes bump { from { transform: translateX(-8px); opacity: 0; } }
  .run-draw .ball.drop { animation: drop .6s var(--d, 0ms) cubic-bezier(.3,1.5,.5,1) both; }
  @keyframes drop { from { transform: translateY(-80px) scale(.6); opacity: 0; } }
  .jackpot .counter { animation: shake .5s ease-in-out; }
  @keyframes shake { 20% { transform: translateX(-8px) rotate(-1deg); } 40% { transform: translateX(7px) rotate(1deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
  .jackpot::after { content: ""; position: fixed; inset: 0; background: #fff; pointer-events: none; animation: flash .7s ease-out forwards; z-index: 20; }
  @keyframes flash { from { opacity: .85; } to { opacity: 0; } }

  /* pick */
  .slip-grid button.mark { animation: mark .28s cubic-bezier(.2,1.6,.4,1); }
  @keyframes mark { from { transform: scale(1.35) rotate(-8deg); } }

  /* intro CTA shine */
  [data-screen="intro"] .k-btn:not(.is-ghost) { position: relative; overflow: hidden; }
  [data-screen="intro"] .k-btn:not(.is-ghost)::after { content: ""; position: absolute; inset: 0 auto 0 -40%; width: 30%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent); animation: shine 3.2s 1s ease-in-out infinite; }
  @keyframes shine { 0%, 60% { left: -40%; } 100% { left: 120%; } }
}
.t-grave .t-big, .t-grave .t-big b { color: #fff5c2; }
.bank-stamp { top: auto; bottom: 12px; right: 16px; font-size: 19px; }
.t-bank .t-cap { padding-right: 70px; }

/* 5th round: the bill after the jackpot, choice memo, grave sign, friend comparison */
.run-net { display: grid; justify-items: center; gap: 2px; margin: 4px auto 0; padding: 12px 18px; max-width: 340px; background: #fbfbf8; color: var(--ink); border-radius: 12px; box-shadow: 0 4px 0 rgba(0,0,0,.18); transform: rotate(-1.5deg); }
.run-net .net-k { font-family: var(--mono); font-size: 13px; color: #6b6f75; }
.run-net b { font-family: "Black Han Sans", var(--sans, sans-serif); font-weight: 400; font-size: clamp(26px, 8vw, 38px); line-height: 1.1; }
.run-net b.loss { color: var(--slip); }
.run-net b.gain { color: #1f7fc0; }
.run-net small { font-weight: 600; font-size: 14px; text-align: center; }
.memo { margin: 12px 0 0; padding: 8px 10px; border: 2px dashed currentColor; border-radius: 8px; font-size: 14px; font-weight: 600; opacity: .9; }
.memo span { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; opacity: .7; }
.yard { position: relative; }
.yard .sign { position: absolute; right: 6px; bottom: 4px; padding: 3px 8px 4px; background: #b98a53; color: #2b1a08; font-size: 12px; font-weight: 700; border-radius: 3px; transform: rotate(4deg); box-shadow: 0 2px 0 #7a5530; z-index: 2; }
.yard .sign::after { content: ""; position: absolute; left: 50%; top: 100%; width: 5px; height: 10px; margin-left: -2.5px; background: #7a5530; }
.compare { margin: 0 0 12px; padding: 12px 14px; background: #fbfbf8; color: var(--ink); border-radius: 12px; border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.compare .t-k { color: var(--slip); }
.compare p { margin: 4px 0 0; font-weight: 700; font-size: 15px; line-height: 1.5; }
@media (prefers-reduced-motion: no-preference) {
  .run-net:not([hidden]) { animation: netin .5s cubic-bezier(.2,1.6,.4,1) both; }
  @keyframes netin { from { transform: scale(2.2) rotate(-8deg); opacity: 0; } to { transform: rotate(-1.5deg); opacity: 1; } }
  .compare:not([hidden]) { animation: popin .45s .2s cubic-bezier(.2,1.6,.4,1) both; }
}

/* one-line timeline: now -> the jackpot year, with this life marked at the start */
.cal-line { margin: 12px 0 2px; }
.cal-line .bar { position: relative; height: 10px; margin: 0 7px; background: #e6e2d4; border-radius: 5px; }
.cal-line .fill { position: absolute; inset: 0; border-radius: 5px; background: repeating-linear-gradient(90deg, var(--ink) 0 6px, transparent 6px 10px); opacity: .35; transform-origin: 0 50%; }
.cal-line .life { position: absolute; left: 0; top: -3px; bottom: -3px; width: var(--life); min-width: 6px; background: var(--b); border-radius: 5px; z-index: 1; }
.cal-line .end { position: absolute; right: -9px; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; background: var(--slip); box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--slip); z-index: 2; }
.cal-line .lbl { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-top: 10px; font-family: var(--mono); font-size: 13px; }
.cal-line .lbl span, .cal-line .lbl strong { display: grid; line-height: 1.15; }
.cal-line .lbl small { font-family: var(--sans, sans-serif); font-size: 11px; font-weight: 700; opacity: .65; }
.cal-line .lbl em { flex: 1; font-style: normal; font-size: 11px; font-weight: 700; color: var(--b); }
.cal-line .lbl strong { text-align: right; font-family: var(--display); font-weight: 400; font-size: 24px; color: var(--slip); }
@media (prefers-reduced-motion: no-preference) {
  .t-cal .cal-line .fill { opacity: 0; }
  .t-cal.in .cal-line .fill { animation: growx 1.4s 1.1s cubic-bezier(.4,0,.2,1) both; }
  .t-cal.in .cal-line .end { animation: popin .4s 2.4s cubic-bezier(.2,1.6,.4,1) both; }
  @keyframes growx { from { transform: scaleX(0); opacity: .35; } to { transform: scaleX(1); opacity: .35; } }
}

/* odds section on the intro */
.odds .odds-big { margin: 4px 0 8px; color: var(--fg); font-family: var(--display); font-size: 22px; }
.odds .odds-big b { font-weight: 400; font-size: 40px; color: var(--slip); }
.odds .odds-big span { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.odds-list { list-style: none; margin: 8px 0 14px; padding: 0; display: grid; gap: 8px; }
.odds-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.odds-list span { min-width: 0; font-weight: 700; color: var(--ink); word-break: keep-all; }
.odds-list small { font-weight: 400; color: #6b6f75; }
.odds-list em { font-style: normal; font-family: var(--mono); font-size: 13px; color: #6b6f75; grid-column: 1; }
.odds-list b { grid-column: 2; grid-row: 1 / span 2; align-self: center; padding: 4px 8px; border-radius: 6px; font-size: 12px; background: #e6e2d4; color: var(--ink); white-space: nowrap; }
.odds-list b.easy { background: var(--b); color: #fff; }
.odds-list b.hard { background: var(--slip); color: #fff; }

/* bigger type on the result page (Robin 11-08: text too small) */
.friend-bar p { font-size: 16px; }
.t-k { font-size: 14px; }
.detail .t-cap { font-size: 16px; line-height: 1.55; }
.t-big { font-size: 48px; }
.t-big span { font-size: 24px; }
.t-type h3 { font-size: 36px; }
.bubble { font-size: 17px; }
.memo { font-size: 16px; }
.memo span { font-size: 12px; }
.cal-year { font-size: 40px; }
.cal-gj small { font-size: 16px; }
.cal-line .lbl { font-size: 15px; }
.cal-line .lbl em { font-size: 13px; }
.cal-line .lbl strong { font-size: 28px; }
.t-bank table { font-size: 15px; }
.t-bank th { font-size: 13px; }
.stickers em { font-size: 15px; }
.stickers b { font-size: 15px; }
.stickers small { font-size: 11px; }
.games .g { font-size: 19px; }
.games .g small { font-size: 12px; }
.games .ball { width: 34px; height: 34px; font-size: 15px; }
.games .r { font-size: 15px; }
.compare p { font-size: 17px; }
.yard .sign { font-size: 13px; }
/* rounded dashed borders leave a gap at the corners in Chrome: draw the dashes as backgrounds on a square box */
.memo { border: 0; border-radius: 0; padding: 10px 12px;
  background:
    linear-gradient(90deg, currentColor 50%, transparent 0) top / 10px 2px repeat-x,
    linear-gradient(90deg, currentColor 50%, transparent 0) bottom / 10px 2px repeat-x,
    linear-gradient(0deg, currentColor 50%, transparent 0) left / 2px 10px repeat-y,
    linear-gradient(0deg, currentColor 50%, transparent 0) right / 2px 10px repeat-y; }
/* graveyard: always 10 graves a row at a readable size, the yard grows downward */
.yard { display: grid; grid-template-columns: repeat(10, 1fr); justify-items: center; align-items: end; gap: 8px 2px; }
.yard .sign { position: relative; right: auto; bottom: auto; grid-column: span 5; justify-self: end; margin: 2px 4px 8px 0; }

/* crying chicken family */
.hens { display: block; width: 100%; height: auto; margin-top: 6px; overflow: visible; }
.hens .body { fill: #fffaf0; stroke: #e2cfae; stroke-width: 2; }
.hens .wing { fill: #f3e6cc; stroke: #e2cfae; stroke-width: 2; }
.hens .tail { fill: none; stroke: #3c6e47; stroke-width: 6; stroke-linecap: round; }
.hens .comb { fill: #e8454f; }
.hens .beak { fill: #f29a1f; }
.hens .leg { fill: none; stroke: #f29a1f; stroke-width: 3; stroke-linecap: round; }
.hens .chickbody { fill: #ffd84a; stroke: #e8b923; stroke-width: 2; }
.hens .eye { stroke: #2b2b2b; stroke-width: 2.4; stroke-linecap: round; }
.hens .stream { stroke: #5bb8ef; stroke-width: 2.2; stroke-linecap: round; }
.hens .tear { fill: #5bb8ef; opacity: 0; }
.hens .puddle { fill: #8fd0f5; opacity: .55; transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: no-preference) {
  .hens .bird { transform-box: fill-box; transform-origin: 50% 100%; animation: sob .42s var(--d) ease-in-out infinite alternate; }
  .hens .tear { animation: tear 1s var(--d) ease-in infinite; }
  .t-chicken.in .hens .puddle { animation: puddle 6s ease-out both; }
  @keyframes sob { to { transform: translateY(-2px) scaleY(.98); } }
  @keyframes tear { 0% { opacity: 1; transform: translateY(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(26px); } }
  @keyframes puddle { from { transform: scale(.2); } to { transform: scale(1); } }
}
@media (prefers-reduced-motion: reduce) { .hens .tear { opacity: 1; } }

/* ferrari parking lot */
.t-ferrari { background: #e9ebee; }
.t-ferrari .t-k { color: #b3202b; }
.t-ferrari .t-big b { font-weight: 400; }
.lot { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 8px; margin-top: 12px; padding: 10px 8px; background: #3a3f46; border-radius: 10px;
  background-image: repeating-linear-gradient(90deg, transparent 0 calc(20% - 2px), rgba(255,255,255,.55) calc(20% - 2px) 20%); }
.car { display: block; overflow: hidden; width: calc(100% * var(--part, 1)); }
.car svg { display: block; width: 100%; min-width: 0; aspect-ratio: 64 / 24; }
.car[style*="--part"] svg { width: calc(100% / var(--part)); }
.car-body { fill: #d8192a; }
.car-win { fill: #24323f; }
.car-line { stroke: rgba(0,0,0,.25); stroke-width: 1; }
.car-wheel { fill: #141414; }
.car-rim { fill: #f2c230; }
@media (prefers-reduced-motion: no-preference) {
  .t-ferrari .car { opacity: 0; transform: translateX(-140%); }
  .t-ferrari.in .car { animation: drivein .55s calc(var(--i) * 70ms + .3s) cubic-bezier(.2,.9,.3,1.15) both; }
  @keyframes drivein { from { opacity: 1; transform: translateX(-160%); } to { opacity: 1; transform: none; } }
}
/* a part of a car: show its front (the cars face right) */
.car[style*="--part"] svg { margin-left: calc(100% - 100% / var(--part)); }

/* old-quote card under the drawing machine */
.quote { display: grid; grid-template-columns: 72px 1fr; gap: 4px 14px; align-items: center; margin: 4px 0 18px; padding: 14px 16px; background: #fbfbf8; color: var(--ink); border-radius: 4px; box-shadow: 0 3px 0 rgba(0,0,0,.15); transform: rotate(-.6deg); }
.quote img { grid-row: 1 / span 2; width: 72px; height: 72px; border-radius: 50%; object-fit: cover; filter: sepia(.35) contrast(1.05); box-shadow: 0 0 0 3px #fbfbf8, 0 0 0 5px var(--ink); }
.quote blockquote { margin: 0; word-break: keep-all; font-family: var(--display); font-size: 21px; line-height: 1.3; text-wrap: balance; }
.quote figcaption { font-size: 14px; font-weight: 700; color: #6b6f75; }
.quote figcaption::before { content: "— "; }
.quote small { font-weight: 400; font-size: 12px; }

/* games a week: one row of OMR-style boxes, like the quantity column on a betting slip */
.k-pick { display: grid; gap: 8px; margin-top: 18px; padding: 12px; background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 var(--paper-line), 0 6px 16px rgba(0,0,0,.08); }
.k-pick-label { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--slip); letter-spacing: .04em; }
.k-chips { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.k-chips button { display: grid; place-items: center; gap: 1px; min-width: 0; padding: 7px 0 6px; border: 1.5px solid var(--slip); border-radius: 4px; background: transparent; color: var(--slip); cursor: pointer; font: inherit; transition: transform .12s; }
.k-chips button b { font-family: var(--mono); font-size: 17px; font-weight: 700; line-height: 1.1; }
.k-chips button small { font-size: 10.5px; font-weight: 600; opacity: .85; white-space: nowrap; }
.k-chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); border-radius: 40% 46% 42% 48% / 46% 40% 48% 42%; transform: rotate(-2deg); }
.k-chips button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.k-hint { margin: 0; font-size: 12.5px; font-weight: 600; color: #5d6268; word-break: keep-all; }
.k-pick.is-compact { margin: 4px 0 8px; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; }
.k-pick.is-compact .k-hint { grid-column: 1 / -1; }
.k-pick.is-compact .k-chips button { padding: 5px 0 4px; }
.k-pick.is-compact .k-chips button b { font-size: 15px; }
.slip-note .more { color: var(--slip); }
.games li.more { display: block; padding: 6px 2px 0; font-size: 13px; color: #5d6268; font-weight: 600; word-break: keep-all; }
.home-btn { margin-top: 4px; }
/* the torn calendar sheets end off to the right: never let them widen the page */
.detail { overflow-x: clip; }
.t-cal.in .sheets i { animation-fill-mode: backwards; }

.machine-wrap { margin-top: 18px; }
.machine { width: 250px; }
.intro-title { margin-top: 18px; }

.k-hint .k-note { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--slip); }
.k-hint .nw { white-space: nowrap; }
/* Robin 11-09: the quote card keeps its portrait; the operator's punchline sits right under it */
.quote { margin: 18px 0 0; }
.quote-op { margin: 10px 4px 0; text-align: right; font-weight: 700; font-size: 16px; color: var(--fg); word-break: keep-all; }
.quote-op span { font-weight: 400; font-size: 13px; opacity: .7; white-space: nowrap; }
