/* ── Design tokens ── */
:root {
  --navbar: #1c1208;
  --orange: #c8621a;
  --orange-hover: #a84f12;
  --cream: #f5f0e4;
  --cream-dark: #ede7d8;
  --green: #3a6b3a;
  --green-light: #e8f0e8;
  --text-dark: #1c1208;
  --text-mid: #4a3820;
  --text-muted: #7a6a55;
  --white: #ffffff;
  --border: #d6ccba;
  --shadow: 0 2px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 6px 24px rgba(0,0,0,0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Lato', sans-serif;
  background: var(--cream);
  min-height: 100vh;
  color: var(--text-dark);
}

/* ── Navbar ── */
.navbar {
  background: var(--navbar);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.navbar-logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; overflow: hidden;
}
.navbar-logo img { width: 100%; height: 100%; object-fit: cover; }
.navbar-title .name { font-weight: 700; color: #fff; font-size: 0.95rem; display: block; }
.navbar-title .sub { font-size: 0.65rem; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 1.5px; }
.navbar-tag { font-size: 0.75rem; color: rgba(255,255,255,0.5); font-weight: 700; letter-spacing: 1px; }

/* ── Layout ── */
.app { max-width: 720px; margin: 0 auto; padding: 16px 14px 60px; }
.app-wide { max-width: 960px; margin: 0 auto; padding: 16px 14px 60px; }

/* ── Page title ── */
.page-title { margin-bottom: 24px; }
.page-title h1 {
  font-family: 'Merriweather', serif;
  font-size: clamp(1.5rem, 5vw, 2rem);
  color: var(--text-dark);
  font-weight: 700;
  margin-bottom: 4px;
}
.page-title p { color: var(--text-muted); font-size: 0.95rem; }

/* ── Card ── */
.card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px 16px 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  animation: slideUp 0.35s ease;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px; background: var(--orange);
}
.card + .card { margin-top: 18px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scoreboard pills ── */
.scoreboard { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.score-pill {
  flex: 1; min-width: 80px;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 10px 8px; text-align: center; box-shadow: var(--shadow);
}
.score-pill .label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); font-weight: 700; margin-bottom: 2px; }
.score-pill .value { font-weight: 900; font-size: 1.5rem; color: var(--orange); line-height: 1.1; }
.score-pill.green .value { color: var(--green); }

/* ── Progress bar ── */
.progress-wrap { height: 6px; background: var(--border); border-radius: 99px; margin-bottom: 20px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--orange); border-radius: 99px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }

/* ── Category badge ── */
.category-badge {
  display: inline-block; background: var(--green); color: var(--white);
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px;
  padding: 3px 10px; border-radius: 4px; margin-bottom: 12px;
}

.question-num { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.question-text {
  font-family: 'Merriweather', serif;
  font-size: clamp(1rem, 3vw, 1.15rem);
  font-weight: 700; color: var(--text-dark); line-height: 1.55; margin-bottom: 20px;
}

/* ── Options ── */
.options { display: grid; gap: 9px; }
.option-btn {
  width: 100%; padding: 13px 16px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--cream);
  font-family: 'Lato', sans-serif; font-size: 0.95rem; font-weight: 700;
  color: var(--text-dark); cursor: pointer; text-align: left;
  transition: all 0.15s ease; display: flex; align-items: center; gap: 12px; line-height: 1.35;
}
.option-btn:hover:not(:disabled) { border-color: var(--orange); background: #fff8f3; }
.option-btn .opt-letter {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--white); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 900; flex-shrink: 0; color: var(--text-muted);
  transition: all 0.15s ease;
}
.option-btn.correct { border-color: var(--green); background: var(--green-light); }
.option-btn.correct .opt-letter { background: var(--green); border-color: var(--green); color: white; }
.option-btn.wrong { border-color: #c0392b; background: #fdf0ef; }
.option-btn.wrong .opt-letter { background: #c0392b; border-color: #c0392b; color: white; }
.option-btn:disabled { cursor: default; }

/* ── Feedback ── */
.feedback { margin-top: 14px; padding: 13px 15px; border-radius: 8px; font-size: 0.88rem; font-weight: 700; line-height: 1.45; display: none; }
.feedback.correct { background: var(--green-light); color: #2a5a2a; border-left: 4px solid var(--green); display: block; }
.feedback.wrong { background: #fff3e0; color: #8a3a00; border-left: 4px solid var(--orange); display: block; }
.feedback .fact { font-weight: 400; margin-top: 5px; opacity: 0.9; }

/* ── Buttons ── */
.btn { display: inline-block; padding: 12px 24px; border-radius: 8px; border: none; font-family: 'Lato', sans-serif; font-size: 0.95rem; font-weight: 900; letter-spacing: 0.5px; cursor: pointer; transition: all 0.2s ease; text-decoration: none; text-align: center; }
.btn-primary { background: var(--orange); color: white; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--orange-hover); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--cream-dark); color: var(--text-dark); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--orange); }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #2d5a2d; }

.big-btn {
  display: inline-block; padding: 15px 36px; border-radius: 99px; border: none;
  background: var(--orange); color: white; font-family: 'Lato', sans-serif;
  font-size: 1rem; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; box-shadow: 0 4px 16px rgba(200,98,26,0.35); transition: all 0.2s ease;
}
.big-btn:hover { background: var(--orange-hover); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(200,98,26,0.4); }
.big-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.next-btn {
  margin-top: 18px; width: 100%; padding: 14px; border-radius: 8px; border: none;
  background: var(--orange); color: white; font-family: 'Lato', sans-serif;
  font-size: 1rem; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s ease; display: none; box-shadow: var(--shadow);
}
.next-btn:hover { background: var(--orange-hover); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.next-btn.show { display: block; animation: fadeIn 0.3s ease; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 700; font-size: 0.85rem; color: var(--text-mid); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.form-control {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--cream);
  font-family: 'Lato', sans-serif; font-size: 1rem; color: var(--text-dark);
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--orange); background: white; }
.form-error { color: #c0392b; font-size: 0.82rem; margin-top: 4px; font-weight: 700; }
.validation-summary { background: #fdf0ef; border-left: 4px solid #c0392b; padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 0.88rem; color: #c0392b; font-weight: 700; }

/* ── Code display ── */
.join-code { font-family: 'Merriweather', serif; font-size: clamp(2.5rem, 8vw, 4rem); font-weight: 700; color: var(--orange); letter-spacing: 8px; text-align: center; padding: 16px 0; line-height: 1.1; }
.join-url-box { background: var(--cream-dark); border: 1.5px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 0.88rem; color: var(--text-mid); word-break: break-all; display: flex; align-items: center; gap: 10px; }
.join-url-box span { flex: 1; }
.copy-btn { flex-shrink: 0; padding: 6px 12px; background: var(--orange); color: white; border: none; border-radius: 6px; font-family: 'Lato', sans-serif; font-weight: 700; font-size: 0.8rem; cursor: pointer; }
.copy-btn:hover { background: var(--orange-hover); }

/* ── Team list ── */
.team-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.team-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--cream-dark); border-radius: 8px; border: 1px solid var(--border); font-weight: 700; }
.team-item .team-badge { background: var(--orange); color: white; border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 900; flex-shrink: 0; }
.team-item .team-pts { margin-left: auto; font-size: 1.2rem; color: var(--orange); font-weight: 900; }
.team-item .team-status { margin-left: auto; font-size: 1.2rem; }

/* ── Answer status grid (host game view) ── */
.answer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.answer-card { padding: 12px 14px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--cream-dark); display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 0.9rem; }
.answer-card.waiting { border-color: var(--border); }
.answer-card.answered { border-color: var(--green); background: var(--green-light); }
.answer-card .status-icon { font-size: 1.3rem; }

/* ── Leaderboard ── */
.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--cream-dark); border-radius: 10px; border: 1.5px solid var(--border); }
.lb-row.first { background: #fff8f3; border-color: var(--orange); }
.lb-rank { font-family: 'Merriweather', serif; font-size: 1.5rem; font-weight: 700; color: var(--text-muted); min-width: 32px; text-align: center; }
.lb-name { flex: 1; font-weight: 700; color: var(--text-dark); }
.lb-pts { font-weight: 900; font-size: 1.3rem; color: var(--orange); }
.lb-time { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; }

/* ── Result ring ── */
.result-ring {
  width: 140px; height: 140px; border-radius: 50%;
  background: conic-gradient(var(--orange) 0%, var(--orange) var(--pct, 0%), var(--border) var(--pct, 0%));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 22px; position: relative;
  box-shadow: 0 0 0 4px var(--cream), 0 0 0 5px var(--border);
}
.result-ring::before { content: ''; position: absolute; inset: 14px; border-radius: 50%; background: var(--white); }
.result-ring .ring-text { position: relative; z-index: 1; text-align: center; }
.result-ring .score-big { font-weight: 900; font-size: 2.4rem; color: var(--orange); line-height: 1; display: block; }
.result-ring .score-total { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }

/* ── Screen / center states ── */
.screen { text-align: center; padding: 12px 0; }
.screen .big-icon { font-size: 4rem; margin-bottom: 14px; display: block; animation: bounce 2s infinite; }
.screen h2 { font-family: 'Merriweather', serif; color: var(--text-dark); font-size: clamp(1.4rem, 5vw, 1.9rem); margin-bottom: 10px; font-weight: 700; }
.screen p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; max-width: 420px; margin: 0 auto 22px; }
.verdict { font-family: 'Merriweather', serif; font-size: 1.3rem; color: var(--orange); margin-bottom: 6px; font-weight: 700; }

/* ── Fixed bottom score bar (player) ── */
.score-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--navbar); color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; z-index: 50; font-weight: 700;
}
.score-bar .sb-name { font-size: 0.9rem; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.score-bar .sb-pts { font-size: 1.3rem; color: var(--orange); font-weight: 900; }
.score-bar .sb-rank { font-size: 0.8rem; opacity: 0.65; }

/* ── QR image ── */
.qr-wrap { text-align: center; margin: 16px 0; }
.qr-wrap img { max-width: 200px; width: 100%; height: auto; border-radius: 8px; border: 3px solid var(--orange); }

/* ── Connecting overlay ── */
.connecting-overlay {
  position: fixed; inset: 0; background: rgba(28,18,8,0.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 200; color: white; gap: 16px;
}
.connecting-overlay.hidden { display: none; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.3); border-top-color: var(--orange); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* ── Locked overlay ── */
.locked-msg { margin-top: 14px; padding: 12px 16px; border-radius: 8px; background: var(--cream-dark); border: 1.5px solid var(--border); font-weight: 700; color: var(--text-mid); text-align: center; display: none; }
.locked-msg.show { display: block; }

/* ── Host control panel ── */
.control-panel { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.control-panel .btn { flex: 1; }

/* ── Section heading ── */
.section-head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); font-weight: 700; margin: 20px 0 10px; }

/* ── Radio + select groups ── */
.radio-group { display: flex; flex-direction: column; gap: 10px; }
.radio-option { flex: 1; }
.radio-option input { display: none; }
.radio-option label {
  display: block; padding: 10px 14px; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--cream-dark); text-align: center; font-weight: 700; cursor: pointer; transition: all 0.15s;
}
.radio-option input:checked + label { border-color: var(--orange); background: #fff8f3; color: var(--orange); }

/* ── Animations ── */
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }

/* ── Responsive: desktop enhancements ── */
@media (min-width: 601px) {
  .app, .app-wide          { padding: 28px 20px 60px; }
  .card                    { padding: 28px 24px 24px; }
  .navbar                  { padding: 0 24px; }
  .control-panel           { flex-direction: row; flex-wrap: wrap; }
  .control-panel .btn      { min-width: 140px; }
  .radio-group             { flex-direction: row; flex-wrap: wrap; }
  .radio-option            { min-width: 100px; }
  .answer-grid             { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .score-pill              { min-width: 90px; padding: 12px 10px; }
  .score-pill .value       { font-size: 1.8rem; }
}
