:root {
  --gold: #e8b04a; --buff: #5bbf6b; --nerf: #e2503c; color-scheme: dark;
  --back: radial-gradient(circle at 50% 46%, transparent 0 27%, var(--gold) 28% 30%, transparent 31%),
          repeating-linear-gradient(45deg, #3a0d0d 0 10px, #2a0808 10px 20px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100svh; color: #fff;
  background: #07070a radial-gradient(ellipse at 50% -10%, #5a1414, transparent 65%) fixed;
  font: 16px/1.5 Inter, system-ui, sans-serif;
}
h1, h2, h3 {
  font-family: Anton, Impact, sans-serif; font-weight: 400; text-transform: uppercase;
  line-height: 1.05; margin: .15em 0; letter-spacing: .01em;
}
p { margin: .3em 0; }
.kicker { color: var(--gold); text-transform: uppercase; letter-spacing: .15em; font-weight: 800; font-size: .8rem; margin: 0; }
.fine { font-size: .75rem; opacity: .65; }
.fine a { color: var(--gold); }

/* Home */
/* Notch and system bars: iOS gives env(), Capacitor on Android injects --safe-area-inset-*. */
:root { --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); }
#home { max-width: 560px; margin: 0 auto; padding: calc(8vh + var(--safe-top)) 24px calc(40px + var(--safe-bottom)); }
#home h1 { font-size: clamp(3rem, 12vw, 5.5rem); }
.lede { font-size: 1.1rem; opacity: .85; }
.fan { display: flex; justify-content: center; height: 150px; margin-bottom: 32px; }
.fan i {
  width: 92px; aspect-ratio: 5 / 7; margin: 0 -16px; border-radius: 8px;
  border: 3px solid var(--gold); background: var(--back); box-shadow: 0 10px 30px #000a;
}
.fan i:nth-child(1) { transform: rotate(-14deg) translateY(12px); }
.fan i:nth-child(2) { z-index: 1; animation: bob 3s ease-in-out infinite; }
.fan i:nth-child(3) { transform: rotate(14deg) translateY(12px); }
@keyframes bob { 50% { transform: translateY(-10px); } }
label { display: block; font-weight: 600; margin: 28px 0 8px; }
.row { display: flex; gap: 8px; }
input {
  flex: 1; min-width: 0; padding: 14px 16px; border-radius: 10px;
  border: 1px solid #fff3; background: #0008; color: #fff; font: inherit;
}
button, .btn {
  padding: 14px 20px; border-radius: 10px; border: 0; background: var(--gold); color: #1a0d00;
  font: 800 1rem Inter, sans-serif; cursor: pointer; text-decoration: none; text-align: center;
}
button:disabled { opacity: .6; cursor: default; }
button:focus-visible, .btn:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#error { color: #ff9b8a; min-height: 1.5em; }
details { margin-top: 24px; opacity: .85; }
summary { cursor: pointer; }

/* Story: a phone-shaped column, centered on desktop */
/* The reel is a phone-shaped box; the share buttons hang outside its right edge, like Facebook Reels on desktop. */
#story {
  position: fixed; inset: 0; display: flex; justify-content: center; align-items: flex-end; gap: 14px;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
  background: radial-gradient(ellipse at 50% -10%, #3a0f0f, transparent 60%), #040406;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#story::before { content: ''; flex: none; width: 68px; } /* balances the button column so the reel stays centred */
#reel {
  position: relative; align-self: stretch; flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column;
  width: calc((100svh - var(--safe-top) - var(--safe-bottom) - 100px) * 10 / 17 + 22px);
  background: #07070a; border: 1px solid #ffffff1a; border-radius: 16px; overflow: hidden;
}
#top { position: relative; flex: none; height: 50px; }
#bars { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; }
#bars span { flex: 1; height: 3px; border-radius: 2px; background: #fff4; overflow: hidden; }
#bars i { display: block; height: 100%; background: #fff; transform: scaleX(0); transform-origin: left; }
#bars .done i { transform: none; }
#bars .current i { animation: fill var(--dur, 8s) linear forwards; }
#story.paused #bars .current i { animation-play-state: paused; }
@keyframes fill { to { transform: none; } }
#close, #mute { position: absolute; top: 16px; background: none; color: #fff; line-height: 1; padding: 4px 10px; }
#close { right: 4px; font-size: 1.9rem; }
#mute { right: 48px; font-size: 1.2rem; top: 20px; }

#stage { position: relative; flex: 1; min-height: 0; container-type: size; --card-w: min(100cqw - 20px, (100cqh - 16px) * 10 / 17); }
.tap { position: absolute; top: 0; bottom: 0; z-index: 2; background: none; border-radius: 0; padding: 0; cursor: pointer; }
.tap:focus-visible { outline-offset: -4px; }
#prev { left: 0; width: 30%; }
#next { right: 0; width: 70%; }
.slide {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--r), transparent 62%), transparent 62%), #07070a;
}
.slide.active { display: flex; }
.hint { opacity: .7; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Booster pack */
.pack {
  width: min(78cqw, (100cqh - 80px) * 5 / 7); aspect-ratio: 5 / 7; border-radius: 20px; padding: 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border-block: 18px solid #0004;
  background: linear-gradient(135deg, #3a0d0d, #c23c2a 30%, var(--gold) 50%, #c23c2a 70%, #3a0d0d) 0 0 / 200% 200%;
  box-shadow: 0 20px 60px #000c, 0 0 70px #c23c2a77;
  animation: foil 4s ease-in-out infinite alternate, wiggle 2.4s ease-in-out infinite;
}
.pack .kicker { color: #1a0508; }
.pack h1 { font-size: clamp(2rem, 9vw, 2.8rem); overflow-wrap: anywhere; text-shadow: 0 2px 12px #000a; }
.avatar { width: 88px; height: 88px; border-radius: 50%; border: 3px solid #fff; }
@keyframes foil { to { background-position: 100% 100%; } }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-3deg); } 90% { transform: rotate(3deg); } 95% { transform: rotate(-2deg); } }

/* Cards: as big as the stage allows, at the canvas's 10:17 shape */
.tilt {
  transform: perspective(1200px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d; transition: transform .15s;
}
.card { position: relative; transform-style: preserve-3d; width: var(--card-w); aspect-ratio: 10 / 17; }
.slide.active .card { animation: deal 1.3s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes deal {
  0% { transform: translateY(110%) rotateY(180deg) rotateZ(-8deg); }
  35% { transform: translateY(0) rotateY(180deg); }
  50% { transform: rotateY(180deg) scale(1.03); }
  100% { transform: rotateY(0); }
}
.face {
  position: absolute; inset: 0; border-radius: 4.4% / 2.6%; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 20px 60px #000c, 0 0 50px color-mix(in srgb, var(--r), transparent 55%);
}
.back {
  transform: rotateY(180deg); display: grid; place-content: center; text-align: center;
  border: 6px solid var(--gold); background: var(--back); color: var(--gold); font: 3rem/.95 Anton, Impact, sans-serif;
}
.back small { display: block; font-size: 1.4rem; margin-top: 8px; }
.front canvas { display: block; width: 100%; height: 100%; }
.front::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen;
  background: linear-gradient(115deg, transparent 40%, #ffffff26 50%, transparent 60%) 0 0 / 300% 100%;
  animation: shine 4s 1.3s ease-in-out infinite;
}
@keyframes shine { from { background-position: 100% 0; } to { background-position: 0 0; } }

#actions { position: relative; z-index: 3; flex: none; display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; transition: opacity .2s; }
#actions.blank { visibility: hidden; }
#story.holding #actions { opacity: 0; pointer-events: none; } /* hold hides the buttons so you can read under them */
#stories, #final-links { display: contents; }
.act {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 68px; padding: 0; border-radius: 0;
  background: none; color: #fff; font: 600 11px/1.2 Inter, sans-serif; text-shadow: 0 1px 4px #000; text-decoration: none;
}
.act svg {
  width: 44px; height: 44px; padding: 11px; border-radius: 50%; background: #0009; backdrop-filter: blur(8px);
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.act:hover svg { background: #000d; }
.act.busy svg { animation: pulse 1s ease-in-out infinite; }
.act span { text-align: center; }
/* Tooltips for mouse users; phones get the label under the icon. */
@media (hover: hover) {
  .act::after {
    content: attr(data-tip); position: absolute; right: calc(100% + 4px); top: 11px; white-space: nowrap; pointer-events: none;
    padding: 6px 10px; border-radius: 6px; background: #fff; color: #111; font: 600 12px/1.2 Inter, sans-serif; text-shadow: none;
    opacity: 0; transition: opacity .15s;
  }
  .act:hover::after, .act:focus-visible::after { opacity: 1; transition-delay: .25s; }
}

/* Phones: no room beside the reel, so it goes full screen and the buttons float over its right edge. */
@media (max-width: 600px) {
  #story { padding: var(--safe-top) 0 var(--safe-bottom); gap: 0; }
  #story::before { display: none; }
  #reel { flex: 1; width: auto; border: 0; border-radius: 0; }
  #actions { position: absolute; right: 2px; bottom: calc(var(--safe-bottom) + 20px); }
}

@media (prefers-reduced-motion: reduce) {
  .slide.active .card, .pack, .hint, .front::after, .fan i, .act.busy svg { animation: none; }
}
