:root {
  --bg: #071014;
  --panel: #101a20;
  --panel-2: #17242b;
  --panel-3: #0b151a;
  --line: rgba(255,255,255,.09);
  --line-strong: rgba(255,255,255,.16);
  --text: #f2f5f4;
  --muted: #8ea2a9;
  --accent: #ff4655;
  --accent-soft: rgba(255,70,85,.15);
  --good: #53e09a;
  --warning: #f5c451;
  --tooltip-select-suffix: " · нажми, чтобы выбрать";
}

html[lang="en"] { --tooltip-select-suffix: " · tap to select"; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 50% -15%, #1c313a 0%, rgba(15,30,36,.72) 25%, transparent 49%),
    linear-gradient(180deg, #071015 0%, #050b0e 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.modal-open { overflow: hidden; }
button { font: inherit; }
button, img { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 76%);
}

.app-shell {
  width: min(1560px, calc(100% - 34px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 46px;
  height: 46px;
  clip-path: polygon(0 0, 46% 0, 50% 44%, 55% 0, 100% 0, 73% 100%, 27% 100%);
  background: var(--accent);
  filter: drop-shadow(0 7px 20px rgba(255,70,85,.22));
}
.brand-title { font-weight: 950; letter-spacing: .13em; font-size: 20px; }
.brand-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.top-stats { display: flex; gap: 10px; }
.stat {
  min-width: 112px;
  background: rgba(14,25,30,.9);
  border: 1px solid var(--line);
  padding: 9px 13px;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.stat span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.stat strong { display: block; margin-top: 2px; font-size: 18px; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(440px, .82fr);
  gap: 18px;
  align-items: stretch;
}
.panel {
  background: linear-gradient(180deg, rgba(18,30,36,.985), rgba(10,18,22,.985));
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
  border-radius: 18px;
  overflow: hidden;
}
.scene-card { padding: 20px; }
.guess-card { padding: 20px; display: flex; flex-direction: column; min-height: 720px; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.eyebrow { color: var(--accent); font-weight: 850; letter-spacing: .15em; font-size: 11px; }
h1, h2 { margin: 4px 0 0; line-height: 1.05; }
h1 { font-size: clamp(23px, 2.4vw, 38px); }
h2 { font-size: 22px; }
.difficulty {
  border: 1px solid rgba(255,70,85,.38);
  color: #ff8994;
  background: rgba(255,70,85,.08);
  border-radius: 99px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .11em;
}
.scene-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  min-height: 590px;
  background: #0a1115;
  border: 1px solid rgba(255,255,255,.06);
}
.scene-image { display: block; width: 100%; height: 100%; min-height: 590px; object-fit: cover; }
.scene-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 56px 18px 14px;
  background: linear-gradient(transparent, rgba(3,7,9,.8));
  color: rgba(255,255,255,.55);
  font-size: 10px;
  letter-spacing: .16em;
}
.scene-top-chip {
  position: absolute;
  top: 14px;
  left: 14px;
  border: 1px solid rgba(255,255,255,.17);
  background: rgba(4,10,13,.72);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}
.hint-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.hint-box { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.hint-label { color: #d9e2e5; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }

.guess-head { margin-bottom: 14px; }
.guess-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.guess-copy { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 9px 0 0; max-width: 520px; }
.step-pill {
  display: grid;
  place-items: center;
  width: 34px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(255,70,85,.35);
  color: #ff9aa3;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.world-step { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.world-map-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 534;
  min-height: 340px;
  border-radius: 15px;
  overflow: visible;
  background: #0b1e26;
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 70px rgba(0,0,0,.25);
}
.world-map-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 14px;
  filter: saturate(.7) brightness(.58) contrast(1.22) hue-rotate(136deg);
}
.world-map-vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(6,15,19,.1), rgba(5,12,15,.26)),
    radial-gradient(circle at center, transparent 48%, rgba(0,0,0,.34) 100%);
}
.world-map-shell::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 12.5% 16.66%;
  mix-blend-mode: overlay;
}
.world-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 3;
  color: rgba(255,255,255,.48);
  font-size: 9px;
  letter-spacing: .14em;
  pointer-events: none;
}
.world-pins { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.map-pin-wrap {
  --pin-x: 50%;
  --pin-y: 50%;
  position: absolute;
  left: var(--pin-x);
  top: var(--pin-y);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  z-index: 2;
}
.map-pin-wrap:hover,
.map-pin-wrap:focus-within { z-index: 20; }
.map-pin {
  position: relative;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: transparent;
  outline: none;
  /* ВАЖНО: хитбокс всегда остаётся ровно 20×20 px. */
}
.map-pin::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* Красный круг + белая центральная точка рисуются одним слоем. */
  background: radial-gradient(circle, #fff 0 29%, var(--accent) 31% 100%);
  box-shadow: 0 0 0 4px rgba(255,70,85,.17), 0 3px 12px rgba(0,0,0,.58);
  transition: transform .16s ease, box-shadow .16s ease;
  pointer-events: none;
}
.map-pin::after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 1px solid rgba(255,70,85,.38);
  border-radius: 50%;
  animation: pulse 2.2s infinite ease-out;
  /* Пульсирующая обводка не участвует в наведении/клике. */
  pointer-events: none;
}
.map-pin:hover::before,
.map-pin:focus-visible::before {
  transform: scale(1.18);
  box-shadow: 0 0 0 6px rgba(255,70,85,.21), 0 3px 16px rgba(0,0,0,.65);
}
@keyframes pulse {
  0% { transform: scale(.65); opacity: .8; }
  70%, 100% { transform: scale(1.45); opacity: 0; }
}

.map-tooltip {
  position: absolute;
  width: 226px;
  left: 50%;
  bottom: calc(100% + 16px);
  transform: translate(-50%, 8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
  padding: 0;
  border-radius: 13px;
  overflow: hidden;
  background: #0b151a;
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 18px 38px rgba(0,0,0,.55);
  cursor: pointer;
  color: white;
  text-align: left;
  pointer-events: auto;
}
.map-pin-wrap[data-tooltip="below"] .map-tooltip { bottom: auto; top: calc(100% + 16px); }
.map-pin-wrap[data-tooltip="left"] .map-tooltip { left: auto; right: calc(100% + 16px); bottom: 50%; transform: translate(8px, 50%); }
.map-pin-wrap[data-tooltip="right"] .map-tooltip { left: calc(100% + 16px); bottom: 50%; transform: translate(-8px, 50%); }
.map-pin-wrap:hover .map-tooltip,
.map-pin-wrap:focus-within .map-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.map-pin-wrap[data-tooltip="left"]:hover .map-tooltip,
.map-pin-wrap[data-tooltip="left"]:focus-within .map-tooltip,
.map-pin-wrap[data-tooltip="right"]:hover .map-tooltip,
.map-pin-wrap[data-tooltip="right"]:focus-within .map-tooltip { transform: translate(0, 50%); }
.tooltip-image-wrap { height: 104px; background: #071014; position: relative; overflow: hidden; }
.tooltip-image { width: 100%; height: 100%; display: block; object-fit: cover; opacity: .86; transition: transform .22s ease; }
.map-tooltip:hover .tooltip-image { transform: scale(1.035); }
.tooltip-image-wrap::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(4,9,11,.8)); }
.tooltip-content { padding: 11px 12px 12px; }
.tooltip-topline { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.tooltip-name { font-size: 16px; font-weight: 950; letter-spacing: .035em; text-transform: uppercase; }
.tooltip-open { color: var(--accent); font-size: 18px; line-height: 1; }
.tooltip-coords { display: block; color: #94a8af; font-size: 10px; margin-top: 5px; letter-spacing: .08em; }
.tooltip-caption { display: block; color: #d1dcdf; font-size: 11px; margin-top: 8px; }

.map-help-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}
.map-help-row span { display: inline-flex; gap: 7px; align-items: center; }
.map-help-row strong { color: #dce5e7; font-size: 11px; font-weight: 700; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255,70,85,.15); }

.local-step { flex: 1; }
.local-step-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.back-map-btn {
  border: 1px solid var(--line);
  background: #0d171c;
  color: #c8d4d8;
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 10px;
  letter-spacing: .08em;
  font-weight: 850;
  cursor: pointer;
}
.back-map-btn:hover { border-color: var(--line-strong); color: white; }
.selected-map-meta { text-align: right; }
.selected-map-meta span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
.selected-map-meta strong { display: block; margin-top: 2px; font-size: 15px; letter-spacing: .07em; }

.minimap-shell, .result-map-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 15px;
  overflow: hidden;
  background: #081013;
  border: 1px solid rgba(255,255,255,.1);
  user-select: none;
}
.minimap-shell { cursor: crosshair; }
.minimap-image, .result-map-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 25% 25%;
  pointer-events: none;
}
.map-crosshair { position: absolute; pointer-events: none; opacity: .16; background: white; }
.map-crosshair.horizontal { left: 0; right: 0; top: 50%; height: 1px; }
.map-crosshair.vertical { top: 0; bottom: 0; left: 50%; width: 1px; }
.minimap-instruction {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
  background: rgba(4,10,13,.78);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(6px);
  padding: 7px 9px;
  border-radius: 8px;
  color: rgba(255,255,255,.73);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  transition: opacity .15s ease;
}
.minimap-shell.has-guess .minimap-instruction { opacity: 0; }
.guess-marker {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: none;
  background: var(--accent);
  border: 3px solid white;
  box-shadow: 0 0 0 6px rgba(255,70,85,.18), 0 4px 12px rgba(0,0,0,.5);
}
.guess-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 8px;
  transform: translateX(-50%);
  background: white;
}
.guess-coordinates {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  border-top: 0;
  padding: 10px 12px;
  border-radius: 0 0 11px 11px;
  margin: -8px 8px 0;
  background: rgba(7,14,17,.8);
}
.guess-coordinates span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.guess-coordinates strong { color: #dde7e9; font-size: 11px; letter-spacing: .06em; }

.primary-btn, .secondary-btn {
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .065em;
  transition: .15s ease;
}
.primary-btn {
  width: 100%;
  margin-top: 15px;
  padding: 15px 16px;
  background: var(--accent);
  color: white;
  box-shadow: 0 9px 24px rgba(255,70,85,.14);
}
.primary-btn:hover:not(:disabled) { background: #ff5865; transform: translateY(-1px); }
.primary-btn:active:not(:disabled) { transform: translateY(0); }
.primary-btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.secondary-btn { background: #17252c; border: 1px solid var(--line); color: #d9e1e4; padding: 10px 14px; }
.secondary-btn:hover:not(:disabled) { border-color: var(--line-strong); }
.secondary-btn:disabled { opacity: .35; cursor: not-allowed; }
.guess-card > .primary-btn { margin-top: auto; }

/* Footer */
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding: 22px 8px 0;
  color: rgba(174, 189, 193, .64);
  font-size: 11px;
  text-align: center;
}
.site-footer p { margin: 0; }
.site-footer a {
  color: rgba(242, 245, 244, .82);
  font-weight: 800;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 70, 85, .5);
  transition: color .15s ease, border-color .15s ease;
}
.site-footer a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Result popup */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(1,6,8,.76);
  backdrop-filter: blur(12px);
  animation: fadeIn .18s ease both;
}
.result-modal {
  position: relative;
  width: min(760px, 100%);
  max-height: min(880px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 18px;
  background: linear-gradient(180deg, #111e24, #091216);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 34px 100px rgba(0,0,0,.62);
  padding: 25px;
  animation: modalIn .22s cubic-bezier(.2,.8,.2,1) both;
}
.modal-accent-line { position: absolute; left: 25px; right: 25px; top: 0; height: 3px; background: linear-gradient(90deg, var(--accent), transparent 70%); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(15px) scale(.98); } to { opacity: 1; transform: none; } }
.result-modal-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.result-modal-head h2 { font-size: 32px; margin-top: 7px; }
.round-score-big { color: white; font-size: clamp(38px, 7vw, 62px); font-weight: 950; line-height: .9; letter-spacing: -.035em; }
.result-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 20px 0 12px; }
.result-stat-card { background: #0b171c; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; min-width: 0; }
.result-stat-card span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .075em; }
.result-stat-card strong { display: block; margin-top: 5px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-map-shell { max-height: 440px; aspect-ratio: 1 / 1; width: min(440px, 100%); margin: 0 auto; }
.result-guess-marker, .result-correct-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  border: 3px solid white;
  box-shadow: 0 0 0 6px rgba(0,0,0,.2), 0 4px 14px rgba(0,0,0,.5);
}
.result-guess-marker { background: var(--accent); }
.result-correct-marker { background: var(--good); }
.result-line { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }
.result-line line { stroke: white; stroke-width: 2; stroke-dasharray: 6 5; opacity: .85; vector-effect: non-scaling-stroke; }
.result-map-note {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 8;
  width: calc(100% - 24px);
  padding: 9px 10px;
  text-align: center;
  border-radius: 9px;
  background: rgba(5,12,15,.86);
  border: 1px solid rgba(255,255,255,.12);
  color: #dce6e8;
  font-size: 11px;
  backdrop-filter: blur(7px);
}
.marker-legend { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 10px; }
.marker-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-marker { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-marker.guess { background: var(--accent); }
.legend-marker.correct { background: var(--good); }
.modal-action { margin-top: 18px; }

.final-header { text-align: center; padding: 8px 0 4px; }
.final-header h2 { font-size: 34px; margin-top: 8px; }
.final-score { font-size: 78px; font-weight: 950; line-height: 1; margin: 18px 0 12px; letter-spacing: -.045em; }
.rank-pill { display: inline-flex; padding: 8px 17px; border-radius: 99px; background: rgba(255,70,85,.12); border: 1px solid rgba(255,70,85,.35); font-weight: 900; letter-spacing: .12em; }
.final-max { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; margin-top: 9px; }
.round-list { margin: 22px 0 4px; display: grid; gap: 8px; }
.round-item { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #0b171c; }
.round-index { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.05); color: #aebdc1; font-size: 10px; font-weight: 900; }
.round-item strong { font-size: 13px; }
.round-item small { display: block; color: var(--muted); margin-top: 3px; font-size: 10px; }
.round-item-score { font-size: 14px !important; }

@media (max-width: 1120px) {
  .game-layout { grid-template-columns: 1fr; }
  .guess-card { min-height: auto; }
  .world-map-shell { min-height: 0; }
  .scene-wrap, .scene-image { min-height: 430px; }
  .guess-card > .primary-btn { margin-top: 15px; }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 18px, 1560px); padding-top: 10px; }
  .topbar { align-items: flex-start; }
  .brand-subtitle { display: none; }
  .brand-mark { width: 39px; height: 39px; }
  .brand-title { font-size: 16px; }
  .top-stats { gap: 6px; }
  .stat { min-width: 78px; padding: 8px 9px; }
  .scene-card, .guess-card { padding: 13px; }
  .scene-wrap, .scene-image { min-height: 270px; }
  .hint-row { align-items: flex-start; }
  .world-label { display: none; }
  .map-tooltip { width: 190px; }
  .tooltip-image-wrap { height: 84px; }
  .minimap-instruction { white-space: normal; width: calc(100% - 24px); text-align: center; }
  .modal-backdrop { padding: 10px; }
  .result-modal { max-height: calc(100vh - 20px); padding: 18px; }
  .result-summary-grid { grid-template-columns: 1fr; }
  .result-modal-head { align-items: center; }
  .result-modal-head h2 { font-size: 25px; }
  .round-score-big { font-size: 40px; }
  .final-score { font-size: 58px; }
  .round-item { grid-template-columns: 36px minmax(0,1fr) auto; }
}

/* V3 navigation + loading */
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.nav-btn, .secondary-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: rgba(14,25,30,.9);
  color: #dfe8ea;
  text-decoration: none;
  border-radius: 11px;
  min-height: 42px;
  padding: 0 15px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
  transition: .15s ease;
}
.nav-btn:hover, .secondary-link-btn:hover { border-color: rgba(255,70,85,.55); color: white; transform: translateY(-1px); }
.loading-banner {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin: 36px auto;
  max-width: 700px;
  text-align: center;
  color: var(--muted);
  background: rgba(14,25,30,.9);
  line-height: 1.6;
}
.loading-banner.error { border-color: rgba(255,70,85,.4); color: #ffd6da; }
.loading-banner strong { color: white; }
.loading-banner small { color: var(--muted); }

.leaderboard-submit {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: #0b171c;
  border-radius: 13px;
  padding: 14px;
}
.leaderboard-submit > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.leaderboard-submit > div:first-child strong { font-size: 13px; }
.leaderboard-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin-top: 11px; }
.leaderboard-form input {
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: #071014;
  color: white;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  font: inherit;
}
.leaderboard-form input:focus { border-color: rgba(255,70,85,.65); box-shadow: 0 0 0 3px rgba(255,70,85,.1); }
.leaderboard-save-status { min-height: 18px; color: var(--muted); font-size: 11px; margin-top: 8px; }
.leaderboard-save-status.success { color: var(--good); }
.leaderboard-save-status.error { color: #ff9aa3; }
.final-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; margin-top: 14px; }
.final-actions .modal-action { margin-top: 0; }
.secondary-link-btn { min-height: 49px; }

@media (max-width: 680px) {
  .topbar-actions { align-items: flex-end; }
  .nav-btn { display: none; }
  .leaderboard-form, .final-actions { grid-template-columns: 1fr; }
  .leaderboard-submit > div:first-child { align-items: flex-start; flex-direction: column; gap: 4px; }
}

/* Discord OAuth */
.discord-auth { display:flex; align-items:center; min-height:42px; }
.discord-login-btn { display:inline-flex; align-items:center; justify-content:center; min-height:40px; padding:0 14px; border-radius:10px; border:1px solid rgba(88,101,242,.48); background:rgba(88,101,242,.13); color:#dfe2ff; text-decoration:none; font-size:11px; font-weight:900; letter-spacing:.035em; white-space:nowrap; transition:.16s ease; }
.discord-login-btn:hover { background:rgba(88,101,242,.23); border-color:rgba(112,123,255,.8); transform:translateY(-1px); }
.discord-login-btn.disabled { opacity:.48; pointer-events:none; filter:saturate(.5); }
.discord-user { display:flex; align-items:center; gap:9px; min-height:42px; padding:5px 7px 5px 6px; border:1px solid rgba(88,101,242,.28); border-radius:11px; background:rgba(88,101,242,.08); }
.discord-avatar { width:30px; height:30px; border-radius:50%; object-fit:cover; border:1px solid rgba(255,255,255,.13); }
.discord-user-copy { min-width:0; display:flex; flex-direction:column; line-height:1.08; }
.discord-user-copy span { color:#88949a; font-size:8px; font-weight:900; text-transform:uppercase; letter-spacing:.12em; }
.discord-user-copy strong { max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#eef3f5; font-size:11px; }
.discord-logout-btn { width:25px; height:25px; display:grid; place-items:center; border:0; border-radius:7px; color:#8c989d; background:transparent; cursor:pointer; font-size:17px; line-height:1; }
.discord-logout-btn:hover { color:#fff; background:rgba(255,255,255,.07); }
.leaderboard-submit small { display:block; margin-top:5px; color:var(--muted); line-height:1.45; font-size:11px; }

@media (max-width: 880px) {
  .topbar-actions .discord-auth { order:3; }
  .discord-user-copy strong { max-width:90px; }
}

/* =========================================================
   v4.1.6 — Mobile layout + touch map previews
   ========================================================= */

/* Explicit state used by game.js on touch devices. */
.map-pin-wrap.touch-preview { z-index: 60; }
.map-pin-wrap.touch-preview .map-pin::before {
  transform: scale(1.18);
  box-shadow: 0 0 0 6px rgba(255,70,85,.21), 0 3px 16px rgba(0,0,0,.65);
}
.map-pin-wrap.touch-preview .map-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.map-pin-wrap[data-tooltip="left"].touch-preview .map-tooltip,
.map-pin-wrap[data-tooltip="right"].touch-preview .map-tooltip {
  transform: translate(0, 50%);
}

@media (hover: none), (pointer: coarse) {
  /* On phones hover emulation must not leave random cards open. */
  .map-pin-wrap:hover .map-tooltip,
  .map-pin-wrap:focus-within .map-tooltip {
    opacity: 0;
    visibility: hidden;
  }
  .map-pin-wrap.touch-preview .map-tooltip,
  .map-pin-wrap.touch-preview:focus-within .map-tooltip {
    opacity: 1;
    visibility: visible;
  }

  .map-pin {
    touch-action: manipulation;
    -webkit-touch-callout: none;
  }

  /* The visible red circle and its hitbox remain the same size.
     The pulse is visual only and never intercepts a finger. */
  .map-pin::after { pointer-events: none; }

  /* A stable mobile preview card, independent of pin position.
     This prevents cards near the map edge from going off-screen. */
  .map-tooltip,
  .map-pin-wrap[data-tooltip="below"] .map-tooltip,
  .map-pin-wrap[data-tooltip="left"] .map-tooltip,
  .map-pin-wrap[data-tooltip="right"] .map-tooltip {
    position: fixed;
    z-index: 1200;
    left: 50%;
    right: auto;
    top: auto;
    bottom: max(14px, env(safe-area-inset-bottom));
    width: min(340px, calc(100vw - 24px));
    transform: translate(-50%, 18px);
    border-radius: 15px;
    box-shadow: 0 22px 65px rgba(0,0,0,.72);
  }

  .map-pin-wrap.touch-preview .map-tooltip,
  .map-pin-wrap[data-tooltip="below"].touch-preview .map-tooltip,
  .map-pin-wrap[data-tooltip="left"].touch-preview .map-tooltip,
  .map-pin-wrap[data-tooltip="right"].touch-preview .map-tooltip {
    transform: translate(-50%, 0);
  }

  .map-tooltip:active { transform: translate(-50%, 2px) !important; }
  .tooltip-caption::after { content: var(--tooltip-select-suffix); color: #ff8994; }
}

@media (max-width: 760px) {
  html { overflow-x: hidden; }
  body { overflow-x: hidden; }

  .app-shell {
    width: calc(100% - 12px);
    padding: 8px 0 calc(26px + env(safe-area-inset-bottom));
  }

  .topbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 9px 12px;
    margin-bottom: 10px;
  }

  .brand { gap: 9px; min-width: 0; }
  .brand-mark { width: 34px; height: 34px; flex: 0 0 34px; }
  .brand-title { font-size: 15px; letter-spacing: .1em; }
  .brand-subtitle { display: none; }

  .topbar-actions {
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 7px;
  }
  .topbar-actions .nav-btn { display: none; }
  .discord-auth { min-width: 0; flex: 0 1 auto; }
  .discord-login-btn { min-height: 42px; padding: 0 10px; font-size: 9px; }
  .discord-user { max-width: 145px; }
  .discord-user-copy strong { max-width: 76px; }

  .top-stats {
    min-width: 0;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 6px;
  }
  .stat {
    flex: 1 1 0;
    min-width: 0;
    max-width: 106px;
    padding: 7px 9px;
    border-radius: 10px;
  }
  .stat span { font-size: 8px; }
  .stat strong { font-size: 15px; }

  .loading-banner { margin: 16px auto; padding: 15px; }

  .game-layout { gap: 10px; }
  .panel { border-radius: 14px; }
  .scene-card, .guess-card { padding: 11px; }

  .panel-head { align-items: center; margin-bottom: 10px; gap: 8px; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: 23px; }
  h2 { font-size: 19px; }
  .difficulty { padding: 6px 8px; font-size: 9px; }

  .scene-wrap {
    min-height: 0;
    aspect-ratio: 16 / 9;
    border-radius: 11px;
  }
  .scene-image {
    min-height: 0;
    height: 100%;
    object-fit: cover;
  }
  .scene-top-chip { top: 9px; left: 9px; padding: 5px 7px; font-size: 8px; }
  .scene-overlay { padding: 36px 11px 9px; font-size: 8px; }

  .hint-row {
    align-items: stretch;
    gap: 8px;
    margin-top: 9px;
  }
  .hint-box { flex: 1; font-size: 11px; }
  .hint-label { font-size: 9px; }
  .hint-row .secondary-btn { flex: 0 0 auto; min-height: 42px; padding: 8px 10px; font-size: 10px; }

  .guess-card { min-height: 0; }
  .guess-head { margin-bottom: 10px; }
  .guess-title-row { gap: 8px; }
  .guess-copy { margin-top: 6px; font-size: 11px; line-height: 1.45; }
  .step-pill { width: 31px; height: 28px; font-size: 10px; }

  .world-map-shell {
    min-height: 0;
    width: 100%;
    aspect-ratio: 800 / 534;
    border-radius: 12px;
  }
  .world-map-image, .world-map-vignette, .world-map-shell::after { border-radius: 11px; }
  .world-label { display: none; }

  .map-help-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    font-size: 9px;
  }
  .map-help-row strong { width: 100%; text-align: left; font-size: 9px; line-height: 1.35; }

  .local-step-head { margin-bottom: 8px; }
  .back-map-btn { padding: 8px 9px; font-size: 9px; }
  .selected-map-meta strong { font-size: 13px; }

  .minimap-shell, .result-map-shell { border-radius: 12px; }
  .minimap-instruction {
    bottom: 9px;
    width: calc(100% - 18px);
    padding: 6px 8px;
    white-space: normal;
    font-size: 8px;
    text-align: center;
  }
  .guess-coordinates { margin: -6px 6px 0; padding: 9px 10px; }
  .guess-coordinates span, .guess-coordinates strong { font-size: 9px; }

  .primary-btn { min-height: 49px; padding: 13px 14px; font-size: 12px; }
  .secondary-btn { min-height: 42px; }

  .site-footer { padding-top: 16px; font-size: 9px; gap: 7px 12px; }
  .site-footer p { width: 100%; }

  /* Results become a bottom sheet on phones. */
  .modal-backdrop {
    padding: 0;
    place-items: end center;
    background: rgba(1,6,8,.79);
  }
  .result-modal {
    width: 100%;
    max-height: calc(100dvh - 8px);
    padding: 17px 14px calc(15px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .modal-accent-line { left: 14px; right: 14px; }
  .result-modal-head { align-items: center; gap: 10px; }
  .result-modal-head h2 { font-size: 23px; }
  .round-score-big { font-size: 38px; }
  .result-summary-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 5px; margin: 13px 0 9px; }
  .result-stat-card { padding: 8px; border-radius: 9px; }
  .result-stat-card span { font-size: 7px; }
  .result-stat-card strong { font-size: 11px; }
  .result-map-shell { width: min(72dvh, 100%); }
  .result-map-note { bottom: 8px; font-size: 9px; padding: 7px 8px; }
  .marker-legend { margin-top: 7px; gap: 12px; font-size: 9px; }
  .modal-action { margin-top: 12px; }

  .final-header h2 { font-size: 26px; }
  .final-score { font-size: 54px; margin: 12px 0 9px; }
  .round-list { margin-top: 15px; }
  .round-item { grid-template-columns: 32px minmax(0,1fr) auto; gap: 7px; padding: 8px; }
  .round-index { width: 30px; height: 30px; }
  .round-item strong { font-size: 11px; }
  .round-item small { font-size: 9px; }
  .round-item-score { font-size: 12px !important; }
  .leaderboard-submit { margin-top: 12px; padding: 11px; }
  .leaderboard-form, .final-actions { grid-template-columns: 1fr; }
  .secondary-link-btn { min-height: 46px; }
}

@media (max-width: 390px) {
  .app-shell { width: calc(100% - 8px); }
  .brand-mark { width: 30px; height: 30px; flex-basis: 30px; }
  .brand-title { font-size: 13px; }
  .discord-login-btn { padding: 0 8px; font-size: 8px; }
  .stat { padding-inline: 7px; }
  .scene-card, .guess-card { padding: 9px; }
  h1 { font-size: 21px; }
  h2 { font-size: 18px; }
  .result-summary-grid { grid-template-columns: 1fr; }
  .result-stat-card { display:flex; align-items:center; justify-content:space-between; gap:10px; }
  .result-stat-card strong { margin-top:0; }
}

/* v4.1.6 touch preview lives directly under <body>, so transformed pin wrappers
   cannot affect its positioning. */
.mobile-map-preview { display: none; }

@media (hover: none), (pointer: coarse) {
  /* Native per-pin tooltip is desktop-only on touch devices. */
  .map-pin-wrap .map-tooltip,
  .map-pin-wrap:hover .map-tooltip,
  .map-pin-wrap:focus-within .map-tooltip,
  .map-pin-wrap.touch-preview .map-tooltip {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .mobile-map-preview {
    position: fixed;
    display: block;
    z-index: 1400;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: min(340px, calc(100vw - 20px));
    padding: 0;
    overflow: hidden;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,.17);
    background: #0b151a;
    color: white;
    text-align: left;
    box-shadow: 0 24px 70px rgba(0,0,0,.72);
    opacity: 0;
    transform: translate(-50%, 18px) scale(.985);
    transition: opacity .16s ease, transform .16s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-map-preview[hidden] { display: none !important; }
  .mobile-map-preview.open { opacity: 1; transform: translate(-50%, 0) scale(1); }
  .mobile-map-preview:active { transform: translate(-50%, 2px) scale(.995); }
  .mobile-map-preview .tooltip-image-wrap { height: 118px; }
  .mobile-map-preview .tooltip-image { opacity: .9; }
  .mobile-map-preview .tooltip-caption { color: #ff9aa3; font-weight: 800; }
}

@media (max-width: 390px) and (hover: none), (max-width: 390px) and (pointer: coarse) {
  .mobile-map-preview { width: calc(100vw - 14px); }
  .mobile-map-preview .tooltip-image-wrap { height: 104px; }
}
