:root {
  --bg: #0c0f14;
  --surface: #151a24;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-dim: rgba(245, 158, 11, 0.15);
  --answer: #34d399;
  --answer-bg: rgba(52, 211, 153, 0.12);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "DM Serif Display", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

body.controls-hidden .host-bar {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

body.controls-hidden .play-top {
  opacity: 0;
  pointer-events: none;
}

body.controls-hidden #intro-host-bar {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#app { height: 100%; }

.screen {
  display: none;
  height: 100%;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* Home */
#screen-home {
  padding: clamp(1.5rem, 4vw, 3rem);
  overflow-y: auto;
  align-items: center;
}

.home-header {
  text-align: center;
  max-width: 640px;
  margin-bottom: 2.5rem;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

h1 {
  font-family: var(--display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.lead {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.6;
}

.round-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  width: min(960px, 100%);
  margin-bottom: 1.5rem;
}

.round-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  font: inherit;
  color: inherit;
}

.round-card:hover {
  border-color: rgba(245, 158, 11, 0.4);
  background: #1a2030;
  transform: translateY(-2px);
}

.round-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.round-card p {
  font-size: 0.85rem;
  color: var(--muted);
}

.tiebreaker-btn { margin-bottom: 1rem; }

.library-panel {
  width: min(720px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.library-lead {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.library-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 220px;
}

.library-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.category-row .library-select {
  flex: 1;
  min-width: 180px;
}

#btn-delete-category {
  white-space: nowrap;
  color: var(--muted);
}

#btn-delete-category:hover:not(:disabled) {
  color: #f87171;
}

#btn-delete-category:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#btn-delete-list {
  white-space: nowrap;
  color: var(--muted);
}

#btn-delete-list:hover:not(:disabled) {
  color: #f87171;
}

#btn-delete-list:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.category-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.5rem;
}

.category-add-row .new-list-input {
  flex: 1;
  min-width: 160px;
}

.library-select {
  font: inherit;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

.selected-list-badge {
  font-size: 0.85rem;
  color: var(--accent);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-dim);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.selected-list-badge.hidden { display: none; }

.list-library {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
  max-height: 240px;
  overflow-y: auto;
}

.list-library-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.75rem 0;
}

.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
  font: inherit;
  color: inherit;
}

.list-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

.list-card:hover {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(255,255,255,0.05);
}

.list-card.selected {
  border-color: rgba(245, 158, 11, 0.55);
  background: var(--accent-dim);
}

.list-card-main { flex: 1; min-width: 0; }

.list-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
}

.list-card-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.list-card-delete {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
}

.list-card-delete:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}

.new-list-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.new-list-input {
  flex: 1;
  min-width: 180px;
  font: inherit;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

.new-list-input::placeholder { color: #64748b; }

.game-setup {
  width: min(640px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.setup-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.rounds-heading { width: min(960px, 100%); margin-bottom: 1rem; }

.difficulty-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  font-size: 0.9rem;
  cursor: pointer;
}

.chip:has(input:checked) {
  border-color: rgba(245, 158, 11, 0.5);
  background: var(--accent-dim);
}

.chip input { accent-color: var(--accent); }

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.start-game-btn {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 1.05rem;
  padding: 0.95rem 1.5rem;
}

#btn-new-list-grok {
  white-space: nowrap;
}

.regen-hint {
  width: 100%;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.2em;
}

.regen-hint.busy { color: var(--accent); }
.regen-hint.error { color: #f87171; }

.rounds-heading.hidden { display: none; }

.single-round-meta {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  width: 100%;
  max-width: 420px;
}

#round-list.single-round {
  grid-template-columns: 1fr;
  max-width: 420px;
}

#round-list.single-round .round-card { display: none; }

.shuffle-label {
  font-size: 0.85rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.host-notes {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  width: 100%;
}

.host-notes-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.host-notes-input {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  resize: vertical;
  min-height: 120px;
}

.host-notes-input:focus {
  outline: none;
  border-color: rgba(245, 158, 11, 0.45);
}

.host-notes-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

/* Intro screen (crowd-facing) */
#screen-intro {
  position: relative;
}

.intro-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 5vw, 4rem);
  text-align: center;
  min-height: 0;
  overflow-y: auto;
}

.intro-display {
  font-family: var(--display);
  font-size: clamp(1.35rem, 3.2vw, 2.25rem);
  line-height: 1.45;
  max-width: min(900px, 92vw);
  white-space: pre-wrap;
  color: var(--text);
}

.difficulty-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  margin-left: 0.5rem;
}

.difficulty-badge.hidden { display: none; }

.difficulty-badge.easy { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.difficulty-badge.medium { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.difficulty-badge.hard { background: rgba(248, 113, 113, 0.15); color: #f87171; }

.round-card .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.hint {
  font-size: 0.8rem;
  color: #64748b;
  text-align: center;
}

kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
}

/* Play screen */
#screen-play {
  position: relative;
}

.play-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.round-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
}

.progress-label {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 4vw, 4rem);
  text-align: center;
  min-height: 0;
}

.question-number {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.question-text {
  font-family: var(--display);
  font-size: clamp(2rem, 5.5vw, 4.25rem);
  font-weight: 400;
  line-height: 1.25;
  max-width: 18ch;
  letter-spacing: -0.01em;
  max-width: min(900px, 92vw);
}

.answer-panel {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  padding: clamp(1.25rem, 3vw, 2rem) clamp(2rem, 5vw, 3rem);
  background: var(--answer-bg);
  border: 2px solid rgba(52, 211, 153, 0.35);
  border-radius: 20px;
  animation: answerIn 0.35s ease-out;
  max-width: min(800px, 92vw);
}

.answer-panel.hidden { display: none; }

@keyframes answerIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.answer-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--answer);
  margin-bottom: 0.5rem;
}

.answer-text {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--answer);
  line-height: 1.2;
}

/* Host bar */
.host-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  transition: transform 0.25s, opacity 0.25s;
}

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #0c0f14;
  padding: 0.85rem 2rem;
  font-size: 1rem;
}

.btn-primary:hover:not(:disabled) { background: #fbbf24; }

.btn-primary.revealed {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-lg { min-width: 180px; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.65rem 1.1rem;
}

.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.05); }

.btn-sm { font-size: 0.85rem; padding: 0.5rem 0.85rem; }

.btn-icon {
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  font-size: 1.1rem;
  margin-left: auto;
}

.btn-icon:hover { color: var(--text); }

/* End screen */
#screen-end {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.end-card {
  text-align: center;
  max-width: 520px;
}

.end-card h2 {
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin-bottom: 1rem;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 2rem;
}

@media print {
  .host-bar, .play-top, #screen-home, .hint { display: none !important; }
  body { background: white; color: black; }
  .question-text { font-size: 24pt; }
  .answer-panel { display: block !important; border-color: #333; }
  .answer-text { color: #065f46; }
}
