/* ============================================================
   PuzzleBlitz — Design System v5
   Mobile-first · Dark/Light · No layout bugs
   ============================================================ */

/* ── DARK (default) ── */
:root {
  --bg:        #0d0f1a;
  --bg2:       #131629;
  --bg3:       #1a1f35;
  --surface:   #1e2440;
  --surface2:  #252b4a;
  --border:    #2e3659;

  --primary:       #6c5ce7;
  --primary-light: #a29bfe;
  --accent:        #00d2ff;
  --accent2:       #b8ff57;   /* lime — use on dark only */
  --score-color:   #b8ff57;   /* adapts per theme */
  --danger:        #ff6b6b;
  --success:       #00cec9;
  --warning:       #fdcb6e;

  --text:       #e8eaf6;
  --text-muted: #7b82a8;
  --text-dim:   #4a5180;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 8px 32px rgba(0,0,0,.42);
  --glow:      0 0 20px rgba(108,92,231,.3);

  --font-display: 'Nunito', sans-serif;
  --font-body:    'Space Grotesk', sans-serif;
  color-scheme: dark;
}

/* ── LIGHT ── */
[data-theme="light"] {
  --bg:        #f0f2fb;
  --bg2:       #e4e8f5;
  --bg3:       #d8ddf0;
  --surface:   #ffffff;
  --surface2:  #f2f4fe;
  --border:    #c2c9e8;

  --primary:       #5b4bd4;
  --primary-light: #7c6ff5;
  --accent:        #0088bb;
  --accent2:       #3a6b00;   /* dark green — readable on white */
  --score-color:   #3a6b00;
  --danger:        #d63031;
  --success:       #007a72;
  --warning:       #c47f00;

  --text:       #111827;
  --text-muted: #4b5675;
  --text-dim:   #8892b0;

  --shadow:    0 4px 20px rgba(0,0,0,.10);
  --glow:      0 0 14px rgba(91,75,212,.15);
  color-scheme: light;
}

/* ── BASE ── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { scroll-behavior:smooth; -webkit-text-size-adjust:100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  transition: background .25s, color .25s;
}

/* ── PARTICLES ── */
.particles { position:fixed; inset:0; pointer-events:none; z-index:0; overflow:hidden; }
.particle  { position:absolute; border-radius:50%; animation:float linear infinite; opacity:.14; }
[data-theme="light"] .particle { opacity:.05; }
@keyframes float {
  0%   { transform:translateY(110vh) rotate(0deg);   opacity:0; }
  10%  { opacity:.14; }
  90%  { opacity:.14; }
  100% { transform:translateY(-120px) rotate(720deg); opacity:0; }
}

/* ── HEADER ── */
.site-header {
  position: fixed; top:0; left:0; right:0; z-index:200;
  display: flex; align-items:center; justify-content:space-between;
  padding: 12px 20px;
  background: rgba(13,15,26,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background .25s, border-color .25s;
}
[data-theme="light"] .site-header { background:rgba(240,242,251,.94); }
.logo { display:flex; align-items:center; gap:8px; text-decoration:none; }
.logo-icon { font-size:22px; }
.logo-text { font-family:var(--font-display); font-size:18px; font-weight:900; color:var(--text); }
.logo-accent { color:var(--primary-light); }
.site-nav { display:flex; align-items:center; gap:4px; }
.nav-link {
  padding:6px 12px; border-radius:8px;
  color:var(--text-muted); text-decoration:none;
  font-size:13px; font-weight:600; transition:all .2s;
  white-space:nowrap;
}
.nav-link:hover, .nav-link.active { background:var(--surface); color:var(--text); }
/* hide nav text labels on very small screens */
@media(max-width:480px) {
  .nav-link { font-size:0; padding:6px 8px; }
  .nav-link::before { font-size:14px; }
  .nav-link[href="index.html"]::before       { content:"🏠"; font-size:16px; }
  .nav-link[href="quickplay.html"]::before   { content:"⚡"; font-size:16px; }
  .nav-link[href="leaderboard.html"]::before { content:"🏆"; font-size:16px; }
  .nav-link[href="host.html"]::before        { content:"👑"; font-size:16px; }
}

/* ── THEME TOGGLE ── */
.theme-btn {
  width:36px; height:36px; border-radius:50%;
  background:var(--surface); border:1.5px solid var(--border);
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  font-size:17px; transition:all .2s; flex-shrink:0; margin-left:4px;
}
.theme-btn:hover { background:var(--surface2); transform:scale(1.1); }

/* ── BUTTONS ── */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  padding:11px 20px; border-radius:var(--radius-sm);
  font-family:var(--font-display); font-weight:800; font-size:14px;
  cursor:pointer; border:none; text-decoration:none;
  transition:all .2s; user-select:none; white-space:nowrap;
  -webkit-tap-highlight-color:transparent;
}
.btn-lg { padding:14px 24px; font-size:15px; width:100%; }
.btn-primary {
  background:linear-gradient(135deg,var(--primary),#a855f7);
  color:#fff; box-shadow:0 4px 18px rgba(108,92,231,.35);
}
.btn-primary:hover { transform:translateY(-2px); box-shadow:0 8px 26px rgba(108,92,231,.45); }
.btn-primary:active { transform:translateY(0); }
.btn-secondary { background:linear-gradient(135deg,#0d7377,var(--accent)); color:#fff; }
.btn-secondary:hover { transform:translateY(-2px); }
.btn-accent { background:linear-gradient(135deg,#e17055,#fd79a8); color:#fff; }
.btn-ghost {
  background:var(--surface); color:var(--text-muted);
  border:1.5px solid var(--border);
}
.btn-ghost:hover { background:var(--surface2); color:var(--text); }
.btn-danger { background:var(--danger); color:#fff; }
.btn-success { background:var(--success); color:#fff; }
.btn-sm { padding:8px 14px; font-size:12px; }
.btn:disabled { opacity:.5; cursor:not-allowed; transform:none!important; }

/* ── INPUTS ── */
input[type="text"], input[type="number"], input[type="password"],
textarea, select {
  width:100%; padding:11px 14px;
  background:var(--surface); border:1.5px solid var(--border);
  border-radius:var(--radius-sm); color:var(--text);
  font-family:var(--font-display); font-size:15px; font-weight:700;
  transition:border-color .2s, box-shadow .2s; outline:none;
  -webkit-appearance:none; appearance:none;
}
input:focus, textarea:focus, select:focus {
  border-color:var(--primary);
  box-shadow:0 0 0 3px rgba(108,92,231,.2);
}
[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background:#fff; border-color:#c2c9e8;
}
label {
  display:block; font-size:11px; font-weight:700;
  color:var(--text-muted); text-transform:uppercase;
  letter-spacing:.08em; margin-bottom:5px;
}
.form-group { margin-bottom:14px; }
.form-error {
  color:var(--danger); font-size:13px; font-weight:600;
  margin-top:7px; padding:8px 12px;
  background:rgba(255,107,107,.1); border-radius:8px;
}
.hidden { display:none!important; }

/* ── UTILS ── */
.spinner {
  width:36px; height:36px; border:4px solid var(--border);
  border-top-color:var(--primary); border-radius:50%;
  animation:spin .8s linear infinite; margin:16px auto;
}
@keyframes spin { to{transform:rotate(360deg)} }
.pulse-dot {
  width:10px; height:10px; border-radius:50%;
  background:var(--success); display:inline-block;
  animation:pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.5);opacity:.5} }
@keyframes popIn { from{transform:scale(0);opacity:0} to{transform:scale(1);opacity:1} }
@keyframes slideUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:none} }

/* ── TOAST ── */
.toast-container { position:fixed; top:72px; right:14px; z-index:999; display:flex; flex-direction:column; gap:6px; }
.toast {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-sm); padding:10px 14px;
  font-size:12px; font-weight:600; max-width:260px;
  animation:slideInRight .3s ease; display:flex; align-items:center; gap:8px;
  box-shadow:var(--shadow);
}
.toast-success { border-color:var(--success); }
.toast-error   { border-color:var(--danger);  }
@keyframes slideInRight { from{transform:translateX(110%);opacity:0} to{transform:translateX(0);opacity:1} }

/* ── SITE FOOTER ── */
.site-footer {
  text-align:center; padding:18px;
  border-top:1px solid var(--border);
  color:var(--text-dim); font-size:12px;
}

/* ── HOME PAGE ── */
.home-main { padding-top:72px; position:relative; z-index:1; }
.hero { text-align:center; padding:60px 20px 48px; max-width:1100px; margin:0 auto; }
.hero-eyebrow {
  display:inline-block; padding:5px 14px;
  background:rgba(108,92,231,.18); border:1px solid rgba(108,92,231,.38);
  border-radius:100px; font-size:12px; font-weight:700;
  color:var(--primary-light); margin-bottom:18px; letter-spacing:.05em;
}
.hero-title {
  font-family:var(--font-display);
  font-size:clamp(34px,7vw,80px);
  font-weight:900; line-height:1.08; margin-bottom:14px;
}
.hero-accent {
  background:linear-gradient(135deg,var(--primary-light),var(--accent));
  -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text;
}
.hero-sub { font-size:15px; color:var(--text-muted); max-width:520px; margin:0 auto 36px; line-height:1.7; }
.action-cards {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:14px; max-width:1040px; margin:0 auto;
}
.action-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:24px; transition:transform .2s,box-shadow .2s;
}
.action-card:hover { transform:translateY(-3px); box-shadow:var(--shadow),var(--glow); }
.card-center { border-color:rgba(0,210,255,.3); }
.card-icon { font-size:34px; margin-bottom:10px; }
.action-card h2 { font-family:var(--font-display); font-size:19px; font-weight:800; margin-bottom:6px; }
.action-card p  { color:var(--text-muted); font-size:13px; margin-bottom:14px; line-height:1.6; }
.card-form { display:flex; flex-direction:column; gap:9px; }
.input-code { text-transform:uppercase; letter-spacing:4px; font-size:18px; text-align:center; }
.game-types { padding:56px 20px; max-width:1100px; margin:0 auto; }
.section-title { font-family:var(--font-display); font-size:26px; font-weight:900; text-align:center; margin-bottom:28px; }
.types-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; }
.type-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:18px; text-align:center; transition:all .2s;
}
.type-card:hover { border-color:var(--primary); transform:translateY(-2px); }
.type-icon { font-size:26px; margin-bottom:8px; }
.type-card h3 { font-family:var(--font-display); font-size:13px; font-weight:800; margin-bottom:5px; }
.type-card p  { font-size:11px; color:var(--text-muted); margin-bottom:8px; }
.type-example { font-family:var(--font-display); font-size:11px; font-weight:700; background:var(--bg3); border-radius:6px; padding:5px 8px; color:var(--score-color); }
.how-it-works { padding:40px 20px 56px; max-width:900px; margin:0 auto; text-align:center; }
.steps { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:6px; margin-top:22px; }
.step { background:var(--surface); border-radius:var(--radius); padding:14px 16px; max-width:160px; text-align:center; }
.step-num { width:34px; height:34px; border-radius:50%; background:linear-gradient(135deg,var(--primary),#a855f7); display:flex; align-items:center; justify-content:center; font-family:var(--font-display); font-size:15px; font-weight:900; margin:0 auto 8px; color:#fff; }
.step p { font-size:11px; color:var(--text-muted); }
.step-arrow { font-size:18px; color:var(--text-dim); }

/* ── MULTIPLAYER PLAY PAGE ── */
.play-wrap { padding-top:66px; }

/* waiting room */
.waiting-room {
  min-height:100vh; display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  padding:24px 20px; text-align:center;
}
.big-code {
  font-family:var(--font-display);
  font-size:clamp(44px,12vw,96px);
  font-weight:900; color:var(--score-color);
  letter-spacing:8px; line-height:1; margin:14px 0;
}
.game-title-label { font-family:var(--font-display); font-size:22px; font-weight:800; color:var(--text-muted); }
.player-lobby { display:flex; flex-wrap:wrap; gap:7px; margin-top:16px; justify-content:center; }
.player-chip {
  display:flex; align-items:center; gap:6px;
  padding:5px 11px; border-radius:100px;
  font-size:12px; font-weight:700;
  background:var(--surface2); border:1px solid var(--border);
  animation:popIn .3s cubic-bezier(.34,1.56,.64,1);
}
.player-avatar {
  width:22px; height:22px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:10px; font-weight:800; color:#fff;
}

/* question layout */
.q-page-wrap { max-width:680px; margin:0 auto; padding:10px 16px 100px; }

/* score + progress bar at top (sticky) */
.q-sticky-bar {
  position:sticky; top:66px; z-index:100;
  background:var(--bg); border-bottom:1px solid var(--border);
  padding:10px 16px 8px;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
}
[data-theme="light"] .q-sticky-bar { background:var(--bg); }
.q-label { font-size:12px; font-weight:700; color:var(--text-muted); }
.q-score-chip {
  display:flex; align-items:center; gap:5px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:100px; padding:5px 13px; flex-shrink:0;
}
.q-score-chip .ql { font-size:10px; font-weight:700; color:var(--text-muted); text-transform:uppercase; }
.q-score-chip .qv { font-family:var(--font-display); font-size:17px; font-weight:900; color:var(--score-color); }
.q-prog-bar { height:5px; background:var(--bg3); border-radius:100px; margin-top:7px; overflow:hidden; }
.q-prog-fill { height:100%; background:linear-gradient(90deg,var(--primary),#a855f7); border-radius:100px; transition:width .5s; }

/* timer bar (horizontal, no ring on mobile) */
.timer-row {
  display:flex; align-items:center; gap:10px; margin:14px 0 10px;
}
.timer-num {
  font-family:var(--font-display); font-size:26px; font-weight:900;
  color:var(--accent); min-width:38px; text-align:center;
  transition:color .3s; flex-shrink:0;
}
.timer-track { flex:1; height:10px; background:var(--bg3); border-radius:100px; overflow:hidden; }
.timer-fill {
  height:100%; border-radius:100px;
  background:linear-gradient(90deg,var(--success),var(--accent));
  transition:width 0.25s linear, background .4s;
}

/* question card */
.q-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:18px 20px;
  margin-bottom:14px; animation:slideUp .3s ease;
}
.q-type-badge {
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 10px; border-radius:100px;
  font-size:11px; font-weight:700; text-transform:uppercase;
  letter-spacing:.07em; margin-bottom:10px;
  background:rgba(108,92,231,.2); color:var(--primary-light);
  border:1px solid rgba(108,92,231,.3);
}
.question-text {
  font-family:var(--font-display);
  font-size:clamp(17px,3.5vw,24px);
  font-weight:800; line-height:1.4; color:var(--text);
}
.shape-canvas-wrap {
  background:var(--bg3); border-radius:var(--radius-sm);
  padding:12px; margin:12px 0; text-align:center;
}
.shape-canvas-wrap canvas { max-width:100%; border-radius:7px; }

/* answer buttons — full width on mobile */
.options-grid {
  display:grid; grid-template-columns:1fr 1fr;
  gap:10px; margin-bottom:12px;
}
@media(max-width:420px) { .options-grid { grid-template-columns:1fr; } }
.option-btn {
  padding:14px 14px;
  border-radius:var(--radius-sm);
  cursor:pointer;
  border:2px solid var(--border);
  background:var(--surface);
  font-family:var(--font-display);
  font-size:clamp(13px,3vw,15px);
  font-weight:800; color:var(--text);
  display:flex; align-items:center; gap:9px;
  transition:all .12s; text-align:left;
  -webkit-tap-highlight-color:transparent;
  min-height:52px;
}
.option-btn:hover:not(:disabled) {
  border-color:var(--primary); transform:translateY(-1px);
}
.option-btn:active:not(:disabled) { transform:scale(.98); }
.option-btn:disabled { cursor:default; }
.option-btn.selected { border-color:var(--primary); background:rgba(108,92,231,.14); }
.option-btn.correct  { border-color:var(--success)!important; background:rgba(0,206,201,.14)!important; color:var(--success); }
.option-btn.wrong    { border-color:var(--danger)!important;  background:rgba(255,107,107,.1)!important; opacity:.7; }
.option-letter {
  width:28px; height:28px; border-radius:7px;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:900; flex-shrink:0;
  pointer-events:none;
}
/* word input */
.word-input-area { display:flex; flex-direction:column; gap:10px; margin-bottom:12px; }
.word-input-area input {
  font-size:20px; font-weight:800;
  text-align:center; letter-spacing:3px;
  text-transform:uppercase; padding:14px;
}

/* feedback banner */
.answer-feedback {
  padding:14px 16px; border-radius:var(--radius-sm);
  margin-bottom:12px; display:flex; align-items:flex-start; gap:12px;
  animation:popIn .25s cubic-bezier(.34,1.56,.64,1);
}
.feedback-correct { background:rgba(0,206,201,.1);  border:1.5px solid var(--success); }
.feedback-wrong   { background:rgba(255,107,107,.09); border:1.5px solid var(--danger);  }
.feedback-timeout { background:rgba(253,203,110,.09); border:1.5px solid var(--warning); }
.feedback-icon    { font-size:22px; flex-shrink:0; }
.feedback-body    { flex:1; }
.feedback-title   { font-family:var(--font-display); font-size:15px; font-weight:800; }
.feedback-ans     { font-size:12px; color:var(--text-muted); margin-top:3px; }
.feedback-points  { font-family:var(--font-display); font-size:22px; font-weight:900; color:var(--score-color); flex-shrink:0; }
.feedback-explanation { font-size:11px; color:var(--text-muted); margin-top:3px; }
.feedback-waiting { font-size:11px; color:var(--text-dim); margin-top:6px; }

/* ── RESULTS ── */
.results-page-wrap {
  max-width:620px; margin:0 auto;
  padding:80px 18px 50px; text-align:center;
}
.results-podium {
  display:flex; align-items:flex-end; justify-content:center;
  gap:6px; margin:28px 0;
}
.podium-item { text-align:center; }
.podium-col {
  width:80px; background:var(--surface);
  border-radius:var(--radius-sm) var(--radius-sm) 0 0;
  display:flex; align-items:flex-end; justify-content:center;
  padding-bottom:8px; border:1px solid var(--border); border-bottom:none;
}
.podium-1 { height:110px; background:linear-gradient(to top,rgba(253,203,110,.2),var(--surface)); border-color:var(--warning); }
.podium-2 { height:84px; }
.podium-3 { height:62px; }
.podium-medal { font-size:24px; }
.podium-name  { font-family:var(--font-display); font-size:12px; font-weight:800; margin-top:6px; }
.podium-score { font-size:11px; color:var(--text-muted); }
.results-table { width:100%; border-collapse:collapse; margin-top:16px; font-size:13px; }
.results-table th { font-size:10px; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted); padding:7px 10px; border-bottom:1px solid var(--border); }
.results-table td { padding:10px; border-bottom:1px solid rgba(46,54,89,.3); }
.rank-badge {
  display:inline-flex; align-items:center; justify-content:center;
  width:24px; height:24px; border-radius:50%;
  background:var(--surface2); font-weight:800; font-size:11px;
}

/* ── HOST PAGE ── */
.host-page { padding:86px 20px 54px; max-width:1080px; margin:0 auto; }
.host-page h1 { font-family:var(--font-display); font-size:clamp(24px,5vw,32px); font-weight:900; margin-bottom:6px; }
.subtitle { color:var(--text-muted); margin-bottom:28px; font-size:14px; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:18px; }
@media(max-width:720px) { .two-col { grid-template-columns:1fr; } }
.panel { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:22px; }
.panel h2 { font-family:var(--font-display); font-size:17px; font-weight:800; margin-bottom:14px; display:flex; align-items:center; gap:7px; }
.question-list { display:flex; flex-direction:column; gap:7px; max-height:400px; overflow-y:auto; }
.question-item { background:var(--bg3); border:1px solid var(--border); border-radius:var(--radius-sm); padding:11px 12px; display:flex; align-items:center; gap:9px; }
.q-num { width:22px; height:22px; border-radius:50%; background:var(--primary); display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:800; color:#fff; flex-shrink:0; }
.q-info { flex:1; overflow:hidden; }
.q-type { font-size:9px; font-weight:700; color:var(--primary-light); text-transform:uppercase; letter-spacing:.07em; }
.q-text { font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.q-timer { font-size:10px; color:var(--text-dim); }
.q-delete { background:none; border:none; cursor:pointer; color:var(--text-dim); font-size:15px; padding:3px; transition:color .2s; }
.q-delete:hover { color:var(--danger); }
.question-type-select { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin-bottom:12px; }
.type-btn { padding:8px 5px; border:1.5px solid var(--border); background:var(--bg3); border-radius:7px; cursor:pointer; text-align:center; font-family:var(--font-display); font-size:10px; font-weight:700; color:var(--text-muted); transition:all .2s; }
.type-btn:hover { border-color:var(--primary); color:var(--text); }
.type-btn.active { border-color:var(--primary); background:rgba(108,92,231,.15); color:var(--primary-light); }
.type-btn .t-icon { font-size:15px; display:block; margin-bottom:3px; }
.options-area { display:flex; flex-direction:column; gap:6px; margin-top:6px; }
.option-row { display:flex; gap:6px; align-items:center; }
.option-row input { flex:1; }
.option-label { font-size:10px; font-weight:700; width:16px; color:var(--text-muted); }
.game-code-display { text-align:center; padding:18px; background:linear-gradient(135deg,rgba(108,92,231,.15),rgba(0,210,255,.1)); border:2px solid rgba(108,92,231,.3); border-radius:var(--radius); margin-bottom:14px; }
.code-label { font-size:10px; font-weight:700; color:var(--text-muted); text-transform:uppercase; letter-spacing:.1em; margin-bottom:5px; }
.code-value { font-family:var(--font-display); font-size:38px; font-weight:900; color:var(--score-color); letter-spacing:7px; }
.player-count { font-size:11px; color:var(--text-muted); margin-top:6px; }
.host-bar { position:fixed; bottom:0; left:0; right:0; background:var(--bg2); border-top:1px solid var(--border); padding:12px 18px; display:flex; align-items:center; justify-content:center; gap:10px; z-index:50; flex-wrap:wrap; }
.answer-progress { font-size:12px; font-weight:700; color:var(--text-muted); background:var(--surface); padding:6px 12px; border-radius:100px; }
