/*
  Cat Quiz — Stylesheet
  Theme: A cat who loves bird watching. Nature-friendly greens, big touch targets for mobile.
  Dark teal-green (logo bg), cream text, gold accents. Cormorant Garamond headings.
  Think Cornell Lab of Ornithology if redesigned by a top-tier studio.
*/

/* ── Design Tokens (from Cat Quiz logo: dark teal #214D4F + cream) ───────── */
:root {
  /* Logo palette — match logo background #00383c exactly */
  --logo-bg:       #00383c;
  --teal-deep:     #00383c;
  --teal-rich:     #004246;
  --teal-canopy:   #0a4a4e;
  --teal-moss:     #125458;
  --teal-sage:     #1e6266;
  --teal-fern:     #2e7276;
  --teal-mint:     #4a9296;
  --pale-mint:     #7ab8bc;

  /* Cream & warmth (logo text, bell) */
  --cream:         #fff8e6;
  --cream-dim:     #f0ead8;
  --parchment:     #e8e2d4;
  --amber:         #daa520;
  --amber-hi:      #e8c05a;

  /* Accent (collar blue) */
  --sky:           #64b5f6;
  --sky-hi:        #90caf9;

  /* UI */
  --bg:            var(--teal-deep);
  --surface:       var(--teal-rich);
  --surface2:      var(--teal-canopy);
  --surface3:      var(--teal-moss);
  --border:        #0e4a4e;
  --border-hi:     #1a5a5e;
  --text:          var(--cream);
  --text-muted:    #7ab8bc;
  --text-dim:      #3a7a7e;
  --reveal-color:  #7b9dd4;
  --reveal-hi:     #9dbcea;

  /* Typography */
  --font-head:     'Cormorant Garamond', 'Georgia', serif;
  --font-body:     'DM Sans', system-ui, sans-serif;

  /* Spacing / shape */
  --radius:        12px;
  --radius-sm:     7px;
  --radius-xs:     4px;
  --shadow:        0 8px 40px rgba(0,0,0,0.55);
  --shadow-sm:     0 3px 12px rgba(0,0,0,0.35);
  --transition:    0.2s ease;
  --max-w:         680px;
  --max-w-wide:    1100px;
  --max-w-xl:      1400px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); line-height: 1.55; min-height: 100vh; overflow-x: hidden; }
/* Mobile: ensure tap targets are at least 44px for accessibility */
a { color: var(--mint); text-decoration: none; }
a:hover { color: var(--pale-mint); text-decoration: underline; }
img { display: block; max-width: 100%; }

.skip-link {
  position: absolute; top: -120px; left: 1rem; z-index: 9999;
  background: var(--amber); color: #111; font-weight: 700;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  transition: top 0.2s;
}
.skip-link:focus { top: 0.75rem; }

/* ── Screen manager ─────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ════════════════════════════════════════════════════════════
   SCREEN 1 — REGION SELECT
════════════════════════════════════════════════════════════ */

/* Hero background */
.hero-bg {
  position: fixed; inset: 0; z-index: 0;
  background: #00383c;
  overflow: hidden;
}
.hero-bg-layer {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0.04;
}
.layer1 {
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 60px,
    rgba(74,146,150,0.08) 60px, rgba(74,146,150,0.08) 61px
  );
}
.layer2 {
  background-image: radial-gradient(circle at 60% 40%, rgba(218,165,32,0.04) 0%, transparent 50%);
}

/* Bird silhouettes floating */
.bird-silhouette {
  position: absolute; fill: rgba(74,146,150,0.12);
  animation: birdFloat linear infinite;
}
.s1 { width: 80px; top: 18%; left: -100px; animation-duration: 28s; animation-delay: 0s; }
.s2 { width: 55px; top: 35%; left: -80px; animation-duration: 38s; animation-delay: 8s; }
.s3 { width: 65px; top: 55%; left: -90px; animation-duration: 32s; animation-delay: 18s; }
@keyframes birdFloat {
  from { transform: translateX(0) translateY(0); }
  30%  { transform: translateX(35vw) translateY(-8px); }
  60%  { transform: translateX(70vw) translateY(5px); }
  to   { transform: translateX(110vw) translateY(-4px); }
}

/* Nav */
.site-nav { position: relative; z-index: 10; padding: 1.5rem 2rem; }
.nav-inner { display: flex; justify-content: center; }
.nav-brand {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--cream);
}
.nav-logo { width: 320px; height: 320px; object-fit: contain; display: block; }

/* Region main layout */
.region-main {
  position: relative; z-index: 5;
  max-width: 860px; margin: 0 auto;
  padding: 0 1.5rem 4rem;
}
@media (min-width: 1100px) {
  .region-main { max-width: 1000px; padding: 0 2rem 4rem; }
}

/* Hero content */
.hero-content { text-align: center; padding: 2rem 0 3rem; }
.hero-eyebrow {
  display: inline-block; margin-bottom: 1.25rem;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--amber); border: 1px solid rgba(196,154,53,0.3);
  padding: 0.3em 0.9em; border-radius: 99px;
}
.hero-title {
  font-family: var(--font-head); font-size: clamp(2.8rem, 6vw, 5rem); font-weight: 700;
  line-height: 1.05; letter-spacing: -0.01em; color: var(--cream);
  margin-bottom: 1.25rem;
}
.hero-title em { color: var(--mint); font-style: italic; }
.hero-desc { font-size: 1rem; color: var(--text-muted); max-width: 480px; margin: 0 auto 2.5rem; line-height: 1.65; }

/* Search */
.search-wrap { position: relative; max-width: 520px; margin: 0 auto 1rem; }
.search-input-row {
  display: flex; align-items: center; gap: 0.75rem;
  background: rgba(0,56,60,0.9); border: 1px solid var(--border-hi);
  border-radius: 99px; padding: 0.9rem 1.35rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 30px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input-row:focus-within {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(74,146,150,0.15), 0 4px 30px rgba(0,0,0,0.4);
}
.search-icon { color: var(--text-dim); flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--font-body); font-size: 1rem; color: var(--text);
}
.search-input::placeholder { color: var(--text-dim); }

.location-suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-hi);
  border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 50; overflow: hidden;
}
.suggestion-item {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.85rem 1.1rem; min-height: 48px; justify-content: center;
  cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background var(--transition); outline: none;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item:focus { background: var(--surface2); }
.sug-name { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.sug-detail { font-size: 0.75rem; color: var(--text-muted); }

.region-error {
  margin-top: 0.5rem; font-size: 0.82rem; color: #e07070;
  background: rgba(224,112,112,0.1); border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem; text-align: center;
}

/* Geo button — min 44px touch target */
.geo-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: transparent; border: 1px solid var(--border-hi);
  color: var(--text-muted); padding: 0.65rem 1.25rem;
  min-height: 44px; border-radius: 99px; font-size: 0.9rem; cursor: pointer;
  transition: all var(--transition);
}
.geo-btn:hover { border-color: var(--mint); color: var(--mint); }

/* Popular regions divider */
.popular-section { margin: 1rem 0 2.5rem; }
.popular-divider {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem;
}
.popular-divider span { flex: 1; height: 1px; background: var(--border); }
.popular-divider h2 {
  font-family: var(--font-head); font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim);
  white-space: nowrap;
}

.popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
}
@media (min-width: 1100px) {
  .popular-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
}
.popular-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  padding: 1rem 0.6rem; min-height: 72px; justify-content: center;
  background: rgba(0,56,60,0.85); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; color: var(--text);
  transition: all var(--transition); backdrop-filter: blur(8px);
}
.popular-btn:hover {
  border-color: var(--mint); background: rgba(58,125,121,0.5);
  transform: translateY(-2px); box-shadow: var(--shadow-sm);
}
.pop-emoji { font-size: 1.5rem; line-height: 1; }
.pop-name { font-size: 0.78rem; font-weight: 600; text-align: center; color: var(--text-muted); }
.popular-btn:hover .pop-name { color: var(--pale-mint); }

/* Mode cards */
.mode-section { margin: 0 0 3rem; }
.mode-section-title {
  text-align: center; font-family: var(--font-head);
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 1rem;
}
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; max-width: 500px; margin: 0 auto; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 1.35rem 1.1rem; min-height: 100px;
  background: rgba(0,56,60,0.8); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: all var(--transition); text-align: center;
  backdrop-filter: blur(8px);
}
.mode-card:hover { border-color: var(--border-hi); background: rgba(18,84,88,0.7); }
.mode-card.active { border-color: var(--mint); background: rgba(30,98,102,0.35); }
.mode-card-icon { font-size: 1.5rem; }
.mode-card-name { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.mode-card-desc { font-size: 0.72rem; color: var(--text-muted); line-height: 1.4; }
.mode-card.active .mode-card-name { color: var(--pale-mint); }

/* Footer */
.region-footer { text-align: center; font-size: 0.73rem; color: var(--text-dim); padding-top: 1rem; }

/* ════════════════════════════════════════════════════════════
   SCREEN 2 — LOADING
════════════════════════════════════════════════════════════ */
#screen-loading {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.loading-wrap { width: 100%; max-width: 460px; padding: 2rem; text-align: center; }

.loading-bird-wrap { height: 80px; position: relative; margin-bottom: 2rem; overflow: visible; }
.loading-bird { width: 100%; height: 80px; }
.bird-flier { animation: birdFly 3s ease-in-out infinite; transform-origin: 16px 8px; }
@keyframes birdFly {
  0%   { transform: translateX(0)     translateY(0)  scaleX(1); }
  48%  { transform: translateX(64px)  translateY(-10px) scaleX(1); }
  50%  { transform: translateX(64px)  translateY(-10px) scaleX(-1); }
  100% { transform: translateX(0)     translateY(0)  scaleX(-1); }
}

.loading-logo { width: 80px; height: 80px; object-fit: contain; margin-bottom: 1rem; }
.loading-title {
  font-family: var(--font-head); font-size: 1.8rem; font-weight: 700;
  color: var(--cream); margin-bottom: 0.5rem;
}
.loading-title span { color: var(--mint); }
.loading-status { font-size: 0.87rem; color: var(--text-muted); margin-bottom: 1.5rem; min-height: 1.5em; }

.loading-bar-wrap { margin-bottom: 0.75rem; }
.loading-bar-track {
  height: 4px; background: var(--moss); border-radius: 99px; overflow: hidden;
}
.loading-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--fern), var(--mint));
  border-radius: 99px; transition: width 0.4s ease;
}
.loading-count { font-size: 0.8rem; color: var(--text-dim); min-height: 1.2em; }
.back-from-loading {
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin-top: 1rem; padding: 0.6rem 1.2rem;
  background: var(--surface2); border: 1px solid var(--border-hi);
  color: var(--cream); border-radius: var(--radius); font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.back-from-loading:hover { background: var(--teal-sage); border-color: var(--mint); }
.api-notices { margin-top: 1.25rem; }
.api-notice {
  font-size: 0.77rem; padding: 0.65rem 0.9rem; border-radius: var(--radius-sm);
  line-height: 1.5; text-align: left;
}
.api-notice.warning { background: rgba(196,154,53,0.12); border: 1px solid rgba(196,154,53,0.3); color: var(--amber-hi); }
.api-notice code { font-family: monospace; background: rgba(0,0,0,0.2); padding: 0.1em 0.3em; border-radius: 3px; }
.api-notice a { color: var(--amber-hi); text-decoration: underline; }

/* ════════════════════════════════════════════════════════════
   SCREEN 3 — QUIZ
════════════════════════════════════════════════════════════ */
#screen-quiz { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); }

/* Quiz header */
.quiz-header {
  background: rgba(0,56,60,0.92); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.quiz-header-inner {
  max-width: var(--max-w-wide); margin: 0 auto;
  padding: 0.6rem 1.25rem;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
@media (min-width: 1400px) {
  .quiz-header-inner { max-width: var(--max-w-xl); }
}
.back-btn {
  display: flex; align-items: center; gap: 0.35rem;
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 0.35rem 0.75rem; border-radius: 99px; font-size: 0.77rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.back-btn:hover { border-color: var(--mint); color: var(--mint); }
.region-label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.quiz-stats { display: flex; align-items: center; gap: 0; flex: 1; justify-content: center; }
.quiz-stat { display: flex; flex-direction: column; align-items: center; padding: 0 0.9rem; }
.quiz-stat-label { font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); }
.quiz-stat-val { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; color: var(--amber); line-height: 1.1; }
.quiz-stat-val.flame:not(:empty)::after { content: ''; }
.quiz-stat-sep { width: 1px; height: 2rem; background: var(--border); }

.quiz-mode-row { display: flex; align-items: center; gap: 0.5rem; }
.mode-toggle { display: flex; background: var(--surface2); border-radius: 6px; border: 1px solid var(--border); overflow: hidden; }
.mode-btn { padding: 0.3rem 0.65rem; font-size: 0.72rem; font-weight: 700; border: none; background: transparent; color: var(--text-muted); cursor: pointer; transition: all var(--transition); }
.mode-btn.active { background: var(--sage); color: var(--cream); }
.mode-btn:not(.active):hover { background: var(--surface3); color: var(--text); }

/* Seed pill */
.seed-pill { display: flex; align-items: center; gap: 0.3rem; }
.seed-pill-label { font-size: 0.67rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.seed-pill-input {
  width: 120px; padding: 0.28rem 0.5rem; font-size: 0.7rem; font-family: monospace;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-xs); outline: none;
}
.seed-pill-input:focus { border-color: var(--mint); }
.seed-pill-btn {
  padding: 0.28rem 0.5rem; font-size: 0.7rem; font-weight: 600;
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius-xs); cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.seed-pill-btn:hover { border-color: var(--mint); color: var(--mint); }

/* Quiz main */
.quiz-main {
  max-width: var(--max-w-wide); margin: 0 auto; width: 100%;
  padding: 1.25rem 2rem 3rem; flex: 1;
  display: flex; flex-direction: column; gap: 1rem;
}
@media (min-width: 920px) {
  .quiz-main {
    max-width: var(--max-w-wide);
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    grid-template-rows: auto auto auto auto auto;
    gap: 1.25rem 2.5rem;
    align-items: start;
    padding: 1.5rem 2.5rem 3rem;
  }
  .quiz-main > .round-indicator { grid-column: 1 / -1; }
  .quiz-main > .bird-card { grid-column: 1; grid-row: 2; margin-bottom: 0; }
  .quiz-main > .audio-player { grid-column: 1; grid-row: 3; padding-top: 0; }
  .quiz-main > .kbd-row { grid-column: 1; grid-row: 4; }
  .quiz-main > #choices-grid { grid-column: 2; grid-row: 2 / 4; align-self: start; }
  .quiz-main > #free-text-wrap { grid-column: 2; grid-row: 2 / 4; align-self: start; }
  .quiz-main > .feedback-row { grid-column: 2; grid-row: 4; }
  .quiz-main > .action-row { grid-column: 2; grid-row: 5; }
}
@media (min-width: 1400px) {
  .quiz-main {
    max-width: var(--max-w-xl);
    gap: 1.5rem 3rem;
    padding: 1.5rem 3rem 3rem;
  }
}

/* Round indicator */
.round-indicator { text-align: right; margin-bottom: 0.6rem; }
.round-pips { font-size: 0.72rem; color: var(--text-dim); font-weight: 600; letter-spacing: 0.04em; }

/* Bird card */
.bird-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
}
.bird-photo-wrap { position: relative; aspect-ratio: 4/3; background: var(--surface2); overflow: hidden; }
@media (min-width: 920px) {
  .bird-photo-wrap { aspect-ratio: 16/9; max-height: min(520px, 55vh); }
}
@media (min-width: 1400px) {
  .bird-photo-wrap { max-height: min(600px, 60vh); }
}
.bird-photo { width: 100%; height: 100%; object-fit: cover; object-position: center top; transition: opacity 0.3s; }
.bird-photo.loading-skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.no-photo-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
  font-size: 0.9rem; color: var(--text-muted);
  background: var(--surface2);
}
.no-photo-overlay span:first-child { font-size: 3rem; }

/* Bird reveal panel */
.bird-reveal {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.75rem 1.1rem;
  background: var(--surface2); border-top: 1px solid var(--border);
  animation: revealSlide 0.25s ease;
}
@keyframes revealSlide { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
.bird-reveal-inner { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0.4rem; }
.reveal-names { display: flex; flex-direction: column; gap: 0.1rem; }
.reveal-common { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; color: var(--pale-mint); }
.reveal-sci { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }
.reveal-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.reveal-family { font-size: 0.72rem; color: var(--text-dim); }
.reveal-difficulty {
  font-size: 0.67rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.15em 0.55em; border-radius: 99px;
}
.diff-easy  { background: rgba(74,146,150,0.25); color: var(--mint); }
.diff-med   { background: rgba(196,154,53,0.2);  color: var(--amber-hi); }
.diff-hard  { background: rgba(200,120,50,0.2);  color: #e0985a; }
.diff-rare  { background: rgba(180,80,80,0.2);   color: #e07070; }

/* Audio player */
.audio-player {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0; margin-bottom: 0.2rem;
}
.play-btn {
  display: flex; align-items: center; gap: 0.55rem;
  background: var(--sage); border: none; color: var(--cream);
  padding: 0.75rem 1.4rem; min-height: 48px; border-radius: 99px;
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
.play-btn:hover:not(:disabled) { background: var(--fern); transform: scale(1.03); }
.play-btn.playing { background: var(--amber); color: #111; animation: pulse 1.1s infinite alternate; }
.play-btn:disabled { opacity: 0.45; cursor: default; }
@keyframes pulse { from { opacity:1; } to { opacity:0.65; } }

.audio-waveform { flex: 1; position: relative; height: 32px; }
.waveform-track { position: absolute; bottom: 4px; left: 0; right: 0; height: 4px; background: var(--surface3); border-radius: 99px; overflow: hidden; }
.waveform-fill { height: 100%; background: linear-gradient(90deg, var(--sage), var(--mint)); border-radius: 99px; transition: width 0.08s linear; width: 0%; }
.waveform-bars {
  display: flex; align-items: flex-end; gap: 2px; height: 28px; padding-bottom: 8px;
  position: absolute; inset: 0;
}
.waveform-bars span {
  flex: 1; background: rgba(74,146,150,0.2); border-radius: 2px;
  animation: barDance 1.2s ease-in-out infinite alternate;
}
.waveform-bars span:nth-child(even)  { animation-delay: 0.15s; }
.waveform-bars span:nth-child(3n)    { animation-delay: 0.3s; }
.waveform-bars span:nth-child(4n+1)  { animation-delay: 0.45s; }
@keyframes barDance {
  from { height: 4px; opacity: 0.2; }
  to   { height: 20px; opacity: 0.5; }
}
.playing ~ .audio-waveform .waveform-bars span { background: rgba(196,154,53,0.4); }

.no-audio-note { font-size: 0.78rem; color: var(--text-dim); font-style: italic; }
.audio-attribution { font-size: 0.68rem; color: var(--text-dim); min-height: 1rem; margin-bottom: 0.25rem; }
.audio-attribution a { color: var(--text-dim); }
.audio-attribution a:hover { color: var(--text-muted); }

/* Keyboard hints */
.kbd-row { font-size: 0.68rem; color: var(--text-dim); margin-bottom: 0.85rem; }
kbd {
  display: inline-block; padding: 0.1em 0.4em;
  background: var(--surface2); border: 1px solid var(--border-hi);
  border-radius: 3px; font-family: monospace; font-size: 0.68rem; color: var(--text-muted);
}

/* Choices */
.choices-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-bottom: 0.75rem; }
.choice-btn {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1rem; min-height: 64px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  cursor: pointer; text-align: left; font-family: var(--font-body);
  transition: all var(--transition);
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--border-hi); background: var(--surface2);
  transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
.choice-btn:disabled { cursor: default; }
.choice-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface3); border: 1px solid var(--border-hi);
  font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.choice-text { display: flex; flex-direction: column; gap: 0.1rem; }
.choice-common { font-size: 0.95rem; font-weight: 600; line-height: 1.2; }
.choice-sci { font-size: 0.7rem; color: var(--text-muted); font-style: italic; }
.choice-btn.correct { border-color: var(--mint); background: rgba(74,146,150,0.18); }
.choice-btn.correct .choice-num { background: var(--sage); border-color: var(--mint); color: var(--cream); }
.choice-btn.wrong   { border-color: #c05050; background: rgba(192,80,80,0.12); }
.choice-btn.wrong   .choice-num { background: #7a2020; border-color: #c05050; }

/* Free text */
.free-text-wrap { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.75rem; }
.free-text-row  { display: flex; gap: 0.55rem; }
.ac-wrap { flex: 1; position: relative; }
.free-input {
  width: 100%; padding: 0.9rem 1.1rem; font-size: 1rem; min-height: 48px;
  font-family: var(--font-body); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  color: var(--text); outline: none; transition: border-color var(--transition);
}
.free-input:focus { border-color: var(--mint); }
.free-input.shake { animation: shake 0.35s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.submit-btn {
  padding: 0.9rem 1.4rem; min-height: 48px; background: var(--sage); border: none; color: var(--cream);
  border-radius: var(--radius); font-weight: 600; font-size: 0.95rem;
  cursor: pointer; white-space: nowrap; transition: background var(--transition);
}
.submit-btn:hover { background: var(--fern); }
.submit-btn:disabled { opacity: 0.5; cursor: default; }
.free-hint { font-size: 0.7rem; color: var(--text-dim); }

.autocomplete {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-hi);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; overflow: hidden;
}
.ac-item {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0.75rem 1rem; min-height: 48px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition); outline: none;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item:focus { background: var(--surface2); }
.ac-name { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.ac-name mark { background: rgba(74,146,150,0.35); color: var(--pale-mint); border-radius: 2px; padding: 0 1px; }
.ac-sci { font-size: 0.7rem; color: var(--text-muted); font-style: italic; }

/* Feedback */
.feedback-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; min-height: 2.2rem; margin-bottom: 0.65rem;
}
.feedback-msg {
  font-size: 0.9rem; font-weight: 600; padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm); flex: 1; transition: all 0.2s;
}
.feedback-msg.idle     { color: var(--text-muted); background: transparent; }
.feedback-msg.correct  { color: var(--pale-mint);  background: rgba(74,146,150,0.15); }
.feedback-msg.wrong    { color: #e07070;            background: rgba(192,80,80,0.12); }
.feedback-msg.revealed { color: var(--reveal-hi);   background: rgba(123,157,212,0.12); }

.points-log { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.point-chip {
  padding: 0.2em 0.6em; border-radius: 99px; font-size: 0.78rem; font-weight: 700;
  animation: popIn 0.2s ease;
}
@keyframes popIn { from{opacity:0;transform:scale(0.6)} to{opacity:1;transform:scale(1)} }
.point-chip.pos { background: rgba(74,146,150,0.25); color: var(--pale-mint); }
.point-chip.neg { background: rgba(192,80,80,0.2);   color: #e07070; }

/* Action buttons */
.action-row { display: flex; gap: 0.65rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.45rem; padding: 0.85rem 1.35rem; min-height: 48px;
  border-radius: var(--radius); font-family: var(--font-body);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition);
}
.btn-reveal {
  background: transparent; color: var(--reveal-color); border-color: var(--reveal-color);
}
.btn-reveal:hover:not(:disabled) { background: rgba(123,157,212,0.1); }
.btn-reveal:disabled { opacity: 0.3; cursor: default; }
.btn-next {
  flex: 1; justify-content: center;
  background: var(--surface2); color: var(--text); border-color: var(--border-hi);
}
.btn-next:hover:not(:disabled) { background: var(--sage); color: var(--cream); border-color: var(--sage); }
.btn-next:disabled { opacity: 0.4; cursor: default; }

/* ════════════════════════════════════════════════════════════
   SCREEN 4 — END / RESULTS
════════════════════════════════════════════════════════════ */
#screen-end { background: var(--bg); padding: 2rem 1.25rem 4rem; }
.end-wrap { max-width: 640px; margin: 0 auto; }
@media (min-width: 1100px) {
  .end-wrap { max-width: 800px; padding: 0 2rem; }
}

.end-hero { text-align: center; margin-bottom: 2rem; padding: 2.5rem 1rem; }
.end-feather { width: 72px; height: 72px; object-fit: contain; display: block; margin: 0 auto 0.75rem; }
.end-score-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.end-score { font-family: var(--font-head); font-size: clamp(4rem, 12vw, 6rem); font-weight: 700; color: var(--amber); line-height: 1; }
.end-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.4rem; }

.end-stats {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.75rem;
}
.end-stat {
  display: flex; flex-direction: column; align-items: center; padding: 1rem 0.5rem;
  background: var(--surface); border-right: 1px solid var(--border);
}
.end-stat:last-child { border-right: none; }
.end-stat-val { font-family: var(--font-head); font-size: 2.2rem; font-weight: 700; line-height: 1; }
.end-stat-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 0.2rem; }
.correct-col { color: var(--mint); }
.wrong-col   { color: #e07070; }
.reveal-col  { color: var(--reveal-hi); }
.streak-col  { color: var(--amber-hi); }

.end-review { margin-bottom: 1.75rem; }
.review-heading { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.75rem; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.6rem; }
@media (min-width: 920px) {
  .review-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.75rem; }
}
.review-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  text-align: center; padding: 0.5rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
}
.review-item.was-wrong    { border-color: rgba(192,80,80,0.35); }
.review-item.was-revealed { border-color: rgba(123,157,212,0.35); }
.review-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.review-img-placeholder {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; background: var(--surface2); border-radius: 4px;
}
.review-name { font-size: 0.72rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.review-sci  { font-size: 0.62rem; color: var(--text-muted); font-style: italic; }
.review-diff { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; padding: 0.1em 0.4em; border-radius: 99px; }
.perfect-msg { font-family: var(--font-head); font-size: 1.2rem; color: var(--amber); text-align: center; padding: 1.5rem 0; }

/* High score */
.hs-form {
  background: var(--surface); border: 1px solid rgba(196,154,53,0.4);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem;
}
.hs-form-inner { text-align: center; }
.hs-form-icon { width: 48px; height: 48px; object-fit: contain; display: block; margin: 0 auto 0.4rem; }
.hs-form-title { font-family: var(--font-head); font-size: 1.3rem; color: var(--amber-hi); margin-bottom: 0.85rem; }
.hs-input-row { display: flex; gap: 0.5rem; justify-content: center; }
.hs-input {
  flex: 1; max-width: 260px; padding: 0.55rem 0.85rem; font-size: 0.9rem;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); outline: none;
}
.hs-input:focus { border-color: var(--amber); }
.hs-submit-btn {
  padding: 0.55rem 1.1rem; background: var(--amber); color: #111;
  border: none; border-radius: var(--radius-sm); font-weight: 700; font-size: 0.88rem; cursor: pointer;
}
.hs-submit-btn:disabled { opacity: 0.5; cursor: default; }

.hs-section { margin-bottom: 1.75rem; }
.hs-title {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 0.65rem;
}
.hs-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.hs-table th { text-align: left; padding: 0.4rem 0.5rem; color: var(--text-dim); font-weight: 600; border-bottom: 1px solid var(--border); }
.hs-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.hs-table tr.highlight td { color: var(--amber-hi); font-weight: 600; }
.no-scores { font-size: 0.82rem; color: var(--text-muted); }

.end-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; }
.btn-primary  { background: var(--sage); color: var(--cream); border-color: var(--sage); }
.btn-primary:hover { background: var(--fern); border-color: var(--fern); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-hi); }
.btn-secondary:hover { background: var(--surface2); border-color: var(--mint); color: var(--pale-mint); }
.end-actions .btn { flex: 1; justify-content: center; padding: 0.9rem 1.2rem; min-height: 52px; }

/* ── Focus ──────────────────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 3px; }

/* ── Mobile-first & responsive ───────────────────────────────────────────── */
/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .action-row { padding-bottom: env(safe-area-inset-bottom); }
  .quiz-main { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 600px) {
  .nav-logo { width: 260px; height: 260px; }
  .hero-title { font-size: 2.4rem; }
  .mode-cards { grid-template-columns: 1fr 1fr; gap: 0.85rem; }
  .choices-grid { grid-template-columns: 1fr; gap: 0.65rem; }
  .choice-btn { min-height: 64px; padding: 1rem 1.1rem; }
  .quiz-mode-row { display: none; }
  .end-stats { grid-template-columns: repeat(2,1fr); }
  .end-actions { flex-direction: column; gap: 0.75rem; }
  .seed-pill { display: none; }
  .popular-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.7rem; }
  .popular-btn { min-height: 76px; }
  .btn-reveal, .btn-next { min-height: 52px; padding: 1rem 1.35rem; }
  .action-row { gap: 0.75rem; margin-top: 0.5rem; }
  .back-btn { padding: 0.5rem 0.9rem; min-height: 44px; }
}
@media (max-width: 380px) {
  .mode-cards { grid-template-columns: 1fr; }
  .popular-grid { grid-template-columns: repeat(2, 1fr); }
}
