@font-face { font-family: Bungee; src: url('/fonts/bungee.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: Outfit; src: url('/fonts/outfit-500.woff2') format('woff2'); font-weight: 400 500; font-display: swap; }
@font-face { font-family: Outfit; src: url('/fonts/outfit-700.woff2') format('woff2'); font-weight: 600 800; font-display: swap; }

:root {
  --ink: #23103a;
  --paper: #fff8ec;
  --pink: #ff4f9a;
  --orange: #ff8a3d;
  --yellow: #ffd83d;
  --lime: #a6f04f;
  --teal: #35e0d0;
  --blue: #5c8dff;
  --violet: #b98cff;
  --bg: var(--pink);
  --accent: var(--yellow);
  --display: Bungee, 'Arial Black', system-ui, sans-serif;
  color-scheme: light;
}

/* Each phase gets its own colour, so the room can tell where it is at a glance. */
body[data-scene='new'], body[data-scene='join'] { --bg: var(--teal); --accent: var(--pink); }
body[data-scene='screen'] { --bg: var(--violet); }
body[data-scene='lobby'] { --bg: var(--orange); }
body[data-scene='cue'] { --bg: var(--blue); }
body[data-scene='play'] { --bg: var(--violet); }
body[data-scene='play'][data-part='dance'] { --bg: var(--lime); --accent: var(--pink); }
body[data-scene='choose'], body[data-scene='discuss'] { --bg: var(--orange); }
body[data-scene='vote'] { --bg: var(--teal); --accent: var(--pink); }
body[data-scene='reveal'] { --bg: var(--yellow); --accent: var(--pink); }

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

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg);
  font: 500 1.0625rem/1.4 Outfit, system-ui, sans-serif;
  transition: background-color .3s;
  -webkit-tap-highlight-color: transparent;
}

main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 12px 16px calc(32px + env(safe-area-inset-bottom));
}
main > div:empty { display: none; }

#top:empty { display: none; }
#top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
}
.mini-logo { font: .9rem var(--display); }
.pill { padding: 3px 12px; border-radius: 99px; background: var(--ink); color: var(--paper); font: 1rem var(--display); letter-spacing: .12em; }

h1, h2, p { margin: 0; text-wrap: balance; }
h2 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font: 1.15rem var(--display); }

.home { padding-top: max(32px, env(safe-area-inset-top)); text-align: center; }
.logo { display: grid; justify-items: center; font: clamp(3.4rem, 20vw, 5.6rem)/.88 var(--display); }
.logo .tilt {
  margin: .08em 0;
  padding: .02em .16em;
  border-radius: .16em;
  background: var(--ink);
  color: var(--yellow);
  transform: rotate(-5deg);
}
.bars { display: flex; align-items: center; justify-content: center; gap: 9px; height: 84px; margin: 18px 0 8px; }
.bars i { width: 17px; height: 60px; border: 3px solid var(--ink); border-radius: 10px; background: var(--teal); animation: bop .96s ease-in-out infinite; }
/* Five move together. One does not. */
.bars .odd { background: var(--yellow); animation: odd 1.3s ease-in-out infinite; }
@keyframes bop { 50% { transform: scaleY(.5); } }
@keyframes odd { 0%, 100% { transform: scaleY(.6) rotate(10deg); } 50% { transform: scaleY(1.2) rotate(-12deg); } }

.title { padding-top: 8px; text-align: center; font: clamp(2.2rem, 11vw, 3.4rem)/1 var(--display); overflow-wrap: anywhere; }
.lede { margin-top: 10px; text-align: center; font-size: 1.22rem; font-weight: 700; }
.eyebrow { margin-bottom: 8px; font-weight: 700; overflow-wrap: anywhere; }
.hint, .fine { font-size: .92rem; }
.hint { margin-top: 8px; text-align: center; }
.fine { margin-top: 12px; }

.card { padding: 18px; border: 3px solid var(--ink); border-radius: 22px; background: var(--paper); box-shadow: 0 6px 0 var(--ink); }
.card + .card, .peek + .card { margin-top: 20px; }

.btn {
  display: block;
  width: 100%;
  min-height: 58px;
  padding: 12px 20px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  font: 1.25rem/1.1 var(--display);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--accent); }
.btn:disabled { background: #e8dff0; color: #62547a; cursor: default; }
.btn.small { width: auto; min-height: 44px; padding: 9px 14px; border-radius: 13px; box-shadow: 0 3px 0 var(--ink); font-size: .85rem; }
.btn + .btn { margin-top: 12px; }
.pulse { animation: pulse .7s ease-in-out infinite; }
@keyframes pulse { 50% { scale: 1.03; } }

.link { min-height: 44px; padding: 6px 4px; border: 0; background: none; color: inherit; font: 700 .98rem Outfit, system-ui, sans-serif; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
#actions, #side > .link { text-align: center; }
#side > .link { display: block; width: 100%; }
.legal { margin-top: 18px; font-size: .9rem; text-align: center; }
.legal a, .policy a { color: inherit; }
.stack { display: grid; gap: 12px; }
.stack > .btn { margin: 0; }
.inline { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.inline > .btn { margin: 0; }
:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }

.howto ol { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.howto li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; counter-increment: step; }
.howto li::before { content: counter(step); display: grid; place-items: center; height: 40px; border: 3px solid var(--ink); border-radius: 50%; background: var(--teal); font: 1.05rem var(--display); }
.howto li:nth-child(2)::before { background: var(--yellow); }
.howto li:nth-child(3)::before { background: var(--lime); }
.howto li:nth-child(4)::before { background: var(--pink); }
.howto li b, .howto li span { display: block; }
.plain { margin: 0 0 14px; padding-left: 22px; }
.plain li { margin-bottom: 6px; }

.field { display: grid; gap: 6px; font-weight: 700; }
.field + .field { margin-top: 16px; }
p + .field { margin-top: 16px; }
.field input:not([type='range']) { width: 100%; min-width: 0; padding: 12px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); font: 700 1.15rem Outfit, system-ui, sans-serif; }
.field .code-input { font: 2.4rem var(--display); letter-spacing: .3em; text-align: center; text-transform: uppercase; }
.range { display: flex; align-items: center; gap: 12px; }
.range input { flex: 1; min-width: 0; height: 36px; accent-color: var(--ink); }

fieldset { min-width: 0; margin: 18px 0 0; padding: 0; border: 0; }
legend { margin-bottom: 8px; padding: 0; font-weight: 700; }
.row { display: grid; gap: 8px; }
.row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.choice > span { display: block; height: 100%; padding: 9px 12px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; }
.row .choice > span { text-align: center; }
.choice b, .choice small { display: block; }
.choice.level > span { padding-inline: 4px; }
.choice.level small { font-size: .78rem; line-height: 1.15; }
.choice.number b { font: 1.7rem var(--display); }
.choice.chip > span { padding: 8px 14px; border-radius: 99px; }
.choice input:checked + span { background: var(--teal); box-shadow: inset 0 0 0 2px var(--ink); }
.choice.chip input:checked + span { background: var(--pink); }
.choice input:focus-visible + span { outline: 4px solid var(--ink); outline-offset: 3px; }
.more summary { min-height: 44px; padding-top: 12px; font-weight: 700; cursor: pointer; }
details.card > summary { padding-top: 0; min-height: 0; }
.card + details.card, details.card + .card { margin-top: 20px; }
fieldset + .more { margin-top: 10px; }

.invite { text-align: center; }
.code { display: flex; justify-content: center; gap: 8px; }
.code span { display: grid; place-items: center; width: 70px; height: 84px; border: 3px solid var(--ink); border-radius: 16px; font: 2.9rem var(--display); background: var(--yellow); }
.code span:nth-child(2) { background: var(--teal); }
.code span:nth-child(3) { background: var(--pink); transform: rotate(6deg); }
.code span:nth-child(4) { background: var(--lime); }
.qr { width: min(210px, 64vw); margin: 16px auto 0; padding: 4px 4px 8px; border: 3px solid var(--ink); border-radius: 18px; background: #fff; }
.qr img { display: block; width: 100%; }
.qr figcaption { font-weight: 700; }
.count { min-width: 38px; padding: 1px 10px; border-radius: 99px; background: var(--ink); color: var(--paper); text-align: center; }

.roster { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.roster li { display: flex; align-items: center; gap: 10px; min-height: 46px; }
.roster .who { flex: 1; min-width: 0; line-height: 1.1; overflow-wrap: anywhere; }
.roster small { display: block; font-size: .8rem; }
.roster .away .avatar { opacity: .35; }
.roster em { padding: 3px 10px; border: 2px solid var(--ink); border-radius: 99px; font-size: .85rem; font-style: normal; font-weight: 700; white-space: nowrap; }
.roster em.yes { background: var(--lime); }
.roster em.guilty-mark { background: var(--pink); }
.place { flex: none; width: 22px; font: 1.1rem var(--display); text-align: center; }
.points { min-width: 46px; font: 1.5rem var(--display); line-height: 1; text-align: center; }
.roster .points small { font: 500 .75rem Outfit, system-ui, sans-serif; }

.kick { width: 44px; height: 44px; border: 0; background: none; color: inherit; font-size: 1.6rem; cursor: pointer; }

.avatar { display: grid; flex: none; place-items: center; width: 42px; height: 42px; border: 3px solid var(--ink); font: normal 1.1rem var(--display); }
.circle { border-radius: 50%; }
.square { border-radius: 10px; }
.arch { border-radius: 22px 22px 8px 8px; }
.leaf { border-radius: 22px 5px; }
.drop { border-radius: 22px 22px 4px 22px; }
.ticket { border-radius: 5px 22px 22px; }
.hue-0 { background: var(--pink); }
.hue-1 { background: var(--teal); }
.hue-2 { background: var(--yellow); }
.hue-3 { background: var(--lime); }
.hue-4 { background: var(--violet); }
.hue-5 { background: var(--orange); }
.hue-6 { background: var(--blue); }

.summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.summary li { padding: 5px 12px; border: 2px solid var(--ink); border-radius: 99px; font-weight: 700; }

.waiting, .problem, .notice { padding: 14px 16px; border: 3px dashed var(--ink); border-radius: 18px; font-weight: 700; text-align: center; }
.waiting.good { border-style: solid; background: var(--lime); }
.waiting + .btn { margin-top: 14px; }
.problem { margin-bottom: 12px; border-style: solid; background: var(--yellow); }
.notice { margin-bottom: 12px; background: var(--paper); }

.soundcheck {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-size: 1.15rem;
  line-height: 1.25;
  text-align: center;
}
.soundcheck b { display: block; font-size: 1.3rem; }

.btn.peek { min-height: 78px; background: var(--ink); color: var(--yellow); }
.peek small { display: block; margin-top: 6px; color: var(--paper); font: 500 .9rem Outfit, system-ui, sans-serif; }
.secret .btn { min-height: 58px; margin-top: 12px; }
.role { margin-bottom: 10px; font-size: 1.3rem; font-weight: 700; line-height: 1.15; }
.song b, .song span { display: block; overflow-wrap: anywhere; }
.song b { font-size: 1.45rem; line-height: 1.1; }
.services { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.service { display: grid; place-items: center; min-height: 46px; padding: 6px; border: 2px solid var(--ink); border-radius: 12px; color: var(--ink); font-weight: 700; text-align: center; text-decoration: none; }
.service.spotify { background: #9ff0b8; }
.service.apple { background: #ffc0cc; }
.service.ytmusic { background: #ffe0a3; }
.service.youtube { background: #ffd0c4; }

/* YouTube's minimum is 200 by 200 pixels with nothing over it. A screen of empty
   space keeps it out of sight from the top, whatever the address bar is doing. */
.player {
  position: relative;
  z-index: 4;
  flex: none;
  align-self: center;
  width: 200px;
  height: 200px;
  margin-top: 100vh;
  margin-top: 100lvh;
  overflow: hidden;
  background: var(--ink);
}
.has-player { overflow-anchor: none; }
.has-player main { padding-bottom: env(safe-area-inset-bottom); }
/* The clock stays put while the page is down at the player. */
.has-player #hero { position: sticky; z-index: 1; top: env(safe-area-inset-top); background: var(--bg); transition: background-color .3s; }
.player iframe { display: block; width: 100%; height: 100%; border: 0; }

.timer { display: grid; justify-items: center; text-align: center; }
.timer p { font: 1.5rem var(--display); }
.timer strong { min-height: 1em; font: clamp(7rem, 38vw, 11rem)/1 var(--display); }
.timer[data-part='count'] strong { color: var(--yellow); -webkit-text-stroke: 4px var(--ink); }

.deadline { display: flex; justify-content: center; align-items: baseline; gap: 8px; margin: 10px 0 14px; font-weight: 700; }
.deadline strong { min-width: 2.2em; font: 2.6rem/1 var(--display); text-align: right; font-variant-numeric: tabular-nums; }
.deadline.soon strong { color: var(--paper); -webkit-text-stroke: 2px var(--ink); }

.suspects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.suspect { display: grid; justify-items: center; gap: 8px; padding: 16px 8px; border: 3px solid var(--ink); border-radius: 18px; background: var(--paper); color: var(--ink); font: 700 1.05rem Outfit, system-ui, sans-serif; overflow-wrap: anywhere; cursor: pointer; }
.suspect[aria-pressed='true'] { background: var(--pink); box-shadow: inset 0 0 0 3px var(--ink); }

.guilty { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; margin-top: 18px; }
.guilty div { display: grid; justify-items: center; gap: 6px; font-size: 1.4rem; overflow-wrap: anywhere; }
.guilty .avatar { width: 104px; height: 104px; font-size: 3rem; animation: wobble 1.2s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { rotate: -7deg; } 50% { rotate: 7deg; } }
.next { margin-top: 18px; text-align: center; }
.next .link { margin-top: 10px; }
.reveal-song.odd { background: #ffc4dd; }

.toast {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  translate: -50% 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.toast.on { opacity: 1; }
.offline { padding: 8px; background: var(--ink); color: var(--paper); font-weight: 700; text-align: center; }

/* One flash only, never a strobe. */
.flash { position: fixed; z-index: 2; inset: 0; background: #ff3b30; opacity: 0; pointer-events: none; }
.flash.on { animation: flash 1.1s ease-out; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }

/* All three home buttons above the fold on a short phone. */
@media (max-height: 640px) {
  .home .bars { display: none; }
}

@media (max-width: 360px) {
  .code span { width: 60px; height: 74px; font-size: 2.4rem; }
}

/* A room screen is read from across the room. */
@media (min-width: 900px) {
  body.screen main, body.screen #top { width: min(100%, 1100px); }
  body.screen .code span { width: 130px; height: 150px; font-size: 5.6rem; }
  body.screen .eyebrow, body.screen .lede { font-size: 1.8rem; }
  body.screen .qr { width: 260px; }
  body.screen .roster { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  /* A box per player, or one's "Ready" reads as part of the next one's avatar. */
  body.screen .roster li { padding: 6px 10px; border: 2px solid var(--ink); border-radius: 14px; }
  body.screen .timer p { font-size: 3.4rem; }
  body.screen .timer strong { font-size: 22rem; }
  body.screen .title { font-size: 4.6rem; }

  /* Code and QR on the left, people on the right, all above the fold. */
  body.screen[data-scene='lobby'] main {
    display: grid;
    grid-template-columns: 560px minmax(0, 1fr);
    align-content: start;
  }
  body.screen[data-scene='lobby'] #hero { grid-row: span 3; }
  body.screen[data-scene='lobby'] .code span { width: 118px; height: 132px; font-size: 5rem; }
  body.screen[data-scene='lobby'] .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.screen[data-scene='lobby'] #side { grid-column: 2; }
  body.screen[data-scene='reveal'] #body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  body.screen[data-scene='reveal'] .card + .card { margin: 0; }
  body.screen[data-scene='lobby'] .scores .roster { grid-template-columns: minmax(0, 1fr); } /* names need the width */
  body.screen[data-scene='reveal'] .scores .roster { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 28px; }
  body.screen[data-scene='reveal'] .services { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-iteration-count: 1 !important; transition: none !important; }
  .bars i, .guilty .avatar, .pulse { animation: none !important; }
  .flash.on { animation-timing-function: steps(1); }
}
