:root {
  --bg: #1a0b2e;
  --bg2: #2d1b4e;
  --card: #3b2266;
  --text: #fff8f0;
  --muted: #c9b8e8;
  --accent: #ff3d7f;
  --accent2: #ffd166;
  --green: #3ddc97;
  --red: #ff5c5c;
  --buzzer-red: #e63946;
  --buzzer-dark: #9b1c28;
  --buzzer-rim: #ffd166;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 20px;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at top, #3a1d6e 0%, var(--bg) 55%, #0d0618 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

a {
  color: var(--accent2);
}

.app {
  max-width: 480px;
  margin: 0 auto;
}

.app.wide {
  max-width: 720px;
}

.brand {
  text-align: center;
  margin-bottom: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #0006;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: linear-gradient(160deg, #4a2a7a, var(--card));
  border: 3px solid #6b3fb0;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #7b52c4;
  background: #1e0f35;
  color: var(--text);
  font-size: 1.05rem;
  outline: none;
}

input:focus {
  border-color: var(--accent2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 16px 18px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  color: #1a0b2e;
  background: linear-gradient(180deg, #ffe08a, var(--accent2));
  box-shadow: 0 6px 0 #c49a2e, 0 10px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  user-select: none;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #c49a2e, 0 4px 10px rgba(0, 0, 0, 0.3);
}

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

.btn.secondary {
  background: linear-gradient(180deg, #c4a8ff, #9b7bdb);
  box-shadow: 0 6px 0 #5e3f9e, 0 10px 20px rgba(0, 0, 0, 0.35);
  color: #1a0b2e;
}

.btn.danger {
  background: linear-gradient(180deg, #ff8a9a, var(--accent));
  box-shadow: 0 6px 0 #b01f4d, 0 10px 20px rgba(0, 0, 0, 0.35);
  color: #fff;
}

.btn.green {
  background: linear-gradient(180deg, #7dffc2, var(--green));
  box-shadow: 0 6px 0 #1f9a65, 0 10px 20px rgba(0, 0, 0, 0.35);
  color: #083524;
}

.btn.small {
  width: auto;
  padding: 10px 14px;
  font-size: 0.85rem;
  border-radius: 12px;
  box-shadow: 0 4px 0 #c49a2e;
}

.btn + .btn {
  margin-top: 12px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.row .btn {
  flex: 1;
  margin-top: 0;
  min-width: 120px;
}

.msg {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1e0f35;
  color: var(--muted);
  font-size: 0.95rem;
  min-height: 1.2em;
}

.msg.error {
  color: #ffb4b4;
  border: 1px solid #ff5c5c55;
}

.msg.ok {
  color: #b8ffd9;
  border: 1px solid #3ddc9755;
}

/* Player name list */
.name-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.name-list button {
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border-radius: 16px;
  border: 3px solid #7b52c4;
  background: #241041;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
}

.name-list button:active {
  transform: scale(0.98);
}

.name-list button:disabled,
.name-list button.taken {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
}

.name-list button.mine {
  border-color: var(--green);
  background: #143d2c;
}

/* Photo / artwork buzzer (assets/buzzer.jpg) */
.play-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 40px);
  gap: 14px;
}

.player-badge {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #241041;
  border: 3px solid var(--accent2);
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 2;
}

.buzzer-stage {
  position: relative;
  width: min(92vw, 380px);
  /* Source art is ~832x1248 portrait with black padding */
  aspect-ratio: 832 / 1248;
  display: grid;
  place-items: center;
  max-height: min(72dvh, 560px);
}

.buzzer-button {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent url("buzzer.jpg") center center / contain no-repeat;
  box-shadow: none;
  cursor: pointer;
  color: transparent;
  font-size: 0;
  line-height: 0;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.buzzer-button:active:not(:disabled) {
  transform: scale(0.94);
  filter: brightness(0.92);
}

.buzzer-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55) brightness(0.7);
  opacity: 0.85;
}

.buzzer-button.locked-out {
  filter: grayscale(0.75) brightness(0.55);
  opacity: 0.8;
}

.buzzer-button.you-won {
  filter: brightness(1.08) saturate(1.15);
  animation: pulse-win 0.7s ease-in-out infinite alternate;
}

@keyframes pulse-win {
  from {
    filter: brightness(1.05) saturate(1.1);
    transform: scale(1);
  }
  to {
    filter: brightness(1.18) saturate(1.2);
    transform: scale(1.03);
  }
}

.status-pill {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  min-height: 1.5em;
}

.status-pill.big {
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  font-weight: 900;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-shadow: 0 4px 0 #0005;
}

.status-pill.win {
  color: #7dffc2;
}

/* Host view */
.host-screen {
  min-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.host-banner {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  background: linear-gradient(160deg, #4a2a7a, #2a1048);
  border: 4px solid #7b52c4;
  border-radius: 28px;
  padding: 24px 16px;
  box-shadow: var(--shadow);
  min-height: 45dvh;
}

.host-banner .waiting {
  font-size: clamp(1.4rem, 6vw, 2rem);
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.host-banner .winner {
  font-size: clamp(2.2rem, 10vw, 3.6rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--accent2);
  text-transform: uppercase;
  line-height: 1.05;
  text-shadow: 0 6px 0 #0005, 0 0 40px rgba(255, 209, 102, 0.35);
  animation: pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes pop-in {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.host-banner .sub {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: #241041;
  border: 2px solid #6b3fb0;
  font-weight: 800;
  font-size: 0.9rem;
}

.chip.claimed {
  border-color: var(--green);
}

.chip.eliminated {
  opacity: 0.45;
  text-decoration: line-through;
}

.chip.winner {
  border-color: var(--accent2);
  background: #4a3510;
  color: var(--accent2);
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #6b3fb055;
}

.admin-list li:last-child {
  border-bottom: none;
}

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

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.admin-actions .btn {
  margin-top: 0;
}

.footer-links {
  text-align: center;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-links a {
  margin: 0 8px;
}

.hidden {
  display: none !important;
}

.add-row {
  display: flex;
  gap: 10px;
}

.add-row input {
  flex: 1;
}

.add-row .btn {
  width: auto;
  margin-top: 0;
  white-space: nowrap;
}

.player-score {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent2);
  letter-spacing: 0.04em;
}

/* Host scoreboard */
.scoreboard {
  list-style: none;
  margin: 0;
  padding: 0;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #6b3fb055;
}

.score-row:last-child {
  border-bottom: none;
}

.score-row.buzzed {
  background: rgba(255, 209, 102, 0.08);
  border-radius: 12px;
  padding-left: 8px;
  padding-right: 8px;
}

.score-row.unclaimed {
  opacity: 0.55;
}

.score-row.eliminated .score-name {
  text-decoration: line-through;
}

.score-info {
  min-width: 0;
  flex: 1;
}

.score-name {
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.score-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.score-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.score-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 14px;
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  color: #1a0b2e;
  background: linear-gradient(180deg, #c4a8ff, #9b7bdb);
  box-shadow: 0 4px 0 #5e3f9e;
  user-select: none;
}

.score-btn.plus {
  background: linear-gradient(180deg, #7dffc2, var(--green));
  box-shadow: 0 4px 0 #1f9a65;
}

.score-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #5e3f9e;
}

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

.score-points {
  min-width: 2.2rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent2);
}

/* Fireworks canvas (winner only) */
.fw-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 900;
  pointer-events: none;
  display: none;
  background: transparent;
}

.fw-canvas.active {
  display: block;
}

/* Full-screen game over on all clients */
.game-over-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 4, 20, 0.88);
  backdrop-filter: blur(6px);
}

.game-over-overlay.winner-celeb {
  background: rgba(10, 4, 20, 0.45);
  backdrop-filter: none;
  pointer-events: none;
}

.game-over-overlay.winner-celeb .game-over-card {
  pointer-events: auto;
  background: linear-gradient(160deg, rgba(90, 47, 138, 0.82), rgba(42, 16, 72, 0.88));
}

.game-over-card {
  text-align: center;
  max-width: 520px;
  padding: 32px 24px;
  border-radius: 28px;
  border: 4px solid var(--accent2);
  background: linear-gradient(160deg, #5a2f8a, #2a1048);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(255, 209, 102, 0.2);
  animation: pop-in 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.game-over-label {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.game-over-title {
  font-size: clamp(2.2rem, 10vw, 3.4rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent2);
  text-shadow: 0 6px 0 #0005, 0 0 40px rgba(255, 209, 102, 0.35);
}

.game-over-sub {
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 1rem;
}

.game-switch {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 3px solid #7b52c4;
  background: #241041;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
}

.game-switch-track {
  position: relative;
  width: 64px;
  height: 36px;
  border-radius: 999px;
  background: #5a3a78;
  flex: 0 0 auto;
}

.game-switch-knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff8f0;
  transition: transform 0.15s ease;
}

.game-switch.is-on {
  border-color: var(--green);
}

.game-switch.is-on .game-switch-track {
  background: var(--green);
}

.game-switch.is-on .game-switch-knob {
  transform: translateX(28px);
}

.game-switch:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
  .game-switch-knob {
    transition: none;
  }
}

/* Host random question panel */
.host-question-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: #1e0f35;
  border: 2px solid #6b3fb0;
}

.host-q-empty {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 4px;
}

.host-q-body.pop {
  animation: pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.host-q-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.host-q-topic {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #1a0b2e;
  background: linear-gradient(180deg, #ffe08a, var(--accent2));
}

.host-q-progress {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.host-q-prompt {
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 12px;
}

.host-q-choices {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.host-q-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #241041;
  border: 2px solid #5e3f9e;
}

.host-q-choice.is-correct {
  border-color: var(--green);
  background: rgba(61, 220, 151, 0.12);
  box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.25);
}

.host-q-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.85rem;
  color: #1a0b2e;
  background: linear-gradient(160deg, #c4a8ff, #9b7bdb);
}

.host-q-choice.is-correct .host-q-letter {
  background: linear-gradient(160deg, #7dffc2, var(--green));
}

.host-q-text {
  font-weight: 700;
  line-height: 1.35;
  padding-top: 3px;
}

.host-q-answer {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid rgba(61, 220, 151, 0.55);
  background: linear-gradient(160deg, rgba(20, 70, 50, 0.55), rgba(12, 40, 30, 0.75));
}

.host-q-answer-label {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7dffc2;
  margin-bottom: 6px;
}

.host-q-answer-main {
  font-size: 1.15rem;
  font-weight: 900;
  color: #b8ffd9;
  line-height: 1.25;
}

.host-q-answer-detail {
  margin-top: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.4;
}
