:root {
  --bg: #051622;
  --card: #0b2a3c;
  --accent: #2da1d0;
  --accent-dark: #1c6f92;
  --text: #f6fbff;
  --muted: #9fb8c7;
  --success: #29cc97;
  --danger: #ff6b6b;
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(45,161,208,0.25), transparent), var(--bg);
  color: var(--text);
}

main.page {
  display: grid;
  grid-template-columns: 3fr 1.25fr;
  gap: 24px;
  padding: 24px;
}

.quiz {
  background: rgba(11,42,60,0.85);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
}

.quiz__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.quiz__meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.quiz__header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.quiz__subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.timer {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer__ring {
  width: 78px;
  height: 78px;
  position: relative;
}

.timer__ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer__ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.1);
  stroke-width: 8;
}

.timer__ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 0;
  stroke-dashoffset: 0;
}

.timer__readout {
  text-align: right;
}

.timer__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 1px;
}

.timer__value {
  display: block;
  font-size: 2.4rem;
  letter-spacing: 2px;
  font-weight: 600;
}

.online-indicator {
  position: relative;
  padding: 10px 16px 10px 28px;
  border-radius: 18px;
  border: 1px solid rgba(45,161,208,0.4);
  background: rgba(45,161,208,0.15);
  display: flex;
  flex-direction: column;
  text-align: right;
  animation: indicatorPulse 2.4s ease-in-out infinite;
}

.online-indicator::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 12px rgba(41,204,151,0.9);
}

.online-indicator__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 1px;
}

.online-indicator__value {
  font-size: 1.8rem;
  font-weight: 700;
}

@keyframes indicatorPulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(45,161,208,0.35);
  }
  50% {
    box-shadow: 0 0 18px rgba(45,161,208,0.65);
  }
}

.screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.stage {
  width: 100%;
  background: var(--card);
  border-radius: 24px;
  padding: 32px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
}

.stage--question {
  text-align: left;
  padding: 40px;
}

.stage__kicker {
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 8px;
}

.stage h2 {
  margin: 0 0 16px;
  font-size: 2.2rem;
}

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

.stage button {
  margin-top: 16px;
  padding: 14px 24px;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #002233;
  transition: background 0.2s ease, transform 0.2s ease;
}

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

.stage button:not(:disabled):hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
}

.result-stats {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-stats__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.result-stats__row.is-correct {
  border-color: var(--success);
  background: rgba(41,204,151,0.12);
}

.result-stats__row span {
  flex: 1;
  text-align: left;
}

.result-stats__row strong {
  min-width: 56px;
  text-align: right;
}

.result-stats__total {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.question__header h2 {
  font-size: 2rem;
}

.question__choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.choice {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  color: var(--text);
  font-weight: 600;
}

.choice:hover {
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-2px);
}

.choice.is-selected {
  border-color: var(--accent);
  background: rgba(45,161,208,0.1);
}

.choice.is-correct {
  border-color: var(--success);
  background: rgba(41,204,151,0.12);
}

.choice.is-wrong {
  border-color: var(--danger);
  background: rgba(255,107,107,0.15);
}

.choice__text {
  flex: 1;
  text-align: left;
}

.choice__count {
  display: none;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.15);
  gap: 2px;
}

.question__choices.choice-counts-visible .choice__count {
  display: flex;
}

.choice__count-number {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.choice__count-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.quiz__footer {
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.membership {
  background: rgba(11,42,60,0.85);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
}

.auth-info {
  margin-top: 16px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
}

.membership__tabs {
  display: flex;
  gap: 8px;
}

.membership__tab {
  flex: 1;
  border: none;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
}

.membership__tab.is-active {
  background: var(--accent);
  color: #002233;
  font-weight: 600;
}

.membership__panels {
  position: relative;
}

.membership__panel {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.membership__panel.is-active {
  display: flex;
}

.membership__panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  gap: 6px;
}

.membership__panel input {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.2);
  color: var(--text);
}

.membership__panel button {
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #002233;
  font-weight: 600;
  cursor: pointer;
}


.player-dashboard {
  background: rgba(0,0,0,0.25);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-dashboard__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.player-dashboard__header h2 {
  margin: 6px 0 0;
}

.player-dashboard__email {
  color: var(--muted);
  margin: 4px 0 0;
}

.player-dashboard__actions {
  display: flex;
  gap: 8px;
}

.player-dashboard__actions button {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
}

.player-dashboard__actions .ghost {
  background: transparent;
  color: var(--text);
  border-color: rgba(255,255,255,0.25);
}

.player-dashboard__actions .danger {
  background: rgba(255,107,107,0.15);
  color: var(--danger);
  border-color: rgba(255,107,107,0.3);
}

.player-dashboard__status {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

.player-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.stat-card__label {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.stat-card__value {
  margin: 6px 0 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.scoreboard {
  background: rgba(0,0,0,0.25);
  border-radius: 18px;
  padding: 16px;
}

#score-breakdown {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.05);
}

.score-item__name {
  font-size: 1rem;
  font-weight: 600;
}

.score-item__value {
  font-size: 1.3rem;
}

.score-item.is-self {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(45,161,208,0.3);
}

.score-item--empty {
  justify-content: center;
  font-size: 0.95rem;
  color: var(--muted);
}

@media (max-width: 1080px) {
  main.page {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .quiz__header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .quiz__meta {
    flex-direction: column;
    width: 100%;
  }

  .timer {
    justify-content: center;
  }

  .online-indicator {
    width: 100%;
    text-align: center;
  }

  .quiz__footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .stage {
    padding: 24px;
  }

  .player-dashboard__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .player-dashboard__actions {
    width: 100%;
    justify-content: flex-start;
  }
}
