/* The big screen: a Kahoot-style lobby on the brand gradient, then the leaderboard. */

.screen-page {
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--stage);
  background-attachment: fixed;
}

.screen-page::before {
  display: none;
}

.screen {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(16px, 3vh, 36px);
  min-height: 100dvh;
  padding: clamp(16px, 3vw, 48px);
}

.screen-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--paper);
}

.screen-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: rgb(25 25 28 / 0.28);
}

.screen-switch button {
  appearance: none;
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.screen-switch button[aria-checked='true'] {
  background: var(--paper);
  color: var(--ink);
}

.screen-switch button:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 2px;
}

/* ---------- lobby ---------- */

.lobby {
  display: grid;
  align-content: start;
  gap: clamp(20px, 4vh, 48px);
}

.join-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(16px, 3vw, 40px);
  padding: clamp(20px, 3vw, 40px);
  border-radius: var(--radius-panel);
  background: var(--paper);
  color: var(--ink);
}

.join-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.join-title {
  font-size: clamp(1.25rem, 1rem + 1.2vw, 2.25rem);
  font-weight: 700;
}

.join-url {
  font-size: clamp(1.75rem, 1rem + 4.2vw, 5.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  color: var(--violet);
}

.join-hint {
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.375rem);
  color: #4a4a52;
}

.join-qr {
  flex: none;
  width: clamp(140px, 18vw, 260px);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
}

.crowd {
  display: grid;
  gap: 18px;
}

.crowd-count {
  font-size: clamp(1.125rem, 0.9rem + 1vw, 2rem);
  font-weight: 700;
  color: var(--paper);
}

.names {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.name {
  max-width: 100%;
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.94);
  color: var(--ink);
  font-size: clamp(1.125rem, 0.9rem + 0.9vw, 1.875rem);
  font-weight: 700;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 0 rgb(25 25 28 / 0.18);
}

.name[data-new] {
  animation: name-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
}

@keyframes name-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.6);
  }
}

/* ---------- leaderboard ---------- */

.board {
  display: grid;
  align-content: start;
  gap: 16px;
  width: min(100%, 1200px);
  margin-inline: auto;
}

.board-heading {
  font-size: clamp(1.5rem, 1rem + 2vw, 3rem);
  font-weight: 800;
  color: var(--paper);
}

.ranks {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank {
  display: grid;
  grid-template-columns: 3.2ch minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: clamp(10px, 2vw, 28px);
  padding: 12px clamp(14px, 2vw, 26px);
  border-radius: 18px;
  background: rgb(25 25 28 / 0.55);
  color: var(--paper);
  font-size: clamp(1rem, 0.85rem + 0.7vw, 1.625rem);
}

.rank:first-child {
  background: var(--paper);
  color: var(--ink);
}

.rank-place {
  font-family: var(--font-mono);
  font-weight: 800;
  text-align: right;
}

.rank-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-pips {
  display: inline-flex;
  gap: 6px;
}

.pip {
  width: clamp(10px, 0.7vw + 6px, 18px);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px currentColor;
  opacity: 0.35;
}

.pip[data-status='solved'] {
  background: var(--done);
  box-shadow: none;
  opacity: 1;
}

.pip[data-status='started'] {
  box-shadow: inset 0 0 0 2px var(--sticker-yellow);
  opacity: 1;
}

.rank-solved,
.rank-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.rank-time {
  min-width: 6ch;
  text-align: right;
}

.board-more,
.board-empty {
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.375rem);
  font-weight: 600;
  color: var(--paper);
}

.screen-offline {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

@media (max-width: 700px) {
  .rank {
    grid-template-columns: 3ch minmax(0, 1fr) auto;
  }

  .rank-pips,
  .rank-time {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .name[data-new] {
    animation: none;
  }
}
