/* ═══════════════════════════════════════════════════════════
   QR Quest PoC-v2 — styl „Editorial premium"
   Jasne tło kość słoniowa, tusz zamiast bieli, hairline'y
   zamiast kart, serif systemowy w nagłówkach i treściach
   fabularnych, sans (system-ui) w etykietach CAPS.
   CTA zawsze czarne; akcent per gra (JS: --accent/--accent-rgb/
   --accent-dark z branding.accent) tylko w detalach.
   Skaner i mapa = ciemne wyspy (kamera / kafelki OSM).
   ═══════════════════════════════════════════════════════════ */

:root {
  /* motyw gry (nadpisywany z JS) */
  --accent: #0d9488;
  --accent-rgb: 13, 148, 136;
  --accent-dark: rgb(8, 89, 82);

  /* powierzchnie i tekst — jasny papier + tusz */
  --bg: #faf9f6;
  --ink: 28, 27, 24;                       /* triplet: rgba(var(--ink), x) */
  --text-hi: rgb(var(--ink));              /* nagłówki, kluczowe dane */
  --text: #44403a;                         /* tekst podstawowy */
  --text-dim: #5f5b52;                     /* drugorzędny */
  --text-faint: #6f6b62;                   /* etykiety, placeholdery — AA na jasnym tle (gra plenerowa) */
  --line: #e3e0d8;                         /* hairline'y */
  --line-soft: #eeece5;                    /* separatory list */
  --line-strong: rgb(var(--ink));          /* ramki editorial */
  --surface-1: #ffffff;                    /* pola formularzy */
  --surface-2: #f3f1ea;                    /* wyróżnienia (paper tint) */
  --danger: #b3542e;
  --danger-rgb: 179, 84, 46;
  --success: #3f6212;

  /* typografia — --font-display nadpisuje JS wg branding.style/font gry */
  --font-display: 'Iowan Old Style', 'Palatino Nova', Palatino, Georgia, serif;
  --serif: var(--font-display);
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fs-xs: 0.72rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.75rem;
  --fs-display: 2.4rem;
  --ls-caps: 0.18em;
  --ls-caps-wide: 0.25em;

  /* promienie — editorial, ostro */
  --r-sm: 2px;
  --r-md: 3px;
  --r-lg: 3px;
}

/* ─── Style wizualne gry (branding.style; JS ustawia data-style na <html>) ───
   elegancki = wartości bazowe :root (dotychczasowy editorial).            */

:root[data-style="nowoczesny"] {
  --bg: #f3f5f9;                /* chłodny, techniczny papier */
  --surface-2: #e9edf3;
  --line: #d7dce5;
  --line-soft: #e4e8ef;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --ls-caps: 0.14em;
  --ls-caps-wide: 0.2em;
}

:root[data-style="zabawny"] {
  --bg: #fdf3e0;                /* słoneczny, cukierkowy papier */
  --surface-2: #f9ead1;
  --line: #e9d6b4;
  --line-soft: #f2e4cb;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 26px;
  --ls-caps: 0.08em;            /* mniej sztywne wersaliki */
  --ls-caps-wide: 0.12em;
}

/* ─── Tryb ciemny per gra (branding.mode; JS ustawia data-mode na <html>) ───
   Cała paleta płynie przez zmienne, więc wystarczy odwrócić tokeny.       */
:root[data-mode="dark"] {
  --bg: #16150f;
  --ink: 240, 237, 228;                    /* „tusz" staje się jasny */
  --text: #cfcabe;
  --text-dim: #a8a396;
  --text-faint: #94907f;
  --line: #37342b;
  --line-soft: #2b2922;
  --surface-1: #201e17;
  --surface-2: #26241b;
  --danger: #e0805c;
  --success: #9bc054;
}
:root[data-mode="dark"][data-style="nowoczesny"] {
  --bg: #131519;
  --surface-1: #1c1f24;
  --surface-2: #21242b;
  --line: #32363e;
  --line-soft: #282b31;
}
:root[data-mode="dark"][data-style="zabawny"] {
  --bg: #1c1712;
  --surface-1: #262019;
  --surface-2: #2c251c;
  --line: #41382b;
  --line-soft: #332c21;
}

/* ─── Sygnatury stylów ──────────────────────────────────────
   To, co odróżnia style na pierwszy rzut oka: kształt CTA,
   pola, quiz, pasek postępu, sygnet, ramki zdjęć. Wszystko
   płynie z --accent gry. elegancki = editorial bazowy + kilka
   własnych detali (ostre CTA, pinstripe).                    */

/* ELEGANCKI — pełny editorial: CTA idealnie ostre, szerokie
   wersaliki, pinstripe w kolorze papieru wewnątrz czarnego CTA */
:root[data-style="elegancki"] .btn {
  border-radius: 0;
  letter-spacing: 0.2em;
}
:root[data-style="elegancki"] .btn-primary {
  /* podwójna rama jak w albumie: tusz / papier / tusz */
  box-shadow: inset 0 0 0 2px rgb(var(--ink)), inset 0 0 0 3.5px var(--bg);
}

/* NOWOCZESNY — pigułkowe CTA z gradientem akcentu, karty
   z miękkim cieniem, pola wypełnione zamiast podkreśleń */
:root[data-style="nowoczesny"] .btn {
  border-radius: 999px;
  letter-spacing: 0.08em;
  font-weight: 700;
}
:root[data-style="nowoczesny"] .btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(var(--accent-rgb), 0.7);
}
:root[data-style="nowoczesny"] .btn-secondary { border-width: 2px; }
:root[data-style="nowoczesny"] .game-display {
  font-weight: 800;
  letter-spacing: -0.02em;
}
:root[data-style="nowoczesny"] .home-icon,
:root[data-style="nowoczesny"] .brand-logo {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.14);
}
:root[data-style="nowoczesny"] .text-input,
:root[data-style="nowoczesny"] .challenge-input,
:root[data-style="nowoczesny"] .taskqr-manual-input {
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 16px;
}
:root[data-style="nowoczesny"] .text-input:focus,
:root[data-style="nowoczesny"] .challenge-input:focus,
:root[data-style="nowoczesny"] .taskqr-manual-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}
:root[data-style="nowoczesny"] .quiz-options { gap: 10px; }
:root[data-style="nowoczesny"] .quiz-option {
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
:root[data-style="nowoczesny"] .quiz-option.selected {
  color: var(--text-hi);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
:root[data-style="nowoczesny"] .progress-bar {
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line-soft);
}
:root[data-style="nowoczesny"] .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
}
:root[data-style="nowoczesny"] .desc-card {
  background: var(--surface-1);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
:root[data-style="nowoczesny"] .hint-btn {
  border: 1.5px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}
:root[data-style="nowoczesny"] .hint-revealed {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
}
:root[data-style="nowoczesny"] .task-image {
  border: none;
  border-radius: var(--r-lg);
  box-shadow: 0 10px 24px -12px rgba(15, 23, 42, 0.35);
}

/* ZABAWNY — naklejki: grube kontury tuszem, twarde odsadzone
   cienie, CTA bez wersalików, cukierkowy pasek postępu */
:root[data-style="zabawny"] .btn {
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--fs-base);
  font-weight: 700;
  border-radius: var(--r-md);
}
:root[data-style="zabawny"] .btn-primary {
  background: var(--accent);
  color: #fff;
  border: 2px solid rgb(var(--ink));
  box-shadow: 4px 4px 0 rgb(var(--ink));
}
:root[data-style="zabawny"] .btn-primary:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 rgb(var(--ink));
  opacity: 1;
}
:root[data-style="zabawny"] .btn-secondary {
  border: 2px solid rgb(var(--ink));
  box-shadow: 4px 4px 0 rgba(var(--ink), 0.18);
}
:root[data-style="zabawny"] .btn-secondary:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 rgba(var(--ink), 0.18);
  opacity: 1;
}
:root[data-style="zabawny"] .btn-ghost { border-width: 2px; }
:root[data-style="zabawny"] .game-display {
  font-weight: 800;
  transform: rotate(-1.5deg);   /* naklejka przyklejona lekko krzywo */
}
:root[data-style="zabawny"] .home-icon,
:root[data-style="zabawny"] .brand-logo {
  border: 3px solid rgb(var(--ink));
  box-shadow: 4px 4px 0 rgba(var(--accent-rgb), 0.85);
}
:root[data-style="zabawny"] .text-input,
:root[data-style="zabawny"] .challenge-input,
:root[data-style="zabawny"] .taskqr-manual-input {
  background: var(--surface-1);
  border: 2px solid rgb(var(--ink));
  border-radius: var(--r-md);
  padding: 12px 16px;
}
:root[data-style="zabawny"] .text-input:focus,
:root[data-style="zabawny"] .challenge-input:focus,
:root[data-style="zabawny"] .taskqr-manual-input:focus {
  border-color: var(--accent);
  box-shadow: 3px 3px 0 rgba(var(--accent-rgb), 0.35);
}
:root[data-style="zabawny"] .quiz-options { gap: 12px; }
:root[data-style="zabawny"] .quiz-option {
  background: var(--surface-1);
  border: 2px solid rgb(var(--ink));
  border-radius: var(--r-md);
  padding: 13px 16px;
  align-items: center;
  box-shadow: 3px 3px 0 rgba(var(--ink), 0.16);
}
:root[data-style="zabawny"] .quiz-option.selected {
  color: var(--text-hi);
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  box-shadow: 3px 3px 0 rgba(var(--accent-rgb), 0.55);
}
:root[data-style="zabawny"] .quiz-option-letter {
  width: 26px;
  height: 26px;
  border: 2px solid currentColor;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-style: normal;
  font-weight: 800;
  font-size: var(--fs-xs);
  text-transform: uppercase;
}
:root[data-style="zabawny"] .progress-bar {
  height: 12px;
  border: 2px solid rgb(var(--ink));
  border-radius: 999px;
  background: var(--surface-1);
  overflow: hidden;
}
:root[data-style="zabawny"] .progress-fill {
  height: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--accent) 0 10px,
    rgba(var(--accent-rgb), 0.55) 10px 20px
  );
}
:root[data-style="zabawny"] .desc-card {
  background: var(--surface-1);
  border: 2px solid rgb(var(--ink));
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: 4px 4px 0 rgba(var(--ink), 0.12);
}
:root[data-style="zabawny"] .hint-btn {
  border: 2px dashed var(--accent);
  border-radius: 999px;
}
:root[data-style="zabawny"] .hint-revealed {
  border: 2px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: var(--r-md);
}
:root[data-style="zabawny"] .task-image,
:root[data-style="zabawny"] .welcome-hero {
  border: 2px solid rgb(var(--ink));
  box-shadow: 5px 5px 0 rgba(var(--accent-rgb), 0.4);
}
:root[data-style="zabawny"] .task-image { transform: rotate(-0.8deg); }
:root[data-style="zabawny"] .tl::before {
  width: 2px;
  left: 4px;
  background: rgba(var(--ink), 0.22);
}
:root[data-style="zabawny"] .tl-dot { border: 2px solid rgb(var(--ink)); }

/* ─── Grafika zadania (task.image) ─── */
.task-image {
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 12px 0;
}
.task-image img {
  display: block;
  width: 100%;
  max-height: 38vh;
  object-fit: cover;
}

/* ─── Logo organizatora (white-label, branding.logo) ─── */
.brand-logo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.brand-logo img[hidden] { display: none; }  /* [hidden] musi wygrać z display:block */

/* ─── Blok organizatora na finiszu (finish.note / CTA) ─── */
.finish-org {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.finish-org-note {
  font-family: var(--serif);
  font-size: var(--fs-lg);
  font-style: italic;
  color: var(--text-hi);
  margin: 0;
}

/* ─── Header gry (branding.headerImage) ─── */
.welcome-hero {
  width: 100%;
  flex-shrink: 0;              /* rodzice bywają flex-column z overflow — nie zgniataj */
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 22px;
  border: 1px solid var(--line);
}
.welcome-hero img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
}
:root[data-style="elegancki"] .welcome-hero,
:root:not([data-style]) .welcome-hero {
  border: 1px solid var(--line-strong);   /* editorial: rama jak w albumie */
}

/* ─── Welcome z headerem: zdjęcie na spad, sygnet nachodzi kółkiem ───
   (klasę has-hero ustawia basic.js, gdy gra ma branding.headerImage)  */
:root .view.has-hero {
  padding: 0;                              /* zdjęcie wchodzi pod notch i na boki */
}
:root .view.has-hero .welcome-body {
  gap: 18px;
  justify-content: flex-start;             /* zdjęcie startuje od samej góry */
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
}
:root .view.has-hero .welcome-actions { margin-top: auto; }  /* CTA przy dole */
:root .view.has-hero .welcome-hero {
  margin: 0;
  border: none;                            /* spad = bez ramy, także w eleganckim */
  border-radius: 0;
  box-shadow: none;                        /* zabawny dodaje naklejkowy cień — nie na spadzie */
}
:root .view.has-hero .welcome-hero img {
  aspect-ratio: auto;
  height: 34vh;                            /* ~1/3 wysokości na mobile */
}
@media (min-width: 768px) {
  :root .view.has-hero .welcome-hero img { height: 26vh; }  /* ~1/4 na desktopie */
}
:root .view.has-hero .brand-intro {
  position: relative;
  z-index: 1;
  margin-top: -44px;                       /* sygnet (88px) w połowie na zdjęciu */
  padding: 0 22px;
}
:root .view.has-hero .welcome-actions { padding: 0 22px; }

/* większy tytuł gry na ekranie startowym */
.view[data-view="welcome"] .game-display {
  font-size: clamp(2.6rem, 9vw, 3.4rem);
  max-width: 380px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: 1.55;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text-hi); line-height: 1.2; font-family: var(--serif); font-weight: 600; }
h1 em, h2 em, .game-display em { font-style: italic; }

/* ── Etykiety CAPS (wspólny wzorzec editorial) ── */
.eyebrow {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps-wide);
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.eyebrow .acc { color: var(--accent); }
.eyebrow-right { color: var(--accent); display: inline-flex; align-items: center; gap: 8px; }

/* ── View dispatcher ── */
.view { display: none; position: fixed; inset: 0; flex-direction: column; }
.view.active { display: flex; }
.view-padded {
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 22px calc(env(safe-area-inset-bottom, 0px) + 20px);
  overflow-y: auto;
}

/* ── Przyciski ── */
.btn {
  border: none;
  border-radius: var(--r-md);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.2;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active:not(:disabled) { transform: scale(0.985); opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: rgb(var(--ink)); color: var(--bg); }
.btn-secondary {
  background: transparent;
  color: var(--text-hi);
  border: 1px solid rgb(var(--ink));
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-danger { background: var(--danger); color: #fff; }

/* ── Nagłówek widoku (back + tytuł-kicker) ── */
.view-header {
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 20px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.view-header h2 {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-faint);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.back-btn:active { background: var(--surface-2); }
.back-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ── Welcome / picker ── */
.welcome-body {
  flex: 1;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 26px;
  display: flex;
  flex-direction: column;
}
.home-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgb(var(--ink));
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-icon svg { width: 32px; height: 32px; fill: rgb(var(--ink)); }

.brand-eyebrow {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps-wide);
  color: var(--text-faint);
  margin-bottom: 12px;
}
.brand-eyebrow span { color: var(--accent); }

.brand-logo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1px solid rgb(var(--ink));
  background: var(--surface-1);
  color: rgb(var(--ink));
  box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.brand-logo svg { width: 46px; height: 46px; display: block; }

@media (prefers-reduced-motion: no-preference) {
  .view.active .brand-intro {
    animation: brand-in 0.55s ease both;
  }
  .view.active .brand-intro .brand-logo {
    animation: brand-in 0.55s ease 0.08s both;
  }
}
@keyframes brand-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* TYMCZASOWE: stopka ze skrótem do strefy admina (dev) */
.home-footer {
  padding-top: 18px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}
.admin-link {
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-faint);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding: 4px 2px;
}
.admin-link:active { color: var(--text-hi); border-bottom-color: rgb(var(--ink)); }

.game-display {
  font-family: var(--serif);
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: 1.1;
  max-width: 320px;
}

.welcome-body h1 {
  font-size: var(--fs-xl);
  font-weight: 600;
}
.welcome-body h1 span { color: var(--accent); }
.welcome-body .intro {
  color: var(--text-dim);
  font-size: var(--fs-sm);
  line-height: 1.6;
  max-width: 320px;
}

.welcome-actions { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.welcome-actions .btn { width: 100%; }

.game-picker { width: 100%; max-width: 380px; display: flex; flex-direction: column; }
.picker-divider {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps-wide);
  color: var(--text-faint);
  text-align: center;
  padding: 22px 0 8px;
}
.game-pick-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 16px 4px;
  text-align: left;
  cursor: pointer;
  color: var(--text-hi);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background 0.15s;
}
.game-pick-card:first-child { border-top: 1px solid var(--line); }
.game-pick-card:active { background: var(--surface-2); }
.game-pick-card .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.game-pick-card .info { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.game-pick-card .t { font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; }
.game-pick-card .s { font-size: var(--fs-xs); color: var(--text-faint); line-height: 1.5; }
.game-pick-card .arrow { color: var(--text-faint); font-size: var(--fs-lg); font-family: var(--serif); }

/* ── Nick ── */
.nick-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}
.nick-body h2 { font-size: var(--fs-xl); text-align: center; }
.nick-body p { color: var(--text-dim); font-size: var(--fs-sm); text-align: center; }

.text-input {
  width: 100%;
  padding: 14px 4px;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid rgb(var(--ink));
  border-radius: 0;
  color: var(--text-hi);
  font-size: var(--fs-lg);
  font-family: var(--serif);
  outline: none;
  text-align: center;
}
.text-input:focus { border-bottom-color: var(--accent); }
.text-input::placeholder { color: var(--text-faint); font-style: italic; }

.nick-actions { display: flex; gap: 12px; }
.nick-actions .btn { flex: 1; }

/* ── Briefing (strona książki) ── */
.briefing-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.briefing-greeting {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-faint);
}
.briefing-greeting span { color: var(--accent); }
.briefing-body h2 { font-size: var(--fs-display); line-height: 1.08; margin-top: 6px; }
.briefing-body h2::after {
  content: '';
  display: block;
  width: 36px;
  height: 1px;
  background: var(--accent);
  margin-top: 14px;
}
.briefing-section-label {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  margin-bottom: 10px;
  font-weight: 600;
}
.briefing-section p {
  color: var(--text);
  font-family: var(--serif);
  font-size: var(--fs-base);
  line-height: 1.7;
}
.briefing-section ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  counter-reset: howto;
}
.briefing-section ul li {
  position: relative;
  counter-increment: howto;
  padding: 9px 0 9px 34px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.briefing-section ul li:last-child { border-bottom: none; }
.briefing-section ul li::before {
  content: counter(howto, lower-roman) '.';
  position: absolute;
  left: 4px;
  top: 8px;
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-base);
  color: var(--accent);
}
.briefing-hint {
  padding: 13px 16px;
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 0;
  color: var(--text);
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.briefing-body .btn { width: 100%; margin-top: 4px; }

/* ── Lista zadań: nagłówek + oś podróży ── */
.tasks-header {
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 22px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tasks-header h2 { font-size: var(--fs-xl); line-height: 1.1; }
/* klasy starego nagłówka — zachowane do czasu Taska 3 */
.tasks-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nick-label { font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: var(--ls-caps); }
.nick-value { font-size: var(--fs-base); font-weight: 600; color: var(--text-hi); font-family: var(--serif); }
.tasks-header-right { display: flex; align-items: center; gap: 10px; }
.score {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.timer-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  background: transparent;
}
.timer-chip.limit { color: var(--accent); border-color: var(--accent); }
.timer-chip.danger { color: var(--danger); border-color: var(--danger); }
.map-open-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-hi);
  font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.map-open-btn:active { background: var(--surface-2); }

.progress { display: flex; flex-direction: column; gap: 6px; }
.progress-bar { position: relative; height: 1px; background: var(--line); overflow: visible; }
.progress-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  height: 1px; background: var(--accent);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-label {
  display: flex; justify-content: space-between;
  font-size: var(--fs-xs); color: var(--text-faint);
  text-transform: uppercase; letter-spacing: var(--ls-caps);
  font-variant-numeric: tabular-nums;
}
.progress-label .done { color: var(--accent); font-weight: 600; }

.tasks-list { flex: 1; overflow-y: auto; padding: 14px 22px 8px; }
.tasks-footer { padding: 10px 22px calc(env(safe-area-inset-bottom, 0px) + 14px); border-top: 1px solid var(--line); }
.tasks-footer .btn { width: 100%; }

/* ── Oś podróży (nowy układ listy — markup w Tasku 3) ── */
.tl { position: relative; padding-left: 22px; }
.tl::before {
  content: '';
  position: absolute;
  left: 5px; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--line);
}
.tl-item { position: relative; padding: 9px 0; }
.tl-item + .tl-item { border-top: 1px solid transparent; }
.tl-dot {
  position: absolute;
  left: -22px; top: 14px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--text-faint);
  box-sizing: border-box;
}
.tl-item.done-ok .tl-dot { background: var(--accent); border-color: var(--accent); }
.tl-item.done-fail .tl-dot { background: var(--danger); border-color: var(--danger); }
.tl-item.current .tl-dot {
  left: -24px; top: 12px;
  width: 15px; height: 15px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
.tl-item.done-ok, .tl-item.done-fail { opacity: 0.55; }
.tl-item.locked { opacity: 0.4; }
.tl-title { font-family: var(--serif); font-size: var(--fs-base); font-weight: 600; color: var(--text-hi); }
.tl-item.done-ok .tl-title, .tl-item.done-fail .tl-title { text-decoration: line-through; font-weight: 400; }
.tl-pts {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin-top: 2px;
}
.tl-item.done-fail .tl-pts { color: var(--danger); }
.tl-item.locked .tl-pts { color: var(--text-faint); }
.tl-kicker {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--accent);
  margin-bottom: 3px;
}
.tl-item.current .tl-title { font-size: var(--fs-lg); }
.tl-desc {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  line-height: 1.55;
  margin: 4px 0 10px;
}
.tl-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgb(var(--ink));
  color: var(--bg);
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 16px;
  cursor: pointer;
}
.tl-cta:active { opacity: 0.85; }
.tl-row { cursor: pointer; }
.tl-row:active .tl-title { color: var(--accent); }

.footer-links {
  display: flex;
  justify-content: center;
  gap: 22px;
}
.footer-link {
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-faint);
  cursor: pointer;
  padding: 8px 2px;
}
.footer-link:active { color: var(--text-hi); }
.footer-link.danger { color: var(--danger); }

/* ── Korpus zadania (quiz / challenge / taskqr / photo) ── */
.task-body {
  flex: 1;
  padding: 14px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}
.task-kicker {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--accent);
  margin-bottom: 8px;
}
.task-question {
  font-family: var(--serif);
  font-size: var(--fs-lg);
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-hi);
}
.task-attempts {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-top: 10px;
}
.task-footer { padding: 12px 22px calc(env(safe-area-inset-bottom, 0px) + 16px); }
.task-footer .btn { width: 100%; }

.quiz-options { display: flex; flex-direction: column; }
.quiz-option {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 4px;
  color: var(--text);
  font-size: var(--fs-base);
  font-family: var(--serif);
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.quiz-option:first-child { border-top: 1px solid var(--line-soft); }
.quiz-option:active { background: var(--surface-2); }
.quiz-option.selected { color: var(--text-hi); border-bottom-color: rgb(var(--ink)); }
.quiz-option-letter {
  width: auto; height: auto;
  background: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--text-faint);
  flex-shrink: 0;
  text-transform: lowercase;
}
.quiz-option.selected .quiz-option-letter { color: var(--accent); font-weight: 600; }

/* ── Challenge (tekst / liczba / zagadka) ── */
.challenge-input-wrap { display: flex; flex-direction: column; gap: 6px; }
.challenge-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--text-faint);
}
.challenge-input {
  width: 100%;
  padding: 12px 2px;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid rgb(var(--ink));
  border-radius: 0;
  color: var(--text-hi);
  font-size: var(--fs-lg);
  font-family: var(--serif);
  outline: none;
}
.challenge-input:focus { border-bottom-color: var(--accent); }
.challenge-input::placeholder { color: var(--text-faint); font-style: italic; font-size: var(--fs-base); }
.challenge-input.num { font-variant-numeric: tabular-nums; text-align: center; letter-spacing: 0.08em; font-family: var(--sans); }

/* ── Podpowiedzi (przypisy z marginesu) ── */
.hints-box { display: flex; flex-direction: column; gap: 10px; }
.hint-btn {
  background: transparent;
  border: 1px dashed var(--accent);
  border-radius: var(--r-md);
  padding: 12px 16px;
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hint-btn:active { background: var(--surface-2); }
.hint-btn .cost { color: var(--danger); font-variant-numeric: tabular-nums; }
.hint-revealed {
  padding: 12px 16px;
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 0;
  color: var(--text);
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.hint-revealed .hint-tag {
  font-family: var(--sans);
  font-style: normal;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--accent);
  font-weight: 600;
  display: block;
  margin-bottom: 5px;
}

/* ── Zadanie QR (intro) ── */
.taskqr-body { flex: 1; padding: 14px 22px 20px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.desc-card { background: transparent; border: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 2px; }
.desc-card .label { font-size: var(--fs-xs); color: var(--accent); text-transform: uppercase; letter-spacing: var(--ls-caps); font-weight: 600; margin-bottom: 8px; }
.desc-card .text { font-family: var(--serif); font-size: var(--fs-base); line-height: 1.65; color: var(--text-hi); }
.taskqr-scan-btn { padding: 18px !important; }
.taskqr-scan-btn svg { width: 20px; height: 20px; fill: currentColor; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--ls-caps); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.taskqr-manual-label { font-size: var(--fs-sm); color: var(--text-dim); margin-bottom: 8px; }
.taskqr-manual-input {
  width: 100%;
  padding: 14px 4px;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid rgb(var(--ink));
  border-radius: 0;
  color: var(--text-hi);
  font-size: var(--fs-lg);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  margin-bottom: 12px;
}
.taskqr-manual-input:focus { border-bottom-color: var(--accent); }
.taskqr-manual-input::placeholder { color: var(--text-faint); letter-spacing: normal; text-transform: none; font-family: var(--sans); font-size: var(--fs-sm); }

/* ── Foto-misja ── */
.photo-body { flex: 1; padding: 14px 22px 20px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.photo-preview-wrap {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-preview-wrap img { width: 100%; max-height: 45vh; object-fit: contain; display: block; }
.photo-placeholder { padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: var(--fs-sm); font-family: var(--serif); font-style: italic; line-height: 1.6; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.photo-placeholder .cam { font-size: 2rem; }
.photo-actions { display: flex; gap: 10px; }
.photo-actions .btn { flex: 1; }

/* ═══ CIEMNA WYSPA: Skaner ═══ */
.scan-camera-wrap { position: relative; flex: 1; overflow: hidden; background: #060708; }
#reader { width: 100%; height: 100%; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover !important; border: none !important; }
#reader canvas { position: absolute !important; opacity: 0 !important; pointer-events: none !important; }
#reader br, #reader img[alt="Info icon"], #reader a[href*="scanapp"], #reader span { display: none !important; }
.overlay { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.overlay::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at center, transparent 120px, rgba(0, 0, 0, 0.55) 180px); }
.scan-frame { position: absolute; top: 50%; left: 50%; width: 260px; height: 260px; transform: translate(-50%, -55%); }
.corner { position: absolute; width: 30px; height: 30px; }
.corner::before, .corner::after { content: ''; position: absolute; background: #fff; }
.corner--tl { top: 0; left: 0; }
.corner--tl::before { top: 0; left: 0; width: 30px; height: 2px; }
.corner--tl::after  { top: 0; left: 0; width: 2px; height: 30px; }
.corner--tr { top: 0; right: 0; }
.corner--tr::before { top: 0; right: 0; width: 30px; height: 2px; }
.corner--tr::after  { top: 0; right: 0; width: 2px; height: 30px; }
.corner--bl { bottom: 0; left: 0; }
.corner--bl::before { bottom: 0; left: 0; width: 30px; height: 2px; }
.corner--bl::after  { bottom: 0; left: 0; width: 2px; height: 30px; }
.corner--br { bottom: 0; right: 0; }
.corner--br::before { bottom: 0; right: 0; width: 30px; height: 2px; }
.corner--br::after  { bottom: 0; right: 0; width: 2px; height: 30px; }
.scan-line {
  position: absolute; left: 8px; right: 8px; height: 1.5px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: scanMove 2.5s ease-in-out infinite;
}
@keyframes scanMove { 0%, 100% { top: 8px; opacity: 0.4; } 50% { top: calc(100% - 10px); opacity: 1; } }
.scan-top-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top, 12px) + 12px) 16px 16px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent);
  display: flex; align-items: center; gap: 12px;
}
.scan-top-bar .back-btn { background: rgba(0, 0, 0, 0.4); border-color: rgba(255, 255, 255, 0.2); color: #fff; }
.scan-top-bar .title {
  flex: 1; text-align: center;
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: var(--ls-caps);
  color: #fff; padding-right: 40px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scan-top-bar .title span { color: #fff; opacity: 0.7; }
.scan-bottom-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  padding: 16px 20px calc(env(safe-area-inset-bottom, 12px) + 16px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  display: flex; flex-direction: column; gap: 12px;
}
.scan-bottom-actions { display: flex; justify-content: center; gap: 24px; }
.tool-btn {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: #fff; font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.15s; pointer-events: auto;
}
.tool-btn:active { transform: scale(0.9); }
.tool-btn.active { background: #fff; border-color: #fff; color: #0a0a0a; }
.tool-btn svg { width: 22px; height: 22px; fill: currentColor; }
.manual-token { display: flex; flex-direction: column; gap: 8px; }
.manual-token-toggle {
  background: none; border: none; color: rgba(255, 255, 255, 0.8);
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: var(--ls-caps);
  font-family: var(--sans); cursor: pointer; padding: 10px;
  text-decoration: underline; text-underline-offset: 3px; align-self: center;
}
.manual-token-form { display: none; gap: 8px; }
.manual-token-form.visible { display: flex; }
.manual-token-form input {
  flex: 1; padding: 12px 14px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25); border-radius: var(--r-sm);
  color: #fff; font-size: var(--fs-sm); font-family: inherit; outline: none;
}
.manual-token-form button {
  padding: 12px 18px; background: #fff; color: #0a0a0a;
  border: none; border-radius: var(--r-sm); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--fs-xs);
  cursor: pointer; font-family: var(--sans);
}
#scan-loading {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #060708; transition: opacity 0.4s;
}
#scan-loading.hidden { opacity: 0; pointer-events: none; }
.loader {
  width: 36px; height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#scan-loading p { color: rgba(255, 255, 255, 0.6); font-size: var(--fs-sm); }
#scan-camera-error {
  position: absolute; inset: 0; z-index: 40; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 32px; background: var(--bg); text-align: center;
}
#scan-camera-error.visible { display: flex; }
.error-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: transparent; border: 1px solid var(--danger);
  display: flex; align-items: center; justify-content: center; margin-bottom: 20px;
}
.error-icon svg { width: 26px; height: 26px; fill: var(--danger); }
#scan-camera-error h2 { margin-bottom: 12px; font-size: var(--fs-lg); }
#scan-camera-error p { color: var(--text-dim); line-height: 1.6; font-size: var(--fs-sm); max-width: 320px; }
#scan-perm-denied {
  position: absolute; inset: 0; z-index: 45; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg); overflow-y: auto;
}
#scan-perm-denied.visible { display: flex; }
#scan-perm-denied .panel { max-width: 360px; width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
#scan-perm-denied h2 { font-size: var(--fs-lg); }
#scan-perm-denied .lead { color: var(--text-dim); line-height: 1.6; font-size: var(--fs-sm); }
#scan-perm-denied .steps { background: var(--surface-2); border: none; border-radius: var(--r-md); padding: 14px 18px; text-align: left; width: 100%; }
#scan-perm-denied .steps-title { font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: var(--ls-caps); font-weight: 600; margin-bottom: 10px; }
#scan-perm-denied ol { padding-left: 20px; color: var(--text); font-size: var(--fs-sm); line-height: 1.6; display: flex; flex-direction: column; gap: 6px; }
#scan-perm-denied ol code { background: rgba(var(--accent-rgb), 0.12); color: var(--accent-dark); padding: 1px 6px; border-radius: 3px; font-size: 0.8em; }
#scan-perm-denied .platform-tabs { display: flex; gap: 6px; width: 100%; }
#scan-perm-denied .platform-tabs button {
  flex: 1; padding: 9px 10px;
  background: transparent; border: 1px solid var(--line);
  color: var(--text-dim); border-radius: var(--r-sm);
  font-family: var(--sans); font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
}
#scan-perm-denied .platform-tabs button.active { border-color: rgb(var(--ink)); color: var(--text-hi); }
#scan-perm-denied .actions { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 4px; }
#scan-perm-denied .actions .btn { width: 100%; }

/* ═══ CIEMNA WYSPA: Mapa ═══ */
.map-wrap { position: relative; flex: 1; background: #101114; }
#map-container { position: absolute; inset: 0; }
.map-top-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500;
  padding: calc(env(safe-area-inset-top, 12px) + 12px) 16px 16px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
  display: flex; align-items: center; gap: 12px; pointer-events: none;
}
.map-top-bar .back-btn { pointer-events: auto; background: rgba(0, 0, 0, 0.55); border-color: rgba(255,255,255,0.2); color: #fff; }
.map-top-bar .title {
  flex: 1; text-align: center;
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: var(--ls-caps);
  color: #fff; padding-right: 40px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
.map-switch {
  position: absolute;
  top: calc(env(safe-area-inset-top, 12px) + 66px);
  left: 50%; transform: translateX(-50%);
  z-index: 500;
  display: flex; gap: 4px; max-width: calc(100% - 32px); overflow-x: auto;
  background: rgba(250, 249, 246, 0.94);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.map-switch[hidden] { display: none; }
.map-switch button {
  border: none; background: transparent; border-radius: var(--r-sm);
  padding: 7px 12px; white-space: nowrap;
  font-family: var(--sans); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim); cursor: pointer;
}
.map-switch button.active { background: rgb(var(--ink)); color: var(--bg); }

.map-legend {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 16px; right: 16px; z-index: 500;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 14px;
  display: flex; justify-content: center; gap: 18px;
  font-size: var(--fs-xs); color: var(--text);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.poi-marker {
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.poi-marker > span { transform: rotate(45deg); font-size: var(--fs-sm); font-weight: 800; color: #fff; line-height: 1; font-family: var(--sans); }
.poi-marker.available { background: var(--accent); }
.poi-marker.locked { background: #64748b; }
.poi-marker.done-ok { background: #16a34a; }
.poi-marker.done-fail { background: var(--danger); }
.leaflet-popup-content-wrapper { background: var(--bg); color: var(--text-hi); border-radius: var(--r-md); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); }
.leaflet-popup-tip { background: var(--bg); }
.poi-popup { min-width: 170px; }
.poi-popup .t { font-weight: 600; font-family: var(--serif); font-size: var(--fs-sm); margin-bottom: 2px; }
.poi-popup .s { font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; margin-bottom: 10px; }
.poi-popup button {
  width: 100%; padding: 9px 12px;
  background: rgb(var(--ink)); color: var(--bg);
  border: none; border-radius: var(--r-sm);
  font-weight: 600; font-family: var(--sans); cursor: pointer;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em;
}

/* ── Finisz (epilog) ── */
.finish-body {
  flex: 1;
  padding: calc(env(safe-area-inset-top, 0px) + 30px) 22px 20px;
  display: flex; flex-direction: column; gap: 20px; overflow-y: auto;
}
.finish-hero { text-align: center; padding: 8px 0 0; }
.finish-hero .trophy {
  width: auto; height: auto; margin: 0 auto 12px;
  border-radius: 0; background: none; border: none; box-shadow: none;
  display: block; font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--ls-caps-wide); text-transform: uppercase; color: var(--text-faint);
}
.finish-hero h2 { font-size: var(--fs-display); line-height: 1.1; margin-bottom: 6px; }
.finish-hero .nick { color: var(--text-hi); font-style: italic; }
.finish-timeout {
  margin: 8px auto 0; display: inline-block; padding: 5px 12px;
  border: 1px solid var(--danger); border-radius: var(--r-sm);
  color: var(--danger); font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.finish-score { display: flex; justify-content: center; gap: 14px; margin-top: 16px; }
.finish-score-item { text-align: center; border: 1px solid rgb(var(--ink)); border-radius: var(--r-md); padding: 14px 22px; min-width: 120px; }
.finish-score-item .value { font-family: var(--serif); font-size: var(--fs-display); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text-hi); }
.finish-score-item .label { font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: var(--ls-caps); margin-top: 8px; }
.finish-summary { background: transparent; border: none; border-top: 1px solid var(--line); border-radius: 0; padding: 4px 0; }
.finish-summary-item { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line-soft); }
.finish-summary-item:last-child { border-bottom: 1px solid var(--line); }
.finish-summary-item .icon { font-size: var(--fs-sm); width: 22px; text-align: center; }
.finish-summary-item .title { flex: 1; font-family: var(--serif); font-size: var(--fs-sm); color: var(--text); }
.finish-summary-item .sub { display: block; font-family: var(--sans); font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }
.finish-summary-item .pts { font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.06em; }
.finish-summary-item.fail .pts { color: var(--danger); }
.finish-gallery-label { font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: var(--ls-caps); font-weight: 600; }
.finish-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.finish-gallery figure { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.finish-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.finish-gallery figcaption { padding: 7px 9px; font-size: var(--fs-xs); color: var(--text-dim); font-family: var(--serif); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finish-footer { padding: 12px 22px calc(env(safe-area-inset-bottom, 0px) + 16px); display: flex; flex-direction: column; gap: 10px; }
.finish-footer .btn { width: 100%; }

/* ── Toast ── */
#toast-container {
  position: fixed; left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateX(-50%); z-index: 1000;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: calc(100% - 32px); max-width: 400px;
}
.toast {
  background: rgb(var(--ink));
  color: var(--bg);
  padding: 13px 18px;
  border: none;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 28px rgba(28, 27, 24, 0.35);
  animation: toastIn 0.25s ease-out, toastOut 0.25s ease-in 2.75s forwards;
  max-width: 100%;
}
.toast.success { box-shadow: 0 8px 28px rgba(28, 27, 24, 0.35), inset 0 0 0 1px var(--accent); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(20px); } }

/* ── Modal ── */
#modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(28, 27, 24, 0.35);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
#modal-backdrop.visible { display: flex; }
.modal-box {
  background: var(--bg);
  border: 1px solid rgb(var(--ink));
  border-radius: var(--r-md);
  padding: 24px 20px;
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 24px 64px rgba(28, 27, 24, 0.3);
  animation: toastIn 0.2s ease-out;
}
.modal-box h3 { font-size: var(--fs-lg); }
.modal-box p { font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; padding: 12px 12px; font-size: var(--fs-xs); }
.modal-actions--stack { flex-direction: column; }

/* ── Fatal error ── */
.fatal-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; gap: 16px; }
.fatal-body h2 { font-size: var(--fs-lg); }
.fatal-body p { color: var(--text-dim); font-size: var(--fs-sm); line-height: 1.6; max-width: 320px; }

/* ── Dostępność: ograniczony ruch ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .scan-line { display: none; }
  .toast { animation: none; }
}
