/* ============================================================
   Mame Reflections — Telegram Mini App
   "Praktika"-style redesign: near-black canvas, bold grotesque
   headings, soft pastel cards (lime / lavender / orange),
   dark meta-pills, swapping Mame mascot, bottom tab bar.
   ============================================================ */

:root {
  /* light theme — the whole app runs on a white canvas */
  --bg: #ffffff;
  --bg-soft: #f4f3f6;
  --ink: #17161c;
  --ink-soft: rgba(23, 22, 28, 0.62);
  --ink-faint: rgba(23, 22, 28, 0.4);
  --amber: #a87600; /* readable "gold" for links/values on white */

  --yellow: #e7ec4b;
  --yellow-2: #dbe23f;
  --lav: #cbb8f3;
  --lav-2: #bda7ef;
  --orange: #f2693c;
  --mint: #aef0c4;
  --mint-2: #97e8b2;
  --card-dark: #1b1a21;

  --on-pastel: #17161c;       /* text on pastel cards */
  --pill-dark: #1c1b22;
  --pill-ink: #f4f3f7;

  --radius-card: 26px;
  --radius-pill: 999px;

  /* env() gives a correct value on the FIRST frame; JS overwrites with Telegram insets when they arrive */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --head: "Space Grotesk", Inter, ui-sans-serif, system-ui, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* kill the 300ms double-tap delay + grey flash on tappable controls */
button, [role="button"], a, .chip, .tab, .back-row, .home-live, .btn-check, .btn-continue, .lb-card {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
img, svg { display: block; max-width: 100%; -webkit-user-drag: none; user-select: none; }
a { color: inherit; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.92em; }


/* ============================== layout ============================== */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 16px calc(32px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ============================== top bar ============================== */
.topbar { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }
.greet { display: flex; align-items: center; gap: 12px; min-width: 0; }
.face-logo {
  width: 54px; height: auto; flex: 0 0 auto;
  filter: drop-shadow(0 3px 6px rgba(23, 22, 28, 0.18));
}
.gm {
  font-family: var(--head);
  font-size: clamp(24px, 7vw, 30px); font-weight: 700; letter-spacing: -0.8px;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bell {
  position: relative;
  width: 46px; height: 46px; border-radius: 16px; border: 0;
  background: var(--bg-soft); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.08);
}
.bell svg { width: 22px; height: 22px; fill: currentColor; }
.bell-dot {
  position: absolute; top: 11px; right: 12px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--yellow); box-shadow: 0 0 0 2px var(--bg-soft);
}

/* ============================== chips ============================== */
.chips {
  display: flex; gap: 9px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1.5px solid rgba(23, 22, 28, 0.16);
  background: transparent; color: var(--ink-soft);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  font: 700 13px/1 var(--body); letter-spacing: 0.1px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 120ms ease;
}
.chip:active { transform: scale(0.96); }
.chip.is-active {
  background: var(--ink); color: #ffffff; border-color: var(--ink);
}

/* ============================== blocks / headings ============================== */
.block { display: flex; flex-direction: column; gap: 13px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.block-head h2 {
  margin: 0; font-family: var(--head);
  font-size: 23px; font-weight: 700; letter-spacing: -0.6px;
}
.live-tag, .count-tag {
  font: 700 12px/1 var(--body); color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 6px;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #46e08a;
  box-shadow: 0 0 0 0 rgba(70, 224, 138, 0.6); animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(70, 224, 138, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(70, 224, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(70, 224, 138, 0); }
}

/* ============================== cards ============================== */
.card {
  position: relative;
  border-radius: var(--radius-card);
  padding: 20px;
  overflow: hidden;
  isolation: isolate;
}
.card--yellow { background: linear-gradient(165deg, var(--yellow), var(--yellow-2)); color: var(--on-pastel); }
.card--lav    { background: linear-gradient(165deg, var(--lav), var(--lav-2)); color: var(--on-pastel); }
.card--orange { background: linear-gradient(165deg, #ff7d4f, var(--orange)); color: #1a0c06; }
.card--mint   { background: linear-gradient(165deg, var(--mint), var(--mint-2)); color: #06140c; }
.card--green  { background: linear-gradient(165deg, #98efad, #5fd884); color: #07150c; }
.card--soft   { background: var(--bg-soft); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.05); }

.card-kicker {
  margin: 0 0 8px; font: 800 11px/1 var(--body); letter-spacing: 1px; text-transform: uppercase;
  opacity: 0.62;
}
.card-value {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-family: var(--head); font-weight: 700; letter-spacing: -1.4px; line-height: 0.95;
}
.card-value > span:first-child { font-size: clamp(40px, 13vw, 54px); }
.card-unit { font-family: var(--body); font-size: 15px; font-weight: 900; letter-spacing: 0; opacity: 0.78; }

.card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.meta-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--pill-dark); color: var(--pill-ink);
  border-radius: var(--radius-pill); padding: 7px 12px;
  font: 700 12px/1 var(--body);
}
.meta-pill b { font-weight: 900; }

/* ---- hero card with swapping mascot ---- */
.card--hero { min-height: 188px; padding-right: 130px; }
.card-mascot {
  position: absolute; right: 6px; bottom: -6px; top: 0;
  width: 132px; pointer-events: none;
  display: grid; place-items: end center;
}
.card--hero .card-mascot { animation: float 4.5s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.mascot {
  grid-area: 1 / 1;
  width: 100%; height: auto; object-fit: contain;
  filter: drop-shadow(0 10px 12px rgba(23, 22, 28, 0.22));
}
/* the reflections hero: character on the coin pile, wider than the old poses */
.card-mascot--coins { width: 150px; right: -4px; bottom: -4px; }

.card-tap {
  position: absolute; right: 16px; bottom: 14px; z-index: 2;
  font: 800 11px/1 var(--body); letter-spacing: 0.4px;
  color: var(--on-pastel); opacity: 0.5;
}
.card--hero { cursor: pointer; }
.card--hero:active { transform: scale(0.992); }

/* ---- checker ---- */
.card--check { padding: 18px; }
.check-copy { margin: 0 0 14px; font-size: 14px; font-weight: 600; line-height: 1.4; opacity: 0.82; }
.check-copy b { font-weight: 900; }
.check-form { display: flex; gap: 9px; }
.check-form input {
  flex: 1; min-width: 0;
  border: 0; border-radius: 16px;
  background: rgba(23, 22, 28, 0.14); color: var(--on-pastel);
  padding: 14px 15px;
  /* 16px min stops iOS from auto-zooming the page on focus */
  font: 800 16px/1.2 ui-monospace, Menlo, Consolas, monospace;
  outline: 2px solid transparent; transition: outline-color 160ms ease, background 160ms ease;
}
.check-form input::placeholder { color: rgba(23, 22, 28, 0.5); font-weight: 700; }
.check-form input:focus { outline-color: rgba(23, 22, 28, 0.55); background: rgba(255, 255, 255, 0.35); }
.btn-check {
  flex: 0 0 auto; border: 0; border-radius: 16px; cursor: pointer;
  padding: 0 22px; min-height: 50px;
  background: #17161c; color: #fff;
  font: 900 15px/1 var(--body); letter-spacing: 0.2px;
  transition: transform 130ms ease, filter 130ms ease;
}
.btn-check:active { transform: translateY(1px) scale(0.98); }
.btn-check:disabled { filter: opacity(0.6); cursor: wait; }
.check-err { margin: 10px 2px 0; font-size: 12.5px; font-weight: 800; color: #7a1414; }
.card--soft .check-err { color: #c2410c; }
.check-err:empty { display: none; }

/* ---- result card ---- */
.card--result { padding-right: 122px; animation: rise 360ms cubic-bezier(0.2, 0.9, 0.25, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result-main .card-value > span:first-child { font-size: clamp(36px, 11vw, 46px); color: var(--ink); }
.card--result .card-kicker { opacity: 0.55; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.result-stats > div {
  background: #ffffff; border-radius: 14px; padding: 10px 11px;
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.06);
}
.result-stats span { display: block; font: 800 10px/1 var(--body); letter-spacing: 0.5px; text-transform: uppercase; opacity: 0.5; margin-bottom: 5px; }
.result-stats strong { font: 900 16px/1 var(--body); font-variant-numeric: tabular-nums; }
.result-note { margin: 13px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-soft); }
.result-note a { color: var(--amber); font-weight: 800; }
.result-mascot { width: 108px; bottom: -4px; }
.result-mascot .mascot { filter: drop-shadow(0 10px 12px rgba(23, 22, 28, 0.2)); }

/* badges */
.badge {
  display: inline-flex; align-items: center;
  margin-top: 10px;
  font: 900 11px/1 var(--body); letter-spacing: 0.3px;
  padding: 5px 11px; border-radius: var(--radius-pill);
}
.badge--exact { background: rgba(18, 163, 90, 0.14); color: #12a35a; }
.badge--est   { background: rgba(168, 118, 0, 0.14); color: var(--amber); }
.badge--excl  { background: rgba(194, 65, 12, 0.14); color: #c2410c; }
.badge--mini  { margin: 0; padding: 1px 7px; font-size: 10px; vertical-align: middle; }
.card--lav .badge--exact, .card--lav .badge--est, .card--yellow .badge--exact, .card--yellow .badge--est {
  background: rgba(23, 22, 28, 0.16); color: var(--on-pastel);
}

/* ============================== leaderboard ============================== */
.lb { display: flex; flex-direction: column; gap: 10px; }
.lb-skeleton { color: var(--ink-soft); font-size: 13px; padding: 22px 4px; text-align: center; }

.lb-card {
  position: relative;
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  border-radius: 20px; padding: 14px 16px; overflow: hidden;
  background: var(--bg-soft); color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.05);
  transition: transform 140ms ease;
}
.lb-card:active { transform: scale(0.99); }
.lb-card.is-me { box-shadow: inset 0 0 0 2px var(--yellow); }

/* top-3 get pastel treatment + mascot */
.lb-card.top { color: var(--on-pastel); box-shadow: none; padding-right: 92px; min-height: 96px; }
.lb-card.top.c1 { background: linear-gradient(160deg, var(--yellow), var(--yellow-2)); }
.lb-card.top.c2 { background: linear-gradient(160deg, var(--lav), var(--lav-2)); }
.lb-card.top.c3 { background: linear-gradient(160deg, #ff7d4f, var(--orange)); color: #1a0c06; }
.lb-card.top .lb-mascot {
  position: absolute; right: -6px; bottom: -8px; top: 0; width: 92px;
  display: grid; place-items: end center; pointer-events: none;
}
.lb-card.top .lb-mascot img { width: 100%; height: auto; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.25)); }

.lb-rank {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px;
  font: 900 15px/1 var(--head); font-variant-numeric: tabular-nums;
  background: rgba(23, 22, 28, 0.06); color: var(--ink-soft);
}
.lb-card.top .lb-rank { background: rgba(23, 22, 28, 0.18); color: var(--on-pastel); width: 44px; height: 44px; font-size: 17px; }

.lb-id { min-width: 0; }
.lb-id .a { font: 800 14px/1.1 ui-monospace, Menlo, Consolas, monospace; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-id .s { font: 800 11px/1 var(--body); opacity: 0.55; }
.lb-card.top .lb-id .s { opacity: 0.6; }

.lb-val { text-align: right; line-height: 1.12; }
.lb-val .v { display: block; font: 900 16px/1 var(--head); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.lb-card:not(.top) .lb-val .v { color: var(--amber); }
.lb-val .p { display: block; margin-top: 3px; font: 800 11px/1 var(--body); opacity: 0.55; }

/* ============================== views / router ============================== */
.view { display: none; flex-direction: column; gap: 22px; animation: viewIn 280ms ease; }
.view.is-active { display: flex; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.back-row {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; cursor: pointer;
  background: var(--bg-soft); color: var(--ink);
  border-radius: var(--radius-pill); padding: 9px 16px 9px 11px;
  font: 800 13px/1 var(--body);
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.08);
}
.back-row svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.back-row:active { transform: scale(0.97); }

/* ---- home headline ---- */
.hero-line h1 {
  margin: 2px 0 6px; font-family: var(--head);
  font-size: clamp(30px, 9vw, 38px); font-weight: 700; line-height: 1.02; letter-spacing: -1px;
}
.hero-line h1 span { color: var(--yellow); }
.hero-line p { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-soft); }

/* ============================== welcome screen ============================== */
.view--welcome {
  position: fixed;
  top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  z-index: 60;
  gap: 0; padding: 0;
  background: #ffffff;
  overflow: hidden;
  animation: welcomeIn 420ms ease;
}
.view--welcome:not(.is-active) { display: none; }
@keyframes welcomeIn { from { opacity: 0; } to { opacity: 1; } }

/* the welcome overlay is white — paint the page white too so nothing dark peeks out */
body.is-welcome { background: #ffffff; }
body.is-welcome .tabbar { display: none; }

/* ============================== light theme (welcome + home) ============================== */
/* (the whole app is light now — former .is-light overrides are folded into base styles) */

.welcome-title {
  position: relative; z-index: 2;
  margin: 0;
  padding: calc(34px + var(--safe-top)) 20px 0;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  font-family: var(--head);
  text-transform: uppercase;
  line-height: 0.86;
}
.wt-sm { font-size: clamp(18px, 5.6vw, 26px); font-weight: 600; letter-spacing: 2px; color: rgba(23, 22, 28, 0.55); }
.wt-xl {
  margin: 2px 0;
  font-size: clamp(76px, 25vw, 128px); font-weight: 700; letter-spacing: -3px; line-height: 0.8;
  color: #17161c;
}
.wt-md { font-size: clamp(34px, 11vw, 58px); font-weight: 700; letter-spacing: 1px; color: #17161c; }

.welcome-hero {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.welcome-glow {
  position: absolute;
  left: 50%; bottom: 6%;
  transform: translateX(-50%);
  width: 92%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(231, 236, 75, 0.35), rgba(231, 236, 75, 0.12) 46%, transparent 68%);
  filter: blur(10px);
}
.welcome-hero img {
  /* absolute centering — reliable even when the image is wider than the view
     (grid center falls back to start-alignment on overflow in some browsers) */
  position: absolute;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  max-width: none; /* override the global img max-width:100% so it can overflow */
  /* as tall as the space under the title allows — width follows, may bleed the sides */
  height: calc(100vh - 205px);
  height: calc(100svh - 205px);
  width: auto;
  filter: drop-shadow(0 16px 30px rgba(23, 22, 28, 0.18));
}
@keyframes welcomeFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.welcome-cta {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 3;
  padding: 0 18px;
}
.btn-continue {
  width: 100%;
  border: 0; cursor: pointer;
  border-radius: 18px;
  min-height: 56px;
  color: #231703;
  background: linear-gradient(180deg, var(--yellow-soft, #ffe66d), var(--yellow-2));
  box-shadow: 0 14px 34px rgba(231, 236, 75, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font: 950 17px/1 var(--body); letter-spacing: 0.3px;
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}
@media (hover: hover) {
  .btn-continue:hover {
    transform: translateY(-2px);
    filter: brightness(1.06) saturate(1.05);
    box-shadow:
      0 18px 44px rgba(231, 236, 75, 0.5),
      0 0 0 3px rgba(231, 236, 75, 0.35),
      inset 0 1px 0 rgba(255, 255, 255, 0.75);
  }
}
.btn-continue:active { transform: translateY(1px) scale(0.99); filter: brightness(1.05); }

@media (prefers-reduced-motion: reduce) {
  .welcome-hero img { animation: none; }
  .view--welcome { animation: none; }
}

/* ============================== menu scroller ============================== */
.menu-scroller, .ep-scroller {
  position: relative;
  display: flex; gap: 12px;
  overflow-x: auto; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  margin: 0 -16px; padding: 8px 16px 16px;
  scrollbar-width: none; -ms-overflow-style: none;
  /* axis-lock: horizontal flicks stay in the rail and never bleed into the page
     scroll or Telegram's vertical swipe-to-close (cross-version guard for <7.7) */
  touch-action: pan-x;
  /* 3D cover-flow space */
  perspective: 1100px;
  perspective-origin: 50% 42%;
}
.menu-scroller::-webkit-scrollbar, .ep-scroller::-webkit-scrollbar { display: none; }

/* carousel motion — JS sets per-card transform/opacity DIRECTLY from scroll
   position every frame (no transform transition → 1:1, butter-smooth). */
.menu-card, .ep-card {
  will-change: transform, opacity;
  transform-origin: center center;
  backface-visibility: hidden;
  transition: box-shadow 260ms ease, filter 200ms ease;
  touch-action: pan-x; /* the card is the hit target — must match the rail to lock horizontal */
}
.menu-card.is-focus { box-shadow: 0 14px 30px rgba(23, 22, 28, 0.14), 0 0 0 1px rgba(23, 22, 28, 0.05); }
.ep-card.is-focus { box-shadow: 0 14px 30px rgba(23, 22, 28, 0.18), 0 0 0 1px rgba(23, 22, 28, 0.07); }
.menu-mascot, .ep-info { will-change: transform; }

.menu-card {
  position: relative; flex: 0 0 47%; min-width: 152px; max-width: 210px;
  scroll-snap-align: center;
  border-radius: var(--radius-card); padding: 16px; min-height: 200px;
  overflow: hidden; isolation: isolate; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
}
.menu-card:active { transform: scale(0.97); }
.menu-card:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
/* the scroll-centred card is the active one — it lights up (mobile-first, no hover);
   lavender keeps its original colour — brightening shifts it towards pink */
.menu-card.is-focus { filter: brightness(1.06) saturate(1.12); }
.menu-card.card--lav.is-focus { filter: none; }
.menu-card h3 {
  margin: 6px 0 4px; font-family: var(--head);
  font-size: 20px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.06;
}
.menu-stat { margin: 0; font-size: 14.5px; font-weight: 800; opacity: 0.82; }
.menu-stat b { font-weight: 900; opacity: 1; }
.menu-mascot {
  position: absolute; right: -4px; bottom: -2px; width: 66px; pointer-events: none;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.26));
}
.menu-mascot img { width: 100%; height: auto; }
/* About / Burn: sprite centred at the bottom of the card.
   Centre via auto margins, NOT transform — the carousel parallax writes an
   inline translateX to this element and would overwrite a transform centre. */
.menu-mascot--about,
.menu-mascot--burn {
  left: 0; right: 0; bottom: -2px;
  margin: 0 auto;
}
.menu-mascot--about { width: 92px; }
.menu-mascot--burn { width: 84px; }

/* ---- Reflections card: coin rain behind, text + coin-pile hero in front ---- */
.coin-rain { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
/* each coin is a sprite-strip player: 37 frames of 64px in coin-strip.webp;
   --sc scales frame + strip together so the background math stays exact */
.coin-rain .coin {
  position: absolute; top: -70px; left: var(--x, 50%);
  width: calc(64px * var(--sc, 0.4));
  height: calc(64px * var(--sc, 0.4));
  background: url(./assets/coin-strip.webp) 0 0 / calc(2368px * var(--sc, 0.4)) 100% no-repeat;
  opacity: 0;
  animation:
    coin-fall var(--d, 3s) linear var(--delay, 0s) infinite,
    coin-spin 3.05s steps(37) var(--delay, 0s) infinite;
}
@keyframes coin-spin {
  to { background-position-x: calc(-2368px * var(--sc, 0.4)); }
}
@keyframes coin-fall {
  0%   { transform: translateY(0); opacity: 0; }
  10%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(300px); opacity: 0; }
}
.refl-txt { position: relative; z-index: 2; }
.menu-card--refl h3 { white-space: nowrap; }
.refl-hero {
  position: absolute; left: 50%; bottom: -2px;
  transform: translateX(-50%);
  width: 96%; z-index: 1; pointer-events: none;
}
.refl-hero img { width: 100%; height: auto; filter: drop-shadow(0 6px 10px rgba(23, 22, 28, 0.18)); }

/* ---- Tax card: buckets flush with the card's bottom edge, coins drop in behind ---- */
.bucket-row {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 10px; pointer-events: none;
}
.bucket-row img { width: 31%; height: auto; display: block; }

/* ---- Buy card: one huge wordmark, coin-flip spin to draw the tap ---- */
.menu-card--buy { justify-content: center; perspective: 520px; }
.menu-card .buy-big {
  margin: 0;
  font-size: clamp(30px, 8.6vw, 42px);
  line-height: 0.94; letter-spacing: -1.4px;
  text-transform: uppercase;
  animation: buy-spin 4.4s cubic-bezier(0.35, 0.05, 0.25, 1) infinite;
  will-change: transform;
}
/* full 360° Y-spin (~1.4s) with a slight mid-spin pop, then rest ~3s */
@keyframes buy-spin {
  0%   { transform: rotateY(0deg) scale(1); }
  16%  { transform: rotateY(180deg) scale(1.12); }
  32%  { transform: rotateY(360deg) scale(1); }
  100% { transform: rotateY(360deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .menu-card .buy-big { animation: none; } }
@media (prefers-reduced-motion: reduce) { .coin-rain .coin { animation: none; opacity: 0; } }

/* ============================== episode (cartoon) cards ============================== */
.ep-card {
  position: relative; flex: 0 0 80%; min-width: 240px; max-width: 360px;
  scroll-snap-align: start;
  aspect-ratio: 16 / 10; border-radius: var(--radius-card);
  overflow: hidden; cursor: pointer;
  background: #1b1a21 center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.06);
  scroll-snap-align: center;
}
.ep-card:active { transform: scale(0.98); }
.ep-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8, 7, 12, 0.05) 30%, rgba(8, 7, 12, 0.82) 100%);
}
.ep-badge {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--yellow); color: #14131a;
  border-radius: var(--radius-pill); padding: 6px 11px;
  font: 900 11px/1 var(--body); letter-spacing: 0.4px;
}
.ep-play {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(13, 12, 18, 0.55); backdrop-filter: blur(4px);
  display: grid; place-items: center;
}
.ep-play svg { width: 15px; height: 15px; fill: #fff; margin-left: 2px; }
.ep-info { position: absolute; left: 14px; right: 14px; bottom: 13px; z-index: 2; }
.ep-info h3 {
  margin: 0; font-family: var(--head); font-size: 18px; font-weight: 700; letter-spacing: -0.4px;
  color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.ep-info .ep-meta { margin-top: 3px; font: 800 12px/1 var(--body); color: rgba(255, 255, 255, 0.78); }

/* episode detail view */
.ep-detail-poster {
  width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-card);
  background: #1b1a21 center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.06);
}
.ep-detail-title { margin: 4px 0 0; font-family: var(--head); font-size: 26px; font-weight: 700; letter-spacing: -0.7px; }
.ep-detail-meta { margin: 6px 0 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); }

/* home live strip */
.home-live { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.home-live .card-value > span:first-child { font-size: 34px; }
.home-live:active { transform: scale(0.99); }

/* ============================== detail screens ============================== */
.detail { gap: 16px; }
.detail-head { display: flex; flex-direction: column; gap: 4px; }
.detail-head .card-kicker { margin: 0; opacity: 1; color: var(--ink-faint, rgba(244,243,247,.5)); }
.detail-title { margin: 0; font-family: var(--head); font-size: clamp(26px, 8vw, 34px); font-weight: 700; letter-spacing: -0.9px; line-height: 1.02; }
.detail-copy { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.55; color: var(--ink-soft); }
.detail-copy b { color: var(--ink); font-weight: 900; }

/* placeholder illustration frame (swap with real art later) */
.illus {
  position: relative;
  border-radius: var(--radius-card);
  aspect-ratio: 5 / 4;
  display: grid; place-items: center;
  overflow: hidden;
}
.illus::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(70% 55% at 50% 18%, rgba(255,255,255,.35), transparent 60%);
}
.illus--lav { background: linear-gradient(165deg, var(--lav), var(--lav-2)); }
.illus--orange { background: linear-gradient(165deg, #ff7d4f, var(--orange)); }
.illus--mint { background: linear-gradient(165deg, var(--mint), var(--mint-2)); }
.illus img { width: 58%; height: auto; filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.28)); }
.illus-tag {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  font: 800 10px/1 var(--body); letter-spacing: 0.6px; text-transform: uppercase;
  color: rgba(23, 22, 28, 0.55); background: rgba(255, 255, 255, 0.42);
  border-radius: 999px; padding: 6px 11px;
}

/* burn: big stat + progress meter */
.big-stat { display: flex; flex-direction: column; gap: 6px; }
.big-stat-num {
  font: 700 clamp(42px, 13vw, 58px)/1 var(--head); letter-spacing: -1.6px;
  background: linear-gradient(180deg, var(--ink) 25%, var(--orange)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.big-stat-unit { font: 800 12px/1 var(--body); letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-soft); }
.meter-track { height: 12px; border-radius: 999px; background: rgba(23, 22, 28, 0.08); overflow: hidden; }
.meter-track span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ff7d4f, var(--orange)); box-shadow: 0 0 14px rgba(242, 105, 60, 0.5); }
.meter-cap { display: flex; justify-content: space-between; margin-top: 8px; font: 800 11px/1 var(--body); color: var(--ink-soft); }

/* tax: split bar + legend */
.split-bar { display: flex; gap: 4px; height: 28px; }
.seg { display: block; border-radius: 8px; }
.seg-1 { background: linear-gradient(180deg, #9fe9b6, var(--mint-2)); }
.seg-2 { background: linear-gradient(180deg, #d3c2f6, var(--lav-2)); }
.seg-3 { background: linear-gradient(180deg, #ffe879, var(--yellow-2)); }
.split-legend { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.split-legend li { display: flex; align-items: center; gap: 11px; font: 700 14px/1 var(--body); color: var(--ink); }
.split-legend li b { margin-left: auto; font-weight: 900; }
.split-legend .dot { width: 13px; height: 13px; border-radius: 5px; flex: 0 0 auto; }
.dot.d1 { background: var(--mint-2); } .dot.d2 { background: var(--lav-2); } .dot.d3 { background: var(--yellow-2); }

/* buy: steps */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li {
  display: flex; align-items: center; gap: 13px;
  background: var(--bg-soft); border-radius: 16px; padding: 14px 16px;
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.06);
}
.steps li b { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font: 900 14px/1 var(--head); background: var(--yellow); color: #14131a; }
.steps li > span { font: 600 14px/1.4 var(--body); color: var(--ink); }
.steps li span b { width: auto; height: auto; background: none; color: var(--yellow); display: inline; padding: 0; font-weight: 900; }

.detail-cta {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  min-height: 54px; text-decoration: none; border-radius: 16px;
  background: linear-gradient(180deg, #ffe66d, var(--yellow-2)); color: #231703;
  box-shadow: 0 12px 30px rgba(231, 236, 75, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font: 950 15px/1 var(--body); letter-spacing: 0.2px;
}

.detail-rows { display: flex; flex-direction: column; gap: 9px; }
.detail-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-soft); border-radius: 16px; padding: 15px 17px;
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.06);
}
.detail-row span { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.detail-row strong { font: 900 15px/1 var(--body); }
.mono-sm { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-pill {
  flex: 1 1 28%; text-align: center; text-decoration: none;
  padding: 13px 12px; border-radius: 14px;
  background: var(--bg-soft); color: var(--ink); font: 800 13px/1 var(--body);
  box-shadow: inset 0 0 0 1px rgba(23, 22, 28, 0.06);
}

/* episode detail media (video / still) */
.ep-media { border-radius: var(--radius-card); overflow: hidden; background: #000; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.ep-video { width: 100%; display: block; aspect-ratio: 16 / 9; background: #000; }
.ep-still { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #1b1a21 center / cover no-repeat; display: grid; place-items: center; }
.ep-still::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(8, 7, 12, 0.7)); }
.ep-soon { position: relative; z-index: 1; font: 900 12px/1 var(--body); letter-spacing: 0.4px; color: #fff; background: rgba(13, 12, 18, 0.55); padding: 8px 14px; border-radius: 999px; }
.ep-detail-title { margin: 0; font-family: var(--head); font-size: clamp(24px, 7vw, 30px); font-weight: 700; letter-spacing: -0.7px; }
.ep-detail-meta { margin: 4px 0 0; font: 700 13px/1 var(--body); color: var(--ink-soft); }

/* ============================== footer ============================== */
.foot { padding: 2px 4px 0; }
.foot p { margin: 8px 0; font-size: 11px; line-height: 1.6; color: rgba(23, 22, 28, 0.45); }
.foot code { color: rgba(23, 22, 28, 0.6); }
.foot-brand { text-align: center; font-weight: 800; }
.foot-brand a { color: var(--amber); }
.stub-note { margin: 0 2px; font-size: 11px; font-weight: 700; color: var(--ink-faint); }

/* ============================== bottom tab bar ============================== */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-bottom)); z-index: 20;
  width: min(460px, calc(100% - 28px));
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(24, 23, 30, 0.92);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-radius: 24px; padding: 9px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.tab {
  border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 0; border-radius: 16px; color: var(--ink-soft);
  font: 800 10px/1 var(--body);
  transition: color 150ms ease, background 150ms ease;
}
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab.is-active { color: #14131a; background: var(--yellow); }

@media (max-width: 360px) {
  .card--hero { padding-right: 112px; }
  .card-mascot { width: 116px; }
  .block-head h2 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot, .card--hero .card-mascot { animation: none; }
  .card--result { animation: none; }
  .mascot--a, .mascot--b { transition: none; }
}
