:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --blue-700: #1b3ee6;
  --blue-500: #3d62ff;
  --blue-800: #14299c;
  --blue-100: #e8ecff;
  --amber-700: #d98a1b;
  --amber-500: #f5a623;
  --amber-100: #fff3dd;
  --ok: #1f7a4d;
  --bad: #b3261e;
  --bg: #e4e7f5;
  --panel: #f5f7ff;
  --raised: #fafbff;
  --text: #0b0e1a;
  --dim: #616888;
  --border: #c6d3ff;
  --shadow: 0 8px 24px rgba(20, 41, 156, 0.1);
  --shadow-lg: 0 20px 48px rgba(20, 41, 156, 0.16);
  --qr-bg: #fafbff;
  --qr-ink: #05070f;
  --gutter: clamp(16px, 5vw, 64px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10131f;
    --panel: #171b2c;
    --raised: #1e2338;
    --text: #e4e7f5;
    --dim: #9da3c0;
    --border: #333850;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
    --ok: #53c28b;
    --bad: #ff8a80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}
body.locked { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; border: 0; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--amber-500); outline-offset: 2px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) var(--gutter) 12px;
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade 0.5s ease both;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.01em; }
.brand img { border-radius: 9px; animation: pop 0.6s var(--ease) both; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; background: var(--amber-100); color: #8a5a0a;
}
.live { width: 8px; height: 8px; border-radius: 50%; background: #2fbf71; position: relative; }
.live::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: #2fbf71;
  animation: ping 1.8s ease-out infinite;
}
@media (prefers-color-scheme: dark) { .chip { background: #3a2c10; color: var(--amber-500); } }

main { max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter) 32px; }

/* Hero */
.hero {
  position: relative; overflow: hidden;
  border-radius: 32px;
  padding: 28px 22px 22px;
  color: var(--blue-100);
  background: linear-gradient(180deg, #1b3ee6 0%, #3d62ff 55%, #6e8cff 100%);
  background-size: 100% 160%;
  box-shadow: var(--shadow-lg);
  animation: rise 0.7s var(--ease) both, hue 12s ease-in-out infinite alternate;
}
.hero > * { position: relative; }
.hero-glow {
  position: absolute !important; inset: -40% -20% auto auto; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 166, 35, 0.55), transparent 65%);
  animation: drift 9s ease-in-out infinite alternate;
  pointer-events: none;
}
.beans { position: absolute !important; inset: 0; pointer-events: none; }
.beans i {
  position: absolute; width: 12px; height: 18px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  animation: bean 7s ease-in-out infinite;
}
.beans i::after {
  content: ""; position: absolute; left: 50%; top: 12%; bottom: 12%; width: 2px; margin-left: -1px;
  border-radius: 2px; background: rgba(27, 62, 230, 0.35); transform: rotate(14deg);
}
.beans i:nth-child(1) { left: 8%; top: 62%; animation-delay: 0s; }
.beans i:nth-child(2) { left: 22%; top: 82%; animation-delay: -1.2s; width: 9px; height: 14px; }
.beans i:nth-child(3) { left: 46%; top: 70%; animation-delay: -2.4s; }
.beans i:nth-child(4) { left: 64%; top: 86%; animation-delay: -3.1s; width: 10px; height: 15px; }
.beans i:nth-child(5) { left: 80%; top: 58%; animation-delay: -4.2s; }
.beans i:nth-child(6) { left: 90%; top: 78%; animation-delay: -5.3s; width: 9px; height: 14px; }
.beans i:nth-child(7) { left: 34%; top: 54%; animation-delay: -6.1s; width: 8px; height: 12px; }

.hero-cup { position: absolute !important; top: 20px; right: 18px; width: 64px; height: 64px; }
.hero-cup path { stroke: var(--blue-100); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.hero-cup .hc-steam { stroke: #ffd89a; stroke-dasharray: 22; animation: steam 2.8s ease-in-out infinite; }
.hero-cup .hc-steam:nth-child(2) { animation-delay: 0.5s; }
.hero-cup .hc-steam:nth-child(3) { animation-delay: 1s; }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.hero h1 { font-size: clamp(28px, 8vw, 46px); line-height: 1.08; font-weight: 800; margin: 8px 0 16px; padding-right: 64px; }

.steps { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.steps li {
  display: flex; align-items: center; gap: 12px; font-size: 15px;
  animation: slideIn 0.5s var(--ease) both;
}
.steps li:nth-child(1) { animation-delay: 0.25s; }
.steps li:nth-child(2) { animation-delay: 0.35s; }
.steps li:nth-child(3) { animation-delay: 0.45s; }
.steps li:nth-child(4) { animation-delay: 0.55s; }
.steps span {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  background: var(--amber-500); color: #3a2300;
}

.callout {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px; border-radius: 22px;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: rise 0.6s var(--ease) 0.7s both;
}
.callout strong { font-size: 16px; display: block; margin-bottom: 4px; }
.callout p { font-size: 13.5px; opacity: 0.95; }
.ring { position: relative; flex: none; width: 64px; height: 64px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: rgba(255, 255, 255, 0.22); }
.ring-fg { stroke: var(--amber-500); stroke-linecap: round; stroke-dasharray: 0 163.4; animation: ringfill 1.4s var(--ease) 0.9s forwards; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Menu */
.menu { margin-top: 26px; }
.menu-head h2 { font-size: 24px; font-weight: 800; margin-bottom: 14px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  position: relative; overflow: hidden; text-align: left; width: 100%;
  min-height: 132px; padding: 14px 14px 16px;
  border-radius: 22px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  opacity: 0; transform: translateY(22px) scale(0.97);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease), box-shadow 0.2s ease, border-color 0.2s ease;
  transition-delay: calc(var(--d, 0) * 60ms), calc(var(--d, 0) * 60ms), 0s, 0s;
  -webkit-tap-highlight-color: transparent;
}
.card.in { opacity: 1; transform: none; }
.card.in:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--blue-500); transition-delay: 0s; }
.card.in:active { transform: scale(0.97); transition-delay: 0s; }
.card[disabled] { opacity: 0.5; cursor: not-allowed; }
.card[disabled].in:hover { transform: none; box-shadow: var(--shadow); border-color: var(--border); }
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; opacity: 0;
  background: radial-gradient(120% 90% at 100% 0%, rgba(61, 98, 255, 0.18), transparent 60%);
  transition: opacity 0.25s ease;
}
.card.in:not([disabled]):hover::before { opacity: 1; }
.card-top { position: relative; display: flex; align-items: center; justify-content: space-between; }
.card > div:last-child { position: relative; }
.cell-badge {
  min-width: 40px; height: 32px; padding: 0 12px; border-radius: 999px;
  display: inline-grid; place-items: center;
  font-weight: 800; font-size: 15px; background: var(--blue-700); color: var(--blue-100);
}
.steam { width: 32px; height: 32px; color: var(--blue-500); overflow: visible; }
.steam path { stroke-dasharray: 26; stroke-dashoffset: 26; animation: steam 3s ease-in-out infinite; }
.steam path:nth-child(2) { animation-delay: 0.6s; }
.steam path:nth-child(3) { animation-delay: 1.2s; }
.card:not([disabled]):hover .steam path { animation-duration: 1.6s; }
.card-name { font-size: 16px; font-weight: 700; line-height: 1.2; }
.card-price { font-size: 14px; color: var(--dim); font-weight: 600; }
.tag {
  display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: var(--amber-100); color: #8a5a0a;
}
@media (prefers-color-scheme: dark) { .tag { background: #3a2c10; color: var(--amber-500); } }
.ripple {
  position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  background: rgba(61, 98, 255, 0.35); pointer-events: none; animation: ripple 0.6s ease-out forwards;
}

.footer { max-width: 1200px; margin: 0 auto; padding: 8px var(--gutter) calc(32px + env(safe-area-inset-bottom)); text-align: center; font-size: 15px; }
.footer .muted { color: var(--dim); font-size: 13px; margin-top: 6px; }

/* Bottom sheet */
.sheet-root { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-root[hidden] { display: none; }
.sheet-root.closing .sheet { animation: slideOut 0.26s ease-in both; }
.sheet-root.closing .backdrop { animation: fadeOut 0.26s ease-in both; }
.backdrop { position: absolute; inset: 0; background: rgba(11, 14, 26, 0.55); animation: fade 0.25s ease both; }
.sheet {
  position: relative; width: 100%; max-width: 480px; max-height: 94dvh; overflow-y: auto;
  background: var(--panel); border-radius: 32px 32px 0 0; padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: slide 0.38s var(--ease) backwards;
  touch-action: pan-y;
}
.sheet::before {
  content: ""; display: block; width: 44px; height: 5px; border-radius: 999px;
  background: var(--border); margin: -10px auto 14px;
}
@media (min-width: 720px) {
  .sheet-root { align-items: center; }
  .sheet { border-radius: 32px; }
}
.close {
  position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--raised); color: var(--text);
  transition: transform 0.2s ease;
  z-index: 3;
}
.close::after { content: ""; position: absolute; inset: -8px; }
.close:hover { transform: rotate(90deg); }
.sheet-head { display: flex; align-items: center; gap: 14px; padding-right: 48px; animation: slideIn 0.45s var(--ease) 0.1s both; }
.sheet-head h3 { font-size: 22px; font-weight: 800; line-height: 1.15; }
.price { color: var(--dim); font-weight: 600; margin-top: 2px; }
.sheet .cell-badge { height: 44px; min-width: 52px; font-size: 20px; }

.qr-wrap { position: relative; margin: 18px auto 14px; width: min(100%, 320px); aspect-ratio: 1; }
.qr {
  position: relative; overflow: hidden;
  width: 100%; height: 100%; padding: 14px; border-radius: 22px;
  background: var(--qr-bg); box-shadow: var(--shadow);
  opacity: 0; transform: scale(0.85) rotate(-3deg); filter: blur(6px);
  transition: opacity 0.4s ease, transform 0.55s var(--ease), filter 0.4s ease;
}
.qr.on { opacity: 1; transform: none; filter: none; }
.qr.out { opacity: 0; transform: scale(0.9) rotate(3deg); filter: blur(8px); transition-duration: 0.22s; }
.qr.scan::after {
  content: ""; position: absolute; left: 0; right: 0; height: 34%; top: -40%;
  background: linear-gradient(180deg, transparent, rgba(61, 98, 255, 0.4), transparent);
  animation: sweep 1s 0.2s ease-out both;
  pointer-events: none;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr svg path { fill: var(--qr-ink); stroke: none; }
.qr svg rect { fill: var(--qr-bg); }

.loader {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px;
  border-radius: 22px; background: var(--raised); color: var(--dim); font-weight: 600;
  animation: fade 0.25s ease both;
}
.loader[hidden] { display: none; }
.brew { width: 96px; height: 96px; }
.b-body { stroke: var(--blue-500); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.b-coffee { fill: var(--amber-500); animation: brew 1.6s ease-in-out infinite; }
.b-steam { stroke: var(--amber-500); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 22; stroke-dashoffset: 22; animation: steam 1.8s ease-in-out infinite; }
.b-steam:nth-of-type(2) { animation-delay: 0.3s; }
.b-steam:nth-of-type(3) { animation-delay: 0.6s; }
.dots::after { content: ""; animation: dots 1.2s steps(4, end) infinite; }

.result {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  animation: fade 0.25s ease both;
}
.result[hidden] { display: none; }
.result svg { width: 132px; height: 132px; stroke-width: 3.2; }
.result circle { stroke: var(--ok); stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw 0.6s ease-out 0.05s forwards; }
.result path { stroke: var(--ok); stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw 0.45s ease-out 0.5s forwards; }
.result.bad circle, .result.bad path { stroke: var(--bad); }
.result.ok svg { animation: pop 0.5s var(--ease) both; }
.result.bad svg { animation: shake 0.5s ease both; }
.confetti { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.confetti i {
  position: absolute; width: 8px; height: 12px; border-radius: 2px; background: var(--c, #f5a623);
  animation: burst 1s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

.instruction { text-align: center; font-size: 16px; animation: rise 0.4s ease 0.2s both; }
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.meta[hidden] { display: none; }
.meta div { background: var(--raised); border-radius: 14px; padding: 10px 12px; text-align: center; animation: pop 0.45s var(--ease) both; animation-delay: calc(var(--k, 0) * 80ms + 0.25s); }
.meta dt { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.meta dd { margin: 2px 0 0; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }

.outcome { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); animation: rise 0.45s var(--ease) 0.5s both; }
.outcome[hidden] { display: none; }
.outcome-title { font-weight: 700; text-align: center; margin-bottom: 10px; }
.outcome-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pill {
  min-height: 50px; border-radius: 999px; font-weight: 700; font-size: 15px;
  background: var(--raised); color: var(--text); border: 2px solid var(--border);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.2s ease;
}
.pill:active { transform: scale(0.95); }
.pill.good { border-color: var(--ok); color: var(--ok); }
.pill.bad { border-color: var(--bad); color: var(--bad); }
.pill.chosen { background: var(--blue-700); border-color: var(--blue-700); color: var(--blue-100); }
.outcome.done .pill:not(.chosen) { opacity: 0.4; }
.thanks { text-align: center; color: var(--ok); font-weight: 700; margin-top: 10px; animation: rise 0.3s ease both; }
.thanks[hidden] { display: none; }

.primary {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; margin-top: 14px; min-height: 52px; border-radius: 999px;
  background: var(--blue-700); color: var(--blue-100); font-weight: 800; font-size: 16px;
  box-shadow: 0 8px 24px rgba(27, 62, 230, 0.35); transition: transform 0.12s ease, background 0.12s ease;
}
.primary svg { transition: transform 0.5s var(--ease); }
.primary:hover { background: var(--blue-500); }
.primary:hover svg { transform: rotate(180deg); }
.primary.spin svg { animation: spin 0.8s var(--ease); }
.primary:active { transform: scale(0.98); }
.primary:disabled { opacity: 0.7; cursor: progress; }
.primary[hidden] { display: none; }
.primary::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  animation: shine 3.2s ease-in-out infinite;
}
.error-box { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: #fde7e4; color: #7a1913; font-weight: 600; font-size: 14px; animation: shake 0.4s ease both; }
@media (prefers-color-scheme: dark) { .error-box { background: #3a1b18; color: #ffb4ab; } }
.error-box[hidden] { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(0.7); } 70% { transform: scale(1.06); } 100% { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slide { from { transform: translateY(100%); } to { transform: none; } }
@keyframes slideOut { from { transform: none; } to { transform: translateY(100%); } }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-30px, 24px) scale(1.15); } }
@keyframes hue { from { background-position: 0 0; } to { background-position: 0 100%; } }
@keyframes bean { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-14px) rotate(35deg); } }
@keyframes steam { 0% { stroke-dashoffset: 26; opacity: 0; } 35% { opacity: 1; } 100% { stroke-dashoffset: -26; opacity: 0; } }
@keyframes ringfill { to { stroke-dasharray: 32.7 163.4; } }
@keyframes ripple { to { transform: scale(16); opacity: 0; } }
@keyframes ping { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(3); opacity: 0; } }
@keyframes sweep { from { top: -40%; opacity: 1; } to { top: 110%; opacity: 0.2; } }
@keyframes brew { 0% { transform: translateY(34px); } 60% { transform: translateY(0); } 100% { transform: translateY(0); } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes burst { 0% { transform: translate(0, 0) rotate(0deg); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shine { 0%, 55% { left: -60%; } 100% { left: 130%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .card { opacity: 1; transform: none; }
}

.chip-btn { border: 0; cursor: pointer; font-family: inherit; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.chip-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.chip-btn:active { transform: scale(0.97); }
.tlink { color: var(--blue-500); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.15s ease; }
.tlink:hover { border-bottom-color: currentColor; }
.info { margin: 16px 0 0; display: grid; gap: 6px; }
.info div { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 10px; background: var(--raised); border-radius: 14px; padding: 10px 12px; animation: pop 0.4s var(--ease) both; animation-delay: calc(var(--k, 0) * 45ms + 0.1s); }
.info dt { color: var(--dim); font-size: 12.5px; }
.info dd { margin: 0; font-weight: 700; font-size: 14px; text-align: right; overflow-wrap: anywhere; }
a.primary { text-decoration: none; }
