:root {
  color-scheme: light;
  --paper: #f5f4f0;
  --white: #fffefa;
  --ink: #17181b;
  --muted: #555961;
  --line: #d8d8d1;
  --blue: #283dc6;
  --blue-dark: #1a2b97;
  --blue-soft: #eef0fc;
  --green: #126348;
  --red: #a22d28;
  font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100svh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
.top, main {
  width: min(100%, 1280px);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3.3vw, 2.5rem);
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 4.25rem;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  white-space: nowrap;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.03em;
}
.mark {
  display: block;
  height: 1rem;
  width: 1rem;
  border: 4px solid var(--blue);
  border-radius: 100%;
}
.connection {
  text-align: right;
  color: var(--muted);
  font-size: .875rem;
}
.connection.online { color: var(--green); }
main {
  padding-block: clamp(1.5rem, 4vw, 2.65rem) max(2rem, env(safe-area-inset-bottom));
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.13; }
h1 { font-size: clamp(2.1rem, 5.8vw, 3.8rem); font-weight: 760; letter-spacing: -.067em; }
h2 { font-size: clamp(1.16rem, 2.4vw, 1.6rem); letter-spacing: -.034em; }
h3 { font-size: 1rem; font-weight: 700; }
.eyebrow {
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
  margin-bottom: .5rem;
}
.hint, label { color: var(--muted); }
.error { color: var(--red); }
.error:empty { display: none; }

button, input, textarea { font: inherit; }
button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: .62rem .95rem;
  min-height: 2.85rem;
  border: 1px solid #bdbfb8;
  border-radius: .4rem;
  color: var(--ink);
  background: var(--white);
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover:not(:disabled), .button:hover { background: #eeeee8; }
button:disabled { color: #656762; border-color: var(--line); background: #eeeee9; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
.quiet { color: var(--muted); }
button.quiet { background: transparent; border-color: transparent; padding-inline: .18rem; }
button.quiet:disabled { visibility: hidden; }
a.quiet { text-underline-offset: .22em; }
.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.primary:hover:not(:disabled) { color: #fff; background: var(--blue-dark); }
input:not([type=checkbox]), textarea {
  width: 100%;
  padding: .68rem .8rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #bdbfb8;
  border-radius: .4rem;
}
textarea { resize: vertical; }

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--white);
  padding: clamp(1rem, 2.6vw, 1.5rem);
}
.guest { max-width: 460px; margin: clamp(.1rem, 5svh, 2.5rem) auto 0; }
.guest h1 { font-size: clamp(2.4rem, 9.5vw, 3.3rem); }
.guest form { display: grid; gap: .75rem; margin-top: 1.35rem; }
.guest form input { min-height: 3rem; }
.guest .error { margin-top: .9rem; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; }
.choice { min-height: 3.35rem; justify-content: flex-start; }
.choice[aria-pressed=true] { background: var(--blue-soft); border: 2px solid var(--blue); color: var(--blue-dark); }
#join { margin-top: .38rem; min-height: 3.4rem; }
.player-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
#guest-round { min-height: 1.5rem; margin: .65rem 0 1.35rem; }
#buzzer {
  width: 100%;
  min-height: clamp(190px, 33svh, 265px);
  border: 1px solid #bfc1bb;
  border-radius: .9rem;
  background: #eaeae4;
  color: #40443f;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#buzzer strong {
  font-size: clamp(2rem, 9.2vw, 3.85rem);
  font-weight: 760;
  letter-spacing: -.06em;
  line-height: 1.04;
}
#buzzer.live {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue-dark);
  box-shadow: 0 .55rem 0 var(--blue-dark);
}
#buzzer.live:hover:not(:disabled) { background: #2337b6; }
#buzzer.live:active { transform: translateY(.27rem); box-shadow: 0 .28rem 0 var(--blue-dark); }
#buzzer.accepted { color: var(--green); background: #edf5ef; border-color: #a9c3b3; }
#buzzer.your-turn { color: #fff; background: var(--green); border-color: var(--green); }
#guest-detail {
  display: grid;
  place-items: center;
  min-height: 2.75rem;
  margin: 1.1rem 0 .5rem;
  text-align: center;
  color: var(--muted);
}

.heading, .section-title, .actions { display: flex; gap: .65rem; align-items: center; }
.heading, .section-title { justify-content: space-between; }
.heading { margin-bottom: 1.25rem; }
.host-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(295px, 355px);
  gap: 1rem;
  align-items: start;
}
.sidebar { display: grid; gap: 1rem; }
.round-card { min-height: 26rem; }
.pill { padding: .4rem .62rem; border-radius: .25rem; background: #ecece6; color: #44474b; font-size: .875rem; font-weight: 650; }
.question { margin: 1rem 0; font-size: 1.23rem; overflow-wrap: anywhere; }
.question:empty { display: none; }
#round-form { display: grid; gap: .65rem; margin-top: 1.05rem; }
#round-form button { justify-self: start; }
.actions { flex-wrap: wrap; margin-top: .9rem; }
.answer {
  margin-top: 1rem;
  padding: 1rem;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  border-radius: 0 .4rem .4rem 0;
}
.answer h2 { font-size: 1.9rem; }
.queue-title { margin-top: 1.3rem; }
.queue, .teams, .scoreboard { padding: 0; margin: .6rem 0 0; list-style: none; }
.queue li, .teams li {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  border-bottom: 1px solid var(--line);
  padding: .59rem .2rem;
}
.queue .position { min-width: 1.55rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.queue .status, .teams .score { margin-left: auto; color: var(--muted); font-size: .875rem; text-align: right; }
.queue .active .status { color: var(--blue); font-weight: 750; }
.queue .wrong .status { color: var(--red); }
.teams .team-name { font-weight: 680; }
.teams .hint { font-size: .875rem; white-space: nowrap; }
.teams .score { color: var(--ink); font-size: 1rem; font-weight: 780; }
.qr-card { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.qr-card img, .hall-join img {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: .4rem;
  height: auto;
}
.qr-card img { width: min(9rem, 43%); aspect-ratio: 1; }
.room-code { margin: .22rem 0 .52rem; font-size: 1.18rem; font-weight: 760; letter-spacing: .075em; }
.bridge .hint { margin-top: .55rem; }
.check { display: flex; align-items: flex-start; gap: .55rem; margin-top: .85rem; font-size: .875rem; }
.check input { width: 1.16rem; height: 1.16rem; accent-color: var(--blue); margin: 0; }
#copy-host { margin-top: .3rem; font-size: .875rem; text-align: left; text-decoration: underline; text-underline-offset: .23rem; }
#host-share { font-size: .9rem; }
#host-error { margin-top: .85rem; }

.hall-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(1rem, 4vw, 3rem);
  min-height: 45vh;
  padding: clamp(1.25rem, 5vw, 3rem);
}
.hall-hero h1 { max-width: 16ch; font-size: clamp(2.3rem, 6.8vw, 5rem); overflow-wrap: anywhere; }
.hall-join { display: grid; justify-items: center; gap: .45rem; text-align: center; }
.hall-join img { width: min(15rem, 33vw); }
.hall-join strong { font-size: 1.35rem; letter-spacing: .09em; }
.hall-join span { max-width: 22ch; overflow-wrap: anywhere; }
#hall-active { margin-top: 1rem; font-size: clamp(1.13rem, 2.9vw, 1.8rem); color: var(--blue-dark); }
.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(123px, 1fr));
  gap: .65rem;
  margin-top: .8rem;
}
.scoreboard li {
  display: grid;
  align-content: space-between;
  gap: .38rem;
  min-height: 6rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: .4rem;
}
.scoreboard .team-name { color: var(--muted); font-weight: 650; font-size: .875rem; }
.scoreboard .score { font-weight: 800; font-size: 2.2rem; line-height: 1; font-variant-numeric: tabular-nums; }
@media (max-width: 830px) {
  .host-layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); }
}
@media (max-width: 520px) {
  .top { min-height: 3.6rem; }
  .heading { flex-direction: column; align-items: start; }
  .hall-hero { grid-template-columns: 1fr; }
  .hall-join img { width: min(66vw, 14rem); }
}
@media (prefers-reduced-motion: reduce) {
  #buzzer.live:active { transform: none; }
}
