:root {
  --bg: #000;
  --fg: #fff;
  --red: #D71921;
  --fg55: rgba(255,255,255,.55);
  --fg40: rgba(255,255,255,.40);
  --fg30: rgba(255,255,255,.30);
  --fg14: rgba(255,255,255,.14);
  --ease: cubic-bezier(.22,1,.36,1);
  --mono: ui-monospace, "SF Mono", Menlo, "Roboto Mono", monospace;
  --doto: "Doto", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#halo {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  transition: opacity .45s var(--ease);
}

body[data-state="setup"][data-setup-mode="startup"] #halo,
body[data-state="setup"][data-setup-mode="startup"] #center-btn,
body[data-state="setup"][data-setup-mode="startup"] #audio-toggle,
body[data-state="setup"][data-setup-mode="startup"] #room-share {
  opacity: 0;
  pointer-events: none;
}

button {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

button:disabled {
  cursor: default;
  opacity: .26;
}

#room-share {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 24px);
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  max-width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 32px);
  padding: 8px;
  gap: 9px;
  border: none;
  background: none;
  color: var(--fg);
  transform: translateX(-50%);
  transition: opacity .25s var(--ease);
}

.room-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: livepulse 2.4s ease-in-out infinite;
  transition: background .25s var(--ease);
}

body[data-connection="linking"] .room-dot {
  background: var(--fg40);
  animation: none;
}

body[data-connection="offline"] .room-dot {
  background: var(--fg30);
  animation: none;
}

body[data-connection="copied"] .room-dot,
body[data-connection="shared"] .room-dot {
  background: var(--fg);
  animation: none;
}

#room-code {
  overflow: hidden;
  max-width: 92px;
  font-family: var(--doto);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .12em;
  text-overflow: ellipsis;
}

body[data-connection="offline"] #room-code {
  color: var(--fg40);
}

#room-status {
  color: var(--fg55);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
}

#room-status:empty {
  display: none;
}

@keyframes livepulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

#center-btn {
  position: fixed;
  top: var(--halo-cy, 44%);
  left: 50%;
  z-index: 3;
  display: grid;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  place-items: center;
  border: none;
  background: none;
  opacity: 0;
  pointer-events: none;
  transform: scale(.72);
  visibility: hidden;
  transition: top .55s var(--ease), transform .55s var(--ease), opacity .4s var(--ease);
}

#center-btn svg {
  grid-area: 1 / 1;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--fg);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}

#center-btn .icon-close {
  opacity: 0;
  transform: rotate(-45deg) scale(.6);
}

body[data-state="idle"] #center-btn svg {
  stroke: var(--fg40);
}

body[data-state="search"] #center-btn {
  top: var(--halo-cy, 20%);
  opacity: 1;
  pointer-events: auto;
  transform: scale(.8);
  visibility: visible;
}

body[data-state="queue"] #center-btn,
body[data-state="setup"][data-setup-mode="share"] #center-btn {
  z-index: 6;
  top: var(--halo-cy, 19%);
  opacity: 1;
  pointer-events: auto;
  transform: scale(.8);
  visibility: visible;
}

body[data-state="search"] #center-btn .icon-search {
  opacity: 0;
  transform: rotate(45deg) scale(.6);
}

body[data-state="queue"] #center-btn .icon-search,
body[data-state="setup"][data-setup-mode="share"] #center-btn .icon-search {
  opacity: 0;
  transform: rotate(45deg) scale(.6);
}

body[data-state="search"] #center-btn .icon-close,
body[data-state="queue"] #center-btn .icon-close,
body[data-state="setup"][data-setup-mode="share"] #center-btn .icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

body[data-state="setup"] #center-btn {
  opacity: 0;
  pointer-events: none;
  transform: scale(.62);
}

body[data-state="queue"] #center-btn {
  opacity: 1;
  pointer-events: auto;
  transform: scale(.8);
}

body[data-state="setup"][data-setup-mode="share"] #center-btn {
  opacity: 1;
  pointer-events: auto;
  transform: scale(.8);
  visibility: visible;
}

.reveal {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}

body[data-state="revealed"] .reveal {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#track {
  position: fixed;
  top: var(--track-top, 68%);
  right: 0;
  left: 0;
  padding: 0 26px;
  text-align: center;
}

#track-title {
  overflow: hidden;
  font-family: var(--doto);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .14em;
  text-indent: .14em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

#track-artist {
  margin-top: 9px;
  overflow: hidden;
  color: var(--fg55);
  font-size: 10px;
  letter-spacing: .34em;
  text-indent: .34em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

#host-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  margin-top: 17px;
  color: var(--fg40);
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
}

#host-stats strong {
  color: var(--fg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

body[data-audio="playing"] #audio-status {
  color: var(--red);
}

body[data-audio="blocked"] #audio-status,
body[data-audio="error"] #audio-status {
  color: var(--fg);
}

.meter {
  width: min(260px, 68vw);
  height: 2px;
  margin: 18px auto 0;
  background: var(--fg14);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--red);
  transition: width .4s linear;
}

#host-controls {
  position: fixed;
  top: calc(var(--track-top, 68%) + 100px);
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: min(22vw, 96px);
  transition-delay: .05s;
}

.host-btn {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: var(--fg55);
}

.host-btn svg {
  grid-area: 1 / 1;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color .25s, transform .25s var(--ease);
}

.host-btn .icon-skip,
.host-btn .icon-play,
.host-btn .icon-pause {
  fill: currentColor;
  stroke: none;
}

.host-btn .icon-search {
  width: 23px;
  height: 23px;
}

#audio-toggle {
  position: fixed;
  top: var(--halo-cy, 44%);
  left: 50%;
  z-index: 4;
  width: clamp(96px, 22vw, 132px);
  height: clamp(96px, 22vw, 132px);
  margin: 0;
  border: 1px solid var(--fg30);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255,255,255,.12) 0%, rgba(255,255,255,.035) 56%, rgba(0,0,0,.12) 100%);
  color: var(--fg);
  opacity: 1;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(1);
  transition:
    top .55s var(--ease),
    border-color .25s var(--ease),
    box-shadow .25s var(--ease),
    color .25s var(--ease),
    opacity .35s var(--ease),
    transform .55s var(--ease);
}

#audio-toggle::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--fg14);
  border-radius: 50%;
}

#audio-toggle svg {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 46px;
}

#audio-toggle .icon-play {
  width: 50px;
  height: 50px;
  margin-left: 5px;
}

#audio-toggle .icon-pause {
  width: 48px;
  height: 48px;
  opacity: 0;
  transform: scale(.72);
}

body[data-audio="playing"] #audio-toggle .icon-play {
  opacity: 0;
  transform: scale(.72);
}

body[data-audio="loading"] #audio-toggle .icon-play,
body[data-audio="buffering"] #audio-toggle .icon-play {
  opacity: 0;
  transform: scale(.72);
}

body[data-audio="playing"] #audio-toggle .icon-pause,
body[data-audio="loading"] #audio-toggle .icon-pause,
body[data-audio="buffering"] #audio-toggle .icon-pause {
  opacity: 1;
  transform: scale(1);
}

body[data-audio="loading"] #audio-toggle .icon-pause,
body[data-audio="buffering"] #audio-toggle .icon-pause {
  animation: audiohold 1.1s ease-in-out infinite;
}

@keyframes audiohold {
  0%, 100% { opacity: .38; }
  50% { opacity: 1; }
}

.host-btn:active svg {
  transform: scale(.84);
}

#skip-track:not(:disabled),
#audio-toggle:not(:disabled) {
  color: var(--fg);
}

#host-search:not(:disabled) {
  color: var(--fg55);
}

body[data-audio="playing"] #audio-toggle {
  border-color: rgba(215,25,33,.58);
  box-shadow: 0 0 34px rgba(215,25,33,.22), inset 0 0 0 1px rgba(215,25,33,.12);
  color: var(--red);
}

body[data-audio="blocked"] #audio-toggle,
body[data-audio="error"] #audio-toggle {
  border-color: var(--fg55);
}

body[data-state="search"] #audio-toggle,
body[data-state="setup"] #audio-toggle,
body[data-state="queue"] #audio-toggle {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.72);
}

#player-shell {
  position: fixed;
  top: 0;
  left: -9999px;
  z-index: -1;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

#player-shell iframe {
  display: block;
  width: 1px;
  height: 1px;
}

body[data-audio="idle"] #player-shell,
body[data-state="setup"][data-setup-mode="startup"] #player-shell {
  opacity: 0;
}

body[data-audio="playing"] #player-shell {
  opacity: 0;
}

body[data-state="search"] #player-shell,
body[data-state="queue"] #player-shell {
  opacity: 0;
}

#queue-tab {
  position: fixed;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition-delay: .1s;
}

#queue-tab .grabber,
#sheet-head .grabber {
  width: 34px;
  height: 2px;
  border-radius: 1px;
  background: var(--fg30);
}

#queue-tab .label,
#sheet-head .label,
.eyebrow {
  color: var(--fg40);
  font-size: 10px;
  letter-spacing: .38em;
  text-indent: .38em;
  text-transform: uppercase;
}

#search-ui {
  position: fixed;
  top: 34%;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  padding: 0 34px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}

body[data-state="search"] #search-ui {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#search-input {
  width: 100%;
  padding: 12px 2px;
  border: none;
  border-bottom: 1px solid var(--fg30);
  border-radius: 0;
  outline: none;
  background: none;
  caret-color: var(--red);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: .22em;
  text-transform: uppercase;
  transition: border-color .3s;
}

#search-input:focus {
  border-color: var(--fg55);
}

#search-input::placeholder {
  color: var(--fg30);
}

#results {
  margin-top: 6px;
}

.search-note {
  padding: 24px 2px;
  color: var(--fg30);
  font-size: 10px;
  letter-spacing: .36em;
  text-transform: uppercase;
}

.r-row {
  display: flex;
  padding: 13px 2px;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  cursor: pointer;
  transition: opacity .2s;
}

.r-thumb {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 1px solid var(--fg14);
  background: #050505;
  object-fit: cover;
}

.r-thumb.px {
  image-rendering: pixelated;
}

.r-row.queued .r-thumb {
  opacity: .3;
}

.r-row .r-meta {
  min-width: 0;
  flex: 1;
}

.r-row .d {
  flex-shrink: 0;
  color: var(--fg30);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
}

.r-row:active {
  opacity: .5;
}

.r-row .t {
  overflow: hidden;
  font-family: var(--doto);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.r-row .a {
  margin-top: 5px;
  overflow: hidden;
  color: var(--fg40);
  font-size: 9px;
  letter-spacing: .28em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.r-row.queued {
  pointer-events: none;
}

.r-row.queued .t {
  color: var(--fg30);
}

.fly-cover {
  position: fixed;
  z-index: 10;
  overflow: hidden;
  border-radius: 8px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 0 0 1px rgba(255,255,255,.20), 0 18px 46px rgba(0,0,0,.55);
  pointer-events: none;
  transform-origin: center;
  transition:
    transform .62s cubic-bezier(.5,0,.15,1),
    opacity .62s,
    border-radius .62s var(--ease);
}

#setup-ui {
  position: fixed;
  top: 31%;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: flex;
  max-width: 390px;
  padding: 0 28px calc(env(safe-area-inset-bottom, 0px) + 28px);
  margin: 0 auto;
  flex-direction: column;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  touch-action: pan-y;
  transform: translateY(12px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}

body[data-state="setup"][data-setup-mode="share"] #setup-ui {
  top: clamp(224px, calc(19dvh + 120px), 310px);
  max-width: 390px;
}

body[data-state="setup"][data-setup-mode="startup"] #setup-ui {
  top: 0;
  max-width: 430px;
  justify-content: stretch;
  padding-top: calc(env(safe-area-inset-top, 0px) + 28px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
  transform: translateY(0);
}

body[data-state="setup"] #setup-ui {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#startup-flow,
#share-flow {
  display: none;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

#share-flow {
  flex: 1 1 auto;
  gap: clamp(30px, 7dvh, 72px);
  justify-content: space-between;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
}

body[data-setup-mode="startup"] #startup-flow,
body[data-setup-mode="share"] #share-flow {
  display: flex;
}

body[data-state="setup"][data-setup-mode="startup"] #startup-flow {
  flex: 1 1 auto;
  min-height: 100%;
  justify-content: space-between;
}

.setup-progress {
  display: flex;
  justify-content: center;
  gap: 9px;
}

.setup-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg14);
  transition: background .3s var(--ease), transform .3s var(--ease);
}

body[data-setup-step="photo"] .setup-dot:nth-child(-n+1),
body[data-setup-step="one"] .setup-dot:nth-child(-n+2),
body[data-setup-step="two"] .setup-dot:nth-child(-n+3),
body[data-setup-step="generating"] .setup-dot:nth-child(-n+3),
body[data-setup-step="review"] .setup-dot:nth-child(-n+4) {
  background: var(--red);
}

.setup-step {
  display: none;
  min-height: 0;
  flex-direction: column;
  justify-content: flex-start;
  gap: 22px;
}

body[data-setup-mode="startup"] .setup-step {
  flex: 1 1 auto;
  justify-content: center;
}

body[data-setup-mode="startup"] .setup-step[data-step-panel="generating"] {
  justify-content: center;
  gap: clamp(18px, 3dvh, 28px);
}

body[data-setup-mode="startup"][data-setup-step="photo"] #startup-flow {
  gap: 26px;
}

body[data-setup-mode="startup"][data-setup-step="photo"] #setup-next {
  display: none;
}

body[data-setup-step="photo"] .setup-step[data-step-panel="photo"],
body[data-setup-step="one"] .setup-step[data-step-panel="one"],
body[data-setup-step="two"] .setup-step[data-step-panel="two"],
body[data-setup-step="generating"] .setup-step[data-step-panel="generating"],
body[data-setup-step="review"] .setup-step[data-step-panel="review"] {
  display: flex;
}

body[data-setup-mode="startup"][data-setup-step="review"] .setup-step[data-step-panel="review"] {
  justify-content: flex-start;
}

.setup-question {
  display: block;
  color: var(--fg);
  font-family: var(--doto);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.18;
  text-transform: uppercase;
}

.setup-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-hint {
  max-width: 34rem;
  color: var(--fg55);
  font-size: 11px;
  letter-spacing: .08em;
  line-height: 1.55;
  text-transform: uppercase;
}

.photo-copy {
  width: min(78vw, 328px);
  align-self: center;
}

.photo-copy .setup-question {
  font-size: 21px;
}

#camera-frame {
  position: relative;
  align-self: center;
  flex: 0 0 auto;
  width: min(68vw, 280px, 40dvh);
  aspect-ratio: 1;
  border: 1px solid var(--fg14);
  border-radius: 50%;
  background:
    linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,.02)),
    #030303;
  overflow: hidden;
}

#camera-frame::before,
#camera-frame::after {
  display: none;
}

#camera-preview,
#photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  object-fit: cover;
  transition: opacity .3s var(--ease);
}

#photo-preview {
  background-position: center;
  background-size: cover;
}

#camera-flash {
  position: absolute;
  z-index: 4;
  inset: 0;
  background: var(--fg);
  opacity: 0;
  pointer-events: none;
}

#camera-frame.flash #camera-flash {
  animation: shutterflash .42s ease-out;
}

@keyframes shutterflash {
  0% { opacity: 0; }
  10% { opacity: .94; }
  100% { opacity: 0; }
}

body[data-camera="ready"] #camera-preview,
body[data-camera="shot"] #photo-preview {
  opacity: 1;
}

#room-photo {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#photo-controls {
  display: grid;
  align-self: center;
  grid-template-columns: 48px 72px 48px;
  gap: 26px;
  align-items: center;
  margin-top: 6px;
}

.photo-tool {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--fg14);
  border-radius: 50%;
  color: var(--fg55);
}

.photo-tool svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.photo-tool:active svg {
  transform: scale(.88);
}

#capture-photo {
  position: relative;
  display: grid;
  width: 72px;
  height: 72px;
  border: 1px solid var(--fg55);
  border-radius: 50%;
  place-items: center;
}

#capture-photo::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--fg30);
  border-radius: 50%;
}

#capture-photo span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--fg);
  transition: transform .18s var(--ease), opacity .18s var(--ease);
}

#capture-photo:active span {
  opacity: .72;
  transform: scale(.88);
}

body[data-camera="shot"] #photo-controls {
  display: none;
}

.setup-secondary {
  min-height: 48px;
  align-self: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--fg55);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .24em;
  text-align: center;
  text-transform: uppercase;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}

#skip-photo {
  width: min(100%, 328px);
  border-color: var(--fg14);
}

#skip-photo:active {
  border-color: var(--fg30);
  color: var(--fg);
}

body[data-camera="shot"] #skip-photo {
  display: none;
}

#photo-review {
  display: none;
  width: min(100%, 328px);
  align-self: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 12px;
  margin-top: 8px;
}

body[data-camera="shot"] #photo-review {
  display: grid;
}

#photo-review button {
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid var(--fg30);
  border-radius: 999px;
  color: var(--fg55);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .24em;
  text-align: center;
  text-transform: uppercase;
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease);
}

#accept-photo {
  border-color: var(--red);
  background: var(--red);
  color: var(--fg);
}

#setup-q1,
#setup-q2 {
  width: 100%;
  min-height: 94px;
  resize: none;
  padding: 14px 2px;
  border: 0;
  border-bottom: 1px solid var(--fg30);
  border-radius: 0;
  outline: none;
  background: transparent;
  caret-color: var(--red);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  letter-spacing: .18em;
  line-height: 1.5;
  text-transform: uppercase;
}

#setup-q1:focus,
#setup-q2:focus {
  border-color: var(--fg55);
}

#setup-q1::placeholder,
#setup-q2::placeholder {
  color: var(--fg30);
}

#setup-actions-row {
  display: flex;
  width: 100%;
  gap: 10px;
}

#setup-next {
  display: grid;
  flex: 1 1 auto;
  min-height: 58px;
  padding: 0 18px;
  place-items: center;
  border: 1px solid var(--red);
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 26px rgba(215,25,33,.26);
  color: var(--fg);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .24em;
  text-align: center;
  text-transform: uppercase;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}

#setup-next:active {
  transform: scale(.98);
}

#setup-back {
  display: none;
  flex: 0 0 auto;
  min-height: 58px;
  padding: 0 18px;
  border: 1px solid var(--fg14);
  border-radius: 999px;
  background: transparent;
  color: var(--fg55);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .24em;
  text-align: center;
  text-transform: uppercase;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}

#setup-back:active {
  border-color: var(--fg30);
  color: var(--fg);
}

body[data-setup-step="one"] #setup-back,
body[data-setup-step="two"] #setup-back,
body[data-setup-step="review"] #setup-back {
  display: grid;
  place-items: center;
}

body[data-setup-step="generating"] #setup-next {
  display: none;
}

#setup-next:disabled {
  border-color: var(--fg14);
  background: transparent;
  box-shadow: none;
  color: var(--fg30);
}

#seed-status {
  min-height: 16px;
  color: var(--fg40);
  font-size: 9px;
  letter-spacing: .32em;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.generating-mark {
  width: 52px;
  height: 2px;
  align-self: center;
  background: var(--fg);
  transform-origin: left center;
  animation: making 1s ease-in-out infinite;
}

.setup-join.generating-share {
  width: 100%;
  gap: clamp(14px, 2.6dvh, 22px);
}

.generating-share .qr-wrap {
  width: min(50vw, 178px, 22dvh);
  height: min(50vw, 178px, 22dvh);
}

#generating-code {
  margin-top: 8px;
  font-family: var(--doto);
  font-size: clamp(42px, 14vw, 62px);
  font-weight: 800;
  line-height: .9;
  letter-spacing: .1em;
  text-indent: .1em;
}

#generating-url {
  display: block;
  margin: 12px auto 0;
  max-width: min(100%, 30ch);
  color: var(--fg55);
  font-size: 10px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes making {
  0%, 100% { transform: scaleX(.22); opacity: .35; }
  50% { transform: scaleX(1); opacity: 1; }
}

#starter-mood {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 12px;
  border: 1px solid var(--fg14);
  border-radius: 999px;
  color: var(--fg40);
  font-size: 10px;
  letter-spacing: .32em;
  text-transform: uppercase;
}

#starter-list {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  touch-action: pan-y;
  scrollbar-width: none;
  mask-image: linear-gradient(to bottom, transparent 0, black 10px, black calc(100% - 10px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 10px, black calc(100% - 10px), transparent 100%);
}

#starter-list::-webkit-scrollbar {
  display: none;
}

.starter-row {
  display: grid;
  min-height: 50px;
  padding: 12px 0;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.starter-row .idx {
  color: var(--fg30);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
}

.starter-row .meta {
  min-width: 0;
}

.starter-row .t {
  overflow: hidden;
  font-family: var(--doto);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .11em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.starter-row .a {
  margin-top: 5px;
  overflow: hidden;
  color: var(--fg40);
  font-size: 9px;
  letter-spacing: .26em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

#regenerate-starter {
  min-height: 44px;
  align-self: flex-start;
  padding: 0 16px;
  border: 1px solid var(--fg14);
  border-radius: 999px;
  color: var(--fg55);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .24em;
  text-transform: uppercase;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}

#regenerate-starter:active {
  border-color: var(--fg30);
  color: var(--fg);
}

.setup-join {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 4dvh, 34px);
  align-items: center;
  text-align: center;
}

.setup-room {
  width: 100%;
  min-width: 0;
}

#setup-code {
  margin-top: 10px;
  font-family: var(--doto);
  font-size: clamp(52px, 18vw, 82px);
  font-weight: 800;
  line-height: .9;
  letter-spacing: .1em;
  text-indent: .1em;
}

#join-url {
  display: block;
  margin: 16px auto 0;
  max-width: min(100%, 30ch);
  color: var(--fg55);
  font-size: 11px;
  line-height: 1.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-wrap {
  display: grid;
  width: min(58vw, 226px, 25dvh);
  height: min(58vw, 226px, 25dvh);
  place-items: center;
  background: var(--fg);
}

#qr,
#generating-qr {
  display: block;
  width: calc(100% - 18px);
  height: calc(100% - 18px);
}

.setup-actions {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.setup-actions button {
  min-height: 40px;
  padding: 0 2px;
  color: var(--fg55);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
}

.setup-actions button:first-child {
  color: var(--fg);
}

#end-room[data-confirm="true"] {
  color: var(--red);
}

#backdrop {
  position: fixed;
  z-index: 4;
  inset: 0;
  display: none;
}

body[data-state="queue"] #backdrop {
  display: block;
}

#sheet {
  position: fixed;
  top: 34%;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  padding: 0 34px calc(env(safe-area-inset-bottom, 0px) + 20px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}

body[data-state="queue"] #sheet {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#sheet.dragging {
  transition: none;
}

#sheet-head {
  display: flex;
  padding: 0 0 14px;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  cursor: grab;
  touch-action: none;
}

#sheet-list {
  flex: 1;
  padding: 0;
  overflow-y: auto;
  touch-action: pan-y;
}

.q-row {
  display: flex;
  padding: 15px 0;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.q-row .idx {
  position: relative;
  width: 22px;
  flex-shrink: 0;
  color: var(--fg30);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .1em;
}

.q-row.now .idx::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -13px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  transform: translateY(-50%);
}

.q-row .meta {
  min-width: 0;
  flex: 1;
}

.q-row .t {
  overflow: hidden;
  font-family: var(--doto);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.q-row .a {
  margin-top: 5px;
  overflow: hidden;
  color: var(--fg40);
  font-size: 9px;
  letter-spacing: .28em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.q-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.q-action {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--fg40);
}

.q-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color .2s var(--ease), transform .2s var(--ease);
}

.q-action:not(:disabled):active svg {
  transform: scale(.84);
}

.q-action.danger:not(:disabled) {
  color: var(--fg55);
}

.q-divider {
  padding: 22px 0 8px;
  color: var(--fg30);
  font-size: 9px;
  letter-spacing: .38em;
  text-transform: uppercase;
}

@media (max-width: 620px) {
  #setup-ui {
    top: 29%;
  }

  body[data-state="setup"][data-setup-mode="share"] #setup-ui {
    top: clamp(212px, calc(19dvh + 108px), 286px);
  }

  .setup-join {
    gap: clamp(18px, 4dvh, 28px);
  }

  .qr-wrap {
    width: min(68vw, 208px, 25dvh);
    height: min(68vw, 208px, 25dvh);
  }

  #qr {
    width: calc(100% - 18px);
    height: calc(100% - 18px);
  }

  #host-stats {
    gap: 16px;
    font-size: 9px;
    letter-spacing: .18em;
  }
}

@media (max-height: 680px) {
  body[data-state="setup"][data-setup-mode="startup"] #setup-ui {
    top: 0;
    padding-top: calc(env(safe-area-inset-top, 0px) + 18px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  }

  body[data-setup-mode="startup"] .setup-step {
    min-height: 0;
    gap: 14px;
  }

  .setup-hint {
    font-size: 10px;
    line-height: 1.45;
  }

  #camera-frame {
    width: min(74vw, 192px);
  }

  #photo-controls {
    grid-template-columns: 44px 64px 44px;
    gap: 22px;
  }

  .photo-tool {
    width: 44px;
    height: 44px;
  }

  #capture-photo {
    width: 64px;
    height: 64px;
  }

  #capture-photo span {
    width: 38px;
    height: 38px;
  }
}
