:root {
  --bg: #0b0f14;
  --panel: rgba(19, 25, 35, 0.88);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e5ecf5;
  --muted: #94a3b8;
  --accent: #4f7cff;
  --accent-strong: #5b8bff;
  --danger: #ff6b6b;
}

:root.theme-light {
  --bg: #f6f7fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --muted: #5f6675;
  --accent: #4f7cff;
  --accent-strong: #3f6fff;
  --danger: #e5484d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 0%, #142032, #0b0f14 55%);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: hidden !important;
}

.theme-light body {
  background: radial-gradient(circle at 10% 0%, #ffffff, #eef2f7 55%);
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(8, 12, 18, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 1000;
}

.theme-light .topbar {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(79, 124, 255, 0.15);
  color: var(--text);
  text-decoration: none;
  font-size: 1.4rem;
  font-weight: 700;
}

.theme-light .back-link {
  background: rgba(79, 124, 255, 0.12);
  color: #0f172a;
}

.topbar-title {
  font-weight: 700;
}

.nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 220px;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(8, 12, 18, 0.9);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 1000;
}

.theme-light .nav {
  background: rgba(255, 255, 255, 0.95);
  border-right: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 12px 0 28px rgba(15, 23, 42, 0.08);
}

.nav-title {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.nav a {
  text-decoration: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.nav a.active,
.nav a:hover {
  background: rgba(79, 124, 255, 0.18);
}

.overlay {
  display: none;
}

.hamburger {
  display: none;
}

.main {
  margin: 0 auto;
  padding: 112px 24px 120px;
  max-width: 1280px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 2.4rem;
}

.hero p {
  margin: 0 0 24px;
  color: var(--muted);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.team-names {
  margin-top: 10px;
}

.team-name-fields {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.panel h2,
.panel h3 {
  margin-top: 0;
}

.panel.mini {
  padding: 16px;
}

.label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 12px;
}

select,
input {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 14, 22, 0.7);
  color: var(--text);
  font-size: 0.95rem;
}

.theme-light select,
.theme-light input {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
}

.btn {
  margin-top: 14px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transform: translate(-50%, -50%);
  transition: width 0.5s ease, height 0.5s ease;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn.mini {
  width: auto;
  padding: 6px 10px;
  font-size: 0.8rem;
  margin-top: 0;
}

.btn.primary {
  background: rgba(148, 163, 184, 0.28);
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
  background: rgba(148, 163, 184, 0.42);
  box-shadow:
    0 10px 28px rgba(148, 163, 184, 0.25),
    0 0 25px rgba(148, 163, 184, 0.15);
}

.btn:active {
  transform: translateY(0) scale(1);
  transition: transform 0.1s ease;
}

.theme-light .btn {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(148, 163, 184, 0.22);
  color: #0f172a;
}

.theme-light .btn.primary {
  background: rgba(148, 163, 184, 0.28);
}

.theme-light .btn:hover {
  background: rgba(148, 163, 184, 0.40);
  box-shadow:
    0 10px 25px rgba(148, 163, 184, 0.2),
    0 0 22px rgba(148, 163, 184, 0.12);
}

.room-code-row {
  margin-top: 14px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.room-code {
  font-weight: 800;
  letter-spacing: 0.2em;
}

.team-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.checkbox-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 14px;
  color: var(--text);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle input {
  display: none;
}

/* Switch body */
.slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: #2a2f3a;
  border-radius: 50px;
  transition: 0.25s ease;
}

/* Switch circle */
.slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.25s ease;
}

/* ON state */
.toggle input:checked + .slider {
  background: #4f7cff; /* adjust to your theme blue */
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
}


.advanced {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.hidden {
  display: none;
}

.chip {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 14, 22, 0.7);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.chip:hover {
  transform: translateY(-2px) scale(1.03);
  background: rgba(79, 124, 255, 0.15);
  border-color: rgba(79, 124, 255, 0.35);
  box-shadow:
    0 8px 22px rgba(79, 124, 255, 0.15),
    0 0 20px rgba(79, 124, 255, 0.1);
}

.chip:active {
  transform: translateY(0) scale(1);
  transition: transform 0.1s ease;
}

.theme-light .chip {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.85);
  color: #0f172a;
}

.chip.active {
  background: rgba(79, 124, 255, 0.3);
  border-color: rgba(79, 124, 255, 0.7);
  box-shadow:
    0 8px 22px rgba(79, 124, 255, 0.25),
    0 0 25px rgba(79, 124, 255, 0.2);
}

.chip.active:hover {
  box-shadow:
    0 12px 28px rgba(79, 124, 255, 0.35),
    0 0 30px rgba(79, 124, 255, 0.25);
}

.error {
  color: var(--danger);
  min-height: 18px;
}

.room.hidden {
  display: none;
}

.room {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

.room-header,
.room-body {
  width: 100%;
  min-width: 0;
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.scoreboard {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 100%;
}

.score {
  background: rgba(10, 14, 22, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 14px;
  border-radius: 12px;
  text-align: center;
  min-width: 90px;
  max-width: 100%;
}

.theme-light .score {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.score strong {
  display: block;
  font-size: 1.4rem;
}

.score span {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.room-body {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
  align-content: start;
}

.desk-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px;
  display: grid;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.desk-section {
  padding: 14px;
  border-radius: 14px;
  background: rgba(10, 14, 22, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 0;
  width: 100%;
}

.theme-light .desk-section {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.desk-section h3 {
  margin: 0 0 10px;
}

.timer-big {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.timer-small {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-strong);
}

.question-image,
#answerImage {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.theme-light .question-image,
.theme-light #answerImage {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.9);
}

.question-text {
  margin-top: 12px;
  font-size: 1rem;
}

.answer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.buzz-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.buzz-row .btn {
  width: auto;
  min-width: 140px;
}

.buzz-giant {
  width: 100%;
  padding: 24px;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
}

.player-timers {
  display: grid;
  gap: 6px;
  text-align: center;
  margin-bottom: 10px;
}

.player-timer-main {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
}

.player-timer-sub {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
}

  .btn-row {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .btn-row.triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

.btn-row.single {
  grid-template-columns: 1fr;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(79, 124, 255, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.theme-light .status-pill {
  background: rgba(79, 124, 255, 0.15);
  color: #1f2937;
}

.status-pill.locked {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5f5;
}

.theme-light .status-pill.locked {
  background: rgba(148, 163, 184, 0.18);
  color: #5f6675;
}

.status-pill.open {
  background: rgba(79, 124, 255, 0.25);
  color: #dbe6ff;
}

.theme-light .status-pill.open {
  color: #0f172a;
}

.log-panel {
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  max-width: 100%;
}

.log-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(10, 14, 22, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.theme-light .log-item {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  max-width: 100%;
  display: block;
  overflow-x: auto;
}

.stats-table th,
.stats-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  word-break: break-word;
}

.stats-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.theme-light .stats-table th,
.theme-light .stats-table td {
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}

.player-list {
  display: grid;
  gap: 8px;
  max-width: 100%;
}

.player-card {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(10, 14, 22, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-light .player-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(15, 23, 42, 0.1);
}

.btn.buzz-locked,
.btn:disabled {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5f5;
  border-color: rgba(255, 255, 255, 0.08);
  cursor: not-allowed;
  transform: none;
}

.theme-light .btn.buzz-locked,
.theme-light .btn:disabled {
  background: rgba(15, 23, 42, 0.08);
  color: #94a3b8;
  border-color: rgba(15, 23, 42, 0.12);
}

.host-controls {
  display: grid;
  gap: 8px;
}

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

.bottom-nav {
  display: none;
}

.host-only {
  display: none;
}

.player-only {
  display: none;
}

.is-host .host-only {
  display: block;
}

.is-host .desk-panel.host-only {
  display: grid;
}

.is-player .player-only {
  display: block;
}

.is-player .host-only {
  display: none;
}

.nav-collapsed .nav,
.nav-collapsed .bottom-nav,
.nav-collapsed .hamburger,
.nav-collapsed .overlay {
  display: none;
}

.nav-collapsed .main {
  margin-left: 0;
}

@media (max-width: 900px) {
  .nav {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .nav.open {
    transform: translateX(0);
  }

  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 900;
  }

  .overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  .hamburger {
    display: block;
    position: fixed;
    top: 18px;
    left: 18px;
    font-size: 1.4rem;
    background: rgba(15, 20, 30, 0.9);
    padding: 8px 12px;
    border-radius: 10px;
    z-index: 1100;
  }

  .theme-light .hamburger {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(15, 23, 42, 0.1);
    color: #0f172a;
  }

  .main {
    margin-left: 0;
    padding: 88px 16px 120px;
  }

  .room-body {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    position: fixed !important;
    bottom: max(0px, env(safe-area-inset-bottom)) !important;
    left: 0 !important;
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: rgba(8, 12, 18, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 0;
    z-index: 1000;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  .theme-light .bottom-nav {
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(15, 23, 42, 0.1);
  }

  .theme-light .bottom-nav a:hover {
    color: #0f172a;
    background: rgba(79,124,255,0.12);
  }

  .theme-light .bottom-nav-more button:hover {
    color: #0f172a;
  }

  .bottom-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
}
