/* css/style.css - Main shared styles */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6c3ff5;
  --primary-d: #5429d8;
  --accent: #ff6b35;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --dark: #0f0f1a;
  --dark2: #1a1a2e;
  --dark3: #16213e;
  --card-bg: #1e1e3f;
  --text: #f0f0ff;
  --text-muted: #9ca3af;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(108, 63, 245, 0.2);
}

.card-sm {
  padding: 18px;
}

/* ── Headings ── */
h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
}
h2 {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 700;
}
h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.logo {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 900;
  background: linear-gradient(135deg, #6c3ff5, #ff6b35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition:
    transform var(--transition),
    opacity var(--transition),
    background var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-d);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) {
  background: #e5562a;
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}
.btn-lg {
  padding: 16px 32px;
  font-size: 1.15rem;
  border-radius: 10px;
}
.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}
.btn-block {
  width: 100%;
}

/* ── Form ── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.form-control {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  background: rgba(108, 63, 245, 0.1);
}
.form-control option {
  background: var(--dark2);
}

/* ── Room Code Display ── */
.room-code {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.2em;
  text-align: center;
  color: var(--primary);
  font-family: "Courier New", monospace;
  text-shadow: 0 0 30px rgba(108, 63, 245, 0.5);
}

/* ── Timer ── */
.timer-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--warning));
  border-radius: 99px;
  transition:
    width 0.5s linear,
    background 0.5s;
}
.timer-bar.danger {
  background: var(--danger);
}
.timer-display {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  color: var(--warning);
}
.timer-display.danger {
  color: var(--danger);
}

/* ── Answer Buttons ── */
.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}
@media (max-width: 480px) {
  .answer-grid {
    grid-template-columns: 1fr;
  }
}

.answer-btn {
  padding: 18px 14px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition:
    transform 0.15s,
    opacity 0.15s,
    background 0.15s;
  color: #fff;
  text-align: left;
  line-height: 1.4;
}
.answer-btn:active {
  transform: scale(0.97);
}
.answer-btn:disabled {
  cursor: not-allowed;
}
.answer-btn.color-0 {
  background: #e74c3c;
}
.answer-btn.color-1 {
  background: #3498db;
}
.answer-btn.color-2 {
  background: #2ecc71;
}
.answer-btn.color-3 {
  background: #9b59b6;
}
.answer-btn.selected {
  border-color: #fff;
  transform: scale(1.02);
}
.answer-btn.correct {
  background: var(--success) !important;
  border-color: #fff;
}
.answer-btn.wrong {
  background: var(--danger) !important;
  opacity: 0.7;
}

/* ── Leaderboard ── */
.leaderboard {
  list-style: none;
}
.leaderboard li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  transition: background 0.3s;
}
.leaderboard li:nth-child(1) {
  background: rgba(255, 215, 0, 0.15);
}
.leaderboard li:nth-child(2) {
  background: rgba(192, 192, 192, 0.12);
}
.leaderboard li:nth-child(3) {
  background: rgba(205, 127, 50, 0.12);
}

.lb-rank {
  width: 28px;
  text-align: center;
  font-size: 1.2rem;
}
.lb-name {
  flex: 1;
  font-size: 1rem;
}
.lb-score {
  font-size: 1.1rem;
  color: var(--warning);
  font-family: monospace;
}

/* ── Winner podium ── */
.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin: 24px 0;
}
.podium-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.podium-name {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.podium-score {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.podium-block {
  width: 70px;
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}
/* Order rendered: [2nd place, 1st place, 3rd place] */
.podium-item:nth-child(1) .podium-block {
  height: 90px;
  background: linear-gradient(180deg, #c0c0c0, #808080);
}
.podium-item:nth-child(2) .podium-block {
  height: 120px;
  background: linear-gradient(180deg, #ffd700, #b8860b);
}
.podium-item:nth-child(3) .podium-block {
  height: 70px;
  background: linear-gradient(180deg, #cd7f32, #8b4513);
}

/* ── Player count badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-primary {
  background: rgba(108, 63, 245, 0.25);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

/* ── Navigation ── */
.nav {
  background: var(--dark2);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.nav-links {
  display: flex;
  gap: 8px;
}
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition:
    color var(--transition),
    background var(--transition);
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

/* ── QR code ── */
.qr-wrap {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  display: inline-flex;
  margin: 0 auto;
}

/* ── Status dot ── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.5s infinite;
}
.status-dot.green {
  background: var(--success);
}
.status-dot.yellow {
  background: var(--warning);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.3);
  }
}

/* ── Question card ── */
.question-text {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  margin-bottom: 6px;
}
.question-meta {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ── Utility ── */
.text-center {
  text-align: center;
}
.text-muted {
  color: var(--text-muted);
}
.text-success {
  color: var(--success);
}
.text-danger {
  color: var(--danger);
}
.text-warning {
  color: var(--warning);
}
.mt-8 {
  margin-top: 8px;
}
.mt-12 {
  margin-top: 12px;
}
.mt-16 {
  margin-top: 16px;
}
.mt-24 {
  margin-top: 24px;
}
.mt-32 {
  margin-top: 32px;
}
.mb-8 {
  margin-bottom: 8px;
}
.mb-16 {
  margin-bottom: 16px;
}
.mb-24 {
  margin-bottom: 24px;
}
.gap-8 {
  gap: 8px;
}
.gap-16 {
  gap: 16px;
}
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.justify-center {
  justify-content: center;
}
.w-full {
  width: 100%;
}
.hidden {
  display: none !important;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 540px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ── Score feedback ── */
.score-feedback {
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--dark2);
}
::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

/* ── Dashboard table ── */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.results-table th,
.results-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.results-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}
.results-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

/* ── Spinner ── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 24px auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
