:root {
  --purple: #7b2ff7;
  --purple-dark: #4b0fb0;
  --pink: #f637ec;
  --bg: #46178f;
  --card-bg: #ffffff;
  --text: #2d2d2d;
  --muted: #6b6b7a;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --success: #26890c;
  --error: #e21b3c;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg), var(--purple) 60%, var(--pink));
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: rgba(255,255,255,0.85); }
.small { font-size: 0.85em; }

a { color: inherit; }
.link-plain { text-decoration: none; color: #fff; font-weight: 600; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--pink); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-ghost { background: rgba(255,255,255,0.15); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 16px 32px; font-size: 20px; }
.btn-block { display: block; width: 100%; }

/* Cards / forms */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}
label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
  color: var(--text);
  font-size: 14px;
}
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], textarea {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 2px solid #ddd;
  font-size: 16px;
  font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--purple); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.alert-error { background: #fde2e2; color: #8a1f1f; }
.alert-success { background: #e1f5e1; color: #1f6b1f; }

/* Auth / landing */
.auth-wrap, .landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}
.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  text-align: left;
}
.auth-card h1 { text-align: center; color: var(--purple-dark); margin-top: 0; }
.auth-card .muted { color: var(--muted); text-align: center; }
.landing h1 { color: #fff; font-size: 2.4em; margin-bottom: 4px; }
.landing-actions { max-width: 360px; width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

/* Admin */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: rgba(0,0,0,0.15);
  color: #fff;
}
.topbar-title { font-weight: 800; font-size: 1.1em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.container { max-width: 900px; margin: 0 auto; padding: 24px; }
.container-narrow { max-width: 600px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 14px; color: #fff; }
.section-header h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.quiz-card h3 { margin: 0 0 4px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.question-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-block; background: var(--purple); color: #fff; border-radius: 50%; width: 26px; height: 26px; line-height: 26px; text-align: center; font-weight: 700; font-size: 13px; }
.choice-input { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.choice-input input[type=text] { flex: 1; }

/* Host screen */
.host-screen, .player-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; color: #fff; text-align: center; }
.view { width: 100%; max-width: 800px; }
.lobby-header h1 { font-size: 1.6em; margin: 6px 0 16px; }
.pin-display { background: #fff; color: var(--purple-dark); font-size: 3em; font-weight: 800; letter-spacing: 8px; border-radius: var(--radius); padding: 16px 24px; display: inline-block; margin: 10px 0; }
.players-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 20px 0; min-height: 50px; }
.player-chip { background: rgba(255,255,255,0.2); padding: 10px 18px; border-radius: 30px; font-weight: 700; }

.qa-top { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 14px; }
.timer { background: #fff; color: var(--purple-dark); font-weight: 800; font-size: 1.4em; border-radius: 50%; width: 56px; height: 56px; display: inline-flex; align-items: center; justify-content: center; }
.question-text { font-size: 1.6em; margin: 10px 0 20px; }
.question-image { max-width: 100%; max-height: 240px; border-radius: 10px; margin-bottom: 16px; }

.choices-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.choice-box {
  border-radius: 12px;
  padding: 20px;
  font-size: 1.1em;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.c0 { background: var(--red); }
.c1 { background: var(--blue); }
.c2 { background: var(--yellow); }
.c3 { background: var(--green); }
.choice-box .shape { font-size: 1.3em; }
.choice-box.correct { outline: 4px solid #fff; }
.choice-box.faded { opacity: 0.45; }
.choice-count { margin-left: auto; background: rgba(0,0,0,0.25); padding: 2px 10px; border-radius: 20px; font-size: 0.85em; }

.choices-grid-player { grid-template-columns: 1fr 1fr; }
.choice-btn {
  border: 2px solid #e2dcf5;
  border-radius: 12px;
  padding: 18px 14px;
  font-size: 1.1em;
  font-weight: 800;
  background: #ffffff;
  color: var(--purple-dark);
  cursor: pointer;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.choice-btn .shape { font-size: 1.6em; line-height: 1; color: var(--purple); }
.choice-btn-text { word-break: break-word; color: var(--text); }
.choice-btn:active { transform: scale(0.96); background: #f4f1fb; }
.choice-btn:disabled { opacity: 0.6; }

.waiting-box { background: rgba(255,255,255,0.12); border-radius: var(--radius); padding: 40px 24px; }
.spinner { width: 40px; height: 40px; border: 5px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; margin: 20px auto 0; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-box { background: rgba(255,255,255,0.12); border-radius: var(--radius); padding: 40px 24px; }
.result-box.correct { background: rgba(38,137,12,0.5); }
.result-box.incorrect { background: rgba(226,27,60,0.5); }
.result-points { font-size: 2em; font-weight: 800; margin: 6px 0; }

.leaderboard { list-style: none; padding: 0; max-width: 420px; margin: 0 auto; text-align: left; }
.leaderboard li { background: rgba(255,255,255,0.15); margin-bottom: 8px; padding: 12px 16px; border-radius: 10px; display: flex; justify-content: space-between; font-weight: 700; }
.leaderboard li:nth-child(1) { background: #ffd60a; color: #4b3600; }
.leaderboard li:nth-child(2) { background: #d9d9e3; color: #333; }
.leaderboard li:nth-child(3) { background: #e0b084; color: #4b2b0d; }

@media (max-width: 560px) {
  .choices-grid, .choices-grid-player { grid-template-columns: 1fr; }
  .pin-display { font-size: 2em; letter-spacing: 4px; }
  .row-2 { grid-template-columns: 1fr; }
}