@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@500;600&family=Anton&family=UnifrakturCook:wght@700&family=Source+Serif+4:ital,wght@0,400;0,600;1,400&display=swap");

/* Paparazzi: a red carpet at night. The scene is one Canvas 2D (#scene, transparent above the theater roofline);
   the searchlights are plain CSS elements behind it, so they cost no draw calls. */
:root {
  --font: "Geist", system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ink: #f1ebe0;
  --panel: rgba(18, 14, 24, 0.78);
  --line: rgba(255, 226, 160, 0.2);
  --gold: #e9c46a;
  --hor: 220px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  -webkit-tap-highlight-color: transparent; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none;
}
body {
  font-family: var(--font); color: var(--ink); touch-action: none; background: #07060d;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* searchlight beams: pure compositor animation */
.sky {
  position: fixed; left: 0; right: 0; top: 0; height: var(--hor); z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(60% 70% at 50% 100%, rgba(120, 80, 140, 0.32), transparent 70%),
    linear-gradient(180deg, #04050c 0%, #0a0b1f 58%, #1c1432 100%);
}
.sky.is-off { display: none; }
.beam {
  position: absolute; bottom: -6px; left: var(--bx); width: var(--bw); height: 230%;
  transform-origin: 50% 100%; transform: translateX(-50%) rotate(var(--a0));
  background: linear-gradient(to top, rgba(214, 230, 255, 0.62), rgba(214, 230, 255, 0.2) 38%, rgba(214, 230, 255, 0.05) 78%, transparent);
  clip-path: polygon(46% 100%, 54% 100%, 100% 0, 0 0);
  mix-blend-mode: screen; filter: blur(1.5px); will-change: transform;
  animation: sweep var(--dur) ease-in-out infinite alternate;
}
.b1 { --bx: 18%; --bw: 34vmin; --a0: -38deg; --a1: 22deg; --dur: 9s; }
.b2 { --bx: 40%; --bw: 28vmin; --a0: 30deg; --a1: -26deg; --dur: 12s; animation-delay: -4s; }
.b3 { --bx: 66%; --bw: 32vmin; --a0: -20deg; --a1: 40deg; --dur: 10.5s; animation-delay: -7s; }
.b4 { --bx: 88%; --bw: 26vmin; --a0: 34deg; --a1: -30deg; --dur: 13s; animation-delay: -2s; }
@keyframes sweep { from { transform: translateX(-50%) rotate(var(--a0)); } to { transform: translateX(-50%) rotate(var(--a1)); } }

canvas { display: block; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#scene { position: fixed; inset: 0; z-index: 1; cursor: crosshair; }

/* the row up top: the counter, the front page button, share */
.bar {
  position: fixed; z-index: 30; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%);
  display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; max-width: calc(100vw - 20px);
}
.counter {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 11px; border-radius: 10px;
  color: #ffe9b0; background: linear-gradient(180deg, rgba(34, 28, 40, 0.9), rgba(14, 11, 20, 0.9)); border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 6px 16px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.counter svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.counter__l { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.7; }
.counter b {
  font-family: var(--mono); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.02em; min-width: 3.1ch; text-align: right;
  font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(255, 210, 110, 0.55); display: inline-block; transform-origin: 70% 60%;
}
.counter.is-bump b { animation: bump 0.16s ease-out; }
@keyframes bump { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }

.pill, .bar .opt-share.opt-share {
  appearance: none; cursor: pointer; font-family: var(--font);
  display: inline-flex; align-items: center; gap: 7px; height: 36px; margin: 0; padding: 0 14px 0 12px;
  border-radius: 999px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em; opacity: 1;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 16px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}
.pill svg { width: 15px; height: 15px; flex: none; }
.pill:hover, .bar .opt-share.opt-share:hover { background: rgba(40, 30, 50, 0.92); border-color: rgba(255, 226, 160, 0.4); text-decoration: none; }
.pill:active, .bar .opt-share.opt-share:active { transform: scale(0.96); }
.pill:focus-visible, .bar .opt-share.opt-share:focus-visible, .sound-btn:focus-visible { outline: 2px dashed rgba(255, 226, 160, 0.95); outline-offset: 2px; }
.share-host { display: inline-flex; }
.share-host:empty { display: none; }

.sound-btn {
  appearance: none; position: fixed; z-index: 31; cursor: pointer; padding: 0;
  top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.sound-btn:active { transform: scale(0.94); }
.sound-btn[aria-pressed="false"] { opacity: 0.55; }
.sound-btn[aria-pressed="false"] .sound-btn__wave { opacity: 0; }

.frame { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.frame__corner {
  position: absolute; font-size: clamp(0.58rem, 1.2vw, 0.7rem); font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase; color: rgba(255, 236, 205, 0.55);
  white-space: nowrap; font-family: var(--font); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
}
.frame__corner--tl { top: calc(max(12px, env(safe-area-inset-top)) + 13px); left: max(18px, env(safe-area-inset-left)); }
.frame__corner--tr { top: calc(max(12px, env(safe-area-inset-top)) + 13px); right: calc(max(12px, env(safe-area-inset-right)) + 54px); }
.frame__corner--bl { bottom: max(18px, env(safe-area-inset-bottom)); left: max(18px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; border-bottom: 1px solid transparent; transition: color .14s, border-color .14s; }
.frame__corner a:hover { color: #fff1d0; border-bottom-color: rgba(255, 241, 208, 0.5); }

.hint {
  position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 48px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(88vw, 560px); margin: 0; padding: 4px 14px; border-radius: 999px; background: rgba(6, 5, 12, 0.62); text-align: center; z-index: 9; pointer-events: none;
  font-size: 0.62rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; line-height: 1.6;
  color: rgba(255, 236, 205, 0.86); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.95); transition: opacity .8s;
}
.hint.is-hidden, .hint.is-under { opacity: 0; }

/* subtitles, set like film captions */
.cc {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); pointer-events: none; text-align: center;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 44px); max-width: min(86vw, 520px);
  font-family: var(--font); font-size: clamp(0.82rem, 2.3vw, 1rem); font-weight: 600; line-height: 1.3; color: #fff;
  background: rgba(8, 6, 12, 0.74); padding: 6px 12px; border-radius: 6px; opacity: 0; transition: opacity 0.18s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.cc.is-on { opacity: 1; }
.cc:empty { display: none; }

/* tip-jar and fullscreen badges sit bottom-right, off the play area */
.opt-tipjar.opt-tipjar { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; }
.opt-fs.opt-fs { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); right: calc(max(14px, env(safe-area-inset-right)) + 54px); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

/* the front page */
.paperwrap {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 3, 8, 0.74); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  padding: calc(max(12px, env(safe-area-inset-top)) + 96px) 16px calc(max(14px, env(safe-area-inset-bottom)) + 8px);
}
.paperwrap[hidden] { display: none; }
.paperbox { display: flex; flex-direction: column; align-items: center; gap: 12px; max-height: 100%; max-width: 100%; }
#paper {
  display: block; height: auto; width: auto; max-width: min(100%, 440px); max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px);
  aspect-ratio: 3 / 4; border-radius: 3px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 2px 0 rgba(255, 255, 255, 0.5) inset;
  transform: rotate(-1.5deg); animation: slap 0.62s cubic-bezier(.2, .8, .25, 1) both;
}
@keyframes slap {
  0% { transform: rotate(-540deg) scale(0.08); opacity: 0; }
  70% { opacity: 1; }
  100% { transform: rotate(-1.5deg) scale(1); opacity: 1; }
}
.pill--close { padding: 0 18px; flex: none; }

/* phones and small tablets: the bar drops under the corner labels so nothing crowds the name */
@media (max-width: 900px) {
  .bar { top: calc(max(12px, env(safe-area-inset-top)) + 44px); }
  .hint { top: calc(max(12px, env(safe-area-inset-top)) + 92px); }
  .paperwrap { padding-top: calc(max(12px, env(safe-area-inset-top)) + 96px); }
}
@media (max-width: 520px) { .hint { max-width: 96vw; border-radius: 14px; letter-spacing: 0.07em; font-size: 0.6rem; } .pill__t { display: none; } #paperBtn { padding: 0 11px; } }
@media (max-width: 380px) {
  .pill, .bar .opt-share.opt-share { font-size: 0.72rem; padding: 0 11px 0 10px; gap: 6px; }
  .counter { padding: 0 10px 0 9px; gap: 6px; }
  .bar { gap: 6px; }
}
@media (max-width: 345px) { .pill svg, .counter__l { display: none; } }
/* a phone on its side is short: the bar goes back up between the corner labels, the paper sits left and its button right */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 600px) {
  .bar { top: max(10px, env(safe-area-inset-top)); }
  .hint { top: calc(max(10px, env(safe-area-inset-top)) + 46px); }
  .cc { bottom: max(14px, env(safe-area-inset-bottom)); }
  .paperwrap { padding: calc(max(10px, env(safe-area-inset-top)) + 46px) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
  .paperbox { flex-direction: row; align-items: center; gap: 18px; }
  #paper { max-height: calc(100vh - 66px - env(safe-area-inset-top)); max-height: calc(100dvh - 66px - env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) {
  .beam { animation-duration: 40s; }
  #paper { animation: fade 0.3s ease both; }
  .counter.is-bump b { animation: none; }
  .pill, .sound-btn, .hint, .cc { transition: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* the scene has come to rest: stop the searchlights too */
body.is-rest .beam { animation-play-state: paused; }
