/* ==========================================================================
   GlobeHunt — local-first country guessing game
   ========================================================================== */

:root {
  --font-sans: "Avenir Next", "Avenir", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Roboto Mono", ui-monospace, monospace;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --topbar-h: 78px;
  --maxw: 1600px;
  --transition: 160ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050c16;
  --panel: rgba(11, 23, 39, 0.72);
  --panel-solid: #0b1828;
  --panel-2: rgba(148, 163, 184, 0.08);
  --panel-3: rgba(148, 163, 184, 0.14);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #eef6ff;
  --text-strong: #ffffff;
  --muted: #93a7bd;
  --muted-2: #64748b;
  --accent: #22d3ee;
  --accent-strong: #67e8f9;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-border: rgba(34, 211, 238, 0.3);
  --accent-contrast: #042f2e;
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --success-border: rgba(74, 222, 128, 0.32);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
  --input-bg: rgba(2, 8, 20, 0.48);
  --toggle-bg: rgba(148, 163, 184, 0.18);
  --scrollbar: rgba(148, 163, 184, 0.24);
  --page-gradient:
    radial-gradient(1100px 700px at 8% -8%, rgba(14, 116, 144, 0.28), transparent 60%),
    radial-gradient(900px 700px at 96% 104%, rgba(88, 28, 135, 0.2), transparent 58%),
    linear-gradient(180deg, #06101c 0%, #050c16 45%, #030812 100%);
  --stage-bg:
    radial-gradient(700px 520px at 50% 38%, rgba(34, 211, 238, 0.09), transparent 68%),
    radial-gradient(500px 420px at 12% 8%, rgba(59, 130, 246, 0.12), transparent 62%),
    linear-gradient(155deg, #0a1a2c 0%, #06101d 56%, #030913 100%);
  --stage-border: rgba(148, 163, 184, 0.17);
  --stage-shadow: 0 30px 90px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --stars-opacity: 0.72;
  --modal-backdrop: rgba(2, 6, 23, 0.68);
  --pin-bg: rgba(8, 20, 35, 0.94);
  --pin-border: rgba(148, 163, 184, 0.28);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef6fb;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --panel-2: rgba(15, 23, 42, 0.045);
  --panel-3: rgba(15, 23, 42, 0.08);
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.17);
  --text: #0f172a;
  --text-strong: #020617;
  --muted: #5f7189;
  --muted-2: #94a3b8;
  --accent: #0891b2;
  --accent-strong: #0e7490;
  --accent-soft: rgba(8, 145, 178, 0.1);
  --accent-border: rgba(8, 145, 178, 0.26);
  --accent-contrast: #ecfeff;
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.1);
  --success-border: rgba(21, 128, 61, 0.26);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --shadow: 0 22px 55px rgba(15, 23, 42, 0.1);
  --input-bg: rgba(255, 255, 255, 0.86);
  --toggle-bg: rgba(15, 23, 42, 0.14);
  --scrollbar: rgba(15, 23, 42, 0.2);
  --page-gradient:
    radial-gradient(1000px 680px at 6% -10%, rgba(125, 211, 252, 0.5), transparent 62%),
    radial-gradient(900px 680px at 98% 104%, rgba(253, 230, 138, 0.42), transparent 58%),
    linear-gradient(180deg, #f5fbff 0%, #eef6fb 52%, #e7f2fa 100%);
  --stage-bg:
    radial-gradient(700px 520px at 50% 38%, rgba(14, 165, 233, 0.16), transparent 68%),
    radial-gradient(520px 420px at 10% 6%, rgba(125, 211, 252, 0.4), transparent 65%),
    linear-gradient(155deg, #e3f4ff 0%, #f0f9ff 56%, #dbeafe 100%);
  --stage-border: rgba(2, 132, 199, 0.16);
  --stage-shadow: 0 26px 70px rgba(14, 116, 144, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --stars-opacity: 0;
  --modal-backdrop: rgba(15, 23, 42, 0.38);
  --pin-bg: rgba(255, 255, 255, 0.96);
  --pin-border: rgba(15, 23, 42, 0.14);
}

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

html {
  min-height: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--page-gradient);
  pointer-events: none;
}

.page-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: var(--stars-opacity);
  background-image:
    radial-gradient(1.2px 1.2px at 9% 17%, rgba(255, 255, 255, 0.9), transparent 100%),
    radial-gradient(1px 1px at 18% 64%, rgba(255, 255, 255, 0.55), transparent 100%),
    radial-gradient(1.4px 1.4px at 27% 8%, rgba(255, 255, 255, 0.7), transparent 100%),
    radial-gradient(1px 1px at 34% 88%, rgba(255, 255, 255, 0.45), transparent 100%),
    radial-gradient(1.1px 1.1px at 43% 32%, rgba(255, 255, 255, 0.75), transparent 100%),
    radial-gradient(1px 1px at 52% 72%, rgba(255, 255, 255, 0.5), transparent 100%),
    radial-gradient(1.3px 1.3px at 61% 12%, rgba(255, 255, 255, 0.6), transparent 100%),
    radial-gradient(1px 1px at 68% 54%, rgba(255, 255, 255, 0.4), transparent 100%),
    radial-gradient(1.2px 1.2px at 76% 82%, rgba(255, 255, 255, 0.55), transparent 100%),
    radial-gradient(1px 1px at 84% 24%, rgba(255, 255, 255, 0.7), transparent 100%),
    radial-gradient(1.3px 1.3px at 92% 68%, rgba(255, 255, 255, 0.5), transparent 100%),
    radial-gradient(1px 1px at 97% 10%, rgba(255, 255, 255, 0.65), transparent 100%);
  animation: twinkle 9s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: calc(var(--stars-opacity) * 0.55); }
  to { opacity: var(--stars-opacity); }
}

/* ==========================================================================
   Header
   ========================================================================== */

.topbar {
  width: 100%;
  max-width: var(--maxw);
  height: var(--topbar-h);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 60;
}

.topbar::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  border-radius: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 6px 14px rgba(249, 115, 22, 0.28));
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-text {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.045em;
  color: var(--text-strong);
  white-space: nowrap;
}

.brand-text span {
  color: var(--accent);
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.mode-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  position: relative;
  white-space: nowrap;
}

.mode-tab .icon {
  width: 16px;
  height: 16px;
}

.mode-tab:hover {
  color: var(--text);
  background: var(--panel-2);
}

.mode-tab[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 5px 16px color-mix(in srgb, var(--accent) 30%, transparent);
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent);
  flex-shrink: 0;
}

.tab-dot.is-lost {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}

.icon-btn:hover {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.layout {
  width: 100%;
  max-width: var(--maxw);
  height: calc(100dvh - var(--topbar-h));
  min-height: 640px;
  margin: 0 auto;
  padding: 0 24px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 412px);
  gap: 20px;
}

/* ==========================================================================
   Globe stage
   ========================================================================== */

.globe-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border-radius: 30px;
  border: 1px solid var(--stage-border);
  background: var(--stage-bg);
  box-shadow: var(--stage-shadow);
  overflow: hidden;
  isolation: isolate;
}

.globe-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--stars-opacity);
  background-image:
    radial-gradient(1px 1px at 14% 22%, rgba(255, 255, 255, 0.65), transparent 100%),
    radial-gradient(1.2px 1.2px at 72% 15%, rgba(255, 255, 255, 0.55), transparent 100%),
    radial-gradient(1px 1px at 86% 44%, rgba(255, 255, 255, 0.45), transparent 100%),
    radial-gradient(1.3px 1.3px at 24% 78%, rgba(255, 255, 255, 0.5), transparent 100%),
    radial-gradient(1px 1px at 63% 88%, rgba(255, 255, 255, 0.4), transparent 100%),
    radial-gradient(1.1px 1.1px at 44% 12%, rgba(255, 255, 255, 0.55), transparent 100%);
}

.globe-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 44%, transparent 42%, rgba(2, 8, 20, 0.16) 78%, rgba(2, 8, 20, 0.42) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 16%, transparent 84%, rgba(0, 0, 0, 0.14));
}

html[data-theme="light"] .globe-stage::after {
  background:
    radial-gradient(circle at 50% 44%, transparent 45%, rgba(2, 132, 199, 0.06) 80%, rgba(2, 132, 199, 0.12) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), transparent 16%, transparent 84%, rgba(2, 132, 199, 0.05));
}

#globe-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.globe-stage.is-dragging #globe-canvas {
  cursor: grabbing;
}

.globe-stage.is-pinching #globe-canvas {
  cursor: zoom-in;
}

.stage-top {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.stage-badge,
.daily-timer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--panel-solid) 62%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

.daily-timer {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.daily-timer .icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.stage-dot.is-won {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent);
}

.stage-dot.is-lost {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent);
}

.globe-hint {
  position: absolute;
  left: 20px;
  bottom: 56px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--panel-solid) 55%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
  transition: opacity 500ms ease, transform 500ms ease;
}

.globe-hint .icon {
  width: 14px;
  height: 14px;
}

.globe-hint.is-hidden {
  opacity: 0;
  transform: translateY(6px);
}

.globe-controls {
  position: absolute;
  right: 18px;
  bottom: 54px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--panel-solid) 58%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
  transition: background var(--transition), transform var(--transition), color var(--transition);
}

.control-btn:hover {
  background: color-mix(in srgb, var(--panel-solid) 82%, transparent);
  color: var(--accent);
}

.control-btn:active {
  transform: scale(0.93);
}

.control-btn .icon {
  width: 17px;
  height: 17px;
}

.stage-footer {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
}

.stage-footer .link-btn {
  color: var(--muted);
}

.stage-footer .link-btn:hover {
  color: var(--text);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 15%, transparent);
}

.status-dot.is-offline {
  background: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 15%, transparent);
}

.sep {
  opacity: 0.45;
}

/* Answer pin */
.answer-pin {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.28));
  transition: opacity 200ms ease;
}

.answer-pin.is-behind {
  opacity: 0;
}

.answer-pin-inner {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px 7px 8px;
  background: var(--pin-bg);
  border: 1px solid var(--pin-border);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.answer-pin-flag {
  font-size: 16px;
  line-height: 1;
}

.answer-pin-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  padding: 2px 5px;
  border-radius: 999px;
}

.answer-pin-stem {
  width: 2px;
  height: 13px;
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

/* ==========================================================================
   Sidebar / cards
   ========================================================================== */

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.game-card {
  padding: 20px;
  flex-shrink: 0;
}

.game-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.game-head-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.game-title {
  margin: 5px 0 0;
  font-size: 23px;
  line-height: 1.12;
  letter-spacing: -0.04em;
  color: var(--text-strong);
}

.guess-pill {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.round-result {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--success-border);
  background: var(--success-soft);
}

.round-result.is-lost {
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  background: var(--danger-soft);
}

.round-result-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.round-result-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.round-result-copy strong {
  font-size: 13px;
  color: var(--text-strong);
}

.round-result-copy span {
  font-size: 11.5px;
  color: var(--muted);
}

/* Search */
.guess-form {
  margin-top: 16px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 13px;
  border-radius: 16px;
  border: 1.5px solid var(--border-strong);
  background: var(--input-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-wrap.is-error {
  border-color: var(--danger);
  animation: shake 320ms ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  flex-shrink: 0;
}

#country-input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-strong);
  font-size: 15.5px;
  font-weight: 550;
}

#country-input::placeholder {
  color: var(--muted-2);
  font-weight: 450;
}

#country-input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.guess-btn {
  flex-shrink: 0;
  padding: 10px 15px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: filter var(--transition), transform var(--transition);
}

.guess-btn:hover {
  filter: brightness(1.08);
}

.guess-btn:active {
  transform: scale(0.96);
}

.guess-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.spelling-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel-2);
  pointer-events: none;
  animation: spelling-card-in 180ms ease-out;
}

@keyframes spelling-card-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.spelling-card-flag {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-solid);
  font-size: 18px;
  line-height: 1;
}

.spelling-card-copy {
  min-width: 0;
}

.spelling-card-question {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}

.spelling-card-question strong {
  color: var(--text-strong);
  font-weight: 650;
}

.spelling-card-help {
  margin: 3px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.spelling-card-help kbd {
  padding: 0 4px;
  font-size: 9.5px;
}

.form-error {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--danger);
  line-height: 1.4;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--text);
  line-height: 1.45;
}

/* Filters */
.filters {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.text-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
}

.text-btn:hover {
  text-decoration: underline;
}

.text-btn:disabled {
  color: var(--muted-2);
  cursor: default;
  text-decoration: none;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.filter-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  transition: opacity var(--transition), background var(--transition);
}

.filter-chip:hover {
  background: var(--panel-2);
  color: var(--text);
}

.filter-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}

.filter-chip.is-active::before {
  opacity: 1;
  background: var(--accent);
}

/* Hints */
.hints {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.hints-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hints-note {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--muted-2);
}

.hint-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.hint-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
  position: relative;
}

.hint-chip .icon {
  width: 15px;
  height: 15px;
}

.hint-chip > span {
  font-size: 10px;
  font-weight: 650;
  line-height: 1.1;
}

.hint-chip small {
  font-size: 9px;
  color: var(--muted-2);
  line-height: 1;
}

.hint-chip:hover:not(:disabled) {
  background: var(--panel-3);
  color: var(--text);
  transform: translateY(-1px);
}

.hint-chip.is-ready {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.hint-chip.is-ready small {
  color: var(--accent-strong);
}

.hint-chip.is-used {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
}

.hint-chip.is-used small {
  color: var(--success);
}

.hint-chip:disabled {
  cursor: default;
}

.hint-reveal {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: revealIn 220ms ease;
}

@keyframes revealIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
}

.hint-line .icon {
  width: 13px;
  height: 13px;
  color: var(--success);
}

.hint-line strong {
  font-weight: 700;
}

/* Game actions */
.game-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), filter var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 22%, transparent);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--panel-3);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--panel-2);
  color: var(--text);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-small {
  padding: 7px 10px;
  font-size: 11.5px;
  border-radius: 9px;
}

#new-round-btn {
  flex: 1;
}

/* ==========================================================================
   Guesses
   ========================================================================== */

.guesses-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 16px 14px;
}

.guesses-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.guesses-head h2 {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: -0.03em;
  color: var(--text-strong);
}

.sort-note {
  font-size: 9.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  padding-top: 4px;
  white-space: nowrap;
}

.guess-scroll {
  flex: 1;
  min-height: 90px;
  overflow-y: auto;
  margin: 11px -5px 0;
  padding: 0 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  overscroll-behavior: contain;
}

.guess-scroll::-webkit-scrollbar {
  width: 8px;
}

.guess-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.guess-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guess-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto 7px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 13px;
  border: 1px solid var(--heat-border, var(--border));
  background: var(--heat-soft, var(--panel-2));
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
  animation: guessIn 360ms cubic-bezier(0.2, 0.7, 0.3, 1);
  position: relative;
}

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

.guess-row:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--heat, var(--accent)) 17%, transparent);
}

.guess-row.is-answer {
  border-color: var(--success-border);
  background: var(--success-soft);
}

.guess-row.is-answer:hover {
  background: color-mix(in srgb, var(--success) 17%, transparent);
}

.guess-flag {
  font-size: 19px;
  line-height: 1;
  text-align: center;
  width: 26px;
}

.guess-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.guess-main strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guess-main small {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guess-row.is-answer .guess-main strong,
.guess-row.is-answer .guess-main small {
  color: var(--success);
}

.guess-distance {
  font-size: 11.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.guess-row.is-answer .guess-distance {
  color: var(--success);
}

.guess-heat {
  width: 7px;
  height: 27px;
  border-radius: 999px;
  background: var(--heat, var(--accent));
  box-shadow: 0 0 10px color-mix(in srgb, var(--heat, var(--accent)) 50%, transparent);
}

.guess-row.is-answer .guess-heat {
  background: var(--success);
  box-shadow: 0 0 12px color-mix(in srgb, var(--success) 60%, transparent);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 16px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-orbit {
  width: 68px;
  height: 68px;
  opacity: 0.8;
}

.empty-orbit svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.empty-orbit-dot {
  fill: var(--accent);
  stroke: none;
  animation: orbitPulse 2.4s ease-in-out infinite;
  transform-origin: 46px 18px;
}

@keyframes orbitPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.empty-state p {
  margin: 0;
  max-width: 270px;
  font-size: 12.5px;
  line-height: 1.5;
}

.empty-state strong {
  color: var(--text);
}

.empty-state .link-btn {
  font-size: 12px;
  font-weight: 650;
}

.legend {
  flex-shrink: 0;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#legend-note {
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted-2);
}

.legend-bar {
  height: 8px;
  margin: 7px 0 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fefce8, #fde68a, #fbbf24, #f59e0b, #ea580c, #dc2626, #991b1b);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted-2);
}

.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px 2px;
  font-size: 10.5px;
  color: var(--muted-2);
}

.link-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
  border-radius: 3px;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Dialogs
   ========================================================================== */

dialog {
  color: var(--text);
}

dialog::backdrop {
  background: var(--modal-backdrop);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.modal {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  position: fixed;
  inset: auto;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  margin: 0;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel-solid);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.42);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  animation: modalIn 240ms cubic-bezier(0.2, 0.7, 0.3, 1);
  position: relative;
}

.modal::-webkit-scrollbar {
  width: 9px;
}

.modal::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
  border: 2px solid var(--panel-solid);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
  background: var(--panel-2);
  color: var(--text);
}

.modal-kicker {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.modal h2 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: -0.045em;
  color: var(--text-strong);
}

.modal-lead {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

/* Result */
.result-modal {
  width: min(520px, calc(100vw - 32px));
}

.result-hero {
  text-align: center;
  padding: 4px 0 18px;
}

.result-flag {
  font-size: 62px;
  line-height: 1;
  margin-bottom: 10px;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.18));
}

.result-kicker {
  margin: 0;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--success);
}

.result-title {
  margin: 4px 0 5px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.045em;
  color: var(--text-strong);
}

.result-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.result-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.fact {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  min-width: 0;
}

.fact span {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact strong {
  display: block;
  margin-top: 3px;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-neighbors {
  margin-top: 11px;
}

.result-neighbors:empty {
  display: none;
}

.result-neighbors > span {
  display: block;
  margin-bottom: 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.neighbor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.neighbor-chip {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.result-countdown {
  margin: 14px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Statistics */
.stats-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.stats-section:first-of-type {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}

.stats-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.stats-section-head h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.stats-section-head span {
  font-size: 10.5px;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 11px 0 14px;
}

.stat-card {
  padding: 11px 6px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  text-align: center;
  min-width: 0;
}

.stat-card strong {
  display: block;
  font-size: 23px;
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.stat-card span {
  display: block;
  margin-top: 3px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.distribution-wrap {
  margin-top: 4px;
}

.distribution-head {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.distribution {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.distribution-row {
  display: grid;
  grid-template-columns: 24px 1fr 28px;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--muted);
}

.distribution-bar-wrap {
  height: 17px;
  background: var(--panel-2);
  border-radius: 5px;
  overflow: hidden;
}

.distribution-bar {
  height: 100%;
  min-width: 3px;
  width: var(--bar-width, 0%);
  border-radius: 5px;
  background: var(--accent);
  transition: width 500ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.distribution-row.is-current .distribution-bar {
  background: var(--success);
}

.distribution-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.stats-footer p {
  margin: 0;
  font-size: 10.5px;
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

/* Help */
.help-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0;
}

.help-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.help-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.help-step strong {
  display: block;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 1px;
}

.help-step p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

.help-legend {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.heat-example {
  flex: 1;
  min-width: 64px;
  text-align: center;
}

.heat-example span {
  display: block;
  height: 25px;
  border-radius: 8px;
  background: var(--heat-example, var(--panel-2));
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.heat-example small {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-top: 18px;
}

.help-grid h3 {
  margin: 0 0 4px;
  font-size: 12.5px;
  color: var(--text-strong);
}

.help-grid p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* Settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.setting-label {
  min-width: 0;
}

.setting-label strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.setting-label span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  flex-shrink: 0;
}

.segmented button {
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  background: var(--text);
  color: var(--bg);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}

.toggle-copy {
  min-width: 0;
}

.toggle-copy strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.toggle-copy small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--toggle-bg);
  border: 1px solid var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--transition), background var(--transition);
}

.toggle-row input:checked + .toggle {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(18px);
  background: var(--accent-contrast);
}

.toggle-row input:focus-visible + .toggle {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.install-row {
  border-bottom: 0;
}

.settings-note {
  margin: 14px 0 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-top: 16px;
}

.about-grid h3 {
  margin: 0 0 4px;
  font-size: 12.5px;
  color: var(--text-strong);
}

.about-grid p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.about-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted-2);
}

/* Confirm */
.confirm-modal {
  width: min(420px, calc(100vw - 32px));
  padding: 26px;
}

.confirm-modal h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.confirm-modal p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.confirm-modal .modal-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 220;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.toast.is-success {
  border-color: var(--success-border);
  color: var(--success);
}

/* Confetti */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 160;
  pointer-events: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 380px);
    gap: 16px;
  }

  .game-title {
    font-size: 21px;
  }

  .game-card {
    padding: 18px;
  }

  .guess-main strong {
    font-size: 12.5px;
  }
}

@media (max-width: 900px) {
  :root {
    --topbar-h: 70px;
  }

  body {
    overflow-y: auto;
  }

  .topbar {
    padding: 0 16px;
    gap: 10px;
  }

  .layout {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    padding: 0 14px 24px;
    gap: 14px;
  }

  .globe-stage {
    height: 48dvh;
    min-height: 330px;
    max-height: 560px;
    border-radius: 24px;
  }

  .sidebar {
    overflow: visible;
  }

  .guess-scroll {
    max-height: 46dvh;
  }

  .game-card,
  .guesses-card {
    border-radius: 22px;
  }

  .topbar-center {
    justify-content: center;
  }

  .stage-footer {
    display: none;
  }

  .globe-hint {
    bottom: 16px;
    left: 16px;
  }

  .globe-controls {
    right: 14px;
    bottom: 14px;
    flex-direction: row;
  }

  .answer-pin-inner {
    font-size: 11px;
    padding: 6px 9px 6px 7px;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 0 12px;
    gap: 6px;
  }

  .brand-text {
    display: none;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .topbar-center {
    justify-content: flex-start;
  }

  .mode-tab {
    padding: 7px 11px;
    font-size: 12px;
    gap: 5px;
  }

  .mode-tab .icon {
    width: 14px;
    height: 14px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .icon-btn .icon {
    width: 17px;
    height: 17px;
  }

  #help-btn {
    display: none;
  }

  .layout {
    padding: 0 10px 20px;
    gap: 12px;
  }

  .globe-stage {
    height: 44dvh;
    min-height: 300px;
    border-radius: 20px;
  }

  .stage-top {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  .stage-badge,
  .daily-timer {
    padding: 6px 9px;
    font-size: 10.5px;
  }

  .globe-hint {
    left: 12px;
    bottom: 12px;
    font-size: 10px;
    padding: 6px 9px;
  }

  .globe-controls {
    right: 10px;
    bottom: 10px;
    gap: 5px;
  }

  .control-btn {
    width: 34px;
    height: 34px;
  }

  .card {
    border-radius: 20px;
  }

  .game-card {
    padding: 16px;
  }

  .game-title {
    font-size: 20px;
  }

  .guess-pill {
    font-size: 10px;
    padding: 5px 8px;
  }

  .hint-chips {
    grid-template-columns: repeat(4, 1fr);
  }

  .hint-chip {
    min-height: 52px;
  }

  .hint-chip > span {
    font-size: 9.5px;
  }

  .game-actions {
    gap: 6px;
  }

  .btn {
    padding: 9px 11px;
    font-size: 12px;
  }

  .guesses-card {
    padding: 16px 12px 12px;
  }

  .modal {
    padding: 24px 20px;
    border-radius: 22px;
    max-height: calc(100dvh - 24px);
  }

  .modal h2 {
    font-size: 26px;
  }

  .result-title {
    font-size: 30px;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .help-grid,
  .about-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .setting-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .stats-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }

  .toast {
    bottom: 14px;
  }
}

@media (max-width: 400px) {
  .mode-tab span {
    font-size: 11px;
  }

  .mode-tab .icon {
    display: none;
  }

  .top-actions {
    gap: 0;
  }

  .icon-btn {
    width: 31px;
    height: 31px;
  }

  #theme-btn {
    display: none;
  }

  .game-title {
    font-size: 18.5px;
  }

  .filter-chip {
    font-size: 10.5px;
    padding: 5px 7px;
  }

  .hint-chip > span {
    font-size: 9px;
  }

  .result-facts {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 760px) and (min-width: 901px) {
  .layout {
    height: auto;
    min-height: 0;
  }

  .globe-stage {
    min-height: 560px;
  }

  .sidebar {
    overflow: visible;
  }

  .guess-scroll {
    max-height: 42vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
