: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;
}

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

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

#halo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#join-screen {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: calc(env(safe-area-inset-top, 0px) + 72px) 30px calc(env(safe-area-inset-bottom, 0px) + 26px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .42s var(--ease), transform .42s var(--ease);
}

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

body[data-state="join"] #room-share,
body[data-state="join"] #center-btn {
  opacity: 0;
  pointer-events: none;
}

body[data-state="join"] #halo {
  opacity: 0;
}

#join-form {
  display: flex;
  width: min(100%, 360px);
  margin: 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.join-mark {
  color: var(--fg);
  font-family: var(--doto);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .28em;
  text-indent: .28em;
}

#join-label,
#join-status {
  color: var(--fg40);
  font-size: 10px;
  letter-spacing: .36em;
  text-indent: .36em;
  text-transform: uppercase;
}

.join-code-boxes {
  display: grid;
  width: min(100%, 304px);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.join-code-box {
  width: 100%;
  height: 82px;
  border: 1px solid var(--fg30);
  border-radius: 6px;
  outline: none;
  background: transparent;
  caret-color: var(--red);
  color: var(--fg);
  font-family: var(--doto);
  font-size: 42px;
  font-weight: 800;
  text-align: center;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease), color .25s var(--ease);
}

.join-code-box:focus {
  border-color: var(--fg55);
  box-shadow: 0 0 0 1px var(--fg55);
}

.join-code-box[aria-invalid="true"] {
  border-color: var(--red);
  color: var(--red);
}

.join-code-box::selection {
  background: transparent;
}

#join-submit,
#host-entry {
  border: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .32em;
  text-align: center;
  text-decoration: none;
  text-indent: .32em;
  text-transform: uppercase;
  cursor: pointer;
}

#join-submit {
  min-height: 44px;
  padding: 0 12px;
}

#join-submit:disabled {
  color: var(--fg30);
  cursor: default;
}

#host-entry {
  display: grid;
  width: min(100%, 360px);
  min-height: 48px;
  margin: 0 auto;
  place-items: center;
  border-top: 1px solid var(--fg14);
  color: var(--fg55);
}

#join-submit:focus-visible,
#host-entry:focus-visible {
  outline: 1px solid var(--fg40);
  outline-offset: 6px;
}

#room-share {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 22px);
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: none;
  color: var(--fg40);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .38em;
  text-transform: uppercase;
  cursor: pointer;
  transform: translateX(-50%);
  transition: color .25s var(--ease), opacity .25s var(--ease);
}

#room-share::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  animation: livepulse 2.4s ease-in-out infinite;
}

#room-share:focus-visible {
  outline: 1px solid var(--fg40);
  outline-offset: 8px;
}

body[data-connection="linking"] #room-share::before {
  background: var(--fg55);
}

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

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

body[data-connection="copied"] #room-share,
body[data-connection="shared"] #room-share {
  color: var(--fg);
}

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

#center-btn {
  position: fixed;
  left: 50%;
  top: var(--halo-cy, 44%);
  z-index: 3;
  display: grid;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  place-items: center;
  border: none;
  background: none;
  cursor: pointer;
  transform: scale(1);
  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;
  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(--fg55);
}

body[data-state="search"] #center-btn {
  top: 20%;
  transform: scale(.8);
}

body[data-state="queue"] #center-btn {
  z-index: 6;
  top: var(--halo-cy, 19%);
  transform: scale(.8);
}

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

body[data-state="queue"] #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 {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.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;
}

#votes {
  position: fixed;
  top: calc(var(--track-top, 68%) + 64px);
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  transition-delay: .05s;
}

.vote-btn {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: none;
  background: none;
  cursor: pointer;
}

.vote-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--fg55);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
  transition: stroke .25s, transform .25s var(--ease);
}

.vote-btn:active svg {
  transform: scale(.82);
}

#vote-up.active svg {
  stroke: var(--red);
}

#vote-down.active svg {
  stroke: var(--fg);
}

#tally {
  min-width: 52px;
  color: var(--fg55);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .18em;
  text-align: center;
  text-indent: .18em;
  transition: color .25s;
}

#tally.up {
  color: var(--red);
}

#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 {
  color: var(--fg40);
  font-size: 10px;
  letter-spacing: .38em;
  text-indent: .38em;
}

#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: baseline;
  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;
}

.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;
  color: var(--fg40);
  font-size: 9px;
  letter-spacing: .28em;
  text-transform: uppercase;
}

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

#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 {
  font-family: var(--doto);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

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

.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);
}
