/* Swap --font-display for a local font (e.g. Pricedown) — see README. */
:root {
  --font-display: 'Bowlby One', Impact, 'Arial Black', sans-serif;
  --font-script: 'Pacifico', 'Brush Script MT', cursive;
  --font-body: 'Rubik', system-ui, sans-serif;

  --ink: #140726;
  --night: #24103d;
  --pink: #ff3d8b;
  --orange: #ff9f43;
  --sun: #ffd166;
  --teal: #2de2e6;
  --paper: #fff7f0;
  --text: #fff7f0;
  --muted: #cbb7e0;
  --siren-red: #ff2e4d;
  --siren-blue: #2e7bff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--ink);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
[hidden] { display: none !important; }

/* ---------- Sunset backdrop ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: linear-gradient(180deg, #140726 0%, #3a0d55 42%, #b8246b 74%, #ff8a3d 100%);
}
.bg::before { /* striped retro sun */
  content: ''; position: absolute; left: 50%; bottom: -22vmin;
  width: 86vmin; height: 86vmin; transform: translateX(-50%); border-radius: 50%;
  background: linear-gradient(180deg, var(--sun), var(--pink));
  -webkit-mask: linear-gradient(#000 45%, transparent 45%), repeating-linear-gradient(180deg, #000 0 16px, transparent 16px 24px);
  mask: linear-gradient(#000 45%, transparent 45%), repeating-linear-gradient(180deg, #000 0 16px, transparent 16px 24px);
  opacity: .5;
}
.bg::after { /* neon floor grid */
  content: ''; position: absolute; left: -50%; right: -50%; bottom: 0; height: 32vh;
  background:
    repeating-linear-gradient(90deg, rgba(45,226,230,.35) 0 2px, transparent 2px 60px),
    repeating-linear-gradient(0deg, rgba(45,226,230,.35) 0 2px, transparent 2px 40px);
  transform: perspective(300px) rotateX(60deg); transform-origin: bottom;
  opacity: .4;
}

/* ---------- Layout ---------- */
.screen {
  display: none; flex-direction: column; gap: 18px;
  max-width: 520px; min-height: 100dvh; margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.screen.active { display: flex; }
#screen-gate { justify-content: center; }

.panel {
  background: rgba(20, 7, 38, .72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,.12); border-radius: 18px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
h2 { font-family: var(--font-display); font-weight: 400; font-size: 20px; text-transform: uppercase; letter-spacing: .5px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center-text { text-align: center; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row > .btn.small { flex: 0 0 auto; }

/* ---------- Logo ---------- */
.hero { text-align: center; }
.logo {
  font-family: var(--font-display); font-weight: 400; text-transform: uppercase;
  font-size: clamp(64px, 22vw, 112px); line-height: .88; text-align: center; letter-spacing: 1px;
  background: linear-gradient(180deg, var(--sun) 10%, var(--orange) 45%, var(--pink) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px var(--ink);
  filter: drop-shadow(0 5px 0 var(--ink)) drop-shadow(0 0 26px rgba(255,61,139,.55));
}
.logo.mid { font-size: clamp(40px, 13vw, 60px); }
.logo.tiny { font-size: 26px; -webkit-text-stroke: 1px var(--ink); filter: drop-shadow(0 3px 0 var(--ink)); }
.tagline {
  font-family: var(--font-script); font-size: 26px; color: var(--teal);
  text-shadow: 0 0 12px rgba(45,226,230,.8); transform: rotate(-5deg); margin-top: 2px;
}
.stars-row { font-size: 30px; letter-spacing: 8px; color: var(--sun); text-shadow: 0 3px 0 var(--ink); margin-bottom: 6px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  font-family: var(--font-display); font-size: 19px; text-transform: uppercase; letter-spacing: .5px;
  border: 3px solid var(--ink); border-radius: 14px; padding: 13px 16px;
  background: var(--sun); color: var(--ink); box-shadow: 0 5px 0 var(--ink);
  cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.pink { background: var(--pink); color: #fff; }
.btn.teal { background: var(--teal); }
.btn.ghost { background: transparent; color: var(--text); border-color: rgba(255,255,255,.35); box-shadow: none; }
.btn.small { font-size: 15px; padding: 9px 14px; }
.btn.big { font-size: 24px; padding: 18px; }
.btn:disabled { opacity: .4; pointer-events: none; }

input {
  min-width: 0; padding: 12px 14px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: var(--text); font-size: 17px;
}
input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45,226,230,.25); }

.player-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.player-list li {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px;
  border-radius: 999px; background: rgba(255,61,139,.18); border: 2px solid var(--pink); font-weight: 600;
}
.player-list button { border: 0; background: rgba(255,255,255,.15); color: var(--text); width: 26px; height: 26px; border-radius: 50%; cursor: pointer; }

.seg { display: flex; background: rgba(255,255,255,.08); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; border: 0; border-radius: 9px; padding: 10px; cursor: pointer;
  font-family: var(--font-display); text-transform: uppercase; background: transparent; color: var(--muted);
}
.seg button.on { background: var(--teal); color: var(--ink); }
.seg button:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- Game ---------- */
.game-top { display: flex; align-items: center; justify-content: space-between; }
.players { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 8px; scrollbar-width: none; }
.players::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 12px; border-radius: 14px; cursor: pointer; position: relative;
  background: rgba(20,7,38,.75); border: 2px solid rgba(255,255,255,.15); color: var(--text);
}
.chip .nm { font-weight: 800; font-size: 14px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .st { font-size: 13px; letter-spacing: 1px; color: rgba(255,255,255,.25); }
.chip .st .on { color: var(--sun); text-shadow: 0 0 6px rgba(255,209,102,.8); }
.chip.current { border-color: var(--sun); box-shadow: 0 0 14px rgba(255,209,102,.5); }
.chip.hot { animation: siren .6s steps(1) infinite; }
.chip .minus {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font-weight: 800; font-size: 13px; line-height: 1;
  cursor: pointer; display: none;
}
.chip.has-stars .minus { display: block; }
.chip.bump { animation: bump .4s ease-out; }
@keyframes siren {
  0%   { border-color: var(--siren-red);  box-shadow: 0 0 16px var(--siren-red); }
  50%  { border-color: var(--siren-blue); box-shadow: 0 0 16px var(--siren-blue); }
}
@keyframes bump { 40% { transform: scale(1.15); } }

.law {
  font-size: 14px; padding: 10px 12px; border-radius: 12px;
  background: rgba(45,226,230,.12); border: 2px dashed var(--teal);
}
.law .law-tag { font-family: var(--font-display); font-weight: 400; color: var(--teal); text-transform: uppercase; margin-right: 6px; }
.law .name { color: var(--sun); }

.card {
  --type: var(--pink);
  background: var(--paper); color: var(--ink);
  border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink), 0 0 40px rgba(255,61,139,.35);
  padding: 20px; min-height: 280px; display: flex; flex-direction: column; gap: 16px;
  position: relative; overflow: hidden;
}
.card::after { /* corner stripe */
  content: ''; position: absolute; right: -40px; top: 18px; width: 160px; height: 14px;
  background: var(--type); transform: rotate(35deg); opacity: .9;
}
.card.deal { animation: deal .4s cubic-bezier(.2,.9,.3,1.3); }
@keyframes deal { from { transform: translateY(30px) rotate(-4deg) scale(.92); opacity: 0; } }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-type {
  font-family: var(--font-display); text-transform: uppercase; font-size: 15px; letter-spacing: .5px;
  background: var(--type); color: #fff; padding: 5px 12px; border-radius: 9px; border: 2px solid var(--ink);
}
.turn { font-family: var(--font-script); font-size: 20px; color: var(--ink); }
.card-text { font-size: 23px; font-weight: 600; line-height: 1.35; flex: 1; display: flex; align-items: center; }
.card-text .name { font-weight: 800; color: var(--pink); }
.card-text .hl { font-weight: 800; color: var(--type); }

.t-rule   { --type: #0b8f9c; }
.t-dare   { --type: #f97316; }
.t-group  { --type: #7b2ff7; }
.t-wanted { --type: #e11d48; }
.t-clean  { --type: #16a34a; }
.t-versus { --type: #db2777; }

.actions { display: flex; gap: 10px; margin-top: auto; }
.actions .btn { flex: 1; }

/* ---------- Busted overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 2, 20, .88); backdrop-filter: grayscale(1) blur(4px); -webkit-backdrop-filter: grayscale(1) blur(4px);
  animation: fade .3s;
}
.bust-box { max-width: 440px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 16px; }
.bust-title {
  font-family: var(--font-display); text-transform: uppercase; font-size: clamp(64px, 20vw, 110px); line-height: 1;
  color: var(--siren-red); -webkit-text-stroke: 2px #000; text-shadow: 0 6px 0 #000;
  animation: slam .5s cubic-bezier(.2,1.6,.4,1);
}
.bust-title.wasted { color: #e5e5e5; }
.bust-name { font-family: var(--font-script); font-size: 28px; color: var(--sun); }
.bust-text { font-size: 20px; font-weight: 600; line-height: 1.4; }
.bust-text .name { color: var(--pink); }
@keyframes slam { from { transform: scale(2.4) rotate(-8deg); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Home & lobby ---------- */
.small-stars { font-size: 22px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.2); }
.code-input { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 6px; text-align: center; font-size: 22px; }
.code-input::placeholder { letter-spacing: 4px; color: rgba(255,255,255,.3); }

.code-panel { align-items: center; text-align: center; }
.room-code {
  font-family: var(--font-display); font-size: clamp(56px, 18vw, 84px); line-height: 1; letter-spacing: 10px; padding-left: 10px;
  background: linear-gradient(180deg, var(--sun), var(--orange) 50%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 2px var(--ink); filter: drop-shadow(0 4px 0 var(--ink));
  user-select: all;
}
.lobby-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lobby-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,.06); font-weight: 600;
}
.lobby-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.25); flex: 0 0 auto; }
.dot.on { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.tag {
  font-family: var(--font-display); font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 6px; background: var(--sun); color: var(--ink);
}
.tag.you { background: var(--teal); }

.head-btns { display: flex; gap: 8px; }
.chip.me .nm::after { content: ' (you)'; font-weight: 400; color: var(--teal); }
.chip.away { opacity: .5; }
.waiting {
  flex: 1; align-self: stretch; display: flex; align-items: center; padding: 0 14px; font-size: 16px;
  color: var(--muted); background: rgba(20,7,38,.8); border-radius: 14px;
}
.waiting b { color: var(--text); }
.busy #actions .btn, .busy #bust-ok, .busy .chip { opacity: .6; pointer-events: none; }

.conn {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30; text-align: center;
  padding: calc(6px + env(safe-area-inset-top)) 16px 6px; font-weight: 600; font-size: 14px;
  background: var(--siren-red); color: #fff;
}

/* ---------- Loading-screen lobby ---------- */
.loading-screen { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.loading-screen > :not(.ls-art):not(.ls-tip) { position: relative; z-index: 1; }
.ls-art { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #0b0414; }
.ls-slide {
  position: absolute; top: -2vh; left: -3%; right: -3%; height: 72vh; background: center 30% / cover no-repeat;
  opacity: 0; transition: opacity 1.4s ease; will-change: transform, opacity;
}
.ls-slide.on { opacity: 1; }
.ls-slide.kb { animation: kenburns 9s ease-out forwards; }
.ls-slide.kb.alt { animation-name: kenburns-alt; }
@keyframes kenburns     { from { transform: scale(1.0) translate(1.5%, 0); }   to { transform: scale(1.08) translate(-1.5%, -1%); } }
@keyframes kenburns-alt { from { transform: scale(1.08) translate(-1.5%, -1%); } to { transform: scale(1.0) translate(1.5%, 0); } }
@media (min-aspect-ratio: 4/5) {
  /* wide screens: show the whole portrait artwork above the centered column */
  .ls-slide { background-size: contain; background-position: center top; }
}
.ls-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,4,20,.4) 0%, rgba(11,4,20,0) 12%, rgba(11,4,20,0) 44%, rgba(11,4,20,.55) 56%, #0b0414 70%);
}
.ls-caption {
  min-height: 50vh; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  transition: opacity .5s;
}
.ls-caption.fade { opacity: 0; }
.ls-caption.empty .ls-role, .ls-caption.empty .ls-line { display: none; }
.ls-role {
  font-family: var(--font-display); text-transform: uppercase; line-height: .95; color: #fff;
  font-size: clamp(32px, 10vw, 46px); transform: rotate(-2deg); transform-origin: left;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink);
}
.ls-line { font-family: var(--font-script); font-size: 20px; color: var(--sun); text-shadow: 2px 2px 0 var(--ink); }
.ls-tip {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(5, 2, 10, .88); border-top: 2px solid rgba(255,255,255,.08);
  font-size: 14px; line-height: 1.35;
}
.ls-tip-text { flex: 1; max-width: 520px; margin: 0 auto; transition: opacity .4s; }
.ls-tip-text b { font-family: var(--font-display); font-weight: 400; text-transform: uppercase; color: var(--sun); margin-right: 8px; }
.ls-spinner {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.15); border-top-color: var(--pink); border-right-color: var(--sun);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Music button ---------- */
.screen { position: relative; }
.music-slot { display: inline-flex; }
#screen-home { padding-top: calc(64px + env(safe-area-inset-top)); }
.music-slot.floating { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; z-index: 2; }
.music-slot:empty { display: none; }
.music-btn { width: 44px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.eq { display: flex; align-items: flex-end; gap: 3px; height: 18px; }
.eq i { width: 4px; height: 4px; border-radius: 2px; background: var(--muted); transition: height .2s; }
.music-ctrls { display: inline-flex; gap: 8px; }
.skip-btn, #unlock-btn { color: var(--text); }
#unlock-btn svg { display: block; width: 20px; height: 20px; }
.unlock-box { width: 100%; max-width: 400px; background: rgba(20,7,38,.96); }
.skip-btn svg { display: block; width: 22px; height: 22px; flex: 0 0 auto; }
.music-btn.on { border-color: var(--teal); }
.music-btn.on.blocked { animation: tap-me 1.2s ease-in-out infinite; }
.music-btn.on.blocked .eq i { animation-play-state: paused; }
@keyframes tap-me { 50% { box-shadow: 0 0 0 4px rgba(45,226,230,.35), 0 0 18px rgba(45,226,230,.6); } }
.music-btn.on .eq i { background: var(--teal); animation: eq .9s ease-in-out infinite alternate; }
.music-btn.on .eq i:nth-child(2) { animation-delay: -.3s; animation-duration: .7s; }
.music-btn.on .eq i:nth-child(3) { animation-delay: -.6s; animation-duration: 1.1s; }
.music-btn.on .eq i:nth-child(4) { animation-delay: -.15s; animation-duration: .8s; }
#music-btn:not(.on)::after { /* mute slash */
  content: ''; position: absolute; width: 26px; height: 2px; background: var(--muted); transform: rotate(-45deg);
}
.music-btn { position: relative; }
@keyframes eq { from { height: 4px; } to { height: 18px; } }

#screen-setup .game-top { gap: 10px; }
#screen-setup .game-top .logo { flex: 1; text-align: center; }
@media (max-width: 460px) {
  #screen-game .game-top .logo, #screen-lobby .game-top .logo { display: none; }
  #screen-game .head-btns, #screen-lobby .head-btns { margin-left: auto; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none; transition: transform .25s, opacity .25s;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px;
  padding: 10px 16px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 5px 0 var(--ink);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
