/* ── Reset & Tokens ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:       #141418;
  --surface:  #1c1c21;
  --border:   #2e2e36;
  --input-bg: #222228;
  --text:     #dddbd5;
  --muted:    #6b6b78;
  --accent:   #5b8cf5;
  --correct:  #4a9e6b;
  --error:    #c0614a;
  --warning:  #d4922a;
  --radius:   8px;
  --font:     'DM Sans', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  min-height: 100dvh;
}

/* ════════════════════════════════════════════════
   LANDING PAGE
════════════════════════════════════════════════ */
.landing-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 80px;
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Header auth controls ───────────────────────── */
.btn-signin {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.btn-signin:hover { color: var(--text); border-color: var(--text); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.user-chip-email {
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.btn-signout {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.btn-signout:hover { color: var(--text); border-color: var(--text); }

.hero { margin-bottom: 28px; }

.hero h1 {
  font-size: clamp(26px, 6vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.hero p { color: var(--muted); font-size: 14px; }

/* ── Mode grid ──────────────────────────────────── */
.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-card {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr 24px;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
  font-family: var(--font);
  color: var(--text);
}

.mode-card:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

.mode-card--custom { align-items: start; }

.mode-icon { font-size: 24px; line-height: 1; padding-top: 2px; }

.mode-name  { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.mode-desc  { font-size: 13px; color: var(--muted); line-height: 1.4; margin-bottom: 8px; }
.mode-tags  { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  font-size: 11px;
  font-weight: 500;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 7px;
}

.mode-arrow {
  font-size: 16px;
  color: var(--muted);
  transition: color .15s, transform .15s;
}

.mode-card:hover .mode-arrow { color: var(--accent); transform: translateX(3px); }

.custom-filters { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.custom-filters .select-wrap { position: relative; }
.custom-filters .select-wrap::after {
  content: 'v';
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 11px;
}

.custom-filters select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 28px 8px 10px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.custom-filters select:focus { border-color: var(--accent); }
.custom-filters select option { background: var(--input-bg); }

/* ════════════════════════════════════════════════
   GAME PAGE
════════════════════════════════════════════════ */
.game-body { display: flex; flex-direction: column; }

/* ── HUD ────────────────────────────────────────── */
.hud {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}

.hud-quit {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  transition: color .15s;
  line-height: 1;
}

.hud-quit:hover { color: var(--error); }

.hud-mode {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.progress-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
  width: 0%;
}

.hud-progress { font-size: 11px; color: var(--muted); }

.hud-right { display: flex; align-items: center; gap: 14px; }

.hud-stat { display: flex; flex-direction: column; align-items: flex-end; }

.hud-stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.hud-stat-value { font-size: 16px; font-weight: 700; line-height: 1.2; }

#timerValue        { color: var(--accent); }
#timerValue.warn   { color: var(--warning); }
#timerValue.danger { color: var(--error); }

/* ── Game content area ──────────────────────────── */
.game-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 16px 48px;
  gap: 16px;
}

.question-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.q-badge {
  font-size: 11px;
  font-weight: 500;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 8px;
}

.question-text {
  font-size: clamp(17px, 4vw, 22px);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

/* ── Answer grid ────────────────────────────────── */
.answer-grid { display: flex; flex-direction: column; gap: 10px; }

.answer-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  transition: border-color .12s, background .12s;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.answer-btn:disabled { cursor: default; }

.answer-btn.correct {
  border-color: var(--correct);
  background: color-mix(in srgb, var(--correct) 10%, var(--surface));
}

.answer-btn.wrong {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, var(--surface));
}

.answer-letter {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--input-bg);
  border-radius: 5px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}

.answer-btn.correct .answer-letter { background: var(--correct); color: #fff; }
.answer-btn.wrong   .answer-letter { background: var(--error);   color: #fff; }
.answer-text { line-height: 1.4; }

/* ── Feedback ───────────────────────────────────── */
.feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
}

.feedback.correct { border-color: var(--correct); color: var(--correct); }
.feedback.wrong   { border-color: var(--error);   color: var(--error); }
.feedback-icon    { font-size: 18px; }

/* ── Next button ────────────────────────────────── */
.btn-next {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

.btn-next:hover { opacity: .88; }

/* ── End screen ─────────────────────────────────── */
.end-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.end-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.end-icon  { font-size: 48px; line-height: 1; }
.end-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.end-score { font-size: 42px; font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
.end-stats { font-size: 13px; color: var(--muted); line-height: 1.8; }
.end-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* ── Shared buttons ─────────────────────────────── */
.btn-submit {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

.btn-submit:hover { opacity: .88; }

.btn-secondary {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 11px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.btn-secondary:hover { color: var(--text); border-color: var(--text); }

/* ── Quit modal ─────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(100%, 320px);
  padding: 24px 20px;
}

.modal-header { margin-bottom: 10px; }
.modal-title  { font-size: 15px; font-weight: 600; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-danger {
  background: var(--error);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  cursor: pointer;
  transition: opacity .15s;
}

.btn-danger:hover { opacity: .85; }

/* ════════════════════════════════════════════════
   AUTH MODAL
════════════════════════════════════════════════ */

/* ── Backdrop ───────────────────────────────────── */
.auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

/* ── Modal box ──────────────────────────────────── */
.auth-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 340px;
  position: relative;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.auth-modal h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.auth-modal p {
  margin: 0 0 1rem;
  font-size: 13px;
  color: var(--muted);
}

/* ── Close button ───────────────────────────────── */
.auth-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  line-height: 1;
  transition: color .15s;
}

.auth-close:hover { color: var(--text); }

/* ── Social buttons ─────────────────────────────── */
.auth-social-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s, background .15s;
}

.auth-social-btn:hover {
  border-color: var(--muted);
  background: color-mix(in srgb, var(--muted) 8%, var(--input-bg));
}

/* ── Divider ────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}

.auth-divider hr {
  flex: 1;
  border: none;
  border-top: 1px solid var(--border);
}

.auth-divider span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Error box ──────────────────────────────────── */
.auth-error {
  background: color-mix(in srgb, var(--error) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--error) 40%, var(--border));
  color: var(--error);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 10px;
}

/* ── Tabs ───────────────────────────────────────── */
.auth-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.auth-tab {
  flex: 1;
  padding: 7px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  color: var(--muted);
  transition: background .15s, color .15s;
}

.auth-tab.active {
  background: var(--input-bg);
  color: var(--text);
  font-weight: 500;
}

/* ── Inputs ─────────────────────────────────────── */
.auth-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
}

.auth-input::placeholder { color: var(--muted); }
.auth-input:focus { border-color: var(--accent); }

/* ── Submit button ──────────────────────────────── */
.auth-submit {
  width: 100%;
  padding: 9px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity .15s;
}

.auth-submit:hover { opacity: .88; }

/* ── Forgot / back links ────────────────────────── */
.auth-link-row {
  text-align: center;
  margin-top: 10px;
  font-size: 13px;
}

.auth-link-row a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-link-row a:hover { text-decoration: underline; }

/* ── Info box (verify / reset confirm) ──────────── */
.auth-info-box {
  background: color-mix(in srgb, var(--correct) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--correct) 40%, var(--border));
  color: var(--correct);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Responsive ─────────────────────────────────── */
@media (min-width: 600px) {
  .landing-wrap { padding: 48px 24px 80px; }
  .hud { padding: 12px 20px; }
  .game-wrap { padding: 36px 24px 60px; }
  .answer-grid { gap: 12px; }
  .end-actions { flex-direction: row; }
}

@media (max-width: 380px) {
  .hud-right { gap: 8px; }
  .hud-stat-value { font-size: 14px; }
  .mode-card { grid-template-columns: 36px 1fr 20px; gap: 10px; padding: 14px 12px; }
  .answer-btn { padding: 12px; }
}

@media (hover: none) {
  .mode-card:hover  { border-color: var(--border); background: var(--surface); }
  .btn-next:hover, .btn-submit:hover { opacity: 1; }
}


/* ── Gamer tag field & hints ─────────────────────── */
.auth-tag-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-tag-hint {
  font-size: 11px;
  min-height: 16px;
  padding-left: 2px;
  color: var(--muted);
  transition: color .15s;
}

.auth-tag-hint--ok    { color: #2a9d5c; }
.auth-tag-hint--error { color: #e05252; }

/* Edit-tag button in header chip */
.btn-set-tag {
  padding: 7px 10px;
  font-size: 15px;
  line-height: 1;
}
