/* =====================================================================
   GeoFlare — styles
   1. Design tokens        6. Game (Street View, HUD, map, results)
   2. Base                 7. Daily Challenge
   3. Components           8. Multiplayer
   4. Site header/footer   9. Teaching Mode (AI Coach + Clue Guide)
   5. Homepage + setup    10. Statistics
                          11. Motion, sound toggle, polish
                          12. Phones & tablets
   ===================================================================== */

/* =====================================================================
   1. Design tokens
   ===================================================================== */
:root {
  /* Surfaces — dark navy / near-black */
  --bg: #0b0e13;             /* page */
  --bg-raised: #0f131a;      /* alternate section background */
  --surface: #141922;        /* cards, panels */
  --surface-2: #1a202b;      /* elevated: menus, hover, popovers */
  --surface-3: #222938;      /* hover on elevated */
  --inset: #0c1016;          /* inputs, wells, tracks */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  /* Text */
  --text: #f2f4f7;
  --text-2: #bcc4d0;
  --text-3: #8e98a9;

  /* Brand — orange leads, blue supports */
  --orange: #ff7a2f;
  --orange-hover: #ff8c4a;
  --orange-press: #f06b20;
  --orange-ink: #1a0c02;
  --orange-soft: rgba(255, 122, 47, 0.12);
  --orange-line: rgba(255, 122, 47, 0.5);
  --gold: #ffc83d;           /* points and scores */
  --blue: #4da3ff;
  --blue-hover: #6cb4ff;
  --blue-ink: #04162b;
  --blue-soft: rgba(77, 163, 255, 0.12);
  --blue-line: rgba(77, 163, 255, 0.5);

  /* Status */
  --success: #3ccf7f;
  --success-soft: rgba(60, 207, 127, 0.12);
  --warning: #ffb020;
  --danger: #ff6159;
  --danger-soft: rgba(255, 97, 89, 0.12);

  /* Older names still used by scripts */
  --accent: var(--gold);
  --accent-2: var(--orange);
  --muted: var(--text-3);
  --line: var(--border);
  --good: var(--success);
  --bad: var(--danger);
  --blue-2: #7cc4ff;
  --panel-solid: var(--surface);

  /* Type — Barlow was drawn from highway signage, which suits a Street View game */
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Semi Condensed", "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-hero: clamp(2.6rem, 1.5rem + 3.4vw, 4.1rem);
  --fs-h1: clamp(1.9rem, 1.45rem + 1.5vw, 2.6rem);
  --fs-h2: clamp(1.5rem, 1.25rem + 0.9vw, 1.95rem);
  --fs-h3: 1.125rem;
  --fs-lg: 1.0625rem;
  --fs-body: 1rem;
  --fs-sm: 0.9375rem;
  --fs-xs: 0.8125rem;
  --fs-2xs: 0.75rem;

  /* Space (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px; --s10: 88px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 999px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --sh-2: 0 10px 28px rgba(0, 0, 0, 0.35);
  --sh-3: 0 24px 64px rgba(0, 0, 0, 0.55);

  /* Motion */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Layout */
  --container: 1160px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* =====================================================================
   2. Base
   ===================================================================== */
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: -0.005em; margin: 0; }
p { margin: 0; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.ic { display: block; flex: 0 0 auto; }
[data-icon] { display: inline-flex; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--s6); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
code { font-size: 0.9em; padding: 1px 5px; border-radius: 5px; background: var(--inset); }

/* =====================================================================
   3. Components
   ===================================================================== */
/* ---- Buttons ---- */
.btn, .btn-play, .btn-secondary, .btn-outline, .btn-blue, .btn-ghost, .btn-text, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; white-space: nowrap; text-decoration: none;
}
.btn, .btn-secondary, .btn-outline, .btn-blue { min-height: 44px; padding: 0 var(--s5); }

/* Primary — orange */
.btn, .btn-play { background: var(--orange); color: var(--orange-ink); }
.btn:hover:not(:disabled), .btn-play:hover:not(:disabled) { background: var(--orange-hover); }
.btn:active:not(:disabled), .btn-play:active:not(:disabled) { background: var(--orange-press); }
.btn-play { min-height: 54px; padding: 0 var(--s7); border-radius: var(--r-lg); font-size: var(--fs-lg); font-weight: 700; box-shadow: 0 8px 24px rgba(255, 122, 47, 0.28); }
.btn-play .ic { width: 18px; height: 18px; }
.btn-sm { min-height: 36px !important; padding: 0 var(--s4) !important; font-size: var(--fs-xs) !important; border-radius: var(--r-sm) !important; }
.btn-md { min-height: 40px; padding: 0 var(--s4); }

/* Secondary — neutral surface */
.btn-secondary { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }

/* Outline — for a second action next to a primary one */
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); border-color: rgba(255, 255, 255, 0.24); }

/* Blue — supporting / informational actions */
.btn-blue { background: var(--blue); color: var(--blue-ink); }
.btn-blue:hover:not(:disabled) { background: var(--blue-hover); }

/* Ghost + text links */
.btn-ghost { min-height: 36px; padding: 0 var(--s3); background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-text { min-height: 44px; padding: 0 var(--s2); background: none; color: var(--text-2); }
.btn-text:hover { color: var(--text); }
.btn-text .ic { transition: transform 0.25s var(--spring); }
.btn-text:hover .ic { transform: translateX(3px); }

/* Square icon buttons */
.icon-btn { width: 38px; height: 38px; padding: 0; border-color: var(--border); background: transparent; color: var(--text-2); }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn[aria-pressed="true"], .icon-btn.on { background: var(--blue-soft); border-color: var(--blue-line); color: var(--text); }

.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.link-btn:hover { color: var(--text); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px;
  font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge.orange { background: var(--orange-soft); color: #ffc7a6; border-color: rgba(255, 122, 47, 0.3); }
.badge.blue { background: var(--blue-soft); color: #cfe4ff; border-color: rgba(77, 163, 255, 0.3); }
.badge.green { background: var(--success-soft); color: #aef0c9; border-color: rgba(60, 207, 127, 0.3); }

/* ---- Cards & panels ---- */
.card {
  width: min(560px, 100%); padding: var(--s7); border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-3);
}
.panel { padding: var(--s6); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.panel h3 { font-size: 1.25rem; }
.note { font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--s3); line-height: 1.5; }
.note.warn { color: #ffb4a8; text-align: center; }

/* ---- Forms ---- */
.field { margin-top: var(--s5); }
.field > label, .field-label { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin-bottom: var(--s2); }
select, input[type=password], input[type=text], input[type=search], #mpNameInput, #mpCodeInput {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--inset); color: var(--text); font: inherit; font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238e98a9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
select:hover:not(:disabled), input:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.24); }
select:focus, input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.2); }
select:disabled { opacity: 0.6; cursor: default; }
optgroup { color: var(--text-3); } option { color: var(--text); background: var(--surface); }

/* Segmented choices */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1 0 auto; min-width: 56px; min-height: 42px; padding: 8px 12px; border-radius: var(--r-md); white-space: nowrap;
  background: var(--inset); border: 1px solid var(--border-strong); color: var(--text-2); font-weight: 500; font-size: var(--fs-sm);
}
.seg button:hover:not(:disabled):not(.active) { color: var(--text); border-color: rgba(255, 255, 255, 0.26); }
.seg button.active { background: var(--orange-soft); border-color: var(--orange); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--orange); }
.seg-desc { font-size: var(--fs-xs); color: var(--text-3); margin-top: var(--s2); }
.seg-desc:empty { display: none; }

/* Checkbox row */
.toggle { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--orange); }

/* ---- Tabs (underline) ---- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 10px 14px 12px; border: 0; background: none; white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-3);
}
.tab::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--orange); transform: scaleX(0); transition: transform 0.25s var(--ease-out); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { transform: scaleX(1); }

/* ---- Modal ---- */
.modal, #quitModal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: var(--s4);
  background: rgba(5, 7, 10, 0.7); animation: fadeIn 0.15s ease;
}
.modal .card, #quitModal .card { width: min(420px, 100%); padding: var(--s6); }
.modal h3, #quitModal h3 { font-size: 1.4rem; margin-bottom: 6px; }
.modal p, #quitModal p { color: var(--text-2); line-height: 1.55; }
.modal .final-actions, #quitModal .final-actions { margin-top: var(--s6); }
.modal-error { color: #ffb4a8; font-size: var(--fs-sm); margin-top: var(--s3); min-height: 1em; }
.modal-error:empty { display: none; }
.modal-icon { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; margin-bottom: var(--s4); background: var(--orange-soft); color: var(--orange); }
#quitModal .card { text-align: left; }
#quitConfirm { background: var(--danger); color: #1c0503; }
#quitConfirm:hover { background: #ff7a73; }

/* ---- Toast ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--sh-2);
  font-size: var(--fs-sm); font-weight: 500; text-align: center;
}

/* ---- Tables ---- */
.table-wrap { max-height: 45vh; overflow-y: auto; margin: var(--s4) 0 var(--s6); border: 1px solid var(--border); border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--text-3); font-weight: 600; font-size: var(--fs-xs); position: sticky; top: 0; background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Skeleton + empty states ---- */
.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s6); border-radius: var(--r-lg); border: 1px dashed var(--border-strong); color: var(--text-2); }
.empty h3 { font-size: 1.15rem; color: var(--text); }
.empty p { font-size: var(--fs-sm); color: var(--text-3); max-width: 46ch; }
.empty .btn { margin-top: var(--s2); }
.empty-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); margin-bottom: var(--s1); }

.final-actions { display: flex; gap: var(--s3); }
.final-actions > * { flex: 1; }

/* =====================================================================
   4. Screens, site header, footer
   ===================================================================== */
.screen { position: fixed; inset: 0; z-index: 30; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); }
.screen-inner {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--s7) + var(--safe-t)) var(--s4) calc(var(--s7) + var(--safe-b));
}
.screen-inner.top { align-items: flex-start; }
/* Screens that show the site header leave room for it */
.screen.with-nav { padding-top: calc(var(--nav-h) + var(--safe-t)); }

.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 35; padding-top: var(--safe-t);
  background: rgba(11, 14, 19, 0.82); backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { height: var(--nav-h); display: flex; align-items: center; gap: var(--s7); }
.nav-brand { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; color: var(--text); }
.nav-word { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }
.nav-word span { color: var(--orange); }
.nav-links { display: flex; align-items: center; gap: var(--s1); height: 100%; }
.nav-link {
  position: relative; height: 100%; display: inline-flex; align-items: center; padding: 0 var(--s3);
  background: none; border: 0; color: var(--text-2); font-weight: 500; font-size: var(--fs-sm);
}
.nav-link::after { content: ""; position: absolute; left: var(--s3); right: var(--s3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--orange); transform: scaleX(0); transition: transform 0.25s var(--ease-out); }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); }
.nav-link.active::after { transform: scaleX(1); }
.nav-actions { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.nav-menu-btn { display: none; }
.nav:has(#navMenu:not(.hidden)) { background: var(--bg); }
.nav-menu {
  border-top: 1px solid var(--border); padding: var(--s2) var(--s4) var(--s4);
  display: flex; flex-direction: column; gap: 2px; animation: slideDown 0.25s var(--ease-out) both;
}
.nav-menu button {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: 0 var(--s3);
  background: none; border: 0; border-radius: var(--r-md); color: var(--text-2); font-size: var(--fs-body); font-weight: 500; text-align: left;
}
.nav-menu button:hover, .nav-menu button.active { background: var(--surface-2); color: var(--text); }
.nav-menu button .ic { color: var(--text-3); }
.nav-menu button.active .ic { color: var(--orange); }

.footer { border-top: 1px solid var(--border); background: var(--bg-raised); padding: var(--s8) 0 calc(var(--s8) + var(--safe-b)); }
.footer-inner { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--s6) var(--s8); align-items: start; }
.footer-brand { display: flex; flex-direction: column; gap: var(--s2); }
.footer-brand .nav-brand { align-self: flex-start; }
.footer-brand p { color: var(--text-3); font-size: var(--fs-sm); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2) var(--s5); }
.footer-links button { background: none; border: 0; padding: 4px 0; color: var(--text-2); font-size: var(--fs-sm); }
.footer-links button:hover { color: var(--text); }
.footer-legal { grid-column: 1 / -1; display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s2) var(--s5); padding-top: var(--s5); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }

/* =====================================================================
   5. Homepage
   ===================================================================== */
#homeScreen { scroll-behavior: smooth; }
#homeScreen > main { position: relative; }

/* ---- Hero: copy on the left, the globe on the right ---- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--border);
  background: radial-gradient(ellipse 55% 70% at 78% 50%, rgba(77, 163, 255, 0.07), transparent 70%), var(--bg); }
.hero-inner {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: var(--s6);
  min-height: min(720px, calc(100vh - var(--nav-h))); padding-top: var(--s9); padding-bottom: var(--s9);
}
.hero-copy { position: relative; z-index: 1; max-width: 600px; }
.hero-eyebrow { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.hero-eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--orange); }
.hero-title { margin: var(--s4) 0 var(--s5); font-size: var(--fs-hero); line-height: 1.02; letter-spacing: -0.015em; }
.hero-title span { color: var(--orange); }
.hero-sub { max-width: 34em; font-size: 1.125rem; line-height: 1.6; color: var(--text-2); }
.hero-cta { display: flex; align-items: center; gap: var(--s4); margin-top: var(--s7); flex-wrap: wrap; }
.hero-facts { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: var(--s7) 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--text-3); }
.hero-facts li { display: inline-flex; align-items: center; gap: 6px; }
.hero-facts li + li::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong); margin-right: var(--s3); }
.hero-facts b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-globe { position: relative; aspect-ratio: 1; width: 100%; max-width: 620px; justify-self: end; }
#globeBg { position: absolute; inset: -6%; width: 112%; height: 112%; filter: blur(1.2px); opacity: 0.95; pointer-events: none; }

/* ---- Home sections ---- */
.home-section { padding: var(--s10) 0 0; scroll-margin-top: var(--nav-h); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s6); }
.section-head h2 { font-size: var(--fs-h2); }
.section-head p { margin-top: 6px; color: var(--text-2); }
.section-label { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 600; color: var(--orange); margin-bottom: var(--s3); }
.section-label.blue { color: var(--blue); }

/* ---- Daily Challenge band ---- */
.daily-band {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s6) var(--s8); align-items: center;
  padding: var(--s7); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border); overflow: hidden;
}
.daily-band::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--blue); }
.db-label { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: var(--fs-sm); font-weight: 600; color: var(--blue); }
.db-day { color: var(--text-3); font-weight: 500; }
.db-title-row { display: flex; align-items: center; gap: var(--s4); margin: var(--s4) 0 var(--s2); }
.db-icon { width: 52px; height: 52px; flex: 0 0 auto; display: grid; place-items: center; font-size: 26px; border-radius: var(--r-lg); background: var(--blue-soft); }
.db-title-row h2 { font-size: var(--fs-h2); }
#dtSub { color: var(--text-2); max-width: 52ch; }
.db-meta { display: flex; flex-wrap: wrap; gap: 4px var(--s3); margin-top: var(--s3); font-size: var(--fs-xs); color: var(--text-3); }
.db-meta span + span::before { content: "·"; margin-right: var(--s3); color: var(--border-strong); }
.db-side { display: flex; flex-direction: column; gap: var(--s4); padding-left: var(--s7); border-left: 1px solid var(--border); }
.db-status { display: flex; flex-direction: column; gap: 6px; }
.db-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); }
.db-state.done { color: var(--success); }
.db-score { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1.1; }
.db-line { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-3); }
.db-line .ic { color: var(--orange); }
.db-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.db-actions .btn { flex: 1; }

/* ---- Mode cards ---- */
.mode-tabs { margin-bottom: var(--s6); }
.mgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.mcard {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: var(--s3); text-align: left; min-height: 196px;
  padding: var(--s5); border-radius: var(--r-lg); color: var(--text); background: var(--surface); border: 1px solid var(--border);
  transition: transform 0.28s var(--spring), border-color 0.2s ease, background 0.2s ease, box-shadow 0.25s ease;
}
.mc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.mc-icon { width: 44px; height: 44px; border-radius: var(--r-md); flex: 0 0 auto; display: grid; place-items: center; color: var(--orange); background: var(--orange-soft); border: 1px solid rgba(255, 122, 47, 0.18); }
.mcard.cat-learn .mc-icon { color: var(--blue); background: var(--blue-soft); border-color: rgba(77, 163, 255, 0.2); }
.mcard.cat-special .mc-icon { color: var(--text); background: repeating-conic-gradient(rgba(255,255,255,0.09) 0 25%, transparent 0 50%) 0 0 / 11px 11px, var(--surface-2); border-color: var(--border-strong); }
.mc-tag { font-size: var(--fs-2xs); font-weight: 600; color: var(--text-3); padding-top: 2px; }
.mc-body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.mc-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.mc-desc { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; }
.mc-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }
.mc-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-arrow { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text-2); transition: color 0.2s ease, transform 0.28s var(--spring); }
.mcard.ready:hover { border-color: var(--orange-line); background: #171d27; }
.mcard.ready:hover .mc-arrow { color: var(--orange); transform: translateX(3px); }
.mcard.soon { cursor: default; background: transparent; border-style: dashed; }
.mcard.soon .mc-icon { color: var(--text-3); background: var(--surface); border-color: var(--border); }
.mcard.soon .mc-name, .mcard.soon .mc-desc { color: var(--text-3); }
.mcard:disabled { opacity: 1; }
.soon-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-3); }
.soon-row > b { font-weight: 600; color: var(--text-2); margin-right: var(--s1); }
.soon-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--r-sm); border: 1px dashed var(--border-strong); color: var(--text-3); }

/* ---- Multiplayer band ---- */
.mp-band {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: var(--s7) var(--s9); align-items: center;
  padding: var(--s8); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border);
}
.mp-copy h2 { font-size: var(--fs-h2); }
.mp-copy p { margin-top: var(--s3); color: var(--text-2); max-width: 44ch; }
.mp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-top: var(--s6); }
.mp-types { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.mp-types li { display: flex; align-items: flex-start; gap: var(--s4); padding: var(--s4) var(--s5); background: var(--bg-raised); }
.mp-types li + li { border-top: 1px solid var(--border); }
.mp-types .ic { color: var(--blue); margin-top: 2px; }
.mp-types b { display: block; font-weight: 600; }
.mp-types span { font-size: var(--fs-sm); color: var(--text-3); }

/* ---- Your progress strip (only when there's history) ---- */
.progress-strip {
  display: flex; align-items: center; gap: var(--s6); flex-wrap: wrap; padding: var(--s5) var(--s6);
  border-radius: var(--r-xl); background: var(--bg-raised); border: 1px solid var(--border);
}
.ps-title { display: flex; align-items: center; gap: var(--s3); font-weight: 600; }
.ps-title .ic { color: var(--orange); }
.ps-stats { display: flex; gap: var(--s7); flex-wrap: wrap; margin-left: auto; }
.ps-stat { display: flex; flex-direction: column; }
.ps-stat span { font-size: var(--fs-2xs); color: var(--text-3); }
.ps-stat b { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- How it works ---- */
.about-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: var(--s8) var(--s9); align-items: start; }
.about h2 { font-size: var(--fs-h2); margin-bottom: var(--s4); }
.about-intro p { color: var(--text-2); line-height: 1.7; }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.how-step { display: grid; grid-template-columns: 44px 1fr; gap: var(--s4); padding: var(--s5) 0; border-top: 1px solid var(--border); }
.how-step:last-child { border-bottom: 1px solid var(--border); }
.how-step b { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-md); font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--orange); background: var(--orange-soft); }
.how-step h3 { font-size: var(--fs-h3); margin-bottom: 4px; }
.how-step p { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.55; }
.about { padding-bottom: var(--s10); }
#homeNote:empty { display: none; }
#homeNote { margin: var(--s6) auto 0; max-width: 720px; }

/* ---- Setup screen ---- */
.setup { width: min(600px, 100%); }
.setup-head { display: flex; align-items: center; gap: var(--s4); margin: var(--s5) 0 var(--s2); }
.setup-icon { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; border-radius: var(--r-md); color: var(--orange); background: var(--orange-soft); }
.setup h2 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem); }
#setupRules { line-height: 1.55; color: var(--text-2); }
.preview {
  margin-top: var(--s6); padding: var(--s4); border-radius: var(--r-md);
  background: var(--inset); border: 1px solid var(--border); font-size: var(--fs-sm); line-height: 1.6; color: var(--text-2);
}
.preview > div:first-child { color: var(--text); }
.preview b { color: var(--gold); font-weight: 600; font-variant-numeric: tabular-nums; }
.preview > div:first-child b { color: var(--text); }
.setup .actions { margin-top: var(--s6); }
.setup .actions .btn { width: 100%; min-height: 50px; font-size: var(--fs-lg); }

/* =====================================================================
   6. Game
   ===================================================================== */
#sv { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; background: #151a22; }
#svJs { position: fixed; inset: 0; z-index: 1; background: #151a22; }
#svBlock { position: fixed; inset: 0; z-index: 5; cursor: not-allowed; }
#blindCover {
  position: fixed; inset: 0; z-index: 6; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); text-align: center; padding: var(--s4);
}
.blind-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }

/* ---- HUD. It's also opaque on purpose: it covers the address card the Street View embed shows in the top-left corner. ---- */
#hud {
  position: fixed; top: 0; left: 0; z-index: 10; width: 420px; min-height: 108px;
  padding: 12px 14px 14px 18px; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-width: 0 1px 1px 0; border-bottom-right-radius: var(--r-xl);
  box-shadow: var(--sh-2);
}
.hud-top { display: flex; align-items: center; gap: var(--s3); min-height: 34px; }
.hud-mode { flex: 1; min-width: 0; font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-actions { display: flex; gap: 6px; }
.hud-actions .icon-btn { width: 34px; height: 34px; border-radius: var(--r-sm); }
.hud-stats { display: flex; gap: var(--s6); align-items: flex-end; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat .label { font-size: var(--fs-2xs); font-weight: 500; color: var(--text-3); }
.stat .value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
#hudTimeStat.low .value { color: var(--danger); }
#hudLives { display: flex; gap: 2px; color: var(--danger); padding: 3px 0 2px; }

/* ---- Loading ---- */
#loading {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4);
  background: var(--bg); text-align: center; padding: var(--s4);
}
#loading .mark { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.92); opacity: 0.65; } }
#loadingText { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.loading-bar { width: 180px; height: 3px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.loading-bar::after { content: ""; display: block; width: 40%; height: 100%; border-radius: 3px; background: var(--orange); animation: loadSlide 1.1s ease-in-out infinite; }
@keyframes loadSlide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
#loading.failed .loading-bar, #loading.failed .mark { display: none; }
#loadingError { max-width: 520px; color: var(--text-2); line-height: 1.55; }
.loading-actions { display: flex; gap: var(--s3); margin-top: var(--s2); }

/* ---- Guess map ---- */
#guessWrap {
  position: fixed; left: 16px; bottom: 16px; z-index: 10;
  width: 320px; display: flex; flex-direction: column; gap: var(--s2);
  transition: width 0.18s ease;
}
#miniMap {
  height: 210px; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--border-strong); box-shadow: var(--sh-2);
  opacity: 0.78; transition: height 0.18s ease, opacity 0.18s ease;
  cursor: crosshair; background: #1c2230;
}
#guessWrap.pinned { width: min(640px, calc(100vw - 32px)); }
#guessWrap.pinned #miniMap { height: min(430px, calc(100vh - 220px)); opacity: 1; }
@media (hover: hover) and (pointer: fine) and (min-width: 701px) {
  #guessWrap:hover { width: min(640px, calc(100vw - 32px)); }
  #guessWrap:hover #miniMap { height: min(430px, calc(100vh - 220px)); opacity: 1; }
}
.guess-row { display: flex; gap: var(--s2); }
#guessBtn, #riskBtn { flex: 1; min-height: 46px; }
#guessBtn:disabled { opacity: 1; background: var(--surface); color: var(--text-3); border-color: var(--border-strong); }
.btn.risky { background: transparent; color: var(--orange); border-color: var(--orange); }
.btn.risky:hover:not(:disabled) { background: var(--orange-soft); }
.btn.risky:disabled { opacity: 1; color: var(--text-3); border-color: var(--border-strong); background: var(--surface); }
#mapToggle { display: none; }
#pinBtn { width: 46px; height: 46px; background: var(--surface); border-color: var(--border-strong); }

.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.5); }
.pin-guess { background: var(--blue); }
.pin-answer { background: var(--success); }

/* ---- Country Quiz / F1 choices ---- */
#quizPanel {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  width: min(580px, calc(100vw - 32px)); padding: var(--s4); border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--sh-3);
}
.quiz-q { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; margin: 0 2px var(--s3); }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.quiz-opt {
  min-height: 48px; padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-weight: 600; text-align: left;
}
.quiz-opt:hover { border-color: var(--orange); }
.f1-opt { display: flex; flex-direction: column; gap: 2px; }
.f1-name { font-weight: 600; }
.f1-sub { font-size: var(--fs-2xs); font-weight: 500; color: var(--text-3); }
#quizPanel.all-choices { width: min(900px, calc(100vw - 32px)); }
#quizPanel.all-choices .quiz-options { grid-template-columns: repeat(4, 1fr); max-height: 42vh; overflow-y: auto; padding-right: 4px; }
#quizPanel.all-choices .quiz-opt { padding: 8px 10px; min-height: 0; }
.f1-search { width: 100%; margin-bottom: var(--s2); }
#quizPanel:not(.all-choices) .f1-search { display: none; }
/* Special modes: flag answers, two-answer questions, Reverse Guess satellite view */
.flag-opt { display: flex; align-items: center; justify-content: center; padding: 8px; }
.flag-opt img { display: block; height: 56px; width: auto; max-width: 100%; border-radius: 4px; box-shadow: 0 0 0 1px rgba(255,255,255,0.12); }
.quiz-options.two .quiz-opt { text-align: center; font-size: var(--fs-lg); }
#revView { position: fixed; inset: 0; z-index: 1; background: #151a22; }
#revView .leaflet-control-zoom { margin-top: 12px; margin-right: 12px; }
.ap-opt { display: flex; flex-direction: column; gap: 2px; }
.ap-code { font-size: var(--fs-lg); font-weight: 800; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.ap-sub { font-size: var(--fs-2xs); font-weight: 500; color: var(--text-3); }
#quizPanel.ap-typing .quiz-options { display: block; }
.ap-type { display: flex; gap: var(--s2); }
.ap-type .ap-input { flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; }
.ap-type .ap-go { flex: 0 0 auto; padding: 0 var(--s5); }
.ap-type .ap-go:disabled { opacity: 0.5; cursor: default; }
.ap-preview { margin-top: var(--s2); font-size: var(--fs-xs); min-height: 1.4em; }
.ap-preview.bad { color: var(--danger); }

/* ---- Round result ---- */
#result { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; background: var(--bg); }
#resultMap { flex: 1; min-height: 200px; background: #1c2230; }
#resultCard {
  padding: var(--s5) var(--s7) calc(var(--s5) + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--border-strong);
  display: flex; align-items: center; gap: var(--s5) var(--s8); flex-wrap: wrap; box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.3);
}
.res-score { min-width: 220px; }
#resultCard .big { font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; line-height: 1.05; color: var(--gold); font-variant-numeric: tabular-nums; }
.bar { height: 6px; width: 220px; border-radius: var(--r-full); background: var(--inset); overflow: hidden; margin-top: var(--s2); }
.bar > div { height: 100%; background: var(--orange); width: 0; transition: width 0.6s var(--ease-out); border-radius: inherit; }
.res-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.res-detail { font-size: 1.125rem; font-weight: 600; }
.country-line { font-size: var(--fs-sm); color: var(--text-2); }
.res-place { color: var(--text-3); font-size: var(--fs-xs); }
.res-note { margin-top: 2px; font-weight: 600; color: var(--gold); }
.res-legend { display: flex; gap: var(--s4); margin-top: 6px; font-size: var(--fs-2xs); color: var(--text-3); }
.res-legend span { display: inline-flex; align-items: center; gap: 6px; }
.res-legend i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; }
.res-legend .lg-guess i { background: var(--blue); }
.res-legend .lg-answer i { background: var(--success); }
.ok { color: var(--success); font-weight: 600; }
.no { color: var(--danger); font-weight: 600; }
.res-actions { display: flex; gap: var(--s3); margin-left: auto; }
#nextBtn { min-width: 170px; min-height: 48px; }

/* ---- Final ---- */
.final-card { width: min(640px, 100%); }
.final-mode { display: flex; align-items: center; gap: var(--s3); color: var(--text-2); font-weight: 600; }
.final-mode .ic { color: var(--orange); }
.final-score { font-family: var(--font-display); font-size: 3.4rem; font-weight: 700; line-height: 1.05; color: var(--gold); margin: var(--s4) 0 var(--s1); font-variant-numeric: tabular-nums; }
#finalOutOf { color: var(--text-2); }
.final-saved { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s5); font-size: var(--fs-xs); color: var(--text-3); }
.final-saved .ic { color: var(--success); }
.final-saved .link-btn { font-size: var(--fs-xs); color: var(--blue); }

/* =====================================================================
   7. Daily Challenge
   ===================================================================== */
.page { width: 100%; max-width: 980px; margin: 0 auto; padding: var(--s8) var(--s6) calc(var(--s9) + var(--safe-b)); }
.page-head { margin-bottom: var(--s7); }
.page-title { font-size: var(--fs-h1); }
.page-sub { margin-top: var(--s2); color: var(--text-2); }
.crumb { margin-bottom: var(--s4); }
.daily { width: 100%; }
.daily-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s6); }
.daily-h { font-size: var(--fs-h1); }
#dailyMeta { margin-top: 6px; color: var(--text-2); }
.countdown { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.dh-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-bottom: var(--s2); }

.daily-card { padding: var(--s6); border-radius: var(--r-xl); margin-bottom: var(--s8); background: var(--surface); border: 1px solid var(--border); }
.daily-card.hero { border-color: var(--blue-line); }
.dc-top { display: flex; gap: var(--s4); align-items: center; }
.dc-icon { width: 56px; height: 56px; flex: 0 0 auto; display: grid; place-items: center; font-size: 28px; border-radius: var(--r-lg); background: var(--blue-soft); }
.dc-kicker { font-size: var(--fs-sm); font-weight: 600; color: var(--blue); }
.dc-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; line-height: 1.15; }
.dc-blurb { margin: var(--s4) 0 var(--s3); line-height: 1.55; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 4px var(--s3); font-size: var(--fs-xs); color: var(--text-3); }
.chip + .chip::before { content: "·"; margin-right: var(--s3); color: var(--border-strong); }
.dc-result { margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--border); }
.dc-result:empty { display: none; }
.dc-score { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.dc-emojis, .fd-emojis { font-size: 20px; letter-spacing: 2px; margin: 4px 0; }
.dc-actions { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s5); }
.dc-podium { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--border); }
.db-podium { grid-column: 1 / -1; padding-top: var(--s5); border-top: 1px solid var(--border); }

/* Podium: 2nd · 1st · 3rd, tallest in the middle */
.podium-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.podium-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: var(--fs-sm); }
.podium-title .ic { color: var(--gold); }
.podium-note { font-size: var(--fs-xs); color: var(--text-3); }
.podium { list-style: none; margin: 0 auto; padding: 0; max-width: 520px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); align-items: end; border-bottom: 1px solid var(--border-strong); }
.pd { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.pd.p1 { order: 2; } .pd.p2 { order: 1; } .pd.p3 { order: 3; }
.pd-name { max-width: 100%; font-weight: 600; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; justify-content: center; }
.pd-you { flex: 0 0 auto; padding: 1px 6px; border-radius: var(--r-full); background: var(--orange-soft); color: var(--orange); font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.pd-score { margin: 2px 0 var(--s2); font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.pd.p1 .pd-score { color: var(--gold); font-size: 1.35rem; }
.pd-block {
  width: 100%; display: grid; place-items: start center; padding-top: var(--s2); border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom: 0;
}
.pd-block b { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-family: var(--font-display); font-size: 1rem; color: #0b0e13; }
.pd.p1 .pd-block { height: 84px; background: linear-gradient(180deg, rgba(255, 200, 61, 0.18), rgba(255, 200, 61, 0.04)); border-color: rgba(255, 200, 61, 0.45); }
.pd.p2 .pd-block { height: 60px; background: linear-gradient(180deg, rgba(201, 209, 220, 0.14), rgba(201, 209, 220, 0.03)); border-color: rgba(201, 209, 220, 0.35); }
.pd.p3 .pd-block { height: 44px; background: linear-gradient(180deg, rgba(208, 138, 79, 0.16), rgba(208, 138, 79, 0.03)); border-color: rgba(208, 138, 79, 0.4); }
.pd.p1 .pd-block b { background: var(--gold); }
.pd.p2 .pd-block b { background: #c9d1dc; }
.pd.p3 .pd-block b { background: #d08a4f; }
.pd.empty .pd-name, .pd.empty .pd-score { color: var(--text-3); font-weight: 500; font-family: var(--font); font-size: var(--fs-xs); }
.pd.empty .pd-block { opacity: 0.55; }
.pd.me .pd-block { box-shadow: inset 0 0 0 1px var(--orange-line); }
.podium-foot { margin-top: var(--s3); font-size: var(--fs-sm); color: var(--text-2); text-align: center; }
.podium-foot.muted { color: var(--text-3); font-size: var(--fs-xs); margin-top: var(--s1); }
.podium-skel { height: 150px; border-radius: var(--r-lg); }
.podium-wrap.compact .pd.p1 .pd-block { height: 60px; }
.podium-wrap.compact .pd.p2 .pd-block { height: 44px; }
.podium-wrap.compact .pd.p3 .pd-block { height: 32px; }
.podium-wrap.compact .pd-block b { width: 24px; height: 24px; font-size: 0.85rem; }

.daily-grid-title { font-size: 1.25rem; margin: 0 0 var(--s4); }
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: var(--s3); }
.day-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: var(--s3); border-radius: var(--r-lg); min-height: 116px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
}
.day-tile:hover:not(:disabled) { border-color: var(--orange-line); }
.dt-num { font-size: var(--fs-2xs); color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.dt-icon { font-size: 22px; line-height: 1.2; }
.dt-icon .ic { color: var(--text-3); }
.dt-title { font-size: var(--fs-xs); font-weight: 600; line-height: 1.3; }
.dt-sub { font-size: var(--fs-2xs); color: var(--text-3); margin-top: auto; }
.day-tile.today { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.day-tile.done { background: linear-gradient(180deg, rgba(60, 207, 127, 0.08), var(--surface) 70%); }
.day-tile.done .dt-sub { color: var(--success); font-weight: 600; }
.day-tile.late .dt-sub { color: var(--gold); font-weight: 600; }
.day-tile.locked { opacity: 0.45; cursor: default; background: transparent; border-style: dashed; }

.final-daily { margin: var(--s4) 0 var(--s2); padding: var(--s4); border-radius: var(--r-lg); background: var(--success-soft); border: 1px solid rgba(60, 207, 127, 0.3); }
.fd-title { font-weight: 600; }
.fd-note { font-size: var(--fs-sm); margin: 4px 0 var(--s3); }

/* =====================================================================
   8. Multiplayer
   ===================================================================== */
.code-input { font-family: var(--font-display); font-size: 28px !important; letter-spacing: 0.35em; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.lobby { width: min(1040px, 100%); display: flex; flex-direction: column; gap: var(--s5); }
.lobby-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s5); flex-wrap: wrap;
  padding: var(--s6); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border);
}
.lobby-head .kicker { font-size: var(--fs-sm); font-weight: 600; color: var(--orange); }
.room-code { font-family: var(--font-display); font-size: clamp(2.6rem, 7vw, 3.8rem); font-weight: 700; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0 6px; }
.lobby-head .muted { font-size: var(--fs-sm); }
.lobby-share { display: flex; gap: var(--s3); flex-wrap: wrap; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: var(--s5); align-items: start; }
.host-tag { font-size: var(--fs-xs); color: var(--orange); font-weight: 600; }
.panel .field:first-child { margin-top: 0; }

.pl-row { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border-radius: var(--r-md); background: var(--bg-raised); border: 1px solid var(--border); margin-bottom: 6px; }
.pl-row.offline { opacity: 0.5; }
.pl-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.pl-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-tag { font-size: var(--fs-2xs); font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-3); }
.pl-crown { display: inline-flex; color: var(--gold); font-size: 14px; }
.pl-actions { margin-left: auto; display: flex; gap: 6px; }
.pl-btn { min-height: 32px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); border-radius: var(--r-sm); padding: 4px 10px; font-size: var(--fs-xs); font-weight: 500; }
.pl-btn:hover { background: var(--surface-2); color: var(--text); }
.pl-btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.pl-hint, .pl-empty { font-size: var(--fs-sm); padding: 8px 4px; }
.team-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.team-col { padding: 10px; border-radius: var(--r-lg); background: transparent; border: 1px solid var(--border); min-width: 0; }
.team-col.red { border-top: 3px solid var(--danger); }
.team-col.blue { border-top: 3px solid var(--blue); }
.team-head { font-weight: 600; margin: 2px 4px 10px; }
.team-col.red .team-head { color: #ff8f88; }
.team-col.blue .team-head { color: var(--blue-2); }

.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.type-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: var(--s3); border-radius: var(--r-md);
  background: var(--inset); border: 1px solid var(--border-strong); color: var(--text);
}
.type-card.active { border-color: var(--orange); background: var(--orange-soft); box-shadow: inset 0 0 0 1px var(--orange); }
.type-card:disabled { opacity: 1; cursor: default; }
.type-card:disabled:not(.active) { opacity: 0.5; }
.tc-icon { display: inline-flex; color: var(--orange); font-size: 20px; }
.tc-name { font-weight: 600; }
.tc-desc { font-size: var(--fs-2xs); color: var(--text-3); line-height: 1.4; }
.panel .seg button:disabled:not(.active) { opacity: 0.45; }
.panel .seg button:disabled.active { opacity: 1; cursor: default; }
.lobby-start { display: flex; align-items: center; justify-content: flex-end; gap: var(--s5); flex-wrap: wrap; }
.lobby-start .muted { font-size: var(--fs-sm); }

/* In-game multiplayer HUD (full width; also covers the embed's address card) */
#mpHud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 22;
  padding: calc(12px + var(--safe-t)) var(--s6) 10px; min-height: 100px;
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--sh-2);
}
.mph-row { display: flex; align-items: center; gap: var(--s6); max-width: 1100px; margin: 0 auto; }
.mph-stat { display: flex; flex-direction: column; min-width: 64px; }
.mph-stat b { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mph-stat .label, .ffa-me .label { font-size: var(--fs-2xs); color: var(--text-3); }
.mph-mult { font-size: var(--fs-2xs); font-weight: 600; color: var(--gold); }
#mphTimeWrap.low b { color: var(--danger); }
.mph-center { flex: 1; min-width: 0; }
.mph-actions { display: flex; gap: 6px; }
.mph-status { text-align: center; font-size: var(--fs-xs); color: var(--text-3); margin-top: 6px; min-height: 1em; }
.ffa-me { display: flex; flex-direction: column; align-items: center; }
.ffa-me b { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--gold); line-height: 1.1; }
.hp-bars { display: flex; align-items: center; gap: var(--s4); }
.hp-side { flex: 1; min-width: 0; }
.hp-top { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); margin-bottom: 6px; }
.hp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-val { font-variant-numeric: tabular-nums; }
.hp-bar { height: 10px; border-radius: var(--r-full); background: var(--inset); overflow: hidden; }
.hp-fill { height: 100%; border-radius: var(--r-full); transition: width 0.9s var(--spring); }
.hp-vs { font-weight: 700; color: var(--text-3); font-size: var(--fs-2xs); }
body:has(#mpHud:not(.hidden)) #quizPanel { display: none; }

#mpResultCard {
  padding: var(--s5) var(--s7) calc(var(--s5) + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--border-strong);
  display: grid; grid-template-columns: 1fr 1.2fr; gap: var(--s3) var(--s7); max-height: 55vh; overflow-y: auto;
}
.mpr-head { grid-column: 1 / -1; }
.mpr-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; color: var(--gold); }
.mpr-list { display: flex; flex-direction: column; gap: 6px; }
.mpr-row { display: grid; grid-template-columns: 22px 12px 1fr auto auto; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: var(--r-md); background: var(--bg-raised); border: 1px solid var(--border); }
.mpr-row.me { background: var(--orange-soft); border-color: rgba(255, 122, 47, 0.35); }
.mpr-rank { color: var(--text-3); font-weight: 600; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.mpr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpr-dist { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.mpr-pts { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
#mprHp { align-self: center; }
#mprHp:empty { display: none; }
.mpr-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.pin-label { background: rgba(11, 14, 19, 0.92); color: #fff; border: 0; border-radius: 6px; font-weight: 600; box-shadow: none; }
.pin-label::before { display: none; }

.mp-final { text-align: center; width: min(560px, 100%); }
.mpf-trophy { width: 84px; height: 84px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--gold); background: rgba(255, 200, 61, 0.1); border: 1px solid rgba(255, 200, 61, 0.25); }
.mp-final h2 { margin: var(--s2) 0 4px; font-size: var(--fs-h1); }
.mp-final .mpr-list { margin: var(--s5) 0 var(--s6); text-align: left; }
.mpf-wait { margin-top: var(--s3); font-size: var(--fs-sm); }
.mpf-wait:empty { display: none; }

/* =====================================================================
   9. Teaching Mode — AI Coach + Clue Guide
   ===================================================================== */
#coach { position: fixed; z-index: 27; right: 0; bottom: 0; pointer-events: none; }
#coach > * { pointer-events: auto; }
.coach-launcher {
  position: fixed; right: 76px; bottom: 18px;
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: var(--r-full);
  font-weight: 600; color: var(--blue-ink); border: 0; background: var(--blue);
  box-shadow: var(--sh-2);
  transition: transform 0.28s var(--spring), bottom 0.3s ease, top 0.3s ease, background 0.2s ease;
  animation: popIn2 0.45s var(--spring) both;
}
.coach-launcher:hover { background: var(--blue-hover); transform: scale(1.05); }
.coach-launcher:active { transform: scale(0.95); }
.cl-dot { position: absolute; top: 3px; right: 5px; width: 11px; height: 11px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 2px var(--bg); }
/* On the round-result screen the launcher moves to the top so it never covers "Next round" */
body:has(#result:not(.hidden)) .coach-launcher { top: calc(16px + var(--safe-t)); bottom: auto; right: 16px; }
body:has(#result:not(.hidden)) .coach-panel { top: calc(16px + var(--safe-t)); bottom: auto; height: min(520px, calc(100vh - 200px)); transform-origin: top right; }

.coach-panel {
  position: fixed; right: 16px; bottom: 16px; width: min(390px, calc(100vw - 32px)); height: min(560px, calc(100vh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: coachIn 0.35s var(--spring) both; transform-origin: bottom right;
}
@keyframes coachIn { from { opacity: 0; transform: translateY(20px) scale(0.94); } to { opacity: 1; transform: none; } }
.coach-head, .guide-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.coach-title, .guide-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--fs-body); }
.coach-title .ic { color: var(--blue); }
.guide-title .ic { color: var(--orange); }
.coach-sub { font-size: var(--fs-2xs); color: var(--text-3); margin-top: 1px; padding-left: 28px; }
.coach-min { width: 34px; height: 34px; }

.coach-head, .coach-suggest, .coach-tags, .coach-input { flex-shrink: 0; }
.coach-msgs { flex: 1; min-height: 70px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.cmsg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: var(--fs-sm); line-height: 1.5; word-wrap: break-word; animation: cardIn 0.3s var(--ease-out) backwards; }
.cmsg.player { align-self: flex-end; background: var(--orange); color: var(--orange-ink); border-bottom-right-radius: 4px; font-weight: 500; white-space: pre-line; }
.cmsg.coach { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.cmsg.coach p { margin: 0 0 6px; } .cmsg.coach p:last-child { margin-bottom: 0; }
.cmsg.coach ul { margin: 4px 0 6px; padding-left: 18px; } .cmsg.coach li { margin: 2px 0; }
.cmsg.coach b { color: #d9e9ff; font-weight: 600; }
.cmsg.divider { align-self: stretch; max-width: none; text-align: center; font-size: var(--fs-2xs); font-weight: 600; color: var(--text-3); padding: 4px; background: none; border-radius: 0; border-top: 1px solid var(--border); margin-top: 4px; }
.cmsg.note { align-self: stretch; max-width: none; font-size: var(--fs-xs); color: var(--text-3); background: var(--bg-raised); border: 1px dashed var(--border-strong); }
.cmsg.error { align-self: stretch; max-width: none; font-size: var(--fs-xs); color: #ffc2bc; background: var(--danger-soft); border: 1px solid rgba(255, 97, 89, 0.3); }
.cmsg-retry { margin-left: 8px; border: 1px solid rgba(255, 194, 188, 0.5); background: transparent; color: #ffd6d2; border-radius: 6px; padding: 2px 8px; font-size: var(--fs-2xs); }
.cmsg.typing { display: inline-flex; gap: 5px; padding: 12px 14px; }
.cmsg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: typing 1s ease-in-out infinite; }
.cmsg.typing span:nth-child(2) { animation-delay: 0.15s; } .cmsg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 100% { opacity: 0.3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

.coach-suggest { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
.coach-suggest::-webkit-scrollbar { display: none; }
.suggest-chip {
  flex: 0 0 auto; min-height: 32px; padding: 6px 11px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  color: #d4e7ff; background: var(--blue-soft); border: 1px solid rgba(77, 163, 255, 0.3);
  transition: transform 0.25s var(--spring), background 0.2s ease;
}
.suggest-chip:hover { background: rgba(77, 163, 255, 0.2); transform: scale(1.04); }
.guide-chip { color: #ffd9c2; background: var(--orange-soft); border-color: rgba(255, 122, 47, 0.35); }
.guide-chip:hover { background: rgba(255, 122, 47, 0.2); }

.coach-obs { max-height: 38%; overflow-y: auto; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--bg-raised); }
.obs-group { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.obs-head { width: 100%; font-size: var(--fs-2xs); font-weight: 600; color: var(--text-3); margin-bottom: 1px; }
.obs-chip, .obs-tag {
  min-height: 30px; padding: 4px 9px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border-strong); transition: transform 0.2s var(--spring), background 0.15s ease, border-color 0.15s ease;
}
.obs-chip:hover { transform: scale(1.05); border-color: var(--orange-line); color: var(--text); }
.obs-chip.on { background: var(--orange-soft); border-color: var(--orange); color: var(--text); }
.coach-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 8px 12px 0; }
.tags-label { font-size: var(--fs-2xs); color: var(--text-3); font-weight: 600; }
.obs-tag { min-height: 26px; background: var(--orange-soft); border-color: rgba(255, 122, 47, 0.4); color: var(--text); font-size: var(--fs-2xs); padding: 3px 8px; }

.coach-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--border); }
.coach-input textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 110px; padding: 9px 12px; border-radius: var(--r-md); font: inherit; font-size: 15px;
  color: var(--text); background: var(--inset); border: 1px solid var(--border-strong); line-height: 1.35;
}
.coach-input textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.18); }
.coach-input textarea:disabled { opacity: 0.5; }
.coach-see { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; border-radius: var(--r-md); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-strong); }
.coach-see:hover { color: var(--text); }
.coach-see.active { border-color: var(--orange); background: var(--orange-soft); color: var(--text); }
.coach-send { width: 42px; height: 40px; display: grid; place-items: center; border-radius: var(--r-md); border: 0; color: var(--blue-ink); background: var(--blue); }
.coach-send:hover:not(:disabled) { background: var(--blue-hover); }
.coach-send:disabled { opacity: 0.4; }

/* Post-round extras on the result card */
.teach-fact { margin-top: 4px; font-size: var(--fs-xs); color: #d4e7ff; }
#teachSummaryBtn { white-space: nowrap; }
#teachSummaryBtn:disabled { opacity: 0.7; }

/* ---- Clue Reporting Guide (top right of the Teaching Mode screen) ---- */
#clueGuide { position: fixed; z-index: 26; top: calc(16px + var(--safe-t)); right: 16px; display: flex; flex-direction: column; align-items: flex-end; }
body:has(#result:not(.hidden)) #clueGuide { display: none; }
.guide-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--r-full);
  font-weight: 600; font-size: var(--fs-sm); color: var(--orange-ink); border: 0; background: var(--orange);
  box-shadow: var(--sh-2); transition: transform 0.28s var(--spring), background 0.2s ease;
  animation: popIn2 0.45s var(--spring) both;
}
.guide-pill:hover { background: var(--orange-hover); transform: scale(1.05); }
.guide-pill:active { transform: scale(0.95); }
.guide-body {
  width: min(360px, calc(100vw - 32px)); max-height: calc(100vh - 32px - var(--safe-t));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-xl); box-shadow: var(--sh-3);
  animation: guideIn 0.32s var(--spring) both; transform-origin: top right;
}
@keyframes guideIn { from { opacity: 0; transform: translateY(-14px) scale(0.94); } to { opacity: 1; transform: none; } }
body:has(#coachPanel:not(.hidden)):has(#guideBody:not(.hidden)) .coach-panel { height: min(470px, 58vh); }
body:has(#coachPanel:not(.hidden)):has(#guideBody:not(.hidden)) .coach-obs { max-height: 30%; }
body:has(#coachPanel:not(.hidden)) .guide-body { max-height: calc(100vh - 44px - min(470px, 58vh) - var(--safe-t)); }
.guide-tabs { display: flex; gap: 0; padding: 0 10px; border-bottom: 1px solid var(--border); }
.guide-tab {
  position: relative; flex: 1; padding: 10px 4px 11px; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  color: var(--text-3); background: none; border: 0;
}
.guide-tab::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--orange); transform: scaleX(0); transition: transform 0.25s var(--ease-out); }
.guide-tab:hover { color: var(--text); }
.guide-tab.active { color: var(--text); font-weight: 600; }
.guide-tab.active::after { transform: scaleX(1); }
.guide-content { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 12px; font-size: var(--fs-sm); line-height: 1.45; }
.guide-content ul { margin: 6px 0; padding-left: 18px; color: var(--text-2); } .guide-content li { margin: 3px 0; }
.guide-p { margin: 0 0 10px; color: var(--text-2); }
.guide-why { margin: 6px 0 10px; font-size: var(--fs-xs); color: var(--text-3); } .guide-why b { color: var(--text-2); font-weight: 600; }
.rel { display: flex; align-items: center; gap: 6px; font-size: var(--fs-2xs); font-weight: 600; color: var(--text-2); }
.rel-dots { color: var(--orange); letter-spacing: 1px; } .rel-dots i { font-style: normal; color: rgba(255, 255, 255, 0.14); }
.guide-use {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600;
  color: var(--blue-ink); border: 0; background: var(--blue); transition: transform 0.25s var(--spring), background 0.2s ease;
}
.guide-use:hover { background: var(--blue-hover); transform: scale(1.04); }
.guide-use:active { transform: scale(0.96); }

.gcat { border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 6px; background: var(--bg-raised); overflow: hidden; }
.gcat.open { border-color: var(--border-strong); background: var(--surface-2); }
.gcat-head { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 11px; text-align: left; font-weight: 600; font-size: var(--fs-sm); color: var(--text); background: transparent; border: 0; }
.gcat-head:hover { background: rgba(255, 255, 255, 0.03); }
.gcat-icon { width: 22px; text-align: center; }
.gcat-name { flex: 1; }
.gcat-chev { color: var(--text-3); transition: transform 0.2s ease; }
.gcat.open .gcat-chev { transform: rotate(180deg); }
.gcat-body { padding: 0 12px 12px 43px; animation: cardIn 0.25s var(--ease-out) backwards; }

.step-head { margin-bottom: 10px; }
.step-dots { display: flex; gap: 5px; margin-bottom: 8px; }
.step-dots span { flex: 1; height: 4px; border-radius: 4px; background: var(--surface-3); }
.step-dots span.done { background: var(--blue-line); }
.step-dots span.on { background: var(--orange); }
.step-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-lg); line-height: 1.25; }
.step-cat { padding: 10px 12px; margin-bottom: 8px; border-radius: var(--r-md); background: var(--bg-raised); border: 1px solid var(--border); }
.step-cat-name { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.step-cat-name .ic, .gcat-icon .ic { color: var(--orange); }
.step-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.step-btn { min-height: 36px !important; padding: 0 14px !important; font-size: var(--fs-xs) !important; }
.step-btn:disabled { opacity: 0.4; }

.tmpl { padding: 10px 12px; margin-bottom: 8px; border-radius: var(--r-md); background: var(--bg-raised); border: 1px solid var(--border); }
.tmpl-name { font-weight: 600; margin-bottom: 6px; }
.tmpl-text { white-space: pre-line; font-size: var(--fs-xs); color: var(--text-2); margin-bottom: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--inset); border-left: 2px solid var(--orange-line); }

/* =====================================================================
   10. Statistics
   ===================================================================== */
.stats-page { max-width: var(--container); }
.stats-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s5) var(--s7); align-items: end; }
.player-card { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s5); border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border); min-width: 320px; }
.player-avatar { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-3); overflow: hidden; }
.player-avatar img { width: 100%; height: 100%; object-fit: cover; }
.player-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.player-name { font-weight: 600; font-size: var(--fs-lg); }
.player-status { font-size: var(--fs-xs); color: var(--text-3); }
.player-card .btn-outline { margin-left: auto; }

.stats-section { margin-top: var(--s8); }
.stats-section > h2, .stats-section-head h2 { font-size: 1.35rem; }
.stats-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.stats-section-head p { color: var(--text-3); font-size: var(--fs-sm); margin-top: 4px; }

/* Stat cards: the first row leads, the second row supports */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.stat-card { display: flex; flex-direction: column; gap: 4px; padding: var(--s4) var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.stat-card .sc-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; }
.stat-card .sc-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
.stat-card .sc-sub { font-size: var(--fs-2xs); color: var(--text-3); }
.stat-card.lead { padding: var(--s5); }
.stat-card.lead .sc-value { font-size: 2.2rem; font-weight: 700; }
.stat-card.lead.accent .sc-value { color: var(--gold); }
.stat-card .sc-value.na { color: var(--text-3); font-size: 1.3rem; font-weight: 500; }
.stat-grid.secondary { margin-top: var(--s3); }
.stat-grid.secondary .stat-card { background: var(--bg-raised); }

/* Performance chart (one series; colors checked for contrast and colour-blind separation on --surface) */
.chart-panel { padding: var(--s5) var(--s5) var(--s4); --chart-line: #e8651c; --chart-ref: #3b8ff0; }
.chart-wrap { position: relative; width: 100%; height: 240px; }
.chart { display: block; width: 100%; height: 100%; overflow: visible; }
.chart:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 4px; }
.chart .grid line { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart-line); fill-opacity: 0.1; }
.chart .avg { stroke: var(--chart-ref); stroke-width: 1.5; stroke-dasharray: 4 5; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart .dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; transition: r 0.15s ease; }
.chart .dot.best { fill: var(--gold); }
.chart .dot.on { r: 6; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; z-index: 2; pointer-events: none; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--sh-2); white-space: nowrap; font-size: var(--fs-2xs); color: var(--text-3); }
.chart-tip b { font-size: var(--fs-sm); color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip .tip-sub { color: var(--text-3); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-top: var(--s3); font-size: var(--fs-xs); color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 8px; }
.chart-legend i { width: 16px; height: 0; border-top: 2px dashed var(--chart-ref); }
.chart-legend i.best { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--gold); }
.chart-seg { display: flex; gap: 4px; padding: 3px; border-radius: var(--r-md); background: var(--inset); border: 1px solid var(--border); }
.chart-seg button { min-height: 32px; padding: 0 12px; border-radius: 7px; border: 0; background: none; color: var(--text-3); font-size: var(--fs-xs); font-weight: 500; }
.chart-seg button.active { background: var(--surface-2); color: var(--text); font-weight: 600; box-shadow: var(--sh-1); }

/* Mode breakdown */
.mode-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s3); }
.ms-card { padding: var(--s4) var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); }
.ms-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.ms-icon { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; color: var(--orange); background: var(--orange-soft); flex: 0 0 auto; }
.ms-card.kind-daily .ms-icon { color: var(--blue); background: var(--blue-soft); }
.ms-card.kind-multiplayer .ms-icon { color: var(--blue); background: var(--blue-soft); }
.ms-name { font-weight: 600; }
.ms-count { font-size: var(--fs-xs); color: var(--text-3); }
.ms-rows { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s4); margin: 0; }
.ms-rows div { display: flex; flex-direction: column; min-width: 0; }
.ms-rows dt { font-size: var(--fs-2xs); color: var(--text-3); }
.ms-rows dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Recent games */
.recent-table { width: 100%; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.recent-table table th { background: var(--surface-2); position: static; }
.recent-table td { vertical-align: middle; }
.rg-mode { display: flex; align-items: center; gap: var(--s3); font-weight: 600; }
.rg-mode .ic { color: var(--orange); }
.rg-sub { display: block; font-size: var(--fs-2xs); color: var(--text-3); font-weight: 500; }
.rg-result { font-size: var(--fs-xs); color: var(--text-2); }
.rg-result.win { color: var(--success); font-weight: 600; }
.rg-toggle { min-height: 32px !important; padding: 0 10px !important; font-size: var(--fs-xs) !important; }
.rg-detail td { background: var(--bg-raised); padding: var(--s3) var(--s4) var(--s4); }
.rg-rounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
.rg-round { padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-xs); }
.rg-round b { display: block; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.rg-round span { color: var(--text-3); }
.recent-cards { display: none; flex-direction: column; gap: var(--s2); }
.rg-card { padding: var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); }
.rg-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.rg-card-score { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.rg-card-meta { display: flex; flex-wrap: wrap; gap: 4px var(--s3); margin-top: var(--s2); font-size: var(--fs-xs); color: var(--text-3); }
.rg-card .rg-rounds { margin-top: var(--s3); }
.rg-more { margin-top: var(--s3); }

/* Records */
.records { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.record { display: flex; gap: var(--s4); align-items: center; padding: var(--s4) var(--s5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); }
.record-icon { width: 40px; height: 40px; flex: 0 0 auto; border-radius: var(--r-md); display: grid; place-items: center; color: var(--gold); background: rgba(255, 200, 61, 0.1); }
.record-label { font-size: var(--fs-xs); color: var(--text-3); }
.record-value { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.record-sub { font-size: var(--fs-2xs); color: var(--text-3); }

/* Achievements (not built yet) */
.ach-preview { display: flex; align-items: center; gap: var(--s5); padding: var(--s5) var(--s6); border-radius: var(--r-xl); border: 1px dashed var(--border-strong); color: var(--text-2); }
.ach-preview .empty-icon { margin: 0; }
.ach-preview p { font-size: var(--fs-sm); color: var(--text-3); }

.stats-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s8); padding-top: var(--s5); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }
.stats-foot .ic { color: var(--text-3); }
.stats-foot p { display: flex; align-items: center; gap: var(--s2); max-width: 70ch; }
.stats-skel { display: grid; gap: var(--s3); }
.stats-skel .skeleton { height: 96px; }
.player-avatar.is-account { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange); font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }

/* =====================================================================
   10b. Accounts (sign in popup + Account settings)
   ===================================================================== */
input[type=email] {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--inset); color: var(--text); font: inherit; font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:disabled { opacity: 0.6; cursor: default; }

/* Danger button (delete) */
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s5);
  border: 1px solid transparent; border-radius: var(--r-md); background: var(--danger); color: #1c0503;
  font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; white-space: nowrap;
}
.btn-danger:hover:not(:disabled) { background: #ff7a73; }

/* Header account icon: a user icon for guests, the player's initial once signed in */
.account-btn.signed-in { border-color: var(--orange-line); background: var(--orange-soft); color: var(--orange); }
.account-btn.signed-in:hover:not(:disabled) { background: rgba(255, 122, 47, 0.2); color: var(--orange-hover); border-color: var(--orange); }
.acct-initial { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; line-height: 1; }

/* Sign in / Create account popup */
.auth-card { position: relative; }
.auth-close { position: absolute; top: var(--s3); right: var(--s3); width: 34px; height: 34px; border-color: transparent; }
.auth-tabs { margin-top: var(--s5); }
.auth-tabs button { flex: 1 1 0; }
.auth-submit { width: 100%; margin-top: var(--s5); }
.auth-submit.loading { color: transparent; position: relative; }
.auth-submit.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--orange-ink); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.auth-foot { display: flex; justify-content: center; margin-top: var(--s4); }
.auth-foot .link-btn { font-size: var(--fs-xs); }
.auth-ok { margin-top: var(--s5); padding: var(--s5); border-radius: var(--r-lg); background: var(--success-soft); border: 1px solid rgba(60, 207, 127, 0.3); text-align: center; }
.auth-ok b { display: block; font-size: var(--fs-lg); }
.auth-ok p { margin-top: var(--s2); font-size: var(--fs-sm); }
.auth-ok p b { display: inline; font-size: inherit; color: var(--text); }
.auth-ok-icon { width: 40px; height: 40px; margin: 0 auto var(--s3); border-radius: 50%; display: grid; place-items: center; background: var(--success); color: #03150b; }
/* Settings (sound lives here instead of in the header) */
.settings-card { position: relative; }
.settings-card h3 { margin-bottom: var(--s4); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s4) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; }
.acct-grid .setting-row { margin-top: var(--s4); border-bottom: 0; padding-bottom: 0; }
.setting-text { display: flex; flex-direction: column; gap: 2px; }
.setting-text b { font-weight: 600; }
.setting-text span { font-size: var(--fs-sm); color: var(--text-3); }
.sound-switch {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 46px; height: 26px; margin: 0; border-radius: var(--r-full);
  background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: background 0.2s ease, border-color 0.2s ease;
}
.sound-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform 0.2s var(--ease-out), background 0.2s ease; }
.sound-switch:checked { background: var(--orange); border-color: var(--orange); }
.sound-switch:checked::after { transform: translateX(20px); background: #fff; }
.sound-switch:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.modal-icon.danger { background: var(--danger-soft); color: var(--danger); }

/* Account settings page */
.account-page { max-width: 760px; }
.account-head { display: flex; align-items: center; gap: var(--s5); }
.acct-avatar {
  width: 72px; height: 72px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: var(--orange-soft); border: 1px solid var(--orange-line); color: var(--orange);
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
}
.acct-kicker { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 2px; }
.account-head .page-title { overflow-wrap: anywhere; }
.account-head .page-sub { overflow-wrap: anywhere; }
.acct-grid { display: grid; gap: var(--s4); }
.acct-grid .panel-head { margin-bottom: 0; }
.acct-grid form > .field:first-of-type { margin-top: var(--s4); }
.acct-row { display: flex; align-items: center; justify-content: flex-end; gap: var(--s4); margin-top: var(--s5); }
.acct-msg { flex: 1; font-size: var(--fs-sm); color: var(--text-3); }
.acct-msg.good { color: var(--success); }
.acct-msg.bad { color: #ffb4a8; }
.acct-banner { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--blue-soft); border: 1px solid var(--blue-line); color: #cfe4ff; font-size: var(--fs-sm); }
.acct-inline { display: flex; align-items: center; justify-content: space-between; gap: var(--s5); }
.acct-inline h3 { margin-bottom: 4px; }
.acct-inline p { font-size: var(--fs-sm); max-width: 46ch; }
.acct-danger { border-color: rgba(255, 97, 89, 0.35); background: linear-gradient(0deg, rgba(255, 97, 89, 0.05), rgba(255, 97, 89, 0.05)), var(--surface); }
.acct-danger h3 { color: #ffb4a8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   11. Motion, sound toggle, polish
   ===================================================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeIn2 { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes popIn2 { 0% { transform: scale(0.85); opacity: 0; } 60% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }

/* ---- Springy hover "bulge" + press (mouse/trackpad only) ---- */
.btn, .btn-play, .btn-outline, .btn-blue, .btn-secondary, .btn-ghost, .icon-btn, .tab, .seg button, .quiz-opt,
.type-card, .day-tile, .mcard, .how-step, .nav-link, .pl-btn, #pinBtn, #mapToggle, .link-btn, .chart-seg button, .record, .stat-card {
  transition: transform 0.28s var(--spring), box-shadow 0.25s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled), .btn-blue:hover:not(:disabled), .btn-secondary:hover:not(:disabled), .btn-outline:hover:not(:disabled) { transform: scale(1.04); }
  .btn-play:hover:not(:disabled) { transform: scale(1.05); }
  .icon-btn:hover:not(:disabled), .pl-btn:hover { transform: scale(1.08); }
  .tab:hover:not(.active) { transform: translateY(-1px); }
  .seg button:hover:not(:disabled):not(.active) { transform: scale(1.04); }
  .quiz-opt:hover { transform: scale(1.03); box-shadow: var(--sh-2); }
  .type-card:hover:not(:disabled) { transform: scale(1.03); }
  .day-tile:hover:not(:disabled) { transform: scale(1.05); box-shadow: var(--sh-2); }
  .mcard.ready:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4); }
  .mcard.ready:hover .mc-icon { transform: rotate(-8deg) scale(1.12); }
  .how-step:hover b { transform: scale(1.12) rotate(-6deg); }
  .record:hover, .stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
  .link-btn:hover .ic { transform: translateX(-3px); }
}
.btn:active:not(:disabled), .btn-play:active:not(:disabled), .btn-outline:active:not(:disabled), .btn-blue:active:not(:disabled), .btn-secondary:active:not(:disabled),
.btn-ghost:active, .icon-btn:active:not(:disabled), .tab:active, .seg button:active:not(:disabled), .quiz-opt:active, .type-card:active:not(:disabled),
.day-tile:active:not(:disabled), .mcard.ready:active, .pl-btn:active, #pinBtn:active, #mapToggle:active {
  transform: scale(0.95) !important; transition-duration: 0.08s;
}
.mc-icon, .how-step b, .link-btn .ic { transition: transform 0.35s var(--spring); }

/* ---- Cursor spotlight on cards (subtle) ---- */
.mcard, .daily-band, .mp-band, .daily-card, .panel { position: relative; overflow: hidden; }
.mcard::after, .daily-band::after, .mp-band::after, .daily-card::after, .panel::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s ease;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 150, 70, 0.08), transparent 65%);
}
.daily-band::after, .mp-band::after { background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(77, 163, 255, 0.06), transparent 65%); }
.mcard.ready:hover::after, .daily-band:hover::after, .mp-band:hover::after, .daily-card:hover::after, .panel:hover::after { opacity: 1; }
.mcard > *, .daily-band > *, .mp-band > *, .daily-card > * { position: relative; z-index: 1; }

/* ---- Play Now: soft glow + shine ---- */
.btn-play { position: relative; overflow: hidden; }
.btn-play::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 60%; left: -80%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg); animation: shine 4.2s ease-in-out 1.2s infinite;
}
#playNow { animation: glow 3.2s ease-in-out infinite; }
@keyframes shine { 0%, 70% { left: -80%; } 100% { left: 130%; } }
@keyframes glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(255, 122, 47, 0.28); }
  50% { box-shadow: 0 10px 36px rgba(255, 122, 47, 0.45); }
}

/* ---- Logo spark twinkle ---- */
.nav-brand svg path { transition: transform 0.4s var(--spring); transform-origin: 49px 15px; animation: twinkle 4s ease-in-out infinite; }
.nav-brand:hover svg path { transform: rotate(90deg) scale(1.2); animation: none; }
@keyframes twinkle { 0%, 88%, 100% { transform: scale(1) rotate(0); } 94% { transform: scale(1.25) rotate(45deg); } }

/* ---- Entrances ---- */
.hero-copy > * { animation: fadeUp 0.7s var(--ease-out) both; }
.hero-copy > :nth-child(1) { animation-delay: 0.05s; }
.hero-copy > :nth-child(2) { animation-delay: 0.12s; }
.hero-copy > :nth-child(3) { animation-delay: 0.2s; }
.hero-copy > :nth-child(4) { animation-delay: 0.28s; }
.hero-copy > :nth-child(5) { animation-delay: 0.36s; }
.hero-globe { animation: fadeIn2 1.2s ease 0.1s both; }
.nav { animation: slideDown 0.5s var(--ease-out) both; }

.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out); }
.js .reveal.in { opacity: 1; transform: none; }
.how.reveal.in .how-step { animation: cardIn 0.6s var(--ease-out) backwards; }
.how.reveal.in .how-step:nth-child(2) { animation-delay: 0.1s; }
.how.reveal.in .how-step:nth-child(3) { animation-delay: 0.2s; }

.mcard { animation: cardIn 0.45s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 35ms); }
.day-tile { animation: cardIn 0.4s var(--ease-out) backwards; }
.stat-card, .ms-card, .record { animation: cardIn 0.45s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 30ms); }

.screen:not(.hidden) > .screen-inner > *, .screen:not(.hidden) > .page { animation: fadeUp 0.45s var(--ease-out) both; }
#homeScreen:not(.hidden) > main { animation: fadeIn2 0.35s ease both; }
#result:not(.hidden) #resultMap { animation: fadeIn2 0.4s ease both; }
#resultCard.rise, #mpResultCard.rise { animation: slideUp 0.5s var(--spring) both; }
#quizPanel:not(.hidden) { animation: quizIn 0.45s var(--spring) both; }
@keyframes quizIn { from { opacity: 0; transform: translate(-50%, 40px); } to { opacity: 1; transform: translate(-50%, 0); } }
#guessWrap:not(.hidden) { animation: fadeUp 0.4s var(--ease-out) both; }
#hud:not(.hidden), #mpHud:not(.hidden) { animation: slideDown 0.45s var(--ease-out) both; }
#loading:not(.hidden) { animation: fadeIn2 0.25s ease both; }
.modal:not(.hidden) .card, #quitModal:not(.hidden) .card { animation: popIn2 0.35s var(--spring) both; }
.room-code { animation: popIn2 0.6s var(--spring) both; }
.pl-row { animation: cardIn 0.35s var(--ease-out) backwards; }
.quiz-opt { animation: cardIn 0.35s var(--ease-out) backwards; }
.quiz-opt:nth-child(2) { animation-delay: 0.05s; } .quiz-opt:nth-child(3) { animation-delay: 0.1s; } .quiz-opt:nth-child(4) { animation-delay: 0.15s; }
.final-score, .mpf-trophy { animation: popIn2 0.7s var(--spring) both; animation-delay: 0.1s; }

.pin-drop { animation: pinDrop 0.45s var(--spring); }
@keyframes pinDrop { 0% { transform: translateY(-22px) scale(0.5); opacity: 0; } 70% { transform: translateY(2px) scale(1.15); opacity: 1; } 100% { transform: none; } }

#hudTimeStat.low .value, #mphTimeWrap.low b { animation: timerPulse 1s ease-in-out infinite; }
@keyframes timerPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---- Keyboard focus ---- */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

/* ---- Confetti ---- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; opacity: 0.95;
  animation: fall 2s cubic-bezier(0.25, 0.6, 0.4, 1) forwards;
}
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: 0.9; } }

/* ---- Scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.24); }

/* =====================================================================
   12. Tablets & phones
   ===================================================================== */
@media (max-width: 1024px) {
  .mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .daily-band { grid-template-columns: 1fr; }
  .db-side { padding-left: 0; padding-top: var(--s5); border-left: 0; border-top: 1px solid var(--border); flex-direction: row; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
  .db-actions .btn { flex: 0 0 auto; }
  .mp-band { grid-template-columns: 1fr; padding: var(--s7); }
  .about-grid { grid-template-columns: 1fr; gap: var(--s6); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .records { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-head { grid-template-columns: 1fr; }
  .player-card { min-width: 0; }
}

@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-menu-btn { display: inline-flex; }
  .hero-inner { grid-template-columns: 1fr; min-height: 0; padding-top: 0; padding-bottom: var(--s8); gap: 0; }
  .hero-globe { order: -1; justify-self: center; width: min(88vw, 460px); margin: calc(var(--s2) * -1) 0 calc(-1 * min(22vw, 110px)); }
  .hero-copy { max-width: none; }
  /* The copy overlaps the bottom of the globe; fade the globe out behind it */
  .hero-globe { -webkit-mask-image: linear-gradient(180deg, #000 45%, transparent 88%); mask-image: linear-gradient(180deg, #000 45%, transparent 88%); }
  .lobby-grid { grid-template-columns: 1fr; }
  .type-cards { grid-template-columns: 1fr; }
  .type-card { flex-direction: row; align-items: center; gap: 10px; }
  .tc-desc { margin-left: auto; text-align: right; max-width: 55%; }
  #mpResultCard { grid-template-columns: 1fr; }
  .recent-table { display: none; }
  .recent-cards { display: flex; }
}

@media (max-width: 700px) {
  .container { padding: 0 var(--s4); }
  .account-head { gap: var(--s4); }
  .acct-avatar { width: 56px; height: 56px; font-size: 1.6rem; }
  .acct-inline { flex-direction: column; align-items: stretch; }
  .acct-inline > button { width: 100%; }
  .acct-row { flex-wrap: wrap; }
  .acct-row .btn { flex: 1 0 auto; }
  .nav-inner { gap: var(--s3); }
  .nav-word { font-size: 1.25rem; }
  .card { padding: var(--s5); border-radius: var(--r-lg); }
  .page { padding: var(--s6) var(--s4) calc(var(--s8) + var(--safe-b)); }

  .hero-title { font-size: clamp(2.3rem, 10.5vw, 3rem); }
  .hero-sub { font-size: var(--fs-body); }
  .hero-cta { flex-direction: column; align-items: stretch; gap: var(--s2); margin-top: var(--s6); }
  .btn-play { width: 100%; }
  .hero-cta .btn-text { justify-content: center; }
  .hero-facts { margin-top: var(--s5); gap: var(--s2) var(--s3); font-size: var(--fs-xs); }
  .hero-facts li + li::before { margin-right: var(--s2); }

  .home-section { padding-top: var(--s9); }
  .daily-band { padding: var(--s5); }
  .db-title-row { gap: var(--s3); }
  .db-icon { width: 44px; height: 44px; font-size: 22px; }
  .db-side { flex-direction: column; align-items: stretch; }
  .db-actions > * { flex: 1; }
  .mgrid { grid-template-columns: 1fr; gap: var(--s2); }
  /* Compact rows on phones: icon · name + description · action */
  .mcard { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; column-gap: var(--s4); min-height: 0; padding: var(--s4); }
  .mc-top { display: contents; }
  .mc-tag, .mc-meta { display: none; }
  .mc-body { gap: 2px; }
  .mc-name { font-size: 1.1rem; }
  .mc-desc { font-size: var(--fs-xs); }
  .mc-foot { padding: 0; border: 0; }
  .mc-arrow { font-size: 0; gap: 0; }
  .mc-arrow .ic { width: 20px; height: 20px; }
  .soon-row { font-size: var(--fs-xs); }
  .mp-band { padding: var(--s5); gap: var(--s5); }
  .mp-actions > button { flex: 1; }
  .mp-actions .badge { order: -1; flex-basis: 100%; justify-content: center; }
  .progress-strip { padding: var(--s4); }
  .ps-stats { margin-left: 0; gap: var(--s5); }
  .about { padding-bottom: var(--s9); }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-links { justify-content: flex-start; }

  /* HUD: a slim bar across the top (still covering the embed's corner card) */
  #hud { right: 0; width: auto; min-height: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); border-width: 0 0 1px 0;
    padding: calc(8px + var(--safe-t)) 10px 8px 14px; flex-direction: row; align-items: center; gap: var(--s3); }
  .hud-top { order: 2; margin-left: auto; min-height: 0; }
  .hud-mode { display: none; }
  .hud-stats { gap: var(--s4); }
  .stat .label { font-size: 11px; }
  .stat .value { font-size: 1.2rem; }
  .hud-actions .icon-btn { width: 38px; height: 38px; }

  /* Map is a bottom sheet */
  #guessWrap {
    left: 0; right: 0; bottom: 0; width: 100% !important;
    padding: 10px 10px calc(10px + var(--safe-b)); gap: 10px;
    background: var(--surface); border-top: 1px solid var(--border-strong); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
  }
  #miniMap { display: none; height: 58dvh !important; opacity: 1 !important; border-radius: var(--r-md); }
  #guessWrap.open #miniMap { display: block; }
  #mapToggle { display: inline-flex; flex: 0 0 auto; padding: 0 16px; min-height: 48px; }
  #pinBtn { display: none; }
  #guessBtn, #riskBtn { min-height: 48px; padding: 0 10px; }

  #quizPanel { bottom: 0; width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--s3) var(--s3) calc(var(--s3) + var(--safe-b)); }
  .quiz-opt { min-height: 52px; }
  .flag-opt img { height: 44px; }
  #quizPanel.all-choices .quiz-options { grid-template-columns: 1fr 1fr; gap: 6px; max-height: 40dvh; }
  #quizPanel.all-choices .f1-name { font-size: var(--fs-xs); }

  #resultCard { gap: var(--s2) var(--s4); padding: var(--s4) var(--s4) calc(var(--s4) + var(--safe-b)); }
  .res-score { min-width: 0; width: 100%; display: flex; align-items: center; gap: var(--s4); }
  #resultCard .big { font-size: 2rem; }
  .res-score .bar { flex: 1; width: auto; margin-top: 0; }
  .res-legend span { white-space: nowrap; }
  .res-detail { font-size: var(--fs-body); }
  .res-actions { width: 100%; margin-left: 0; flex-direction: column-reverse; }
  #nextBtn { width: 100%; }
  #teachSummaryBtn { width: 100%; }

  .final-score { font-size: 2.8rem; }
  th, td { padding: 8px 8px; font-size: var(--fs-xs); }

  .daily-head { align-items: flex-start; }
  .daily-card { padding: var(--s5); }
  .dc-title { font-size: 1.45rem; }
  .dc-actions > * { flex: 1; }
  .day-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
  .day-tile { min-height: 100px; padding: 10px; }

  .lobby-head { padding: var(--s5); }
  .lobby-share { width: 100%; }
  .lobby-share > * { flex: 1; }
  .panel { padding: var(--s4); }
  .lobby-start { justify-content: stretch; }
  .lobby-start .btn-play { width: 100%; }
  .lobby-start .muted { width: 100%; text-align: center; }
  #mpHud { padding: calc(8px + var(--safe-t)) 10px 6px; min-height: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .mph-row { gap: 10px; }
  .mph-stat { min-width: 0; }
  .mph-stat b { font-size: 1.2rem; }
  .hp-top { font-size: var(--fs-2xs); }
  .hp-bar { height: 8px; }
  .hp-bars { gap: 8px; }
  .hp-vs { display: none; }
  .ffa-me b { font-size: 1.2rem; }
  .tc-desc { display: none; }
  .mpr-title { font-size: 1.35rem; }
  .mpr-row { grid-template-columns: 18px 10px 1fr auto; }
  .mpr-dist { display: none; }
  .mpr-foot .btn { flex: 1; }

  .coach-launcher { right: 12px; bottom: calc(86px + var(--safe-b)); padding: 0 14px; }
  .cl-text { display: none; }
  .coach-panel { left: 0; right: 0; bottom: 0; width: 100%; height: min(74dvh, 620px); border-radius: var(--r-xl) var(--r-xl) 0 0; border-left: 0; border-right: 0; border-bottom: 0; transform-origin: bottom center; }
  body:has(#result:not(.hidden)) .coach-panel { top: 0; bottom: auto; height: min(52dvh, 460px); border-radius: 0 0 var(--r-xl) var(--r-xl); border-top: 0; border-bottom: 1px solid var(--border-strong); }
  .coach-see span { display: none; }
  .coach-input textarea { font-size: 16px; }

  #clueGuide { top: calc(66px + var(--safe-t)); right: 10px; }
  .guide-pill { min-height: 38px; padding: 0 13px; font-size: var(--fs-xs); }
  body:has(#guideBody:not(.hidden)) #clueGuide { left: 8px; right: 8px; top: calc(62px + var(--safe-t)); }
  .guide-body, body:has(#coachPanel:not(.hidden)) .guide-body { width: 100%; max-height: min(60dvh, 520px); }

  .stats-section { margin-top: var(--s7); }
  .stat-grid { gap: var(--s2); }
  .stat-card { padding: var(--s3) var(--s4); }
  .stat-card.lead { padding: var(--s4); }
  .stat-card .sc-value { font-size: 1.3rem; }
  .stat-card.lead .sc-value { font-size: 1.6rem; }
  .records { grid-template-columns: 1fr; }
  .player-card { flex-wrap: wrap; padding: var(--s4); }
  .player-card .btn-outline { margin-left: 0; width: 100%; }
  .chart-wrap { height: 200px; }
  .ach-preview { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 380px) {
  .hud-stats { gap: var(--s3); }
  .hud-actions { gap: 4px; }
  .hud-actions .icon-btn { width: 34px; height: 34px; }
}

/* ---- Respect "reduce motion" ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
  #homeScreen { scroll-behavior: auto; }
}
