/* ── Reset & Base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #07071a;
  --surface:  rgba(255,255,255,0.05);
  --border:   rgba(255,255,255,0.10);
  --gold:     #d4a017;
  --gold-dim: #a07810;
  --orange:   #c45c26;
  --text:     #f0e8d8;
  --muted:    #9a9080;
  --success:  #4ade80;
  --error:    #f87171;
  --radius:   16px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 24px 16px 48px;
  background: radial-gradient(ellipse at 50% 0%, rgba(212,160,23,0.12) 0%, transparent 60%),
              var(--bg);
}

/* ── Screens ──────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 640px;
  gap: 20px;
  animation: fadeIn 0.35s ease;
}
.screen.active { display: flex; }

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

/* ── Typography ───────────────────────────────── */
h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  text-shadow: 0 0 40px rgba(212,160,23,0.4);
  line-height: 1.2;
}
h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
h3 {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Landing ──────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: -8px;
}
.brand-icon { font-size: 2rem; }
.brand-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.tagline {
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.8;
}

.input-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}
.input-row input {
  flex: 1;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.input-row input:focus { border-color: var(--gold); }
.input-row input::placeholder { color: var(--muted); }

button {
  padding: 14px 28px;
  background: var(--gold);
  color: #07071a;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
button:hover  { background: #e8b820; }
button:active { transform: scale(0.97); }

.error-msg  { color: var(--error); font-size: 0.875rem; }
.hidden     { display: none !important; }

/* ── Leaderboard Card ─────────────────────────── */
.leaderboard-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  backdrop-filter: blur(10px);
}
.leaderboard-card h3 { margin-bottom: 14px; }

.lb-rows { display: flex; flex-direction: column; gap: 8px; }
.lb-empty { color: var(--muted); font-size: 0.875rem; text-align: center; padding: 8px 0; }

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  transition: background 0.2s;
}
.lb-row:first-child { background: rgba(212,160,23,0.10); }
.lb-rank  { width: 24px; text-align: center; font-weight: 600; color: var(--muted); font-size: 0.8rem; }
.lb-name  { flex: 1; font-weight: 500; }
.lb-score { font-weight: 700; color: var(--gold); }
.lb-date  { font-size: 0.75rem; color: var(--muted); }

/* ── Loading ──────────────────────────────────── */
.loader-icon {
  font-size: 4rem;
  animation: spin 2s linear infinite;
}
@keyframes spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}

.loader-text {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.loader-bar {
  width: 280px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.loader-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  animation: loadingBar 3s ease-in-out infinite;
}
@keyframes loadingBar {
  0%   { width: 0%;   transform: translateX(0); }
  50%  { width: 70%;  transform: translateX(0); }
  100% { width: 100%; transform: translateX(0); }
}

/* ── Game Header ──────────────────────────────── */
.game-header {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.progress-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
}
.dot.done    { background: var(--gold); }
.dot.current { background: var(--gold); transform: scale(1.35); box-shadow: 0 0 8px var(--gold); }

.score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.score-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
#live-score  { font-family: 'Playfair Display', serif; font-size: 1.5rem; color: var(--gold); font-weight: 700; }

/* ── Timer ────────────────────────────────────── */
.timer-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.timer-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  width: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width linear, background-color linear;
}
.timer-fill.urgent { background: var(--error); }
.timer-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  width: 24px;
  text-align: right;
}

/* ── Question Card ────────────────────────────── */
.question-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  backdrop-filter: blur(10px);
}
.question-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-cat  { background: rgba(212,160,23,0.15); color: var(--gold); }
.badge-diff-easy   { background: rgba(74,222,128,0.15); color: #4ade80; }
.badge-diff-medium { background: rgba(212,160,23,0.15); color: var(--gold); }
.badge-diff-hard   { background: rgba(248,113,113,0.15); color: var(--error); }

.q-number { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.q-text   { font-size: clamp(1rem, 2.5vw, 1.3rem); line-height: 1.5; }

/* ── Options ──────────────────────────────────── */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
@media (max-width: 480px) { .options-grid { grid-template-columns: 1fr; } }

.option-btn {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(212,160,23,0.08);
}
.option-btn:disabled { cursor: default; }
.option-btn .key-hint {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255,255,255,0.07);
  border-radius: 5px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.option-btn.selected  { border-color: var(--gold); background: rgba(212,160,23,0.12); }
.option-btn.correct   { border-color: var(--success); background: rgba(74,222,128,0.12); color: var(--success); }
.option-btn.wrong     { border-color: var(--error); background: rgba(248,113,113,0.12); color: var(--error); }
.option-btn.reveal    { border-color: var(--success); background: rgba(74,222,128,0.08); }

/* ── Result Overlay ───────────────────────────── */
.result-overlay {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(12px);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-icon  { font-size: 2.5rem; }
.result-title { font-family: 'Playfair Display', serif; font-size: 1.4rem; font-weight: 700; }
.result-title.correct { color: var(--success); }
.result-title.wrong   { color: var(--error); }
.result-points { font-size: 1.1rem; font-weight: 700; color: var(--gold); }
.result-comment { color: var(--muted); font-style: italic; text-align: center; font-size: 0.9rem; }

.fun-fact-box {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
}
.fun-fact-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  display: block;
  margin-bottom: 4px;
}
.fun-fact-box p { font-size: 0.875rem; color: var(--muted); }

#btn-next { margin-top: 4px; }

/* ── Game Over ────────────────────────────────── */
.go-brand { font-size: 4rem; }
#go-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  color: var(--gold);
  text-align: center;
}
.go-username { color: var(--muted); font-size: 0.95rem; }
.go-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.go-score-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.go-score {
  font-family: 'Playfair Display', serif;
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(212,160,23,0.5);
  line-height: 1;
}

.achievement {
  padding: 10px 24px;
  background: rgba(212,160,23,0.12);
  border: 1px solid rgba(212,160,23,0.3);
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
  text-align: center;
}

/* ── Animations ───────────────────────────────── */
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  40%       { transform: scale(1.18); }
  70%       { transform: scale(0.93); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}
.anim-bounce { animation: bounce 0.5s ease; }
.anim-shake  { animation: shake 0.4s ease; }
