/* QuizMe — theme.css */
:root {
  --c-primary:   #1B5E20;
  --c-secondary: #F57F17;
  --c-accent:    #E65100;
  --c-bg:        #0D1B0E;
  --c-surface:   #1A2E1B;
  --c-surface2:  #243825;
  --c-text:      #E8F5E9;
  --c-text-muted:#A5D6A7;
  --c-correct:   #43A047;
  --c-incorrect: #E53935;
  --c-gold:      #FFD600;
  --c-silver:    #B0BEC5;
  --c-bronze:    #A1887F;

  /* Category colours */
  --cat-history:    #1565C0;
  --cat-notable:    #6A1B9A;
  --cat-sport:      #E65100;
  --cat-arts:       #AD1457;
  --cat-language:   #00695C;
  --cat-geography:  #2E7D32;
  --cat-culture:    #F57F17;
  --cat-law:        #4527A0;
  --cat-science:    #00838F;
  --cat-society:    #558B2F;

  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0,0,0,.45);
  --transition: .25s cubic-bezier(.4,0,.2,1);
  --font-main: 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Segoe UI', system-ui, sans-serif;
}

/* High-contrast theme */
[data-theme="high-contrast"] {
  --c-bg: #000;
  --c-surface: #111;
  --c-text: #fff;
  --c-text-muted: #ddd;
}

/* Dyslexia-friendly font */
[data-font="dyslexia"] {
  --font-main: 'OpenDyslexic', 'Comic Sans MS', cursive;
  --font-display: 'OpenDyslexic', 'Comic Sans MS', cursive;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Top Bar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px; height: 56px;
  background: rgba(13,27,14,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar .logo { font-size: 1.3rem; font-weight: 700; color: var(--c-gold); margin-right: auto; text-decoration: none; }
.topbar a, .topbar button {
  color: var(--c-text-muted); background: none; border: none; cursor: pointer;
  font-size: .9rem; padding: 6px 12px; border-radius: 8px;
  text-decoration: none; transition: background var(--transition), color var(--transition);
}
.topbar a:hover, .topbar button:hover { background: var(--c-surface2); color: var(--c-text); }
.topbar a.active { color: var(--c-gold); }

/* ── Page wrapper ── */
.page { padding-top: 72px; min-height: 100vh; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ── Cards ── */
.card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.06);
}

/* ── Mode tiles (main menu) ── */
.mode-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; padding: 40px 0; }
.mode-tile {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg); padding: 40px 32px;
  cursor: pointer; text-decoration: none; color: var(--c-text);
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow);
}
.mode-tile:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 12px 40px rgba(0,0,0,.6); }
.mode-tile::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.08) 0%, transparent 60%);
  pointer-events: none;
}
.mode-tile .tile-icon { font-size: 3rem; margin-bottom: 16px; display: block; }
.mode-tile h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.mode-tile p { font-size: .9rem; opacity: .8; line-height: 1.5; }
.tile-single   { background: linear-gradient(135deg, #1B5E20, #2E7D32); }
.tile-team     { background: linear-gradient(135deg, #1A237E, #283593); }
.tile-expo     { background: linear-gradient(135deg, #BF360C, #E64A19); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: var(--c-secondary); color: #000; }
.btn-primary:hover:not(:disabled) { background: #FFA000; transform: translateY(-1px); }
.btn-success   { background: var(--c-correct); color: #fff; }
.btn-success:hover:not(:disabled) { background: #388E3C; }
.btn-danger    { background: var(--c-incorrect); color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #C62828; }
.btn-ghost     { background: transparent; color: var(--c-text-muted); border: 1px solid rgba(255,255,255,.2); }
.btn-ghost:hover:not(:disabled)   { background: var(--c-surface2); color: var(--c-text); }
.btn-lg { padding: 16px 36px; font-size: 1.15rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 7px 14px; font-size: .85rem; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
label { display: block; font-size: .85rem; color: var(--c-text-muted); margin-bottom: 6px; font-weight: 500; }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; padding: 10px 14px;
  background: var(--c-surface2); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius); color: var(--c-text); font-size: 1rem;
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-secondary);
  box-shadow: 0 0 0 3px rgba(245,127,23,.2);
}
input[type="range"] { width: 100%; accent-color: var(--c-secondary); }

/* ── Answer buttons ── */
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.answer-btn {
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--c-surface2); border: 2px solid rgba(255,255,255,.1);
  color: var(--c-text); font-size: 1rem; cursor: pointer; text-align: left;
  transition: all var(--transition); line-height: 1.4;
}
.answer-btn:hover:not(:disabled) { border-color: var(--c-secondary); background: var(--c-surface); transform: translateY(-2px); }
.answer-btn.correct  { background: rgba(67,160,71,.25); border-color: var(--c-correct); animation: pulse-correct .4s ease; }
.answer-btn.incorrect { background: rgba(229,57,53,.25); border-color: var(--c-incorrect); animation: shake .4s ease; }
.answer-btn .label { font-weight: 700; color: var(--c-secondary); margin-right: 10px; }

/* ── Score / streak display ── */
.score-bar {
  display: flex; gap: 24px; align-items: center;
  background: var(--c-surface); border-radius: var(--radius);
  padding: 12px 20px; margin-bottom: 20px;
}
.score-item { text-align: center; }
.score-item .val { font-size: 1.6rem; font-weight: 700; color: var(--c-gold); }
.score-item .lbl { font-size: .75rem; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Timer ── */
.timer-ring { position: relative; width: 64px; height: 64px; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring .track { fill: none; stroke: var(--c-surface2); stroke-width: 5; }
.timer-ring .progress { fill: none; stroke: var(--c-secondary); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .9s linear, stroke .3s; }
.timer-ring .num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: 700; }
.timer-ring.urgent .progress { stroke: var(--c-incorrect); }
.timer-ring.urgent .num { color: var(--c-incorrect); }

/* ── Streak stars ── */
.streak-track { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.streak-star { font-size: 1.8rem; transition: transform .3s, filter .3s; filter: grayscale(1) opacity(.4); }
.streak-star.lit { filter: none; transform: scale(1.15); animation: star-pop .3s ease; }

/* ── Progress bar ── */
.progress-bar { height: 6px; background: var(--c-surface2); border-radius: 3px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--c-secondary); border-radius: 3px; transition: width .4s ease; }

/* ── Category badge ── */
.cat-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; padding: 10px 12px; color: var(--c-text-muted); border-bottom: 1px solid rgba(255,255,255,.08); font-weight: 600; }
.table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.05); }
.table tr:hover td { background: var(--c-surface2); }

/* ── Drag-drop zone ── */
.drop-zone {
  border: 2px dashed rgba(255,255,255,.2); border-radius: var(--radius-lg);
  padding: 48px; text-align: center; cursor: pointer;
  transition: all var(--transition);
}
.drop-zone.drag-over { border-color: var(--c-secondary); background: rgba(245,127,23,.08); }
.drop-zone .icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--c-surface); border-radius: var(--radius-lg);
  padding: 32px; max-width: 560px; width: 100%;
  transform: scale(.95); transition: transform var(--transition);
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.3rem; }
.modal-close { background: none; border: none; color: var(--c-text-muted); font-size: 1.5rem; cursor: pointer; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--c-surface); border-radius: var(--radius);
  padding: 12px 20px; box-shadow: var(--shadow);
  border-left: 4px solid var(--c-secondary);
  animation: slide-in-right .3s ease;
  font-size: .9rem;
}
.toast.success { border-color: var(--c-correct); }
.toast.error   { border-color: var(--c-incorrect); }

/* ── Leaderboard ── */
.leaderboard-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px; background: var(--c-surface2); }
.leaderboard-row .rank { font-size: 1.3rem; font-weight: 700; width: 36px; text-align: center; }
.leaderboard-row.rank-1 .rank { color: var(--c-gold); }
.leaderboard-row.rank-2 .rank { color: var(--c-silver); }
.leaderboard-row.rank-3 .rank { color: var(--c-bronze); }
.leaderboard-row .name { flex: 1; font-weight: 600; }
.leaderboard-row .score { font-size: 1.1rem; font-weight: 700; color: var(--c-secondary); }

/* ── Attract screen ── */
.attract-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #BF360C 0%, #1B5E20 50%, #1A237E 100%);
  cursor: pointer;
}
.attract-screen h1 { font-size: clamp(2.5rem, 8vw, 6rem); font-weight: 900; color: #fff; text-align: center; text-shadow: 0 4px 20px rgba(0,0,0,.5); }
.attract-screen .tap-hint { font-size: clamp(1rem, 3vw, 1.8rem); color: rgba(255,255,255,.8); margin-top: 20px; animation: pulse-opacity 1.5s ease-in-out infinite; }

/* ── Team scoreboard strip ── */
.team-strip { display: flex; gap: 12px; padding: 12px 20px; background: rgba(0,0,0,.4); flex-wrap: wrap; }
.team-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 30px; font-weight: 700;
  transition: all .5s ease;
}
.team-chip .team-score { font-size: 1.2rem; }
.team-chip.buzzed { box-shadow: 0 0 0 3px #fff, 0 0 20px rgba(255,255,255,.5); transform: scale(1.05); }

/* ── Presenter view ── */
.presenter-question { font-size: clamp(1.4rem, 3.5vw, 2.2rem); font-weight: 700; text-align: center; line-height: 1.4; margin: 32px 0; }
.presenter-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.presenter-answer {
  padding: 24px 28px; border-radius: var(--radius-lg);
  background: var(--c-surface2); border: 2px solid rgba(255,255,255,.1);
  font-size: clamp(1rem, 2.5vw, 1.4rem); font-weight: 600;
}
.presenter-answer.revealed.correct { background: rgba(67,160,71,.3); border-color: var(--c-correct); }

/* ── Animations ── */
@keyframes pulse-correct {
  0%   { box-shadow: 0 0 0 0 rgba(67,160,71,.6); }
  70%  { box-shadow: 0 0 0 12px rgba(67,160,71,0); }
  100% { box-shadow: 0 0 0 0 rgba(67,160,71,0); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}
@keyframes pulse-opacity {
  0%,100% { opacity: 1; }
  50%     { opacity: .4; }
}
@keyframes star-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.5); }
  100% { transform: scale(1.15); }
}
@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes count-up {
  from { transform: scale(1.4); color: var(--c-gold); }
  to   { transform: scale(1); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes winner-bounce {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.08); }
}

.fade-in { animation: fade-in .4s ease forwards; }
.score-bump { animation: count-up .4s ease; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .answer-grid { grid-template-columns: 1fr; }
  .presenter-answers { grid-template-columns: 1fr; }
  .mode-tiles { grid-template-columns: 1fr; }
  .topbar .hide-mobile { display: none; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--c-bg); }
::-webkit-scrollbar-thumb { background: var(--c-surface2); border-radius: 3px; }

/* ── Utility ── */
.text-center { text-align: center; }
.text-muted  { color: var(--c-text-muted); }
.text-gold   { color: var(--c-gold); }
.text-correct   { color: var(--c-correct); }
.text-incorrect { color: var(--c-incorrect); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
