/* ============================================================
   VEXDLE — brutalist console × retro-futuristic HUD
   Dark cosmos base, neon graticule, hard-edged blocks,
   offset shadows, Space Grotesk display + IBM Plex Mono labels.
   ============================================================ */
:root {
  /* surfaces */
  --bg: #05070d;
  --bg-2: #080c16;
  --surface: #0d1322;
  --surface-2: #131b2e;
  --panel-line: #243049;
  --border: #2b3a57;

  /* ink / text */
  --text: #e9f1ff;
  --text-dim: #7e8db0;
  --ink: #04060c;

  /* neon accents */
  --accent: #36e0d0;          /* cyan (primary) */
  --accent-magenta: #ff4d9d;  /* magenta */
  --accent-2: #ffd23f;        /* signal yellow */
  --green: #34e07b;
  --red: #ff5470;

  /* globe */
  --globe-ocean: #070d1a;
  --globe-grid: rgba(54,224,208,.35);
  --globe-land: #1b2a4a;
  --globe-border: rgba(120,200,255,.55);
  --globe-edge: rgba(54,224,208,.8);
  --globe-correct: rgba(54,224,208,.5);

  --radius: 4px;
  --maxw: 580px;
  --shadow: 4px 4px 0 rgba(0,0,0,.55);
  --shadow-cyan: 4px 4px 0 rgba(54,224,208,.35);
  --shadow-mag: 4px 4px 0 rgba(255,77,157,.35);

  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  -webkit-text-size-adjust: 100%;
}

/* cosmic + graticule backdrop */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(54,224,208,.10), transparent 60%),
    radial-gradient(900px 600px at 90% 110%, rgba(255,77,157,.08), transparent 55%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(54,224,208,.04) 38px 39px),
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(54,224,208,.04) 38px 39px),
    var(--bg);
  background-attachment: fixed;
}

.hidden { display: none !important; }
a { color: var(--accent); }

/* ---------- Header ---------- */
.app-header {
  width: 100%;
  border-bottom: 2px solid var(--panel-line);
  background: linear-gradient(180deg, rgba(13,19,34,.95), rgba(8,12,22,.9));
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.logo {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.55rem; letter-spacing: .04em;
  text-transform: uppercase; line-height: 1;
}
/* Whole logo is a link back to the home screen. */
.logo-link {
  display: flex; align-items: center; gap: 8px;
  color: inherit; text-decoration: none; cursor: pointer;
}
.logo-link:hover .logo-word { color: var(--accent); }
/* Inline SVG brand mark (map pin + waving flag). Inline — not an <img> — so it
 * inherits nothing external and the wordmark stays real text in our webfonts. */
.logo-mark {
  height: 1.55em; width: auto; flex: none;
  filter: drop-shadow(0 0 10px rgba(54, 224, 208, .3));
}
/* "Vexdle" is ONE flex item (the gap only separates mark and word). */
.logo-word { transition: color .15s ease; }
.logo-accent {
  color: var(--accent);
  text-shadow: 0 0 16px rgba(54,224,208,.6);
}
.header-actions { display: flex; align-items: center; gap: 8px; }

.mode-switch {
  display: inline-flex;
  background: var(--bg-2);
  border: 2px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 2px;
}
.mode-btn {
  border: 0; background: transparent;
  color: var(--text-dim);
  padding: 7px 13px; border-radius: 2px;
  font-family: var(--font-mono); font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; cursor: pointer;
}
.mode-btn.active {
  background: var(--accent); color: var(--ink);
  box-shadow: 0 0 14px rgba(54,224,208,.4);
}

.filter-select {
  background: var(--bg-2); color: var(--text);
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  padding: 6px 8px; font-family: var(--font-mono); font-size: .8rem;
}
/* Language toggle: segmented control with a loud active state (the old
 * <select> was easy to miss). */
.lang-switch {
  display: inline-flex; background: var(--bg-2);
  border: 2px solid var(--panel-line); border-radius: var(--radius); padding: 2px;
}
.lang-btn {
  border: 0; background: transparent; color: var(--text-dim); cursor: pointer;
  padding: 6px 10px; border-radius: 2px;
  font-family: var(--font-mono); font-size: .78rem; font-weight: 700; letter-spacing: .04em;
}
.lang-btn.active { background: var(--accent); color: #041318; }
.lang-btn:not(.active):hover { color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; display: block; margin: 0 auto; }
.icon-btn:hover svg { color: var(--accent); }
.icon-btn {
  background: var(--bg-2); border: 2px solid var(--panel-line);
  border-radius: var(--radius); width: 36px; height: 36px;
  font-size: 1rem; cursor: pointer; color: var(--text);
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- Main ---------- */
.app-main { width: 100%; max-width: var(--maxw); padding: 16px 14px; flex: 1; }

.academy-bar { margin-bottom: 14px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-row label {
  font-family: var(--font-mono); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim);
}

/* ---------- Hero flag ---------- */
/* Column layout: the rotation note renders BELOW the canvas instead of
 * squeezed beside it (it was getting clipped on narrow screens). */
.flag-panel { display: flex; flex-direction: column; align-items: center; margin: 6px 0 16px; }
.main-flag {
  width: 100%; max-width: 340px;
  border: 3px solid var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-cyan);
  background: var(--surface-2);
  position: relative;
  image-rendering: auto;
}

/* ---------- Optional hint chips ---------- */
.hints-bar { margin-bottom: 14px; min-height: 20px; }
.hints-locked {
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--text-dim); text-align: center;
  letter-spacing: .03em; padding: 6px 0;
}
.hints-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center; }
.hints-title {
  width: 100%; text-align: center;
  font-family: var(--font-mono); font-size: .68rem;
  text-transform: uppercase; letter-spacing: .14em; color: var(--accent);
  margin-bottom: 4px;
}
.hint-chip {
  background: var(--surface); color: var(--text);
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  padding: 8px 14px;
  font-family: var(--font-mono); font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
  cursor: pointer; transition: transform .08s, box-shadow .08s, border-color .12s;
}
.hint-chip:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translate(-1px,-1px); }
.hint-chip:active { transform: translate(2px,2px); box-shadow: none; }
.hint-chip.revealed {
  background: rgba(54,224,208,.14); border-color: var(--accent); color: var(--accent);
  cursor: default; box-shadow: none; transform: none;
}

/* ---------- Clue cards ---------- */
.clue-stage { margin-bottom: 14px; }
.clue-card {
  background: var(--surface);
  border: 2px solid var(--panel-line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }
.clue-title {
  font-family: var(--font-mono); font-size: .68rem;
  text-transform: uppercase; letter-spacing: .14em; color: var(--accent);
  margin-bottom: 6px; font-weight: 600;
}
.clue-body { font-size: .95rem; line-height: 1.45; }

/* ---------- Guess area ---------- */
.guess-area { display: flex; gap: 8px; margin-bottom: 10px; }
.search-wrap { position: relative; flex: 1; }
.guess-input {
  width: 100%; background: var(--bg-2); color: var(--text);
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  padding: 13px 14px; font-family: var(--font-display); font-size: 1rem;
}
.guess-input::placeholder { color: var(--text-dim); }
.guess-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-cyan); }

.btn-primary {
  background: var(--accent); color: var(--ink);
  border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 0 20px; font-family: var(--font-display); font-weight: 700;
  font-size: .9rem; text-transform: uppercase; letter-spacing: .04em;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s;
}
.btn-primary:hover:not(:disabled) { transform: translate(-1px,-1px); box-shadow: 6px 6px 0 rgba(0,0,0,.55); }
.btn-primary:active:not(:disabled) { transform: translate(2px,2px); box-shadow: none; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  background: var(--surface-2); color: var(--text);
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  padding: 9px 14px; font-family: var(--font-mono); font-weight: 600;
  font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); }

/* ---------- Autocomplete ---------- */
.autocomplete {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); list-style: none;
  max-height: 250px; overflow-y: auto; z-index: 30;
  box-shadow: var(--shadow);
}
.autocomplete li {
  padding: 11px 14px; cursor: pointer; font-size: .95rem;
  border-bottom: 1px solid var(--panel-line);
}
.autocomplete li:last-child { border-bottom: 0; }
.autocomplete li.active, .autocomplete li:hover { background: var(--surface-2); color: var(--accent); }

/* Invalid input feedback (country not found / already guessed). */
.search-wrap.shake { animation: input-shake .4s ease; }
@keyframes input-shake {
  10%, 90% { transform: translateX(-2px); }
  25%, 75% { transform: translateX(5px); }
  40%, 60% { transform: translateX(-7px); }
  50%      { transform: translateX(7px); }
}

.attempts-line {
  color: var(--text-dim); font-family: var(--font-mono);
  font-size: .8rem; letter-spacing: .03em; margin-bottom: 12px;
}

/* ---------- Proximity grid ---------- */
.grid-head, .guess-grid li {
  display: grid; grid-template-columns: 1.5fr 1fr .95fr .6fr;
  gap: 6px; align-items: center;
}
.grid-head {
  font-family: var(--font-mono); font-size: .64rem;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-dim); padding: 0 10px 6px;
}
.guess-grid { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.guess-grid li {
  background: var(--surface); border: 2px solid var(--panel-line);
  border-radius: var(--radius); padding: 11px 10px; font-size: .85rem;
}
/* Only the NEWEST row animates (old rows used to re-pop on every re-render). */
.guess-grid li.row-in {
  animation: row-flip-in .45s cubic-bezier(.2, .85, .3, 1.1) both;
  transform-origin: 50% 0;
}
@keyframes row-flip-in {
  from { opacity: 0; transform: perspective(600px) rotateX(-55deg); }
  to   { opacity: 1; transform: none; }
}
.guess-grid li.row-win {
  border-color: var(--green);
}
.guess-grid li.row-in.row-win {
  animation: row-flip-in .45s cubic-bezier(.2, .85, .3, 1.1) both,
             row-win-pop .55s ease .45s;
}
@keyframes row-win-pop {
  0% { transform: scale(1); box-shadow: none; }
  40% { transform: scale(1.03); box-shadow: 0 0 18px rgba(52, 224, 123, .35); }
  100% { transform: scale(1); box-shadow: 0 0 10px rgba(52, 224, 123, .18); }
}
.cell { text-align: center; }
.cell.country { display: flex; align-items: center; gap: 7px; text-align: left; font-weight: 600; }
/* contain, not cover: Nepal (non-rectangular) and the square flags
 * (Switzerland, Vatican) must not be cropped in the guess grid. */
.cell.country .g-flag { width: 22px; height: 15px; object-fit: contain; border-radius: 2px; flex: none; }
.cell.continent {
  border-radius: 2px; padding: 4px 2px; font-weight: 600;
  font-family: var(--font-mono); font-size: .76rem;
}
.cell.continent.correct { background: rgba(52,224,123,.18); color: var(--green); }
.cell.continent.wrong { background: rgba(255,84,112,.12); color: var(--red); }
.cell.distance { font-family: var(--font-mono); }
/* Distance colored by proximity: --p is 0 (far, red) .. 1 (close, green),
 * set inline by renderGrid(). Hue 8 (red) -> 120 (green). */
.cell.distance.scored {
  border-radius: 2px; padding: 4px 2px; font-weight: 600;
  color: hsl(calc(8 + var(--p, 0) * 112), 78%, 64%);
  background: hsla(calc(8 + var(--p, 0) * 112), 70%, 45%, .13);
}
.cell.direction { font-size: 1.15rem; }

/* Breathing room between the result button and the grid header below it. */
.result-btn { margin-bottom: 18px; }

/* ---------- Daily bar (archive) ---------- */
.daily-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.archive-btn {
  background: var(--surface); border: 1px solid var(--panel-line);
  color: var(--text-dim); border-radius: var(--radius);
  padding: 7px 12px; cursor: pointer;
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: .04em;
}
.archive-btn:hover { color: var(--accent); border-color: var(--accent); }
.archive-playing {
  color: var(--accent); font-family: var(--font-mono);
  font-size: .74rem; letter-spacing: .04em;
}
.streak-badge {
  color: #ffb347; font-family: var(--font-mono); font-weight: 700;
  font-size: .78rem; letter-spacing: .04em;
  background: rgba(255, 179, 71, .1); border: 1px solid rgba(255, 179, 71, .35);
  border-radius: var(--radius); padding: 5px 9px;
}

/* Capital-mode stimulus: the capital name IS the puzzle. */
.capital-stimulus {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 34px 20px; margin: 0 auto;
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  background: var(--surface); min-width: min(340px, 90%);
  box-shadow: var(--shadow-cyan);
}
.capital-stimulus.hidden { display: none; }
.capital-label {
  font-family: var(--font-mono); font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em; color: var(--text-dim);
}
.capital-name {
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  letter-spacing: .02em; color: var(--accent);
  text-shadow: 0 0 18px rgba(54, 224, 208, .35);
  text-align: center;
}

/* Vexillology-mode stimulus: the flag DESCRIPTION is the puzzle. */
.flagdesc-body { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 400px; }
.fd-row {
  display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; align-items: center;
  text-align: left; font-size: .9rem;
}
.fd-k {
  font-family: var(--font-mono); font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim);
}
.fd-v { color: var(--text); }
.swatch {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.35); margin-right: 3px; vertical-align: -2px;
}

.next-inline {
  margin-left: auto; color: var(--text-dim);
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em;
}
.next-inline .countdown { color: var(--accent); font-weight: 600; }
@media (max-width: 480px) {
  .daily-bar { flex-wrap: wrap; }
  .next-inline { margin-left: 0; width: 100%; }
}
.archive-list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.archive-row {
  display: grid; grid-template-columns: 4.5em 1fr 1.5em; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--panel-line);
  border-radius: var(--radius); padding: 9px 12px; cursor: pointer;
  color: inherit; font-family: var(--font-mono); font-size: .8rem; text-align: left;
}
.archive-row:hover { border-color: var(--accent); color: var(--accent); }
.archive-mark.ok { color: var(--green); }
.archive-mark.bad { color: var(--red); }

/* ---------- Hard mode toggle ---------- */
.hard-btn {
  background: var(--surface); border: 1px solid var(--panel-line);
  color: var(--text-dim); border-radius: var(--radius);
  padding: 7px 12px; cursor: pointer;
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: .04em;
}
.hard-btn.active { border-color: var(--red); color: var(--red); background: rgba(255,84,112,.08); }

/* ---------- Shape rotation note ---------- */
.shape-note {
  margin-top: 8px; color: var(--text-dim);
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .04em;
  text-align: center; max-width: 100%; padding: 0 12px;
  overflow-wrap: break-word;
}
.shape-note.hidden { display: none; }

/* ---------- Ko-fi support link ---------- */
.foot-donate { color: #72a4f2; }
.foot-donate:hover { color: #9dc0f7; }

/* ---------- Stats modal: mode tabs ---------- */
.stats-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px;
}
.stats-tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 2px solid var(--panel-line);
  border-radius: var(--radius); padding: 6px 10px; cursor: pointer;
  color: var(--text-dim); font-family: var(--font-mono);
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
}
.stats-tab svg { width: 17px; height: 17px; display: block; }
.stats-tab:hover { color: var(--text); border-color: var(--accent); }
.stats-tab.active { color: var(--accent); border-color: var(--accent); background: rgba(54,224,208,.08); }
@media (max-width: 480px) {
  .stats-tab-label { display: none; }        /* icons only on small screens */
  .stats-tab { padding: 8px 10px; }
}

/* ---------- Result modal extras ---------- */
.next-daily {
  margin: 12px 0 8px; color: var(--text-dim);
  font-family: var(--font-mono); font-size: .8rem; letter-spacing: .04em;
}
.next-daily .countdown { color: var(--accent); font-weight: 600; }
.other-mode-btn { display: block; width: 100%; margin-top: 8px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,4,9,.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px; backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto;
  padding: 22px; box-shadow: var(--shadow-cyan);
  animation: pop .2s ease;
}
.modal h2 { font-family: var(--font-display); font-size: 1.5rem; text-transform: uppercase; letter-spacing: .02em; margin-bottom: 6px; }
.modal h3 {
  font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--accent); margin: 16px 0 6px;
}
.modal p { font-size: .92rem; line-height: 1.5; margin-bottom: 8px; }
.modal .close-x { float: right; background: none; border: 0; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal .close-x:hover { color: var(--accent); }
.result-flag {
  display: block; max-width: 200px; margin: 10px auto;
  border: 3px solid var(--text); border-radius: var(--radius); box-shadow: var(--shadow);
}
.globe-cta {
  width: 100%; margin: 6px 0 4px; background: var(--accent-magenta);
  color: var(--ink); border-color: var(--ink); box-shadow: var(--shadow-mag);
  font-family: var(--font-display); font-weight: 700; padding: 12px;
}
.globe-cta:disabled { opacity: 1; background: var(--surface-2); color: var(--accent-2); box-shadow: none; border-color: var(--panel-line); }
.globe-cta.locate-ok:disabled { background: rgba(52,224,123,.18); color: var(--green); border-color: var(--green); }
.globe-cta.locate-bad:disabled { background: rgba(255,84,112,.16); color: var(--red); border-color: var(--red); }

.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 4px; }
.fact-grid .fact { background: var(--bg-2); border: 1px solid var(--panel-line); border-radius: 2px; padding: 9px 11px; }
.fact-grid .fact .k { font-family: var(--font-mono); font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); }
.fact-grid .fact .v { font-size: .95rem; font-weight: 600; }
.pop-source { font-family: var(--font-mono); font-size: .68rem; color: var(--text-dim); margin: 2px 0 6px; }

.facts-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.facts-list li {
  position: relative; padding-left: 18px; font-size: .92rem; line-height: 1.45;
}
.facts-list li::before { content: "›"; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }

.share-block {
  background: var(--bg-2); border: 2px solid var(--panel-line);
  border-radius: var(--radius); padding: 12px; font-family: var(--font-mono);
  font-size: 1rem; white-space: pre-wrap; text-align: center; margin: 10px 0; line-height: 1.3;
}
.stat-row { display: flex; justify-content: space-around; text-align: center; margin: 14px 0; }
.stat-row .stat .num { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--accent); }
.stat-row .stat .lbl { font-family: var(--font-mono); font-size: .62rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }
.modal .btn-primary, .modal .btn-secondary { width: 100%; padding: 13px; margin-top: 6px; }

/* ---------- Globe overlay ---------- */
.globe-overlay {
  position: fixed; inset: 0; z-index: 60;
  background:
    radial-gradient(800px 600px at 50% 0%, rgba(54,224,208,.10), transparent 60%),
    rgba(2,4,9,.94);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.globe-card {
  width: 100%; max-width: 640px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-cyan);
  max-height: 96vh;
}
.globe-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.globe-title { font-family: var(--font-display); font-size: 1.3rem; text-transform: uppercase; letter-spacing: .02em; }
.globe-toggle {
  background: var(--bg-2); color: var(--accent); border: 2px solid var(--panel-line);
  border-radius: var(--radius); padding: 7px 12px; cursor: pointer;
  font-family: var(--font-mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
}
.globe-toggle:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.globe-instr { font-family: var(--font-mono); font-size: .76rem; color: var(--text-dim); margin-bottom: 10px; line-height: 1.4; }
.globe-stage { position: relative; display: flex; justify-content: center; min-height: 240px; }
.globe-gl-host { display: flex; justify-content: center; align-items: center; }
.globe-gl-host canvas { display: block; touch-action: none; }
.globe-canvas { touch-action: none; cursor: grab; background: transparent; }
.globe-canvas:active { cursor: grabbing; }
.globe-zoom {
  position: absolute; right: 6px; bottom: 6px;
  display: flex; flex-direction: column; gap: 6px;
}
.globe-zoom button {
  width: 38px; height: 38px;
  background: rgba(8,12,22,.85); color: var(--text);
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  cursor: pointer; line-height: 1;
}
.globe-zoom button:hover { border-color: var(--accent); color: var(--accent); }
.globe-zoom button:active { transform: translate(1px,1px); }
.globe-status {
  min-height: 40px; text-align: center; margin: 12px 0;
  font-family: var(--font-mono); font-size: .95rem;
}
.globe-status strong { color: var(--accent); font-size: 1.15rem; }
.globe-status strong.ok { color: var(--green); }
.globe-status strong.bad { color: var(--red); }
.globe-status .legend { display: block; margin-top: 6px; font-size: .72rem; color: var(--text-dim); }
.globe-status .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 4px 0 12px; vertical-align: middle; border: 1px solid #fff; }
.globe-status .dot.mag { background: var(--accent-magenta); }
.globe-status .dot.acc { background: var(--accent); }
.globe-action { width: 100%; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--ink);
  border: 2px solid var(--ink); padding: 10px 18px; border-radius: var(--radius);
  font-family: var(--font-mono); font-weight: 600; font-size: .85rem;
  z-index: 70; box-shadow: var(--shadow); animation: pop .15s ease;
}

@media (max-width: 480px) {
  .logo { font-size: 1.3rem; }
  .mode-btn { padding: 6px 9px; font-size: .72rem; }
  .grid-head, .guess-grid li { font-size: .78rem; }
  .header-actions { gap: 6px; }
  .header-inner { padding: 10px 10px; }
  .lang-btn { padding: 6px 8px; font-size: .72rem; }
  .icon-btn { width: 32px; height: 32px; }
  .archive-btn, .hard-btn { padding: 6px 9px; font-size: .68rem; }
  .main-flag { max-width: 100%; }
  .cell.direction { font-size: 1rem; }
  .modal { max-height: 86vh; }
}

/* ---------- Footer (in-game) ---------- */
.app-footer {
  width: 100%; max-width: var(--maxw);
  margin: 4px auto 24px; padding: 0 14px;
  display: flex; gap: 10px; align-items: center; justify-content: center;
}
.foot-link {
  font-family: var(--font-mono); font-size: .7rem;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-dim); text-decoration: none;
  padding: 7px 14px; border: 1px solid var(--panel-line); border-radius: 999px;
  transition: color .15s, border-color .15s, background .15s;
}
.foot-link:hover { color: var(--accent); border-color: var(--accent); background: rgba(54,224,208,.08); }

/* ---------- Doc pages (privacy / credits) ---------- */
.doc-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px;
  border-bottom: 2px solid var(--panel-line);
  background: linear-gradient(180deg, rgba(13,19,34,.96), rgba(8,12,22,.92));
  backdrop-filter: blur(6px);
}
.doc-logo {
  font-family: var(--font-display); font-weight: 700; font-size: 1.35rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
}
.doc-logo:hover .logo-word { color: var(--accent); }
.doc-actions { display: flex; align-items: center; gap: 10px; }
.doc-langs { display: inline-flex; background: var(--bg-2); border: 2px solid var(--panel-line); border-radius: var(--radius); padding: 2px; }
.doc-langs button {
  border: 0; background: transparent; color: var(--text-dim); cursor: pointer;
  padding: 6px 12px; border-radius: 2px;
  font-family: var(--font-mono); font-size: .74rem; font-weight: 600; letter-spacing: .04em;
}
.doc-langs button.active { background: var(--accent); color: var(--ink); }
.doc-back { font-family: var(--font-mono); font-size: .74rem; color: var(--text-dim); text-decoration: none; white-space: nowrap; }
.doc-back:hover { color: var(--accent); }

.doc-page { max-width: 760px; margin: 0 auto; padding: 30px 20px 72px; }
.doc-kicker { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .18em; color: var(--accent); margin-bottom: 8px; }
.doc-page h1 { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.12; letter-spacing: -.01em; margin-bottom: 12px; }
.doc-lead { font-size: 1.08rem; line-height: 1.55; color: var(--text); margin-bottom: 8px; }
.doc-meta { font-family: var(--font-mono); font-size: .72rem; color: var(--text-dim); margin-bottom: 22px; }
.doc-card {
  background: var(--surface); border: 2px solid var(--panel-line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
}
.doc-card h2 { font-family: var(--font-mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); margin-bottom: 8px; }
.doc-card p { font-size: .95rem; line-height: 1.6; margin-bottom: 8px; }
.doc-card p:last-child { margin-bottom: 0; }
.doc-card ul { list-style: none; margin: 8px 0; }
.doc-card li { position: relative; padding-left: 18px; font-size: .95rem; line-height: 1.5; margin-bottom: 5px; }
.doc-card li::before { content: "\203A"; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }
.doc-contact { font-family: var(--font-mono); font-size: .85rem; color: var(--text-dim); }
.doc-placeholder { color: var(--accent-2); }
.credit-list { display: flex; flex-direction: column; gap: 12px; }
.credit-list > div { display: flex; flex-direction: column; gap: 2px; }
.credit-list dt { font-family: var(--font-display); font-weight: 700; font-size: .98rem; }
.credit-list dd { font-family: var(--font-mono); font-size: .8rem; color: var(--text-dim); }

/* ---------- Action row (skip / give up) ---------- */
.action-row { display: flex; gap: 10px; justify-content: center; margin: -2px 0 14px; }
.action-row button {
  flex: 1; max-width: 180px; padding: 9px 12px; cursor: pointer;
  font-family: var(--font-mono); font-size: .76rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  border: 2px solid var(--panel-line); border-radius: var(--radius);
  transition: transform .08s, box-shadow .08s, border-color .12s, background .12s;
}
.skip-btn { background: var(--surface); color: var(--text-dim); }
.skip-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow); transform: translate(-1px,-1px); }
.skip-btn:active { transform: translate(2px,2px); box-shadow: none; }
.giveup-btn { background: rgba(255,84,112,.10); color: var(--red); border-color: rgba(255,84,112,.55); }
.giveup-btn:hover { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 4px 4px 0 rgba(255,84,112,.3); transform: translate(-1px,-1px); }
.giveup-btn:active { transform: translate(2px,2px); box-shadow: none; }

/* skipped row in the guess grid */
.guess-grid li.skip-row {
  display: block; text-align: center; color: var(--text-dim);
  font-family: var(--font-mono); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  border-style: dashed;
}


/* ---------- Attempt distribution chart ---------- */
.dist-title { font-family: var(--font-mono); font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); margin: 12px 0 6px; }
.dist-chart { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.dist-row { display: flex; align-items: center; gap: 8px; }
.dist-row .dist-n { font-family: var(--font-mono); font-size: .72rem; color: var(--text-dim); width: 12px; text-align: center; }
.dist-bar {
  background: var(--accent); color: var(--ink);
  font-family: var(--font-mono); font-size: .72rem; font-weight: 600;
  text-align: right; padding: 2px 6px; border-radius: 2px; min-width: 8px; box-sizing: border-box;
}


/* ---- Accessibility ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn:focus-visible, .mode-btn:focus-visible, .hint-chip:focus-visible { outline-offset: 1px; }
.autocomplete li[aria-selected="true"] { background: var(--surface-2); color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

.foot-donate { color: var(--accent); font-weight: 600; }
.foot-donate:hover { text-decoration: underline; }

/* ---- Home menu + mode cards ---- */
.home-screen { max-width: 720px; margin: 0 auto; padding: 8vh 18px 40px; text-align: center; }
/* Indexable "about" copy on the home screen (SEO + first-time visitors). */
.home-about { margin-top: 48px; text-align: left; color: var(--text-dim); }
.home-about h2 {
  font-family: var(--font-mono); font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; color: var(--accent);
  margin-bottom: 10px;
}
.home-about p { font-size: .92rem; line-height: 1.65; margin-bottom: 12px; }
.home-title { font-family: var(--font-display, var(--font-mono)); font-size: 1.4rem; letter-spacing: .04em; margin: 0 0 22px; }
/* 2x2 on desktop (4 modes), single column on phones. */
.mode-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 480px) { .mode-cards { grid-template-columns: 1fr; } }
.mode-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: inherit; cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s; }
.mode-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-cyan, 0 0 0 1px var(--accent)); }
.mode-card-icon svg { width: 34px; height: 34px; display: block; }
.mode-card:hover .mode-card-icon svg { transform: scale(1.08); transition: transform .15s ease; }
.other-mode-btn svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 4px; }

/* Gentle entrance when switching between home and game screens
 * (display:none -> block restarts the animation). */
.app-main, .home-screen {
  animation: screen-in .22s ease;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Visible keyboard focus, in brand color. */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.mode-card-icon { font-size: 1.8rem; }
.mode-card-name { font-family: var(--font-mono); font-weight: 600; font-size: 1.05rem; }
.mode-card-tag { font-size: .82rem; opacity: .72; }

/* ---- Shape (silhouette) stimulus ---- */
.shape-canvas { display: block; margin: 0 auto; }
.shape-canvas.hidden, .main-flag.hidden { display: none; }

/* ---- Stats: per-mode sub-labels ---- */
.stat-sub { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .6; margin: 10px 0 4px; }
