/* Layout: scene on top and script below on phones, side by side on wide screens.
   One dark look on purpose: it's a nightclub. */
:root {
  --curtain: #1c0b14;
  --velvet: #3a1226;
  --velvet-deep: #26101c;
  --spot: #ffd27a;
  --neon: #ff5d8f;
  --pink: #f54baf;
  --ink: #f6ece4;
  --dim: #c9b3b9;
  --line: #5b2a40;
  --good: #7fe0a6;
  --bad: #ff7a6b;
  --shade: rgba(0, 0, 0, .35);
  --condensed: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --display: "Bowlby One", Impact, "Arial Black", sans-serif;
  --body: "Libre Franklin", system-ui, -apple-system, sans-serif;
  --note: "Courier Prime", "Courier New", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-height: 100%; }
body {
  margin: 0;
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(32px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background-color: var(--curtain);
  background-image:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(255, 210, 122, .2), transparent 70%),
    repeating-linear-gradient(90deg, rgba(58, 18, 38, .55) 0 18px, transparent 18px 36px);
  color: var(--ink);
  font: 16px/1.55 var(--body);
}

button { font-family: inherit; cursor: pointer; }
button:focus-visible, .scene-title:focus-visible { outline: 2px solid var(--spot); outline-offset: 2px; }
.scene-title:focus { outline: none; }

.screen { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

.game-screen { padding-top: 32px; }
.sound {
  position: absolute;
  z-index: 5;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  padding: 6px 10px;
  color: var(--dim);
  background: var(--curtain);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 12px var(--note);
}
.sound[aria-pressed="true"] { color: var(--spot); border-color: var(--spot); }

.row { display: flex; flex-wrap: wrap; gap: 10px; }
.primary, .secondary { padding: 13px 18px; border-radius: 8px; font-size: 15px; font-weight: 800; }
.primary { color: var(--curtain); background: var(--neon); border: 0; }
.secondary { color: var(--ink); background: var(--shade); border: 1px solid var(--line); }
.secondary:hover { border-color: var(--spot); }

.credit, .eyebrow, .label, .progress { font-family: var(--note); color: var(--dim); }
.credit { margin: 0; font-size: 13px; }

/* Title */
.title-screen {
  max-width: 1120px;
  min-height: min(82vh, 680px);
  justify-content: center;
  align-items: flex-start;
  padding: 48px 24px;
  background-position: 65% center;
  background-size: cover;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.logo { max-width: 240px; max-height: 160px; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--spot); }
.marquee, .ending-title {
  margin: 0;
  font: 800 clamp(54px, 9vw, 96px)/.93 var(--condensed);
  letter-spacing: -.01em;
  text-transform: uppercase;
  color: var(--ink);
}
.marquee span { display: block; color: var(--pink); text-shadow: 0 0 30px rgba(245, 75, 175, .3); }
.pitch { margin: 0; max-width: 44ch; font-size: 18px; }
.title-screen .primary, .ending-screen .primary { color: var(--curtain); background: var(--spot); font-size: 16px; padding: 15px 24px; }
.title-screen .primary:hover, .ending-screen .primary:hover { background: #ffe3ac; }

/* Ending */
.ending-screen { max-width: 860px; }
.ending-screen .stage { aspect-ratio: 16 / 7; }
.ending-body { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 8px 0; text-align: center; }
.ending-body .text { align-items: center; }
.ending-body .row { justify-content: center; }
.ending-title { font-size: clamp(45px, 8vw, 75px); text-wrap: balance; }
.ending-title:focus { outline: none; }
.tag { padding: 5px 14px; color: var(--spot); border: 1px solid var(--spot); border-radius: 30px; font-size: 13px; }
.stats { margin: 0; color: var(--spot); font-variant-numeric: tabular-nums; }
.night { width: 100%; max-width: 620px; padding: 12px 16px; text-align: left; border: 1px solid var(--line); border-radius: 7px; }
.night summary { color: var(--spot); font-size: 14px; cursor: pointer; }
.night ol { margin: 10px 0 0; padding-left: 20px; font-size: 14px; }
.night li { padding: 6px 0; }
.night li span { display: block; color: var(--dim); font-family: var(--note); }

.production { margin: 0; font: 700 clamp(18px, 3.4vw, 24px)/1.2 var(--condensed); letter-spacing: .06em; text-transform: uppercase; color: var(--spot); }
.link-button { display: inline-block; text-decoration: none; }
.credit a { color: var(--spot); }
.promo, .vip, .share-card { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 620px; padding: 22px 18px; border: 1px solid var(--line); border-radius: 10px; }
.promo { background: linear-gradient(180deg, var(--velvet), var(--velvet-deep)); }
.promo h2 { margin: 0; font: 800 clamp(32px, 6vw, 46px)/1 var(--condensed); text-transform: uppercase; color: var(--pink); text-wrap: balance; }
.promo p, .vip p { margin: 0; }
.promo-live { font-size: 20px; font-weight: 800; }
.promo .row, .share-card .row { justify-content: center; }
.share-card img { width: 100%; max-width: 420px; border-radius: 8px; }
.vip-form { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; width: 100%; }
.vip-form label { flex-basis: 100%; font-size: 13px; color: var(--dim); }
.vip-form input { flex: 1 1 220px; min-width: 0; padding: 13px 14px; color: var(--ink); background: var(--shade); border: 1px solid var(--line); border-radius: 8px; font: 16px var(--body); }

/* Character select */
.select-screen, .gallery-screen { max-width: 720px; padding-top: 32px; }
.heading { margin: 0; font: 400 clamp(24px, 6vw, 34px)/1.15 var(--display); color: var(--spot); text-wrap: balance; }
.subheading { margin: 8px 0 0; font: 400 18px var(--display); color: var(--spot); }
.rookies { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rookie-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  color: var(--ink);
  background: var(--shade);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 800;
}
.rookie-card:hover { border-color: var(--spot); }
.rookie-art { display: block; aspect-ratio: 2 / 3; background-repeat: no-repeat; }

/* HUD */
.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 12px;
  background: var(--shade);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.hud-laughs { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-stat { display: flex; align-items: baseline; gap: 6px; }
.hud-stat:last-child { margin-left: auto; }
.hud-stat strong { font: 700 16px var(--note); font-variant-numeric: tabular-nums; color: var(--spot); }
.label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.bars { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.bars i { height: 14px; border-radius: 2px; background: #3b1b2a; transform-origin: bottom; transition: background .3s, transform .3s; }
.bars i.on { background: var(--good); }
.bars i.on.hot { background: var(--spot); }
.bars i.on.max { background: var(--neon); }
#pay.dropping { color: var(--bad); }

/* Scene */
.layout { display: flex; flex-direction: column; gap: 16px; }
.stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background-color: var(--velvet-deep);
  background-position: center;
  background-size: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: background-image .35s ease;
}
.stage.impact { animation: shake .45s ease-out; }
.stage.impact::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: var(--ink);
  opacity: 0;
  animation: flash .3s ease-out;
}
.char {
  position: absolute;
  bottom: 0;
  height: 92%;
  aspect-ratio: 2 / 3;
  background-repeat: no-repeat;
  transform: translateX(-50%);
  animation: enter .35s ease;
}
.pos-left { left: 20%; }
.pos-center { left: 50%; }
.pos-right { left: 80%; }
.char.speaking { animation: enter .35s ease, bounce .5s ease .1s 2; }

.panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 16px;
  background: linear-gradient(180deg, var(--velvet), var(--velvet-deep));
  border: 1px solid var(--line);
  border-radius: 10px;
}
.scene-title { margin: 0; font: 400 22px/1.2 var(--display); color: var(--spot); text-wrap: balance; }
.text { display: flex; flex-direction: column; gap: 10px; max-width: 62ch; }
.text p { margin: 0; }
.text .say {
  padding: 8px 12px;
  font-family: var(--note);
  color: var(--spot);
  background: rgba(0, 0, 0, .3);
  border-left: 3px solid var(--neon);
  border-radius: 0 4px 4px 0;
}
.recap { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.recap p { margin: 0; max-width: 62ch; }
.recap .say {
  padding: 8px 12px;
  font-family: var(--note);
  color: var(--spot);
  background: rgba(0, 0, 0, .3);
  border-left: 3px solid var(--neon);
  border-radius: 0 4px 4px 0;
}
.recap-title { font: 400 15px var(--display); color: var(--neon); }
.who { color: var(--spot); font-weight: 800; }
.choices small { display: block; margin-top: 3px; color: var(--dim); font-size: 13px; font-weight: 400; }
.pocket { display: flex; flex-wrap: wrap; gap: 8px; }
.pocket span { padding: 4px 10px; color: var(--spot); background: rgba(255, 210, 122, .06); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.feedback { align-self: flex-start; padding: 5px 10px; border-radius: 4px; font: 14px var(--note); }
.feedback.up { color: var(--good); background: rgba(127, 224, 166, .1); }
.feedback.down { color: var(--bad); background: rgba(255, 122, 107, .1); }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choices button {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 13px 16px;
  color: var(--ink);
  background: var(--shade);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 600 16px/1.35 var(--body);
  text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
}
.choices button:hover { border-color: var(--spot); background: rgba(255, 210, 122, .08); }
.choices button:active { transform: translateY(1px); }
.k { flex: none; font: 400 14px var(--display); color: var(--neon); }

/* Gallery tags */
.pay-tag { padding: 3px 9px; color: var(--curtain); background: var(--neon); border-radius: 3px; font: 700 13px var(--note); }
.pay-tag.locked { color: var(--dim); background: var(--shade); border: 1px dashed var(--line); }

/* Gallery */
.progress { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.ending-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  min-height: 112px;
  padding: 12px;
  background-color: var(--velvet);
  background-position: center;
  background-size: cover;
  border: 1px solid var(--spot);
  border-radius: 8px;
}
.ending-card strong { font: 400 15px/1.2 var(--display); color: var(--spot); }
.ending-card span { font: 13px var(--note); color: var(--dim); }
.ending-card.locked { background-color: var(--shade); border: 1px dashed var(--line); }
.ending-card.locked strong { color: var(--dim); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }

/* Motion */
.fade { animation: fade .35s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-12px, 4px) rotate(-1deg); }
  35% { transform: translate(10px, -4px) rotate(1deg); }
  55% { transform: translate(-7px, 2px); }
  75% { transform: translate(4px, -1px); }
}
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5%); }
}
@media (prefers-reduced-motion: reduce) {
  .fade, .char, .char.speaking, .stage.impact, .stage.impact::after { animation: none; }
  .bars i, .stage, .choices button { transition: none; }
}

/* Wide screens: scene and script side by side */
@media (min-width: 900px) {
  .layout { flex-direction: row; align-items: flex-start; }
  .stage { flex: 1.5 1 0; min-width: 0; position: sticky; top: 16px; }
  .panel { flex: 1 1 0; }
  .hud-laughs { flex: 1 1 0; }
  .hud-stat:last-child { margin-left: 0; }
}
