/* ═══════════════════════════════════════════════════════════
   Milton's Quizzes — shared stylesheet
   Used by: index.html (homepage)  +  play.html (quiz player)
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #080e1c;
  --card-bg:     #0c1a30;
  --card-border: #1a3050;
  --accent:      #00bfff;
  --accent-glow: rgba(0,191,255,0.25);
  --gold:        #ffd700;
  --gold-faint:  rgba(255,215,0,0.12);
  --text:        #dce9f5;
  --text-muted:  #6a90b0;
  --correct:     #22c55e;
  --wrong:       #ef4444;
  --shadow:      0 30px 60px rgba(0,0,0,0.6);
  --quiz-color:  #00bfff;   /* overridden per quiz on play.html */
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 25% 15%, rgba(0,100,160,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 85%, rgba(0,50,120,0.15)  0%, transparent 55%);
}

/* ── Shared card ────────────────────────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow), 0 0 80px rgba(0,150,220,0.07);
  text-align: center;
}

/* ── Shared buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: block;
  width: 100%;
  padding: 0.9rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-bottom: 0.75rem;
}
.btn:last-child { margin-bottom: 0; }

.btn-primary {
  background: linear-gradient(135deg, #005f8a, var(--accent));
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,180,255,0.35);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(0,180,255,0.5);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--card-border);
}
.btn-ghost:hover { border-color: var(--accent); background: rgba(0,191,255,0.06); }

/* ── Globe animation (ready / welcome screens) ──────────────────────────────── */

.globe-anim {
  font-size: 4rem;
  display: inline-block;
  margin-bottom: 0.75rem;
  animation: spin 12s linear infinite;
}
.globe-anim.small { font-size: 2.8rem; }

@keyframes spin {
  0%   { transform: rotate(0deg)   scale(1);    }
  50%  { transform: rotate(180deg) scale(1.06); }
  100% { transform: rotate(360deg) scale(1);    }
}

/* ── Shared leaderboard ─────────────────────────────────────────────────────── */

.leaderboard {
  background: rgba(0,0,0,0.25);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  text-align: left;
}

.lb-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover      { background: rgba(255,255,255,0.03); }

.lb-pos   { width:2.5rem; font-size:1.1rem; flex-shrink:0; }
.lb-name  { flex:1; font-size:0.95rem; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding-right:0.5rem; }
.lb-score { font-weight:700; color:var(--accent); font-size:0.95rem; white-space:nowrap; }
.lb-loading, .lb-empty { padding:1.4rem; text-align:center; color:var(--text-muted); font-size:0.92rem; }
.lb-heading { font-size:1rem; color:var(--text); margin-bottom:0.75rem; }

/* ═══════════════════════════════════════════════════════════
   HOMEPAGE  (index.html)
   ═══════════════════════════════════════════════════════════ */

.home-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 3rem 1rem 4rem;
}

.home-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.home-logo {
  font-size: 3.5rem;
  animation: spin 16s linear infinite;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.home-title {
  font-size: 2.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4rem;
}

.home-sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

/* Name input row */
.name-row { display:flex; justify-content:center; margin-bottom:0.5rem; }

.name-input {
  width: 100%;
  max-width: 380px;
  padding: 0.9rem 1.4rem;
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.05rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: center;
}
.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.name-input::placeholder { color: var(--text-muted); }

.name-error {
  color: var(--wrong);
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.load-error {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.92rem;
  margin-top: 1rem;
}

.hidden { display: none !important; }

/* Quiz card grid */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* Individual quiz card */
.quiz-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 4px solid var(--quiz-color, var(--accent));
  border-radius: 18px;
  padding: 1.75rem 1.5rem 1.5rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.quiz-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 0 1px var(--quiz-color, var(--accent));
}

/* Skeleton loading state */
.quiz-card.skeleton {
  animation: pulse 1.5s ease-in-out infinite;
  min-height: 220px;
  cursor: default;
}
.quiz-card.skeleton:hover { transform: none; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }

@keyframes pulse {
  0%,100% { opacity:1; }
  50%      { opacity:0.4; }
}

.qc-emoji { font-size: 2.8rem; line-height: 1; }
.qc-title { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.qc-desc  { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; flex: 1; }
.qc-meta  { font-size: 0.82rem; color: var(--text-muted); }

.qc-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.qc-btn {
  flex: 1;
  padding: 0.7rem 1rem;
  background: linear-gradient(135deg, rgba(0,95,138,0.7), rgba(0,191,255,0.7));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.97rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-align: center;
}
.quiz-card:hover .qc-btn {
  background: linear-gradient(135deg, #005f8a, var(--quiz-color, var(--accent)));
  transform: translateY(-1px);
}

.qc-lb-btn {
  padding: 0.7rem 0.9rem;
  background: transparent;
  color: var(--gold);
  border: 2px solid rgba(255,215,0,0.3);
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.qc-lb-btn:hover {
  border-color: var(--gold);
  background: var(--gold-faint);
}

/* ── Leaderboard modal ──────────────────────────────────────────────────────── */

.lb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lb-modal-card {
  max-width: 460px;
  width: 100%;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
  animation: fadeUp 0.25s ease;
}

.lb-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.lb-modal-close:hover { color: var(--text); background: rgba(255,255,255,0.08); }

/* Name-field shake animation on validation error */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-8px); }
  75%      { transform: translateX(8px); }
}
.shake { animation: shake 0.4s ease; }

/* ═══════════════════════════════════════════════════════════
   PLAY PAGE  (play.html)
   ═══════════════════════════════════════════════════════════ */

/* Centre the card vertically on the play page */
body:has(#screen-ready) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.screen {
  display: none;
  width: 100%;
  max-width: 580px;
  padding: 1rem;
  margin: auto;
  animation: fadeUp 0.35s ease;
}
.screen.active { display: block; }

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

/* Ready / welcome screen text */
h2 { font-size:1.8rem; font-weight:700; margin-bottom:1.2rem; color:var(--text); }

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 2rem;
}
.subtitle strong { color: var(--accent); }

/* Quiz screen */
.quiz-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
#q-score { color:var(--gold); font-weight:700; }

.progress-track {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1.6rem;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--quiz-color, var(--accent)), var(--gold));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.q-emoji { font-size:2.6rem; margin-bottom:0.75rem; line-height:1; }
.q-text  { font-size:1.25rem; font-weight:600; line-height:1.45; margin-bottom:1.5rem; color:var(--text); }

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.opt-btn {
  padding: 0.85rem 0.75rem;
  background: rgba(255,255,255,0.04);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.97rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: left;
  line-height: 1.3;
}
.opt-btn:hover:not(:disabled) {
  border-color: var(--quiz-color, var(--accent));
  background: rgba(0,191,255,0.08);
  transform: translateY(-1px);
}
.opt-btn.correct { border-color:var(--correct)!important; background:rgba(34,197,94,0.15)!important; color:var(--correct); font-weight:700; }
.opt-btn.wrong   { border-color:var(--wrong)!important;   background:rgba(239,68,68,0.15)!important;  color:var(--wrong); }
.opt-btn:disabled { cursor:not-allowed; }

.feedback {
  min-height: 1.8rem;
  font-size: 0.97rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.feedback.correct { color:var(--correct); }
.feedback.wrong   { color:var(--wrong);   }

/* Results screen */
.results-card { padding-bottom:2rem; }

.res-emoji { font-size:3.5rem; margin-bottom:0.4rem; line-height:1; }
.results-card h2 { margin-bottom:1.2rem; }

.score-circle {
  display: flex;
  align-items: baseline;
  justify-content: center;
  width: 130px; height: 130px;
  border-radius: 50%;
  border: 3px solid var(--quiz-color, var(--accent));
  background: radial-gradient(circle, rgba(0,100,160,0.3) 0%, transparent 70%);
  box-shadow: 0 0 35px rgba(0,191,255,0.2);
  margin: 0 auto 1.4rem;
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--gold);
}
.denom { font-size:1rem; font-weight:400; color:var(--text-muted); }

.res-msg  { color:var(--text-muted); font-size:1rem; margin-bottom:1rem; line-height:1.5; }

.res-rank {
  background: var(--gold-faint);
  border: 1px solid rgba(255,215,0,0.25);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 1.4rem;
}
.res-rank.hidden { display:none; }

/* ── Touch / tap feedback (hover doesn't fire reliably on mobile) ────────── */

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 12px rgba(0,180,255,0.35);
}
.btn-ghost:active   { background: rgba(0,191,255,0.1); }
.opt-btn:active:not(:disabled) {
  border-color: var(--quiz-color, var(--accent));
  background: rgba(0,191,255,0.06);
  transform: none;
}
.qc-btn:active    { transform: translateY(1px); }
.qc-lb-btn:active { background: var(--gold-faint); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */

/* Tablet (768px) — tighten outer spacing */
@media (max-width: 768px) {
  .home-wrap { padding: 2rem 1rem 3rem; }
}

/* Phone (480px) */
@media (max-width: 480px) {

  /* ── Homepage ── */
  .home-wrap    { padding: 1.25rem 0.75rem 2.5rem; }
  .home-header  { margin-bottom: 1.25rem; }
  .home-logo    { font-size: 2.8rem; }
  .home-title   { font-size: 1.85rem; }
  .home-sub     { font-size: 0.9rem; margin-bottom: 1rem; }

  .name-input   { font-size: 1rem; padding: 0.8rem 1rem; }

  .quiz-grid    { gap: 0.75rem; }

  .quiz-card    { padding: 1.1rem 1rem 1rem; gap: 0.35rem; }
  .qc-emoji     { font-size: 2.2rem; }
  .qc-title     { font-size: 1.1rem; }
  .qc-desc      { font-size: 0.86rem; }

  /* Stack Play / Scores buttons vertically so they're easy to tap */
  .qc-actions   { flex-direction: column; gap: 0.4rem; }
  .qc-btn       { padding: 0.75rem 1rem; font-size: 0.95rem; }
  .qc-lb-btn    { text-align: center; padding: 0.65rem 1rem; }

  /* ── Leaderboard modal → slides up as a bottom sheet ── */
  .lb-modal-overlay {
    align-items: flex-end;
    padding: 0;
    backdrop-filter: none;          /* save GPU on low-end phones */
    background: rgba(0,0,0,0.8);
  }
  .lb-modal-card {
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
    max-width: 100%;
    width: 100%;
    padding: 1.5rem 1rem 2rem;
  }
  /* Pull-bar hint at top of bottom sheet */
  .lb-modal-card::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 0 auto 1.25rem;
  }
  .lb-modal-close { top: 0.75rem; right: 0.75rem; }

  /* ── Play page ── */
  .card         { padding: 1.4rem 1rem; }
  .q-text       { font-size: 1.05rem; }
  h2            { font-size: 1.55rem; }
  .subtitle     { font-size: 0.92rem; margin-bottom: 1.4rem; }

  .options-grid { grid-template-columns: 1fr; gap: 0.5rem; }
  .opt-btn      { padding: 0.9rem 1rem; font-size: 0.95rem; }

  /* ── Results ── */
  .score-circle { width: 110px; height: 110px; font-size: 2.4rem; }
  .res-emoji    { font-size: 2.8rem; }
}
