:root {
  color-scheme: dark light;
  --bg: #080b0f;
  --panel: #111820;
  --panel-2: #17222d;
  --text: #f5f1e8;
  --muted: #9aa7b1;
  --line: #2b3844;
  --accent: #f7c948;
  --accent-2: #23d3b6;
  --danger: #ff5b6e;
  --ok: #59d46b;
  --shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(35, 211, 182, .18), transparent 28rem),
    linear-gradient(135deg, #080b0f 0%, #141a20 55%, #0b1116 100%);
  color: var(--text);
  font-family: Avenir Next, Segoe UI, Helvetica, Arial, sans-serif;
}

/* Host page fills the viewport exactly — no page scroll; panels scroll internally. */
body.host {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.host #hostApp {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .8rem 1rem;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

button.primary,
.primary {
  border-color: #e5b83a;
  background: var(--accent);
  color: #15120a;
  font-weight: 800;
}

button.danger,
.danger {
  border-color: #9d3342;
  background: #4b1921;
  color: #ffd9de;
}

.hidden {
  display: none !important;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 24, 32, .92);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 .45rem;
  color: var(--accent-2);
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.error {
  min-height: 1.4rem;
  color: var(--danger);
}

.phone-shell {
  width: min(100%, 34rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem;
}

.join-panel,
.play-area {
  padding: 1.25rem;
}

.join-panel h1,
.play-area h1 {
  margin: .25rem 0 1rem;
  font-size: clamp(2rem, 10vw, 3.5rem);
  line-height: 1;
}

/* Phone question stem: keep it compact so the answer buttons sit near the top
   of the viewport (fast-tap game — players should not scroll past a huge stem). */
.play-area h1.qstem {
  font-size: clamp(1.15rem, 4.6vw, 1.6rem);
  line-height: 1.25;
  margin: .2rem 0 .9rem;
}

label {
  display: grid;
  gap: .35rem;
  margin: 1rem 0;
  color: var(--muted);
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #06090d;
  color: var(--text);
  font-size: 1.15rem;
}

.join-panel .primary,
.lock {
  width: 100%;
  min-height: 4rem;
  font-size: 1.35rem;
}

.player-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: .8rem 0;
  background: rgba(8, 11, 15, .9);
  backdrop-filter: blur(12px);
}

.player-top strong,
.player-top span {
  display: block;
}

.player-top span {
  color: var(--muted);
}

.score-pill {
  min-width: 4.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .9rem;
  text-align: center;
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 900;
}

.choice-grid {
  display: grid;
  gap: .75rem;
  margin: 1rem 0;
}

.choice {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  text-align: left;
  font-size: 1.05rem;
}

.choice b {
  display: grid;
  place-items: center;
  flex: 0 0 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: #25313d;
  color: var(--accent);
}

.selected {
  outline: 3px solid var(--accent);
}

.confidence {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
  margin-bottom: 1rem;
}

.buzz {
  width: 100%;
  min-height: 11rem;
  border-color: #e5b83a;
  background: var(--accent);
  color: #171306;
  font-size: clamp(3rem, 18vw, 6rem);
  font-weight: 1000;
}

.big-input {
  margin: 1rem 0;
  font-size: 2rem;
  text-align: center;
}

.host-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 15, .88);
}

.host-bar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 3.2rem);
}

.mode-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
}

.mode-controls select {
  width: auto;
  min-width: 13rem;
  padding: .75rem;
}

.mode-controls button.pending {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(247, 201, 72, .18), 0 0 1.2rem rgba(247, 201, 72, .34);
  animation: reveal-pending 1.4s ease-in-out infinite;
}

.mode-controls button.is-primary {
  border-color: #e5b83a;
  background: var(--accent);
  color: #15120a;
  font-weight: 800;
}

.mode-controls button.armed {
  border-color: var(--danger);
  background: #4b1921;
  color: #ffd9de;
  font-weight: 900;
}

@keyframes reveal-pending {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(247, 201, 72, .14), 0 0 .85rem rgba(247, 201, 72, .24);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(247, 201, 72, .24), 0 0 1.35rem rgba(247, 201, 72, .42);
  }
}

.host-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 20rem 1fr 20rem;
  grid-template-rows: minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  overflow: hidden;
}

/* Each column fills the row height and scrolls INTERNALLY — the page itself never scrolls. */
.room-card,
.leader-card,
.stage {
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
}

.stage {
  padding: 1rem 1.25rem;
}

.stage.is-cw-reveal {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stage.is-cw-reveal .answers-in {
  display: none;
}

.room-code {
  margin: .1rem 0 1rem;
  color: var(--accent);
  font-size: clamp(2.25rem, 3vw, 3.25rem);
  font-weight: 900;
  letter-spacing: .12em;
  line-height: 1;
}

.qr {
  margin: .5rem auto 1rem;
  width: max-content;
  max-width: 100%;
  overflow: hidden;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem;
  line-height: .72rem;
  white-space: pre;
}

.room-card.round-live .qr {
  display: none;
}

.join-url {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.roster-row,
.leader-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: .65rem 0;
  font-size: 1.05rem;
}

.empty {
  color: var(--muted);
}

.answers-in {
  min-height: 2rem;
  margin-bottom: .75rem;
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 900;
}

.stage h2 {
  margin: .15rem 0 .85rem;
  font-size: clamp(1.4rem, 2.3vw, 2.7rem);
  line-height: 1.15;
}

.host-options {
  display: grid;
  gap: .55rem;
}

.host-option {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  align-items: center;
  gap: .85rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: .7rem 1rem;
  background: #0d1319;
  font-size: clamp(1rem, 1.35vw, 1.5rem);
}

.host-option b {
  display: grid;
  place-items: center;
  flex: 0 0 2.4rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: #25313d;
  color: var(--accent);
}

.host-option.has-picks {
  grid-template-columns: 2.4rem minmax(0, 1fr) auto;
}

.host-option.has-picks b {
  align-self: start;
}

.option-text {
  min-width: 0;
}

.host-option.correct {
  border-color: var(--ok);
  background: rgba(89, 212, 107, .14);
}

.pickrow {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .65rem;
}

.pickbar {
  display: block;
  height: .55rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(154, 167, 177, .18);
}

.pickbar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(255, 91, 110, .72);
}

.host-option.correct .pickbar-fill {
  background: var(--ok);
}

.pickcount {
  min-width: 1.7rem;
  color: var(--text);
  font-size: .95rem;
  font-weight: 900;
  text-align: right;
}

.pickers {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: clamp(.78rem, .9vw, .95rem);
  line-height: 1.25;
}

.cw-reveal-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "head head"
    "options teaching";
  gap: .9rem 1.4rem;
  overflow: hidden;
}

.cw-reveal-head {
  grid-area: head;
  min-width: 0;
}

.cw-meta {
  margin: 0 0 .3rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stage .cw-reveal-question {
  margin: 0;
  font-size: clamp(1.15rem, 1.5vw, 1.65rem);
  line-height: 1.2;
}

.cw-options {
  grid-area: options;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: .55rem;
}

.cw-dist-row {
  position: relative;
  isolation: isolate;
  min-height: 3.3rem;
  overflow: hidden;
  border: 1px solid rgba(154, 167, 177, .22);
  border-radius: 8px;
  background: #0d1319;
}

.cw-option-fill {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 0;
  border-radius: inherit;
  transform-origin: left;
  animation: cw-fill-in .32s ease-out both;
}

.cw-dist-row.is-correct {
  border-color: rgba(89, 212, 107, .92);
  box-shadow: inset 3px 0 0 var(--ok);
}

.cw-dist-row.is-correct .cw-option-fill {
  background: rgba(89, 212, 107, .28);
}

.cw-dist-row.has-wrong-picks .cw-option-fill {
  background: rgba(255, 91, 110, .14);
}

.cw-dist-row.has-wrong-picks .cw-option-content {
  opacity: .85;
}

.cw-dist-row.is-zero {
  opacity: .6;
}

.cw-option-content {
  position: relative;
  z-index: 1;
  min-height: 3.3rem;
  display: grid;
  grid-template-columns: 2.35rem minmax(0, 1fr) 2.6rem;
  grid-template-areas:
    "letter answer count"
    "letter names  count";
  align-items: center;
  gap: .1rem .7rem;
  padding: .4rem .8rem;
}

.cw-letter { grid-area: letter; align-self: center; }
.cw-option-answer { grid-area: answer; }
.cw-picker-names { grid-area: names; }
.cw-count { grid-area: count; align-self: center; }

.cw-letter {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  background: #25313d;
  color: var(--accent);
  font-weight: 900;
}

.cw-dist-row.is-correct .cw-letter {
  background: var(--ok);
  color: #07100a;
}

.cw-option-answer {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .45rem;
  color: var(--text);
  font-size: clamp(1rem, 1.15vw, 1.3rem);
  font-weight: 800;
  line-height: 1.15;
}

.cw-option-answer .cw-option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cw-check {
  flex: 0 0 auto;
  color: var(--ok);
  font-weight: 1000;
}

.cw-picker-names {
  min-width: 0;
  justify-self: start;
  overflow: hidden;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cw-picker-names:empty {
  display: none;
}

.cw-count {
  justify-self: end;
  min-width: 2rem;
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 1000;
  line-height: 1;
  text-align: right;
}

@keyframes cw-fill-in {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.teaching {
  margin-top: 1rem;
  border-left: 3px solid var(--accent-2);
  padding: 1rem;
  background: rgba(13, 19, 25, .78);
}

.teaching h3 {
  margin: .15rem 0 .35rem;
  color: var(--accent-2);
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.teaching p {
  margin: .25rem 0 .75rem;
  font-size: 1.15rem;
  line-height: 1.45;
}

.cw-teaching {
  grid-area: teaching;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: .75rem;
  margin-top: 0;
  overflow-y: auto;
  padding: 0 .35rem 0 0;
  border-left: 0;
  background: transparent;
}

.teaching-card {
  --card-accent: var(--accent-2);
  border: 1px solid rgba(154, 167, 177, .22);
  border-left: 3px solid var(--card-accent);
  border-radius: 8px;
  padding: .85rem 1rem;
  background: rgba(13, 19, 25, .78);
}

.trap-card {
  --card-accent: var(--accent);
}

.debrief-card {
  --card-accent: var(--accent-2);
}

.wall-card {
  --card-accent: rgba(255, 91, 110, .78);
}

.teaching-card h3 {
  margin: 0 0 .35rem;
  color: var(--card-accent);
}

.teaching-card p {
  margin: 0;
}

.wall {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.wall span {
  border-radius: 999px;
  padding: .4rem .7rem;
  background: rgba(255, 91, 110, .16);
  color: #ffd9de;
  border: 1px solid rgba(255, 91, 110, .28);
  font-weight: 900;
}

.wall-empty {
  margin: 0;
  color: var(--muted);
}

.jeopardy-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(3rem, 1fr);
  gap: .5rem;
  height: 100%;
}

.cat-head {
  display: grid;
  place-items: center;
  text-align: center;
  padding: .5rem;
  border-radius: 8px;
  background: #10202a;
  color: var(--accent-2);
  font-weight: 900;
  font-size: clamp(.8rem, 1vw, 1.15rem);
}

.clue-cell {
  display: grid;
  place-items: center;
  border: 2px solid #29445a;
  border-radius: 8px;
  background: #082f4a;
  color: var(--accent);
  text-align: center;
  font-size: clamp(1.4rem, 2.4vw, 2.8rem);
  font-weight: 1000;
}

.clue-cell.used {
  background: #10151a;
  color: #3c4854;
}

.buzz-panel,
.answer-key,
.final-card {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: #0d1319;
}

.answer-key summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 900;
}

.final-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: .75rem;
}

.final-card h3 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 .75rem;
}

.final-card.judged {
  opacity: .55;
}

@media (max-width: 1050px) {
  .host-layout {
    grid-template-columns: 1fr;
  }

  .room-card,
  .leader-card,
  .stage {
    min-height: auto;
  }

  .stage.is-cw-reveal {
    overflow-y: auto;
  }

  .cw-reveal-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "head"
      "options"
      "teaching";
    overflow: visible;
  }

  .cw-teaching {
    overflow: visible;
  }
}

@media (max-width: 720px) {
  .host-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-controls {
    justify-content: stretch;
  }

  .mode-controls > * {
    flex: 1 1 9rem;
  }

}
