/* Slap Laugh — game UI in the landing design language.
   Cream paper, ink, one loud red. Passion One for display, Instrument Sans for body. */
:root {
  --paper: #FFFDFB;
  --card: #FDF3EF;
  --card-2: #FBEAE4;
  --ink: #221512;
  --muted: #6B4F48;
  --faint: #B08A80;
  --red: #E23B2E;
  --red-deep: #C4271C;
  --go: #1FA34A;
  --go-deep: #157A37;
  --go-soft: #E2F6E9;
  --line: #F3D8CF;
  --line-strong: #221512;
  --radius: 22px;
  --display: 'Passion One', 'Arial Black', sans-serif;
  --body: 'Instrument Sans', -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}

@keyframes wob { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes popIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 251, 0.92);
  position: sticky;
  top: 0;
  z-index: 45;
  backdrop-filter: blur(8px);
}
.logo {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.logo .brand-red { color: var(--red); }
.logo img { width: 26px; height: 26px; animation: wob 3s ease-in-out infinite; }
.rec-dot {
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
}
.top-code {
  font-family: var(--display);
  letter-spacing: 0.22em;
  color: var(--red-deep);
  background: var(--card-2);
  border-radius: 999px;
  padding: 0.15rem 0.75rem 0.25rem;
  font-size: 1.05rem;
}

main { max-width: 480px; margin: 0 auto; padding: 0 1.2rem 3rem; }
.screen { padding-top: 0.6rem; }
.screen.center { text-align: center; padding-top: 3.2rem; }

h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin: 1rem 0 0.7rem;
  text-wrap: balance;
}
h1 .wavy { color: var(--red); text-decoration: underline wavy var(--red) 4px; text-underline-offset: 8px; }
.sub { color: var(--muted); margin: 0 0 1.2rem; }
.muted { color: var(--muted); }
.eyebrow {
  display: inline-block;
  background: var(--card-2);
  color: var(--red-deep);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  transform: rotate(-1deg);
  margin: 1rem 0 0.5rem;
}
.section-title {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 1.4rem 0 0.6rem;
}

.field { display: block; margin: 0 0 1rem; }
.field span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
input {
  width: 100%;
  background: var(--paper);
  border: 3px solid var(--line-strong);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  font-size: 1.05rem;
  font-family: var(--body);
}
input::placeholder { color: #C9A9A2; }
input:focus-visible { outline: none; border-color: var(--red); box-shadow: 0 0 0 4px var(--card-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--red);
  border-color: var(--red);
  color: var(--paper);
  box-shadow: 4px 4px 0 var(--line-strong);
}
.btn.primary:not(:disabled):hover { transform: translate(-2px, -2px) rotate(-1deg); box-shadow: 7px 7px 0 var(--line-strong); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); font-family: var(--body); font-size: 0.95rem; text-transform: none; letter-spacing: 0; font-weight: 600; }
.btn.big { padding: 1.05rem; font-size: 1.5rem; }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.btn:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }

.join-row { display: flex; gap: 0.7rem; }
.join-row input {
  flex: 1;
  font-family: var(--display);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-align: center;
  font-size: 1.2rem;
}
.join-row .btn { width: auto; padding-inline: 1.5rem; }
.join-row input::placeholder { letter-spacing: 0.08em; font-size: 0.85rem; font-family: var(--body); }

.big-code {
  font-family: var(--display);
  font-size: 3.4rem;
  letter-spacing: 0.3em;
  font-weight: 900;
  color: var(--red);
  background: var(--paper);
  border: 3px dashed var(--red);
  border-radius: 26px;
  text-align: center;
  padding: 0.6rem 0 0.7rem 0.3em;
  margin-bottom: 1.2rem;
  transform: rotate(-0.6deg);
}

.player-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.player-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 0.65rem 0.95rem;
}
.player-row .who { font-weight: 700; }
.player-row .role { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.player-row.off { opacity: 0.5; }
.badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  color: var(--faint);
  text-transform: uppercase;
}
.badge.ok { color: var(--red-deep); border-color: var(--red); background: var(--card-2); }

/* One card at a time — swipe sideways to browse. */
.script-list {
  display: flex;
  gap: 0.8rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0.3rem 0.2rem 0.6rem;
  -webkit-overflow-scrolling: touch;
}
.script-card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 26px;
  padding: 1.2rem 1.25rem;
  cursor: pointer;
  color: var(--ink);
  transform: rotate(-0.5deg);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.script-card:nth-child(even) { transform: rotate(0.5deg); }
.script-card .t { font-family: var(--display); font-weight: 900; font-size: 1.55rem; text-transform: uppercase; line-height: 1.05; }
.script-card .d { color: var(--red-deep); font-weight: 600; font-size: 0.92rem; margin-top: 0.15rem; }
.script-card .p { font-size: 0.94rem; line-height: 1.5; margin-top: 0.7rem; color: var(--muted); }
.script-card .r { color: var(--muted); font-size: 0.85rem; margin-top: 0.7rem; }
.script-card .n {
  display: inline-block;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--red-deep);
  background: var(--card-2);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  margin-top: 0.8rem;
}
.script-card.selected { border: 3px solid var(--red); box-shadow: 5px 6px 0 var(--card-2); transform: rotate(0deg); }
.script-card.unavailable { opacity: 0.55; }
.script-card.unavailable .pick-state { color: var(--faint); }
.script-card .pick-state { margin-top: 0.6rem; font-weight: 700; font-size: 0.9rem; color: var(--red); min-height: 1.2em; }
.swipe-hint { text-align: center; color: var(--faint); font-size: 0.78rem; margin: 0.2rem 0 0.8rem; }
#btn-start-setup { margin-top: 1rem; }
#screen-wrap .btn { margin-bottom: 0.65rem; }
.call-status { font-size: 0.85rem; color: var(--muted); margin-top: 0.6rem; }
.call-status.ok { color: var(--red-deep); font-weight: 700; }

.opt-grid { display: flex; flex-direction: column; gap: 0.55rem; }
.opt {
  text-align: left;
  background: var(--paper);
  border: 2px solid var(--line);
  color: var(--ink);
  border-radius: 16px;
  padding: 0.75rem 0.95rem;
  font-size: 0.97rem;
  font-family: var(--body);
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}
.opt.selected {
  border: 3px solid var(--red);
  background: var(--card-2);
  font-weight: 700;
  box-shadow: 3px 3px 0 var(--line-strong);
  transform: rotate(-0.5deg);
}
.roll-result {
  font-family: var(--display);
  font-size: 1.3rem;
  background: var(--card-2);
  border: 3px dashed var(--red);
  border-radius: 16px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.7rem;
  text-align: center;
  transform: rotate(-0.6deg);
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.roll-buttons { display: flex; gap: 0.6rem; }
.roll-buttons .btn { flex: 1; }

.notice {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}
.notice p { color: var(--muted); font-size: 0.87rem; margin: 0.6rem 0 0; }

/* Buttons with a title + subtitle stack vertically. */
.choice-btn { flex-direction: column; gap: 0.15rem; padding: 0.95rem 1.1rem; border-radius: 22px; }
.choice-btn .bt { font-size: 1.35rem; }
.choice-btn small { font-family: var(--body); font-weight: 500; font-size: 0.8rem; opacity: 0.9; line-height: 1.35; text-transform: none; letter-spacing: 0; }

.field-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
.gender-row { display: flex; gap: 0.5rem; }
.gender-row .opt { flex: 1; text-align: center; border-radius: 999px; }

.home-label {
  display: inline-block;
  background: var(--card-2);
  color: var(--red-deep);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  transform: rotate(-1deg);
  margin: 1.5rem 0 0.6rem;
}
.hot-text { color: var(--go-deep); font-weight: 800; }
.ok-text { color: var(--go-deep); font-weight: 800; }

#step-body { min-height: 46vh; display: flex; flex-direction: column; justify-content: center; margin-bottom: 1.2rem; }
.step-title {
  font-family: var(--display);
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1.02;
  margin: 0 0 0.7rem;
  text-wrap: balance;
}
.step-text { font-size: 1.08rem; line-height: 1.55; color: var(--ink); }
.step-note { color: var(--muted); font-size: 0.9rem; margin-top: 0.8rem; }
.role-brief { font-size: 1.05rem; line-height: 1.55; margin: 0.2rem 0 0; }

.role-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 26px;
  padding: 1.3rem 1.25rem;
  margin-bottom: 1.2rem;
  transform: rotate(-0.5deg);
}
.role-name {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1;
  margin: 0 0 0.3rem;
  color: var(--red);
}
.role-energy {
  display: inline-block;
  background: var(--card-2);
  color: var(--red-deep);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  margin: 0.2rem 0 0.4rem;
  transform: rotate(-0.8deg);
}
.role-directions { margin: 0.9rem 0; display: flex; flex-direction: column; gap: 0.5rem; }
.role-directions .dir {
  background: var(--card-2);
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
}
.role-tip { color: var(--muted); font-size: 0.9rem; margin: 0.9rem 0 0; }

.up-next {
  text-align: center;
  color: var(--red-deep);
  background: var(--card-2);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-weight: 700;
  margin: 0 0 0.8rem;
  animation: popIn 0.25s ease both;
}
.beat-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 26px;
  padding: 1.5rem 1.3rem;
  min-height: 38vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.beat-card.my-turn {
  background: var(--paper);
  border: 4px solid var(--go);
  box-shadow: 6px 8px 0 var(--go-soft), 0 0 42px rgba(31, 163, 74, 0.35);
}
.beat-card.my-turn .beat-speaker { background: var(--go); color: var(--paper); }
.beat-speaker {
  align-self: flex-start;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red-deep);
  background: var(--card-2);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  margin: 0 0 0.9rem;
}
.beat-line {
  font-size: clamp(1.45rem, 6.2vw, 2.05rem);
  font-weight: 700;
  line-height: 1.32;
  margin: 0;
  text-wrap: balance;
}
.beat-line.waiting { color: var(--faint); font-weight: 500; font-size: 1.2rem; }
.beat-direction { margin: 1rem 0 0; color: var(--red-deep); font-size: 0.95rem; font-style: italic; }
.btn.go { background: var(--go); border-color: var(--go); color: var(--paper); box-shadow: 4px 4px 0 var(--line-strong); }

.perform-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.8rem;
}
.standing {
  background: var(--card);
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.mute-btn {
  position: fixed;
  left: 0.9rem;
  bottom: 0.9rem;
  z-index: 41;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--line-strong);
}
.mute-btn.muted { border-color: var(--red); color: var(--red); }

.flip-btn {
  position: fixed;
  right: 0.9rem;
  bottom: calc(0.9rem + 78px);
  z-index: 41;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.countdown {
  font-family: var(--display);
  font-size: 9rem;
  font-weight: 900;
  color: var(--red);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 1.2rem 0;
  animation: wob 1s ease-in-out infinite;
  text-shadow: 6px 6px 0 var(--card-2);
}

.rec-indicator {
  position: fixed;
  top: 0.9rem;
  right: 1.1rem;
  z-index: 46;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
  background: var(--paper);
  border: 2px solid var(--red);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.rec-indicator .rec-dot { animation: blink 1.2s infinite; }

.playback { width: 100%; border-radius: 22px; border: 3px solid var(--line-strong); margin-bottom: 1rem; background: #000; }

/* Export render progress */
.render-bar { margin: 0.9rem 0; }
.render-track {
  height: 18px;
  border: 3px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  overflow: hidden;
}
.render-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: repeating-linear-gradient(-45deg, var(--red), var(--red) 12px, var(--red-deep) 12px, var(--red-deep) 24px);
  background-size: 34px 34px;
  animation: renderStripes 0.9s linear infinite;
  transition: width 0.9s ease;
}
@keyframes renderStripes { from { background-position: 0 0; } to { background-position: 34px 0; } }
.render-label { text-align: center; color: var(--muted); font-weight: 600; font-size: 0.9rem; margin: 0.5rem 0 0; }

#camera-preview {
  position: fixed;
  right: 0.9rem;
  bottom: 0.9rem;
  width: 108px;
  border-radius: 14px;
  border: 3px solid var(--line-strong);
  z-index: 40;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) rotate(-1deg);
  background: var(--ink);
  color: var(--paper);
  border-radius: 14px;
  padding: 0.75rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  max-width: 90vw;
  z-index: 60;
  box-shadow: 4px 4px 0 var(--card-2);
}
