:root {
  color-scheme: dark;
  --bg: #060817;
  --panel: #101735;
  --panel-2: #182252;
  --ink: #f7f8ff;
  --muted: #aeb8e5;
  --gold: #ffd44d;
  --gold-2: #ff9f1c;
  --blue: #163ee9;
  --blue-2: #071b9b;
  --green: #21c486;
  --red: #ff496d;
  --line: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 212, 77, 0.14), transparent 28rem),
    linear-gradient(135deg, #060817, #091246 52%, #03040a);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #24306a;
  color: var(--ink);
  padding: 0.62rem 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover,
.file-button:hover {
  border-color: rgba(255, 212, 77, 0.8);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #171000;
}

.success {
  background: var(--green);
  color: #031911;
}

.danger {
  background: var(--red);
  color: #24020a;
}

.ghost {
  background: rgba(255, 255, 255, 0.06);
}

.small {
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--ink);
  padding: 0.55rem 0.65rem;
}

textarea {
  min-height: 5.2rem;
  resize: vertical;
}

label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

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

.host-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 2vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(4, 8, 32, 0.86);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.host-topbar h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
}

.topbar-actions,
.inline-controls,
.clue-actions,
.mode-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.answer-warning {
  padding: 0.72rem 1rem;
  text-align: center;
  background: #4d1022;
  color: #fff5f7;
  font-weight: 900;
}

.host-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  gap: 1rem;
  padding: 1rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 23, 53, 0.88);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: start;
  margin-bottom: 0.8rem;
}

.panel-header h2 {
  margin: 0.15rem 0 0;
}

.board-panel,
.editor-panel {
  grid-column: 1;
}

.clue-panel,
.players-panel {
  grid-column: 2;
}

.host-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
}

.host-category,
.host-tile,
.tv-category,
.tv-tile {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, var(--blue), var(--blue-2));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.host-category {
  min-height: 4.4rem;
  display: grid;
  place-items: center;
  padding: 0.45rem;
  text-align: center;
  font-weight: 950;
  opacity: 0.42;
}

.host-category.revealed {
  opacity: 1;
}

.host-tile {
  min-height: 4.2rem;
  color: var(--gold);
  display: grid;
  place-items: center;
  gap: 0;
}

.host-tile span {
  font-size: clamp(1.15rem, 2vw, 1.85rem);
  font-weight: 950;
}

.host-tile small {
  color: white;
}

.host-tile.active {
  outline: 3px solid var(--gold);
}

.host-tile.solved,
.tv-tile.solved {
  background: rgba(255, 255, 255, 0.05);
  color: transparent;
  opacity: 0.38;
  animation: solvedFade 260ms ease both;
}

@keyframes solvedFade {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.96);
    opacity: 0.38;
  }
}

.players-list {
  display: grid;
  gap: 0.65rem;
}

.player-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8rem auto;
  gap: 0.55rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.05);
}

.player-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 212, 77, 0.18);
}

.player-select {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  border: 0;
  background: transparent;
}

.player-index {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #1d1400;
  font-weight: 950;
}

.score-edit input {
  text-align: right;
}

.player-flags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.player-flags span,
.pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.24rem 0.48rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
}

.host-clue-card,
.active-clue-empty,
.daily-controls,
.final-controls {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.85rem;
}

.host-clue-card h3 {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  line-height: 1.16;
}

.host-answer {
  margin-top: 0.8rem;
  padding: 0.7rem;
  border-radius: 8px;
  background: rgba(255, 212, 77, 0.13);
  color: #fff4c2;
}

.host-media img,
.host-media video,
.tv-media img,
.tv-media video {
  max-width: 100%;
  max-height: 35vh;
  border-radius: 8px;
  object-fit: contain;
}

.clue-actions {
  margin-top: 0.75rem;
}

.shortcut-help {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.8rem;
}

.daily-controls,
.final-controls {
  margin-top: 0.8rem;
}

.final-grid {
  display: grid;
  gap: 0.5rem;
}

.final-player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(6rem, 9rem) auto;
  gap: 0.6rem;
  align-items: center;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
}

.toggle-line input {
  width: auto;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.validation-box {
  margin-bottom: 0.8rem;
  border-radius: 8px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.validation-box.ok {
  color: #a9ffd7;
}

.validation-box.bad {
  color: #ffd0d9;
  background: rgba(255, 73, 109, 0.12);
}

.editor-meta,
.round-toolbar,
.round-actions,
.category-editors,
.clue-editor {
  display: grid;
  gap: 0.65rem;
}

.editor-meta {
  grid-template-columns: minmax(10rem, 1fr) minmax(10rem, 1fr) auto auto;
  align-items: end;
  margin-bottom: 0.8rem;
}

.editor-toggle {
  align-self: center;
  min-height: 2.6rem;
}

.round-toolbar,
.round-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.round-toolbar {
  margin-bottom: 0.8rem;
}

.round-actions {
  margin: 0.65rem 0;
}

.round-editor,
.category-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  margin-bottom: 0.65rem;
  background: rgba(255, 255, 255, 0.04);
}

.round-editor summary,
.category-editor summary {
  cursor: pointer;
  font-weight: 950;
  color: var(--gold);
}

.clue-editor {
  grid-template-columns: 5rem minmax(12rem, 1fr) minmax(12rem, 1fr) 8rem minmax(10rem, 1fr) auto;
  align-items: start;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.clue-editor:last-child {
  border-bottom: 0;
}

.display-body {
  overflow: hidden;
}

.display-app {
  min-height: 100vh;
  padding: clamp(0.7rem, 1.5vw, 1.3rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
}

.display-waiting {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2rem;
}

.launch-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 3rem);
}

.launch-hero {
  width: min(62rem, 100%);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(16, 62, 233, 0.9), rgba(7, 27, 155, 0.92)),
    var(--blue);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 5vw, 4rem);
  text-align: center;
}

.launch-hero h1 {
  margin: 0.15rem 0 0.65rem;
  font-size: clamp(4rem, 12vw, 9rem);
  line-height: 0.86;
  text-transform: uppercase;
}

.launch-copy {
  max-width: 48rem;
  margin: 0 auto 1.25rem;
  color: #e6ebff;
  font-size: clamp(1.15rem, 2vw, 1.7rem);
  font-weight: 750;
}

.launch-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.launch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #24306a;
  color: var(--ink);
  padding: 0.75rem 1rem;
  font-weight: 950;
  text-decoration: none;
}

.launch-button:hover {
  border-color: rgba(255, 212, 77, 0.8);
}

.launch-note {
  margin: 1rem 0 0;
  color: var(--muted);
  font-weight: 800;
}

.display-waiting h1 {
  font-size: clamp(3rem, 8vw, 7rem);
  margin: 0.25rem 0;
}

.tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 6.4rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-block img {
  max-width: 5.5rem;
  max-height: 5.5rem;
  object-fit: contain;
}

.brand-block h1 {
  margin: 0.1rem 0 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.9;
  text-transform: uppercase;
}

.tv-scoreboard {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  max-width: 56vw;
}

.tv-player {
  min-width: 9rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.42rem 0.7rem;
  background: rgba(0, 0, 0, 0.28);
  text-align: center;
}

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

.tv-player span {
  font-size: clamp(0.9rem, 1.5vw, 1.25rem);
  font-weight: 950;
}

.tv-player strong {
  color: var(--gold);
  font-size: clamp(1.2rem, 2.1vw, 1.9rem);
}

.tv-player.active {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(255, 212, 77, 0.9);
}

.tv-player.control::after {
  content: "CONTROL";
  display: block;
  color: #fff4c2;
  font-size: 0.65rem;
  font-weight: 950;
}

.tv-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: minmax(5.5rem, 0.8fr) repeat(5, minmax(5rem, 1fr));
  gap: clamp(0.38rem, 0.8vw, 0.72rem);
  min-height: 0;
}

.tv-category,
.tv-tile {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.5rem;
}

.tv-category {
  font-size: clamp(1rem, 2vw, 2.2rem);
  font-weight: 950;
  text-transform: uppercase;
  line-height: 1;
  transform-origin: center;
}

.tv-category.revealed {
  animation: categoryPop 380ms ease both;
}

.tv-category.hidden-category {
  background: rgba(255, 255, 255, 0.06);
}

@keyframes categoryPop {
  from {
    opacity: 0;
    transform: rotateX(80deg) scale(0.94);
  }
  to {
    opacity: 1;
    transform: rotateX(0) scale(1);
  }
}

.tv-tile {
  color: var(--gold);
  font-size: clamp(2rem, 4vw, 4.5rem);
  font-weight: 950;
  text-shadow: 0 3px 0 #5b3000;
}

.tv-tile.active {
  outline: 0.28rem solid var(--gold);
}

.tv-clue-takeover,
.tv-final,
.tv-gameover {
  min-height: 0;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(16, 62, 233, 0.9), rgba(7, 27, 155, 0.92)),
    var(--blue);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  text-align: center;
  padding: clamp(1rem, 4vw, 4rem);
  animation: clueIn 260ms ease both;
}

@keyframes clueIn {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.tv-clue-takeover h2,
.tv-final h2,
.tv-gameover h2 {
  max-width: 14ch;
  margin: 0;
  font-size: clamp(3rem, 8vw, 8rem);
  line-height: 0.96;
  text-transform: uppercase;
  text-wrap: balance;
}

.tv-clue-takeover h2 {
  max-width: 18ch;
  font-size: clamp(2.6rem, 6.4vw, 7rem);
}

.daily-double-burst {
  border: 0.35rem solid var(--gold);
  border-radius: 8px;
  padding: 0.45rem 1rem;
  color: var(--gold);
  font-size: clamp(2rem, 5vw, 5.4rem);
  font-weight: 950;
  text-transform: uppercase;
  animation: pulseGold 800ms ease infinite alternate;
}

@keyframes pulseGold {
  from {
    box-shadow: 0 0 8px rgba(255, 212, 77, 0.4);
  }
  to {
    box-shadow: 0 0 34px rgba(255, 212, 77, 0.95);
  }
}

.answer-locked {
  border-radius: 999px;
  padding: 0.55rem 1rem;
  background: rgba(0, 0, 0, 0.26);
  color: var(--muted);
  font-weight: 900;
}

.tv-answer {
  width: min(100%, 72rem);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 212, 77, 0.16);
  border: 2px solid var(--gold);
  animation: categoryPop 300ms ease both;
}

.tv-answer span {
  display: block;
  color: var(--gold);
  font-weight: 950;
  text-transform: uppercase;
}

.tv-answer strong {
  display: block;
  font-size: clamp(2rem, 5vw, 5rem);
  line-height: 1;
}

.tv-media {
  max-width: min(80vw, 70rem);
}

.tv-media audio {
  width: min(80vw, 45rem);
}

.final-clue,
.final-hold,
.winner-score {
  font-size: clamp(2rem, 5vw, 5rem);
  font-weight: 950;
  max-width: 18ch;
  line-height: 1.02;
}

.final-standings {
  width: min(70rem, 90vw);
  display: grid;
  gap: 0.45rem;
}

.final-standings div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  background: rgba(0, 0, 0, 0.22);
  font-size: clamp(1.3rem, 2.8vw, 2.7rem);
  font-weight: 950;
}

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

  .board-panel,
  .editor-panel,
  .clue-panel,
  .players-panel {
    grid-column: 1;
  }

  .clue-editor {
    grid-template-columns: 1fr 1fr;
  }

  .editor-meta,
  .final-player-row,
  .player-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .host-topbar,
  .panel-header,
  .tv-header {
    align-items: stretch;
    flex-direction: column;
  }

  .host-board,
  .tv-board {
    gap: 0.25rem;
  }

  .host-category,
  .host-tile {
    min-height: 3.3rem;
    font-size: 0.72rem;
  }

  .tv-scoreboard {
    max-width: none;
    justify-content: flex-start;
  }

  .tv-player {
    min-width: 7rem;
  }
}
