/*
 * TableTopMeta stream overlay. Drawn over a stream, so: a transparent page,
 * everything sized for a 1080p canvas, and motion only where a viewer is meant
 * to look (a pull, the box paying off, the final result).
 */
:root {
  --bg: 23 19 16;
  --ink: #f4ece1;
  --muted: #bfb09c;
  --faint: #8d7f6e;
  --gold: #e2b04a;
  --gold-hi: #ffd88a;
  --ahead: #5ecf95;
  --short: #f2735f;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --inset: 36px;
}

* { box-sizing: border-box; }
/* The control page is dark; an iframe whose color-scheme differs from its
   page gets an opaque backdrop in Chrome, so the preview matches it. */
html.preview { color-scheme: dark; }
html, body {
  margin: 0;
  background: transparent;
  overflow: hidden;
  width: 100%;
  height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#sparks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* ── The dock: panel and pull moment, anchored to a corner ─────────────── */

.dock {
  position: fixed;
  display: flex;
  gap: 22px;
  transform: scale(var(--s, 1));
  z-index: 2;
}
.dock.pos-br { right: var(--inset); bottom: var(--inset); flex-direction: row-reverse; align-items: flex-end; transform-origin: 100% 100%; }
.dock.pos-bl { left: var(--inset); bottom: var(--inset); flex-direction: row; align-items: flex-end; transform-origin: 0 100%; }
.dock.pos-tr { right: var(--inset); top: var(--inset); flex-direction: row-reverse; align-items: flex-start; transform-origin: 100% 0; }
.dock.pos-tl { left: var(--inset); top: var(--inset); flex-direction: row; align-items: flex-start; transform-origin: 0 0; }

.column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 420px;
}
.pos-tr .column, .pos-tl .column { flex-direction: column-reverse; }

/* ── The panel ─────────────────────────────────────────────────────────── */

.panel {
  position: relative;
  border-radius: 22px;
  padding: 18px 20px 14px;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(226, 176, 74, 0.13), transparent 60%),
    linear-gradient(180deg, rgba(41, 33, 27, 0.94), rgba(var(--bg) / 0.94));
  border: 1px solid rgba(226, 176, 74, 0.28);
  box-shadow:
    0 1px 0 rgba(255, 236, 200, 0.08) inset,
    0 18px 50px rgba(0, 0, 0, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out);
}
.panel.on { opacity: 1; transform: none; }
.panel.done { border-color: rgba(226, 176, 74, 0.55); }

.head { display: flex; align-items: center; gap: 12px; }
.icon {
  width: 34px;
  height: 34px;
  flex: none;
  filter: invert(84%) sepia(28%) saturate(900%) hue-rotate(354deg) brightness(96%);
}
.icon[hidden] { display: none; }
.titles { min-width: 0; flex: 1; }
.set {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.boxname {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.packs {
  flex: none;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--faint);
  text-transform: uppercase;
}
.packs b {
  display: block;
  font-size: 24px;
  letter-spacing: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.packs b small { font-size: 15px; color: var(--faint); font-weight: 700; }

.packbar {
  margin-top: 12px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.packbar i {
  display: block;
  height: 100%;
  background: rgba(244, 236, 225, 0.45);
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 500ms var(--ease-out);
}

.value { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; }
.num {
  font-size: 60px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff6e6 20%, #f0d39a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.panel.ahead .num { background-image: linear-gradient(180deg, #eafff3 10%, #7fe0ac 100%); }
.label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* The bar: what's been pulled against what the box cost. */
.bar {
  position: relative;
  margin-top: 14px;
  height: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) inset;
}
.bar .fill {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, #b8862f, var(--gold) 70%, var(--gold-hi));
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 700ms var(--ease-out);
}
.panel.ahead .bar .fill { background: linear-gradient(90deg, #2f9a64, var(--ahead) 70%, #b6f5d2); }
.bar .tick {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 2px rgba(var(--bg) / 0.9);
  transition: left 700ms var(--ease-out);
}
.bar .tick[hidden] { display: none; }

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.vs { color: var(--muted); }
.vs b { font-weight: 800; }
.vs .up { color: var(--ahead); }
.vs .down { color: var(--short); }
.luck {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 300ms ease, color 300ms ease;
}
.luck.hot { background: rgba(94, 207, 149, 0.16); color: var(--ahead); }
.luck.cold { background: rgba(242, 115, 95, 0.15); color: var(--short); }
.luck.even { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.luck[hidden] { display: none; }

.best {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.best[hidden] { display: none; }
.pick {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}
.pick.on { opacity: 1; transform: none; }
.pick img {
  width: 30px;
  height: 42px;
  border-radius: 3px;
  object-fit: cover;
  flex: none;
  background: rgba(255, 255, 255, 0.06);
}
.pick div { min-width: 0; }
.pick span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick b { display: block; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pick.foil b { color: var(--gold-hi); }

/* The result, once the last pack is in. */
.result {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 500ms var(--ease-out);
}
.result > div { overflow: hidden; }
.panel.done .result { grid-template-rows: 1fr; }
.panel.done .luck { display: none; }
.panel.done .live::before { animation: none; background: var(--gold); }
.result .inner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(226, 176, 74, 0.2), rgba(226, 176, 74, 0.06));
  border: 1px solid rgba(226, 176, 74, 0.35);
  display: flex;
  align-items: center;
  gap: 14px;
}
.result .pct {
  flex: none;
  white-space: nowrap;
  font-size: 34px;
  font-weight: 900;
  color: var(--gold-hi);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.result p { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--ink); }
.result p span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }

.foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.foot b { color: var(--gold); letter-spacing: 0.06em; text-transform: none; font-size: 13px; }
.live::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--short);
  vertical-align: 1px;
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }

/* ── Banner: the box paid off, the box is done ─────────────────────────── */

.banner {
  align-self: stretch;
  text-align: center;
  padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(90deg, #3b2b10, #5a4216 50%, #3b2b10);
  border: 1px solid rgba(255, 216, 138, 0.6);
  box-shadow: 0 0 40px rgba(226, 176, 74, 0.45), 0 12px 30px rgba(0, 0, 0, 0.5);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-hi);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition: opacity 360ms var(--ease-out), transform 360ms var(--ease-out);
}
.banner.green {
  background: linear-gradient(90deg, #103b26, #17583a 50%, #103b26);
  border-color: rgba(182, 245, 210, 0.6);
  box-shadow: 0 0 40px rgba(94, 207, 149, 0.45), 0 12px 30px rgba(0, 0, 0, 0.5);
  color: #c9f8de;
}
.banner.on { opacity: 1; transform: none; }
.banner[hidden] { display: none; }
.banner small { display: block; font-size: 13px; letter-spacing: 0.14em; color: var(--ink); opacity: 0.85; margin-top: 2px; }
.banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-100%);
}
.banner.on::after { animation: sweep 1.4s 200ms var(--ease-in-out) 2; }
@keyframes sweep { to { transform: translateX(100%); } }

/* ── The pull moment ───────────────────────────────────────────────────── */

.moment {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 280px;
  opacity: 0;
  transform: translateY(36px) scale(0.94);
  transition: opacity 280ms var(--ease-out), transform 280ms var(--ease-out);
  pointer-events: none;
}
.moment[hidden] { display: none; }
.moment.on {
  opacity: 1;
  transform: none;
  transition-duration: 520ms;
}
.moment.t-huge, .moment.t-chase { width: 330px; }

.glow {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 150%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(226, 176, 74, 0.55), rgba(226, 176, 74, 0.12) 55%, transparent 72%);
  opacity: 0;
  z-index: -1;
}
.moment.on .glow { animation: glow 2.4s ease-in-out infinite; }
.moment.t-hit .glow { background: radial-gradient(closest-side, rgba(244, 236, 225, 0.25), transparent 70%); }
.moment.t-chase .glow {
  background: conic-gradient(from 0deg, rgba(255, 120, 180, 0.4), rgba(255, 216, 138, 0.55), rgba(120, 220, 255, 0.4), rgba(180, 140, 255, 0.4), rgba(255, 120, 180, 0.4));
  -webkit-mask: radial-gradient(closest-side, #000 30%, transparent 72%);
  mask: radial-gradient(closest-side, #000 30%, transparent 72%);
}
.moment.t-chase.on .glow { animation: glow 2.4s ease-in-out infinite, spin 9s linear infinite; }
@keyframes glow {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}
@keyframes spin { to { rotate: 360deg; } }

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 488 / 680;
  border-radius: 4.75% / 3.5%;
  overflow: hidden;
  background: #1d1814;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: perspective(900px) rotateY(-28deg) rotateX(6deg);
  transition: transform 900ms var(--ease-out);
}
.moment.on .card { transform: perspective(900px) rotateY(0deg) rotateX(0deg); }
.card img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card .ph { display: none; }
.card.noimg img { display: none; }
.card.noimg .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
  background:
    radial-gradient(90% 70% at 50% 30%, rgba(226, 176, 74, 0.25), transparent 70%),
    linear-gradient(160deg, #3a2d1c, #1d1814);
  border: 6px solid #0f0c0a;
  border-radius: inherit;
}

/* Foil: a band of light that crosses the card, and a faint rainbow over it. */
.sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.moment.foil .sheen {
  opacity: 1;
  background:
    linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.55) 46%, rgba(255, 255, 255, 0.0) 60%),
    linear-gradient(115deg, rgba(255, 0, 128, 0.18), rgba(255, 220, 0, 0.16), rgba(0, 255, 170, 0.16), rgba(0, 140, 255, 0.18), rgba(200, 0, 255, 0.16));
  background-size: 250% 250%, 100% 100%;
  background-position: 120% 0, 0 0;
  mix-blend-mode: color-dodge;
  animation: foil 2.6s var(--ease-in-out) 300ms infinite;
}
@keyframes foil {
  0% { background-position: 120% 0, 0 0; }
  60%, 100% { background-position: -40% 0, 0 0; }
}

.caption {
  margin-top: 14px;
  text-align: center;
  padding: 10px 18px 12px;
  border-radius: 16px;
  background: rgba(var(--bg) / 0.92);
  border: 1px solid rgba(226, 176, 74, 0.3);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  max-width: 100%;
}
.tier {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: rgba(244, 236, 225, 0.1);
  color: var(--muted);
}
.t-big .tier { background: rgba(226, 176, 74, 0.2); color: var(--gold-hi); }
.t-huge .tier { background: var(--gold); color: #1b140c; }
.t-chase .tier {
  background: linear-gradient(90deg, #ff8ac0, #ffd88a, #8fe3ff, #c6a2ff);
  color: #1b140c;
}
.mname {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mprice {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--gold-hi);
}
.t-hit .mprice { font-size: 30px; color: var(--ink); }
.t-chase .mprice { font-size: 52px; }

/* ── The preview's hint, inside the control page only ──────────────────── */

.hint {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  color: rgba(244, 236, 225, 0.55);
  text-align: center;
  padding: 0 20%;
  line-height: 1.3;
}
.hint[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .panel, .moment, .banner, .pick { transform: none !important; }
  .card { transform: none !important; transition: none; }
  .moment.on .glow, .moment.t-chase.on .glow { animation: none; opacity: 0.8; }
  .moment.foil .sheen, .banner.on::after, .live::before { animation: none; }
}
