/* MelonMap — premium dark geography game */

:root,
body[data-theme="dark"] {
  --bg: #070b14;
  --bg-elev: #0e1628;
  --bg-panel: rgba(12, 20, 38, 0.88);
  --line: rgba(148, 163, 184, 0.18);
  --text: #e8eef8;
  --muted: #93a4bd;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --flame: #fb923c;
  --ok-soft: #a7f3d0;
  --bad-soft: #fecaca;
  --radius: 16px;
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --map-dim: saturate(0.85) brightness(0.55);
  --panel-grad-a: rgba(45, 212, 191, 0.16);
  --panel-grad-b: rgba(56, 189, 248, 0.12);
  --panel-grad-c: rgba(16, 24, 42, 0.94);
  --panel-grad-d: rgba(8, 12, 22, 0.92);
  --stat-bg: rgba(255, 255, 255, 0.04);
  --chip-bg: var(--bg-panel);
}

body[data-theme="light"] {
  --bg: #d7e8f5;
  --bg-elev: #f4f7fb;
  --bg-panel: rgba(255, 255, 255, 0.96);
  --line: rgba(15, 23, 42, 0.22);
  --text: #0f172a;
  --muted: #334155;
  --accent: #0f766e;
  --accent-2: #1d4ed8;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #047857;
  --flame: #c2410c;
  --ok-soft: #065f46;
  --bad-soft: #991b1b;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  --map-dim: saturate(0.95) brightness(0.94);
  --panel-grad-a: rgba(13, 148, 136, 0.1);
  --panel-grad-b: rgba(37, 99, 235, 0.08);
  --panel-grad-c: rgba(255, 255, 255, 0.97);
  --panel-grad-d: rgba(241, 245, 249, 0.98);
  --stat-bg: rgba(15, 23, 42, 0.05);
  --chip-bg: rgba(255, 255, 255, 0.92);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
}

/* Smooth light ↔ dark swap (enabled after first theme apply to avoid boot flash) */
body.theme-animated {
  transition:
    background-color 0.4s ease,
    color 0.4s ease;
}

body.theme-animated .overlay-panel,
body.theme-animated .theme-toggle,
body.theme-animated .feedback-launch,
body.theme-animated .btn,
body.theme-animated .icon-btn,
body.theme-animated .prompt-card,
body.theme-animated .hud-top,
body.theme-animated .progress-wrap,
body.theme-animated .type-panel,
body.theme-animated .feedback-card,
body.theme-animated .confirm-dialog,
body.theme-animated .mode-card,
body.theme-animated .streak-pill,
body.theme-animated .account-tab,
body.theme-animated .stats-modal-body,
body.theme-animated input,
body.theme-animated select,
body.theme-animated textarea {
  transition:
    background-color 0.4s ease,
    background 0.4s ease,
    color 0.4s ease,
    border-color 0.4s ease,
    box-shadow 0.4s ease,
    fill 0.4s ease;
}

@media (prefers-reduced-motion: reduce) {
  body.theme-animated,
  body.theme-animated .overlay-panel,
  body.theme-animated .theme-toggle,
  body.theme-animated .feedback-launch,
  body.theme-animated .btn,
  body.theme-animated .icon-btn,
  body.theme-animated .prompt-card,
  body.theme-animated .hud-top,
  body.theme-animated .progress-wrap,
  body.theme-animated .type-panel,
  body.theme-animated .feedback-card,
  body.theme-animated .confirm-dialog,
  body.theme-animated .mode-card,
  body.theme-animated .streak-pill,
  body.theme-animated .account-tab,
  body.theme-animated .stats-modal-body,
  body.theme-animated input,
  body.theme-animated select,
  body.theme-animated textarea {
    transition: none !important;
  }
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.map-shake {
  animation: map-shake var(--shake-ms, 80ms) ease-in-out;
}

@keyframes map-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  25% {
    transform: translate3d(-7px, 0, 0);
  }
  75% {
    transform: translate3d(7px, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-shake {
    animation: none;
  }
}

.theme-toggle {
  position: fixed;
  z-index: 30;
  top: 0.85rem;
  right: 0.85rem;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  transition: transform 0.15s ease, background 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: scale(0.97);
}

body[data-screen="play"] .theme-toggle {
  display: none;
}

.feedback-launch {
  position: fixed;
  z-index: 30;
  left: 0.85rem;
  bottom: max(0.85rem, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.2s ease;
}

.feedback-launch:hover {
  transform: translateY(-1px);
}

.feedback-launch:active {
  transform: scale(0.97);
}

body[data-screen="play"] .feedback-launch,
body[data-screen="loading"] .feedback-launch {
  display: none;
}

.feedback-types {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.map-pulse {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 2;
  opacity: 0;
}

.map-pulse.go.ok {
  animation: pulseOk 0.65s ease-out;
}

.map-pulse.go.bad {
  animation: pulseBad 0.65s ease-out;
}

@keyframes pulseOk {
  0% {
    opacity: 0;
    box-shadow: inset 0 0 0 0 rgba(52, 211, 153, 0);
  }

  35% {
    opacity: 1;
    box-shadow: inset 0 0 120px 40px rgba(52, 211, 153, 0.22);
  }

  100% {
    opacity: 0;
  }
}

@keyframes pulseBad {
  0% {
    opacity: 0;
    box-shadow: inset 0 0 0 0 rgba(248, 113, 113, 0);
  }

  35% {
    opacity: 1;
    box-shadow: inset 0 0 120px 40px rgba(248, 113, 113, 0.22);
  }

  100% {
    opacity: 0;
  }
}

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  pointer-events: none;
}

.screen.active {
  display: flex;
  pointer-events: auto;
}

/* Home: scroll when mode cards exceed the viewport */
#screen-home.active {
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: max(0.75rem, env(safe-area-inset-top)) 0 max(0.75rem, env(safe-area-inset-bottom));
}

#screen-home .home-panel {
  margin: 0 auto;
}

.home-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.home-head-text {
  min-width: 0;
  flex: 1;
}

.home-head .brand {
  margin-bottom: 0.45rem;
}

.home-head .meta-row {
  margin-bottom: 0;
}

.btn-show-stats {
  flex: 0 0 auto;
  margin-top: 0.15rem;
  white-space: nowrap;
}

.home-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.home-broadcast {
  display: flex;
  align-items: center;
  margin: 0 0 1rem;
  padding: 0.65rem 0.95rem;
  border-radius: 12px;
  background: rgba(45, 212, 191, 0.12);
  border: 1px solid rgba(45, 212, 191, 0.38);
  color: #99f6e4;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.35;
}

.home-broadcast[hidden] {
  display: none !important;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Auth buttons: only one group visible, driven by body[data-auth] */
#auth-guest-actions,
#auth-user-actions {
  display: none !important;
}

body[data-auth="guest"] #auth-guest-actions {
  display: flex !important;
}

body[data-auth="user"] #auth-user-actions {
  display: flex !important;
}

.account-modal .account-dialog {
  width: min(480px, calc(100% - 1.5rem));
  text-align: left;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.account-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.account-field input,
.account-field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.account-field textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.account-field input:focus,
.account-field textarea:focus {
  outline: 2px solid rgba(45, 212, 191, 0.35);
  border-color: rgba(45, 212, 191, 0.45);
}

.btn-tip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
  white-space: nowrap;
  border: 1px solid rgba(46, 160, 90, 0.35);
  background: linear-gradient(
    145deg,
    rgba(120, 210, 130, 0.22),
    rgba(46, 160, 90, 0.12)
  );
  color: var(--text);
  font-weight: 700;
}

.btn-tip:hover {
  border-color: rgba(46, 160, 90, 0.55);
  transform: translateY(-1px);
}

.tip-intro {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.tip-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.tip-fieldset legend {
  padding: 0;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.tip-amounts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.tip-amount {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 0.35rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.tip-amount:hover {
  transform: translateY(-1px);
}

.tip-amount[aria-pressed="true"] {
  border-color: rgba(46, 160, 90, 0.65);
  background: rgba(46, 160, 90, 0.18);
}

.tip-custom-field {
  margin-top: 0.55rem;
}

.tip-freq {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.tip-freq-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.5rem;
  cursor: pointer;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
}

.tip-freq-option:has(input:checked) {
  border-color: rgba(46, 160, 90, 0.65);
  background: rgba(46, 160, 90, 0.18);
}

.tip-freq-option input {
  accent-color: #2ea05a;
}

.tip-optional {
  font-weight: 400;
  opacity: 0.8;
}

.tip-secure {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.account-hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.account-error {
  margin: 0;
  color: #f87171;
  font-size: 0.9rem;
}

.account-success {
  margin: 0;
  color: var(--accent);
  font-size: 0.9rem;
}

.account-profile {
  margin: 0.5rem 0 1rem;
}

.account-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.account-title {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.account-email {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.account-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 0.85rem 0 0.75rem;
  padding: 0.25rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.account-tab {
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.account-tab:hover {
  color: var(--text);
}

.account-tab.active,
.account-tab[aria-selected="true"] {
  background: rgba(45, 212, 191, 0.16);
  color: var(--text);
}

.account-tab-panel {
  min-height: 8rem;
}

.account-tab-panel[hidden] {
  display: none !important;
}

.account-stats-body {
  max-height: min(42vh, 360px);
  overflow: auto;
  padding-right: 0.15rem;
}

.account-stats-kpi {
  margin-bottom: 0.65rem;
}

.account-stats-meta {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.account-mode-list {
  margin: 0;
}

.account-joined {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.account-joined strong {
  color: var(--text);
  font-weight: 700;
}

.map-colors-form {
  gap: 0.85rem;
}

.map-colors-fieldset {
  margin: 0;
  padding: 0.75rem 0.85rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.85rem;
}

.map-colors-fieldset legend {
  padding: 0 0.35rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.map-color-field {
  margin: 0;
}

.map-color-field input[type="color"] {
  width: 100%;
  height: 2.5rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

body[data-theme="light"] .map-color-field input[type="color"] {
  background: #fff;
}

.account-tab-actions {
  margin-top: 0.85rem;
  justify-content: flex-start;
}

.account-settings-actions {
  margin-top: 0.35rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.account-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.btn-account-logout {
  min-width: 5.5rem;
  padding: 0.55rem 1rem;
  color: var(--muted);
}

.btn-account-logout:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.45);
}

.account-section-title {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.account-reminder-block {
  margin: 0.5rem 0 1rem;
}

.account-check {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.35;
}

.account-check input {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  accent-color: #14b8a6;
}

.account-check small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.account-actions-row {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.account-warn {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: #f87171;
}

.account-switch-row {
  margin-top: 0.85rem;
  justify-content: center;
}

.account-switch-text {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.btn-text-link {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text-link:hover {
  color: var(--accent-2, var(--accent));
}

.btn-text-link:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  text-decoration: none;
}

.btn-text-danger {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  color: #ef4444;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text-danger:hover {
  color: #f87171;
}

.btn-text-danger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  text-decoration: none;
}

.login-resend {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
}

.confirm-modal:not([hidden]) {
  display: grid !important;
  pointer-events: auto;
}

.confirm-modal .confirm-dialog {
  pointer-events: auto;
}

.turnstile-slot {
  min-height: 0;
}

body[data-theme="light"] .account-field input {
  background: #fff;
}


/*
  Play HUD must NEVER cover the map with an invisible hit target.
  Flex stretch + pointer-events:auto on .hud was blocking pan/click on land & water.
*/
#screen-play.active {
  display: block;
  pointer-events: none;
}

#screen-play .hud {
  pointer-events: none;
}

#screen-play .hud-top,
#screen-play .prompt-card,
#screen-play .progress-wrap {
  pointer-events: auto;
}

#screen-play .timer-wrap {
  pointer-events: none;
}

#screen-play .type-panel {
  pointer-events: none;
}

#screen-play .type-panel:not([hidden]) {
  pointer-events: auto;
}

/* Loading / Home overlays */
.overlay-panel {
  margin: auto;
  width: min(1020px, calc(100% - 2rem));
  padding: 2rem;
  border-radius: calc(var(--radius) + 4px);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--panel-grad-a), transparent 50%),
    radial-gradient(900px 400px at 90% 0%, var(--panel-grad-b), transparent 45%),
    linear-gradient(180deg, var(--panel-grad-c), var(--panel-grad-d));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  animation: rise 0.55s ease;
  color: var(--text);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin: 0 0 0.4rem;
  background: linear-gradient(120deg, #f8fafc 10%, var(--accent) 55%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(251, 146, 60, 0.12);
  border: 1px solid rgba(251, 146, 60, 0.35);
  color: #fdba74;
  font-weight: 600;
}

.streak-shield {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  margin-left: 0.1rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
}

.streak-shield.bronze {
  background: rgba(217, 119, 6, 0.22);
  box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.5);
}

.streak-shield.silver {
  background: rgba(203, 213, 225, 0.18);
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.55);
}

.streak-shield.gold {
  background: rgba(251, 191, 36, 0.22);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.6);
}

.stamps-line {
  font-weight: 600;
}

.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}

.mode-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  text-align: left;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.mode-card:hover {
  transform: translateY(-3px);
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.06);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.mode-art {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  overflow: hidden;
  background: #0b1220;
  border-bottom: 1px solid var(--line);
}

.mode-art img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.28s ease;
}

.mode-card:hover .mode-art img {
  transform: scale(1.04);
}

.mode-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 0.2rem;
  padding: 0.8rem 0.95rem 0.95rem;
  min-height: 5.25rem;
}

.mode-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.25;
  margin: 0;
}

.mode-blurb {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  min-height: 2.15em;
}

.mode-footer {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: auto;
  padding-top: 0.35rem;
  min-height: 1.35rem;
}

.mode-high,
.mode-meta {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.mode-high {
  color: var(--accent);
  font-weight: 600;
}

.mode-meta {
  font-size: 0.72rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.mode-medals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.4rem;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  line-height: 1.3;
}

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

.medal.gold {
  color: #fbbf24;
}

.medal.silver {
  color: #cbd5e1;
}

.medal.bronze {
  color: #d97706;
}

.medal.none {
  opacity: 0.45;
}

/* Settings */
.settings-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.settings-head h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 1.6rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  outline: none;
}

.field select:focus {
  border-color: var(--accent);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #042f2e;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 650;
}

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

/* Loading */
.loading-copy {
  text-align: center;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.loading-copy .brand {
  margin-bottom: 0;
}

.loading-bar {
  width: min(240px, 68vw);
  height: 3px;
  margin: 1.65rem auto 0.9rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  overflow: hidden;
}

.loading-error {
  margin-top: 1.1rem;
  display: grid;
  gap: 0.85rem;
  justify-items: center;
}

.loading-error[hidden] {
  display: none;
}

.loading-error-message {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  font-weight: 600;
}

.loading-bar-fill {
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}

#loading-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

body[data-theme="light"] .loading-bar {
  background: rgba(15, 23, 42, 0.12);
}

/* HUD */
.hud {
  position: fixed;
  z-index: 12;
  left: 0;
  right: 0;
  top: 0;
  padding: 0.75rem;
  display: grid;
  gap: 0.65rem;
  background: linear-gradient(180deg, rgba(7, 11, 20, 0.75), transparent);
}

.hud-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.hud-stats[hidden] {
  display: none !important;
}

body[data-play-mode="explore"] #hud-stats-quiz,
body[data-play-mode="quiz"] #hud-stats-explore,
body[data-play-mode="blitz"] #hud-stats-explore {
  display: none !important;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 0.85rem;
  font-weight: 600;
}

.chip.streak.hot {
  border-color: rgba(251, 146, 60, 0.55);
  box-shadow: 0 0 20px rgba(251, 146, 60, 0.25);
  color: #fdba74;
  animation: flicker 0.9s ease-in-out infinite alternate;
}

.chip.streak.combo-gold {
  border-color: rgba(251, 191, 36, 0.85);
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  font-size: 1.02rem;
}

.chip.streak.pop {
  animation: combo-pop 0.38s cubic-bezier(0.2, 1.4, 0.3, 1);
}

@keyframes combo-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.28);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes flicker {
  from {
    filter: brightness(1);
  }

  to {
    filter: brightness(1.15);
  }
}

.hud-actions {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.icon-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.prompt-card {
  justify-self: center;
  width: min(640px, 100%);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  text-align: center;
  box-shadow: var(--shadow);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.prompt-card.combo-3 {
  border-color: rgba(45, 212, 191, 0.65);
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.22);
}

.prompt-card.combo-5 {
  border-color: rgba(251, 146, 60, 0.7);
  box-shadow: 0 0 28px rgba(251, 146, 60, 0.28);
}

.prompt-card.combo-10 {
  border-color: rgba(251, 191, 36, 0.95);
  box-shadow: 0 0 36px rgba(251, 191, 36, 0.42);
}

.prompt-card small {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}

.streak-risk {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fdba74;
}

.prompt-main {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 750;
}

.prompt-flag {
  font-size: clamp(2.8rem, 8vw, 4rem);
  line-height: 1;
}

.prompt-clue {
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  font-weight: 600;
  line-height: 1.35;
}

.prompt-card:has(.photo-slider) {
  width: min(420px, 100%);
  padding: 0.75rem 0.85rem 0.9rem;
}

.photo-slider {
  position: relative;
  user-select: none;
}

.photo-caption {
  display: block;
  margin: 0.55rem 0 0;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--text);
  line-height: 1.3;
  min-height: 1.3em;
  text-align: center;
}

.photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: min(320px, 42vh);
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #0b1220;
  border: 1px solid var(--line);
}

.photo-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  /* Never auto — re-enables hit-testing through a hidden feedback card. */
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  transition: opacity 0.25s ease;
}

.photo-slide.active {
  opacity: 1;
}

.photo-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 11, 20, 0.72);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.photo-prev {
  left: 0.35rem;
}

.photo-next {
  right: 0.35rem;
}

.photo-nav:hover {
  background: rgba(45, 212, 191, 0.25);
  border-color: rgba(45, 212, 191, 0.45);
}

.photo-dots {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.photo-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
  cursor: pointer;
}

.photo-dot.active {
  background: var(--accent);
  width: 18px;
}

body[data-theme="light"] .photo-frame {
  background: #e2e8f0;
}

body[data-theme="light"] .photo-nav {
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
}

.progress-wrap {
  width: min(640px, 100%);
  justify-self: center;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.progress-text {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.timer-wrap {
  position: fixed;
  z-index: 12;
  right: 0.85rem;
  bottom: 5.5rem;
  width: 64px;
  height: 64px;
}

.timer-ring {
  --p: 1;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1turn), rgba(255, 255, 255, 0.08) 0);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.timer-ring::before {
  content: "";
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-elev);
}

.timer-ring span {
  position: absolute;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-ring.urgent {
  background: conic-gradient(var(--danger) calc(var(--p) * 1turn), rgba(255, 255, 255, 0.08) 0);
  animation: urgentPulse 0.6s ease infinite alternate;
}

@keyframes urgentPulse {
  to {
    transform: scale(1.05);
  }
}

/* Type panel */
.type-panel {
  position: fixed;
  z-index: 13;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 1.5rem));
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.type-row {
  display: flex;
  gap: 0.5rem;
}

.type-row input {
  flex: 1;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  outline: none;
}

.type-suggest {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.25rem;
}

.suggest-item {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.suggest-item:hover {
  border-color: rgba(45, 212, 191, 0.4);
}

/* Feedback */
.feedback-card {
  --drag-x: 0px;
  --drag-y: 0px;
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 1rem;
  transform: translateX(calc(-50% + var(--drag-x))) translateY(calc(20px + var(--drag-y)));
  width: min(440px, calc(100% - 1.5rem));
  padding: 0.65rem 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  text-align: center;
}

.feedback-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-height: 32px;
  margin: 0 0 0.45rem;
  cursor: grab;
}

.feedback-card.minimized .feedback-toolbar {
  margin: 0;
}

.feedback-min-title {
  flex: 1;
  min-width: 0;
  margin: 0 0.35rem 0 0.15rem;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 3.2vw, 1.25rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  cursor: grab;
}

.feedback-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.feedback-tool-btn,
.feedback-close {
  position: static;
  top: auto;
  right: auto;
  z-index: 5;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
  padding: 0;
}

.feedback-tool-btn:hover,
.feedback-close:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(148, 163, 184, 0.4);
}

.feedback-body {
  text-align: center;
}

.feedback-card.minimized {
  padding: 0.45rem 0.55rem;
  width: min(360px, calc(100% - 1.5rem));
}

.feedback-card.minimized .feedback-body {
  display: none !important;
}

.feedback-card.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  cursor: grab;
  transform: translateX(calc(-50% + var(--drag-x))) translateY(var(--drag-y));
}

.feedback-card.show.is-dragging {
  cursor: grabbing;
  transition: none;
  user-select: none;
}

.feedback-card.ok {
  border-color: rgba(52, 211, 153, 0.45);
}

.feedback-card.bad {
  border-color: rgba(248, 113, 113, 0.45);
}

.fb-emoji {
  font-size: 1.8rem;
}

.feedback-card h3 {
  margin: 0.25rem 0;
  font-family: var(--font-display);
}

.fb-points {
  color: var(--ok);
  font-weight: 700;
  margin: 0.2rem 0;
}

.fb-answer {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  text-align: left;
  margin: 0.75rem 0;
}

.fb-flag {
  font-size: 2.2rem;
}

.fb-cap,
.fb-languages,
.fb-fact,
.fb-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.2rem 0 0;
}

.fb-fact {
  font-style: italic;
}

.feedback-card.explore {
  border-color: rgba(45, 212, 191, 0.45);
  text-align: left;
}

.explore-top {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto;
  gap: 0.75rem 1rem;
  align-items: center;
}

.explore-top-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.35rem;
  min-width: 0;
}

.explore-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
}

.explore-flag {
  font-size: clamp(4.2rem, 15vw, 6.3rem);
  line-height: 1;
  text-align: right;
}

.explore-capital {
  margin: 0;
  font-size: 1.02rem;
}

.explore-languages {
  margin: 0;
  font-size: 0.95rem;
}

.explore-continent {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.explore-landmark {
  margin: 0.65rem 0 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.explore-accuracy {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.explore-gallery {
  margin-top: 0.9rem;
}

.explore-gallery .photo-frame {
  max-height: min(240px, 36vh);
  aspect-ratio: 1 / 1;
}

@media (max-width: 380px) {
  .explore-top {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .explore-top-right {
    text-align: center;
    align-items: center;
  }
}

.explore-prompt {
  font-size: clamp(1.05rem, 2.8vw, 1.35rem) !important;
}

body[data-play-mode="explore"] .timer-wrap {
  display: none;
}

/* End screen */
.end-panel {
  max-height: min(90vh, 820px);
  overflow: auto;
}

.end-score {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  margin: 0;
  background: linear-gradient(120deg, var(--warn), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.end-stars {
  font-size: 1.6rem;
  color: var(--warn);
  letter-spacing: 0.15em;
  margin: 0.25rem 0 1rem;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.end-stats .stat {
  padding: 0.7rem;
  border-radius: 12px;
  background: var(--stat-bg);
  border: 1px solid var(--line);
  text-align: center;
}

.end-stats .stat span {
  display: block;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.end-stats .stat label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.end-unlock {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--accent);
  text-align: center;
  font-weight: 600;
}

.end-unlock-detail {
  display: inline-block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.end-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.end-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.end-list li:last-child {
  border-bottom: none;
}

.end-list li.ok {
  color: var(--ok-soft);
}

.end-list li.bad {
  color: var(--bad-soft);
}

.fb-stamp {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}

/* Rare perfect-round postcard */
.postcard {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.postcard[hidden] {
  display: none !important;
}

.postcard-card {
  position: relative;
  width: min(420px, 100%);
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: center;
}

.postcard-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(248, 250, 252, 0.35);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}

.postcard-close:hover {
  background: rgba(15, 23, 42, 0.9);
}

.postcard-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.postcard-kicker {
  margin: 0.85rem 0 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fdba74;
}

.postcard-title {
  margin: 0.35rem 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 750;
  color: #f8fafc;
}

.postcard-fact {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.4;
}

.wax-seal {
  position: fixed;
  z-index: 8;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
  pointer-events: none;
}

.wax-seal[hidden] {
  display: none !important;
}

.wax-seal-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fb7185, #9f1239 58%, #7f1d1d);
  box-shadow:
    0 8px 18px rgba(127, 29, 29, 0.45),
    inset 0 2px 5px rgba(255, 255, 255, 0.28);
  color: #fde68a;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 800;
}

.wax-seal.go .wax-seal-disc {
  animation: wax-stamp 0.55s cubic-bezier(0.2, 1.4, 0.3, 1) forwards;
}

@keyframes wax-stamp {
  0% {
    transform: translateY(-46px) scale(1.4) rotate(-14deg);
    opacity: 0;
  }
  58% {
    transform: translateY(5px) scale(0.9) rotate(5deg);
    opacity: 1;
  }
  78% {
    transform: translateY(-3px) scale(1.08) rotate(-2deg);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0);
  }
}

.unlock-card {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(2, 6, 23, 0.32);
  cursor: pointer;
  text-align: center;
}

.unlock-card[hidden] {
  display: none !important;
}

.unlock-kicker {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fdba74;
}

.unlock-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 3.6rem);
  font-weight: 800;
  color: #f8fafc;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  .wax-seal.go .wax-seal-disc,
  .chip.streak.pop {
    animation: none;
  }
}

/* Toast */
.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -8px);
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(45, 212, 191, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

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

.help-keys {
  margin-top: 1.25rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
}

/* Must sit above stats/account modals (those also use .confirm-modal) */
#confirm-modal {
  z-index: 200;
}

#confirm-modal[hidden] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.stats-modal {
  z-index: 85;
  align-items: start;
  padding-top: 4vh;
  overflow-y: auto;
}

.stats-dialog {
  width: min(728px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1.25rem 1rem;
}

.stats-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.stats-dialog-head h2 {
  margin: 0;
}

.stats-modal-body {
  overflow-y: auto;
  flex: 1;
  display: grid;
  gap: 1.1rem;
  padding-right: 0.15rem;
}

.stats-section h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.stats-mode-summary {
  margin: 0 0 0.35rem !important;
  color: var(--text) !important;
  font-weight: 650;
  font-size: 0.88rem !important;
}

.stats-section p,
.stats-section li {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.stats-kpi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

@media (max-width: 560px) {
  .stats-kpi {
    grid-template-columns: 1fr;
  }
}

.stats-kpi .kpi-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
}

.stats-kpi strong {
  display: block;
  font-size: 1.35rem;
  font-family: var(--display, inherit);
  color: var(--text);
  margin-bottom: 0.15rem;
}

.stats-kpi span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.stats-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  padding: 0.28rem 0;
}

.stats-list .val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.stats-continent-block {
  margin-top: 0.55rem;
}

.stats-continent-block h4 {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  color: var(--text);
}

.stats-empty {
  font-style: italic;
}

.stats-io {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.95rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.stats-io #btn-stats-reset {
  margin-right: auto;
}

.stats-io #btn-stats-reset[hidden] {
  display: none !important;
}

.stats-cancel {
  min-width: 5.5rem;
}

body[data-theme="light"] .stats-kpi .kpi-card {
  background: rgba(15, 23, 42, 0.03);
}

.confirm-modal[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.confirm-dialog {
  width: min(500px, 100%);
  padding: 1.35rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.confirm-dialog h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.confirm-dialog p {
  margin: 0 0 1.15rem;
  color: var(--muted);
  line-height: 1.45;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
}

.btn-danger:hover {
  background: #ef4444;
}

body[data-theme="light"] .confirm-dialog {
  background: #fff;
}

.kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
}

@media (max-width: 720px) {
  .overlay-panel {
    padding: 1.25rem;
    width: calc(100% - 1rem);
  }

  .home-head {
    flex-wrap: wrap;
    align-items: center;
  }

  .btn-show-stats {
    margin-top: 0;
  }

  .modes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .mode-body {
    min-height: 0;
    padding: 0.65rem 0.7rem 0.75rem;
    gap: 0.15rem;
  }

  .mode-name {
    font-size: 0.95rem;
  }

  .mode-blurb {
    font-size: 0.72rem;
    min-height: 0;
  }

  .mode-footer {
    min-height: 0;
    padding-top: 0.2rem;
  }

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

  .end-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timer-wrap {
    right: 0.6rem;
    bottom: auto;
    top: 7.5rem;
  }

  .hud {
    padding: 0.55rem;
  }

  .prompt-card {
    padding: 0.7rem 0.85rem;
  }

  .mapboxgl-ctrl-bottom-right {
    bottom: 70px !important;
  }
}

@media (max-width: 420px) {
  .modes-grid {
    grid-template-columns: 1fr;
  }

  .home-head {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-show-stats,
  .btn-tip {
    width: 100%;
    justify-content: center;
  }

  .tip-amounts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #tip-form .btn-row {
    display: block;
  }

  #btn-tip-submit {
    width: 100%;
    justify-content: center;
  }

  .meta-row {
    flex-wrap: wrap;
  }
}

/* Dim map under menus */
body[data-screen="home"] #map,
body[data-screen="settings"] #map,
body[data-screen="loading"] #map,
body[data-screen="end"] #map {
  filter: var(--map-dim);
}

body[data-theme="light"] .btn-primary {
  color: #fff;
}

body[data-theme="light"] .btn-ghost {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.35);
  color: #0f172a;
}

body[data-theme="light"] .btn-ghost:hover {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.5);
}

body[data-theme="light"] .brand {
  background: linear-gradient(120deg, #0f172a 8%, #0f766e 55%, #1d4ed8);
  -webkit-background-clip: text;
  background-clip: text;
}

body[data-theme="light"] .end-score {
  background: linear-gradient(120deg, #b45309, #0f766e);
  -webkit-background-clip: text;
  background-clip: text;
}

body[data-theme="light"] .mode-card {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(15, 23, 42, 0.18);
}

body[data-theme="light"] .mode-card:hover {
  background: rgba(13, 148, 136, 0.12);
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

body[data-theme="light"] .mode-blurb,
body[data-theme="light"] .mode-meta,
body[data-theme="light"] .tagline,
body[data-theme="light"] .help-keys,
body[data-theme="light"] .meta-row,
body[data-theme="light"] .field label,
body[data-theme="light"] .fb-cap,
body[data-theme="light"] .fb-languages,
body[data-theme="light"] .fb-fact,
body[data-theme="light"] .fb-sub,
body[data-theme="light"] .progress-text {
  color: #334155;
}

body[data-theme="light"] .mode-high {
  color: #0f766e;
  font-weight: 700;
}

body[data-theme="light"] .chip,
body[data-theme="light"] .icon-btn,
body[data-theme="light"] .theme-toggle,
body[data-theme="light"] .feedback-launch,
body[data-theme="light"] .prompt-card,
body[data-theme="light"] .type-panel,
body[data-theme="light"] .feedback-card {
  background: var(--chip-bg);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.2);
}

body[data-theme="light"] .prompt-card.combo-3 {
  border-color: rgba(13, 148, 136, 0.7);
  box-shadow: 0 0 22px rgba(13, 148, 136, 0.18);
}

body[data-theme="light"] .prompt-card.combo-5 {
  border-color: rgba(194, 65, 12, 0.7);
  box-shadow: 0 0 24px rgba(194, 65, 12, 0.16);
}

body[data-theme="light"] .prompt-card.combo-10 {
  border-color: rgba(180, 83, 9, 0.85);
  box-shadow: 0 0 28px rgba(180, 83, 9, 0.2);
}

body[data-theme="light"] .feedback-close,
body[data-theme="light"] .feedback-tool-btn {
  border: none;
  color: #0f172a;
}

body[data-theme="light"] .feedback-close:hover,
body[data-theme="light"] .feedback-tool-btn:hover {
  background: rgba(15, 23, 42, 0.1);
}

body[data-theme="light"] .prompt-card small {
  color: #475569;
  font-weight: 700;
}

body[data-theme="light"] .field select,
body[data-theme="light"] .type-row input {
  background: #fff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.28);
}

body[data-theme="light"] .kbd {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.28);
  color: #0f172a;
}

body[data-theme="light"] .end-list {
  background: rgba(255, 255, 255, 0.7);
}

body[data-theme="light"] .end-list li {
  font-weight: 600;
}

body[data-theme="light"] .streak-pill {
  background: rgba(194, 65, 12, 0.1);
  border-color: rgba(194, 65, 12, 0.4);
  color: #9a3412;
}

body[data-theme="light"] .streak-risk {
  color: #9a3412;
}

body[data-theme="light"] .medal.silver {
  color: #64748b;
}

body[data-theme="light"] .postcard {
  background: rgba(15, 23, 42, 0.62);
}

body[data-theme="light"] .postcard-close {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.2);
  color: #0f172a;
}

body[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border-color: rgba(15, 118, 110, 0.45);
}

body[data-theme="light"] .home-broadcast {
  background: rgba(15, 118, 110, 0.1);
  border-color: rgba(15, 118, 110, 0.28);
  color: #0f766e;
}

body[data-theme="light"] .timer-ring::before {
  background: #eef4f9;
}

body[data-theme="light"] .mapboxgl-ctrl-group {
  background: rgba(255, 255, 255, 0.95);
}

body[data-theme="light"] .mapboxgl-ctrl-group button+button {
  border-top-color: rgba(15, 23, 42, 0.16);
}

body[data-theme="light"] .mapboxgl-ctrl button {
  filter: invert(0.85);
}

/* One-more-round modes */
#screen-chapter.active {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
  pointer-events: none;
}

#screen-chapter .chapter-panel {
  pointer-events: auto;
  width: min(520px, calc(100% - 2rem));
  margin: 0 1rem max(1.2rem, env(safe-area-inset-bottom));
  padding: 1.35rem 1.4rem 1.2rem;
}

.chapter-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fdba74;
}

#chapter-title {
  margin: 0.25rem 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
}

.chapter-fog-list {
  margin: 0.35rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.prompt-card.boss-prompt {
  border-color: rgba(251, 191, 36, 0.9);
  box-shadow: 0 0 28px rgba(251, 191, 36, 0.35);
}

.revenge-sils {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  margin: 0.75rem 0 0.35rem;
}

.revenge-sils[hidden] {
  display: none !important;
}

.revenge-sil {
  width: 72px;
  height: 56px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #e2e8f0;
}

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

body[data-play-mode="blitz"] #hud-lives {
  display: none;
}

.mode-card.mode-done .mode-name {
  color: var(--ok);
}

.mode-card.mode-disabled {
  opacity: 0.62;
  cursor: default;
}

.mode-card.mode-disabled:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.mode-off {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--danger);
  background: rgba(248, 113, 113, 0.16);
  vertical-align: middle;
}

.mode-off.mode-beta {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.14);
}

.mode-off.mode-soon {
  color: var(--warn);
  background: rgba(251, 191, 36, 0.18);
}

body[data-theme="light"] .chapter-kicker {
  color: #c2410c;
}

body[data-theme="light"] .revenge-sil {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

body[data-theme="light"] .prompt-card.boss-prompt {
  border-color: #d97706;
  box-shadow: 0 0 22px rgba(217, 119, 6, 0.28);
}