:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f7f7;
  --border: #e5e5e5;
  --border-dark: #cecece;
  --text: #4b4b4b;
  --text-strong: #3c3c3c;
  --muted: #777777;

  /* Autentyczna paleta Duolingo */
  --green: #58cc02;
  --green-dark: #58a700;
  --green-bg: #d7ffb8;
  --green-text: #46a302;

  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --blue-bg: #ddf4ff;

  --gold: #ffc800;
  --gold-dark: #e5a400;
  --gold-bg: #fff5cc;

  --orange: #ff9600;
  --orange-dark: #e08200;

  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --red-bg: #ffdfe0;

  --purple: #ce82ff;
  --purple-dark: #a560e8;

  --radius: 20px;
}

/* ---------- Tryb Ciemny w stylu Duolingo Dark Mode ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131f24;
  --surface: #1b2b32;
  --surface-soft: #243740;
  --border: #37464f;
  --border-dark: #2c3a42;
  --text: #dce6ec;
  --text-strong: #ffffff;
  --muted: #98aeb8;

  --green-bg: #1c381f;
  --green-text: #6ee019;
  --blue-bg: #183446;
  --gold-bg: #362e14;
  --red-bg: #3b1b22;
}
[data-theme="dark"] .topbar,
[data-theme="dark"] .lesson-topbar,
[data-theme="dark"] .lesson-footer,
[data-theme="dark"] .sidebar {
  background: #131f24;
}
[data-theme="dark"] .side-hero-img,
[data-theme="dark"] .logo-img,
[data-theme="dark"] .prompt-mascot,
[data-theme="dark"] .end-mascot {
  background: transparent;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.38));
}
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #131f24;
  border-color: #37464f;
  color: #ffffff;
}
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  background: #18272e;
  border-color: var(--blue);
}
[data-theme="dark"] .btn.white {
  background: #243740;
  border-color: #37464f;
  color: #ffffff;
}
[data-theme="dark"] .btn:disabled {
  background: #202f36 !important;
  border-color: #37464f !important;
  color: #52656d !important;
}
[data-theme="dark"] .folder-card:nth-child(4n+1) .fc-icon { background: #1c381f; border-color: #2e5c33; }
[data-theme="dark"] .folder-card:nth-child(4n+2) .fc-icon { background: #183446; border-color: #24506b; }
[data-theme="dark"] .folder-card:nth-child(4n+3) .fc-icon { background: #362e14; border-color: #5c4e21; }
[data-theme="dark"] .folder-card:nth-child(4n+4) .fc-icon { background: #2d1f42; border-color: #4d3570; }
[data-theme="dark"] .rule-badge.green,
[data-theme="dark"] .tol-badge,
[data-theme="dark"] .preset.selected {
  background: #1c381f;
  border-color: #46a302;
  color: #78e026;
}
[data-theme="dark"] .rule-badge.blue { background: #183446; border-color: #1899d6; color: #49c0f8; }
[data-theme="dark"] .rule-badge.gold,
[data-theme="dark"] .badge.gold,
[data-theme="dark"] .rank-badge { background: #362e14; border-color: #e5a400; color: #ffc800; }
[data-theme="dark"] .lesson-chip.streak { background: #382514; border-color: #e08200; color: #ffab33; }
[data-theme="dark"] .lesson-chip.gem { background: #183446; border-color: #1899d6; color: #49c0f8; }
[data-theme="dark"] .lesson-chip.xp { background: #362e14; border-color: #e5a400; color: #ffc800; }
[data-theme="dark"] .lesson-progress-bar,
[data-theme="dark"] .bar { background: #202f36; }
[data-theme="dark"] .hud-dot { background: #37464f; }
[data-theme="dark"] .dir-hint { background: rgba(0, 0, 0, 0.35); color: #ffd966; }
[data-theme="dark"] .lesson-footer.state-good { background: #16301b; border-top-color: #2e5c33; }
[data-theme="dark"] .lesson-footer.state-warn { background: #332a12; border-top-color: #665422; }
[data-theme="dark"] .lesson-footer.state-bad  { background: #381920; border-top-color: #702c3a; }
[data-theme="dark"] .lesson-footer.state-warn .rr-msg { color: #ffc800; }
[data-theme="dark"] .lesson-footer.state-bad .rr-msg  { color: #ff6b6b; }

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #d4d4d4 transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

html, body { height: 100%; margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-weight: 800;
}

h1, h2, h3 {
  margin: 0;
  color: var(--text-strong);
  font-weight: 900;
  letter-spacing: -0.015em;
}
a { color: var(--blue); font-weight: 800; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-weight: 700; }
.accent-text { color: var(--green-text); font-weight: 900; }
.warn-text { color: var(--orange); font-weight: 900; }
.small { font-size: 0.88rem; }
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.full-w { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; width: 100%; }
.row.center { justify-content: center; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.hint { color: var(--muted); font-size: 0.85rem; font-weight: 700; margin: 6px 0 0; line-height: 1.45; }

/* ---------- Topbar (Duolingo Clean Navigation) ---------- */
.topbar {
  height: 74px;
  flex: none;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  z-index: 1000;
}
.topbar-inner {
  max-width: 1180px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  font-weight: 900;
  font-size: 1.9rem;
  color: var(--green);
  text-decoration: none !important;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.03em;
}
.logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 12px;
}

.duo-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: var(--surface);
  font-size: 1.02rem;
  font-weight: 900;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s, box-shadow 0.18s;
  cursor: pointer;
}
.stat-pill:hover {
  background: var(--surface-soft);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.stat-pill.streak { color: var(--orange); }
.stat-pill.gem { color: var(--blue-dark); }
.stat-pill.xp { color: var(--green-text); }
.stat-pill.crown { color: #e5a400; }
.stat-svg { width: 24px; height: 24px; display: inline-flex; transition: transform 0.18s ease; }
.stat-svg svg { width: 100%; height: 100%; }
.stat-pill.streak:hover .stat-svg svg { animation: flameBounce 0.65s infinite alternate ease-in-out; }
.stat-pill.gem:hover .stat-svg svg { animation: gemGleam 0.7s infinite alternate ease-in-out; }
.stat-pill.crown:hover .stat-svg svg { animation: crownPulse 0.7s infinite alternate ease-in-out; }

.btn-svg { width: 20px; height: 20px; display: inline-flex; }
.btn-svg svg { width: 100%; height: 100%; }
.btn.icon-only { padding: 8px 11px; }
.lang-toggle-btn {
  padding: 7px 12px !important;
  gap: 6px;
  font-weight: 900;
  min-width: 64px;
}
.lang-toggle-btn .btn-svg {
  width: 22px;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
}
.inline-svg { width: 18px; height: 18px; display: inline-flex; vertical-align: middle; }
.inline-svg svg { width: 100%; height: 100%; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }
body[data-view="game"] .topbar { display: none; }

/* ---------- Tactile 3D Duolingo Buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 900;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 2px solid var(--border-dark);
  border-bottom-width: 4px;
  background: var(--surface);
  color: var(--text-strong);
  padding: 11px 18px;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none !important;
  user-select: none;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.12s ease,
              border-bottom-width 0.1s ease,
              filter 0.12s ease,
              background 0.14s ease,
              border-color 0.14s ease;
}
.btn .btn-svg svg,
.btn .inline-svg svg {
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-bottom-width: 5px;
  filter: brightness(1.04);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.btn:hover:not(:disabled) .btn-svg svg,
.btn:hover:not(:disabled) .inline-svg svg {
  transform: scale(1.15) rotate(-3deg);
}
.btn:active:not(:disabled) {
  transform: translateY(2px);
  border-bottom-width: 2px;
  filter: brightness(0.96);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.12) !important;
}
.btn:active:not(:disabled) .btn-svg svg,
.btn:active:not(:disabled) .inline-svg svg {
  transform: scale(0.94);
}
.btn:disabled {
  background: #e5e5e5 !important;
  border-color: #d4d4d4 !important;
  color: #afafaf !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  border-bottom-width: 3px !important;
}

.btn.primary {
  background: var(--green);
  border-color: var(--green-dark);
  color: #ffffff;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.32), 0 2px 0 rgba(0, 0, 0, 0.06);
}
.btn.primary:hover:not(:disabled) {
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.4), 0 5px 16px rgba(88, 204, 2, 0.35);
}

.btn.secondary {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: #5c4000;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.42), 0 2px 0 rgba(0, 0, 0, 0.06);
}
.btn.secondary:hover:not(:disabled) {
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.5), 0 5px 16px rgba(255, 200, 0, 0.35);
}

.btn.blue {
  background: var(--blue);
  border-color: var(--blue-dark);
  color: #ffffff;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.32), 0 2px 0 rgba(0, 0, 0, 0.06);
}
.btn.blue:hover:not(:disabled) {
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.4), 0 5px 16px rgba(28, 176, 246, 0.35);
}

.btn.white {
  background: #ffffff;
  border-color: var(--border-dark);
  color: var(--text-strong);
}

.btn.ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--text-strong);
  border-color: var(--border-dark);
}

.btn.active-mode {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.btn.danger {
  color: #ffffff;
  border-color: #d82b2b;
  background: var(--red);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.28), 0 2px 0 rgba(0, 0, 0, 0.06);
}
.btn.danger:hover:not(:disabled) {
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.35), 0 5px 16px rgba(255, 75, 75, 0.32);
}

.btn.sm { padding: 8px 14px; font-size: 0.78rem; border-radius: 13px; }
.btn.lg { padding: 14px 28px; font-size: 0.98rem; border-radius: 18px; }

.icon-btn {
  background: var(--surface);
  border: 2px solid transparent;
  color: #afafaf;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 900;
  padding: 5px 9px;
  border-radius: 12px;
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.14s, background 0.14s;
}
.icon-btn:hover {
  color: var(--red);
  background: var(--red-bg);
  transform: scale(1.1);
}
.icon-btn:active {
  transform: scale(0.92);
}

/* ---------- Views ---------- */
main { flex: 1; position: relative; min-height: 0; }
.view { display: none; position: absolute; inset: 0; }
.view.active { display: block; }
#view-home { overflow-y: auto; padding: 32px 24px 72px; }

/* ---------- Duolingo 2-Column Dashboard ---------- */
.duo-dashboard {
  max-width: 1140px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 32px;
  align-items: start;
}
.duo-main-col { min-width: 0; }

/* Unit Header Card (solid flat green like Duolingo Unit Banner) */
.unit-header-card {
  background: var(--green);
  border: 2px solid var(--green-dark);
  border-bottom-width: 6px;
  border-radius: 24px;
  padding: 24px 28px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.unit-header-info { flex: 1; min-width: 240px; }
.unit-kicker {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d7ffb8;
  margin-bottom: 6px;
}
.unit-header-card h1 {
  color: #ffffff;
  font-size: 1.65rem;
  line-height: 1.2;
}
.unit-header-card p {
  margin: 6px 0 0;
  color: #f0ffe3;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
}
.unit-header-actions .btn.white {
  color: var(--green-text);
  border-color: #c7f09e;
}

/* Right Sidebar Cards */
.duo-side-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.side-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 22px;
  padding: 20px;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
}
.side-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.06);
}
.mascot-card { padding: 16px 20px 20px; text-align: center; }
.side-hero-img {
  width: 100%;
  max-width: 240px;
  height: 170px;
  object-fit: contain;
  margin: 0 auto 8px;
  display: block;
}
.side-card h3 { font-size: 1.18rem; margin-bottom: 6px; }
.side-card p {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
  margin: 0 0 14px;
}

.duo-rule-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.duo-rule-list li {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rule-badge {
  min-width: 62px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 900;
  border: 2px solid transparent;
  border-bottom-width: 4px;
}
.rule-badge.green { background: #eaffd6; color: var(--green-text); border-color: #b5f08b; }
.rule-badge.blue  { background: var(--blue-bg); color: var(--blue-dark); border-color: #9ee0ff; }
.rule-badge.gold  { background: var(--gold-bg); color: #b37d00; border-color: #ffe066; }
.duo-rule-list b { display: block; font-size: 0.9rem; color: var(--text-strong); }
.duo-rule-list small { color: var(--muted); font-size: 0.78rem; font-weight: 700; }

.section-bar {
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title-group { display: flex; align-items: center; gap: 10px; }
.section-bar h2 { font-size: 1.35rem; }
.count-pill {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 99px;
  padding: 3px 12px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 800;
}
.home-search { width: 240px; }

/* ---------- Folder Cards (Duolingo Skill Nodes) ---------- */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.folder-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 5px;
  border-radius: 22px;
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s ease,
              border-color 0.2s ease;
}
.folder-card:hover {
  transform: translateY(-5px);
  border-color: var(--blue);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(28, 176, 246, 0.2);
}
.folder-card:active {
  transform: translateY(-1px);
}
.fc-top { display: flex; gap: 14px; align-items: center; }
.fc-icon {
  width: 62px;
  height: 62px;
  padding: 10px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--blue-bg);
  border: 2px solid #b5e5ff;
  border-bottom-width: 4px;
  border-radius: 18px;
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.folder-card:hover .fc-icon {
  transform: scale(1.08) rotate(-3deg);
}
.fc-icon svg { width: 100%; height: 100%; }
.folder-card:nth-child(4n+1) .fc-icon { background: #eaffd6; border-color: #b5f08b; }
.folder-card:nth-child(4n+2) .fc-icon { background: #ddf4ff; border-color: #9ee0ff; }
.folder-card:nth-child(4n+3) .fc-icon { background: #fff5cc; border-color: #ffe066; }
.folder-card:nth-child(4n+4) .fc-icon { background: #f3e5ff; border-color: #d7b2ff; }

.fc-head h3 { font-size: 1.12rem; margin-bottom: 3px; }
.fc-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 0.77rem;
  font-weight: 800;
  padding: 4px 11px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 2px solid var(--border);
}
.badge.gold {
  background: var(--gold-bg);
  color: #9e6d00;
  border-color: #ffe066;
}
.fc-actions { margin-top: auto; padding-top: 4px; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 52px 24px;
  background: var(--surface);
  border: 3px dashed var(--border-dark);
  border-radius: 24px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty h3 { color: var(--text-strong); }

/* ---------- Folder View ---------- */
.folder-layout { display: flex; height: 100%; }
.sidebar {
  width: 410px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border-right: 2px solid var(--border);
  background: var(--surface);
  min-height: 0;
}
.sidebar-top { display: flex; flex-direction: column; gap: 12px; }
.folder-header h2 {
  font-size: 1.42rem;
  cursor: pointer;
  margin-bottom: 4px;
}
.folder-header h2:hover { color: var(--blue); }
.folder-meta { color: var(--muted); font-size: 0.86rem; line-height: 1.4; }
.add-place { display: flex; gap: 8px; }
.add-place .btn { flex: none; }
.sort-select { width: 155px; padding: 8px 10px; font-size: 0.85rem; }

input, select, textarea {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.94rem;
  color: var(--text-strong);
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus {
  background: var(--surface);
  border-color: var(--blue);
}
textarea { resize: vertical; }

.place-list {
  list-style: none;
  margin: 0;
  padding: 6px 2px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  border-top: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
}
.place-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.place-list li:hover { background: var(--surface-soft); }
.empty-li { padding: 20px !important; justify-content: center !important; cursor: default !important; }
.pl-text { min-width: 0; }
.pl-text b { display: block; font-weight: 800; font-size: 0.95rem; color: var(--text-strong); }
.pl-text small { color: var(--muted); font-size: 0.8rem; font-weight: 700; }

.folder-map-wrap { flex: 1; position: relative; height: 100%; }
.map { width: 100%; height: 100%; background: #a8d8f0; }
.map-floating-bar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 500;
  display: flex;
  gap: 8px;
}

/* Wikipedia Inspector Card */
.wiki-card {
  position: absolute;
  bottom: 22px;
  left: 22px;
  z-index: 550;
  width: min(380px, calc(100% - 44px));
  background: var(--surface);
  border: 2px solid var(--border-dark);
  border-bottom-width: 5px;
  border-radius: 22px;
  overflow: hidden;
  animation: pop 0.18s ease-out;
}
.wiki-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-strong);
  z-index: 2;
}
.wiki-img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  display: block;
  border-bottom: 2px solid var(--border);
}
.wiki-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.wiki-tag { font-size: 0.76rem; color: var(--green-text); font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; }
.wiki-body h3 { font-size: 1.15rem; }
.wiki-extract {
  font-size: 0.86rem;
  color: var(--text);
  font-weight: 700;
  line-height: 1.5;
  margin: 0;
  max-height: 110px;
  overflow-y: auto;
}
.wiki-links { font-size: 0.82rem; padding-top: 4px; }

/* ---------- Markers ---------- */
.dot-marker {
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #ffffff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.12s;
}
.dot-marker:hover { transform: scale(1.22); }
.dot-marker.guess {
  background: var(--orange);
  box-shadow: 0 0 0 5px rgba(255, 150, 0, 0.35);
}
.dot-marker.target {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(88, 204, 2, 0.38);
}

/* ---------- Leaflet tweaks ---------- */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface);
  color: var(--text-strong);
  border: 2px solid var(--border);
  border-radius: 16px;
  font-family: inherit;
  font-weight: 800;
}
.leaflet-container { font-family: inherit; }
.target-tip {
  background: var(--green) !important;
  color: #ffffff !important;
  border: 2px solid var(--green-dark) !important;
  border-radius: 12px !important;
  padding: 5px 12px !important;
  font-weight: 900;
  font-size: 0.92rem;
}
.target-tip::before { display: none; }

/* ---------- Duolingo Lesson Game View ---------- */
#view-game.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
}

.lesson-topbar {
  height: 70px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  z-index: 650;
}
.lesson-close {
  background: none;
  border: 0;
  font-size: 1.45rem;
  font-weight: 900;
  color: #afafaf;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 12px;
}
.lesson-close:hover { color: var(--text-strong); background: var(--surface-soft); }

.lesson-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 540px;
}
.lesson-progress-bar {
  height: 16px;
  background: #e5e5e5;
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.lesson-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.lesson-progress-shine {
  position: absolute;
  top: 3px;
  left: 10px;
  right: 10px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.32);
  pointer-events: none;
}
.hud-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
}
.hud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0e0e0;
}
.hud-dot.current { background: var(--blue); transform: scale(1.25); }
.hud-dot.great { background: var(--green); }
.hud-dot.good { background: #89e219; }
.hud-dot.ok { background: var(--gold); }
.hud-dot.bad { background: var(--red); }

.lesson-chips {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lesson-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 14px;
  border: 2px solid var(--border);
  font-size: 0.94rem;
  font-weight: 900;
  background: var(--surface);
}
.lesson-chip.streak { background: #fff9f0; border-color: #ffd28a; color: var(--orange); }
.lesson-chip.gem { background: var(--blue-bg); border-color: #9ee0ff; color: var(--blue-dark); }
.lesson-chip.xp { background: #fffdf0; border-color: #fde68a; color: #b47800; }
.chip-svg { width: 20px; height: 20px; display: inline-flex; }
.chip-svg svg { width: 100%; height: 100%; }
.heart-svg { width: 20px; height: 20px; display: inline-flex; vertical-align: middle; margin: 0 1px; }
.heart-svg svg { width: 100%; height: 100%; }

.game-style-pills {
  display: flex;
  gap: 4px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  padding: 4px;
  border-radius: 14px;
}
.style-pill {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 5px 11px;
  border-radius: 10px;
  cursor: pointer;
}
.style-pill:hover { color: var(--text-strong); }
.style-pill.active {
  background: var(--surface);
  color: var(--blue-dark);
  box-shadow: 0 2px 0 var(--border);
}

.timer-track {
  height: 6px;
  background: #ffe5e5;
  flex: none;
}
.timer-fill {
  height: 100%;
  background: var(--orange);
  transition: width 0.1s linear;
}

/* Map Stage & Mascot Speech Bubble Prompt */
.game-stage {
  flex: 1;
  position: relative;
  min-height: 0;
}
.game-stage .map {
  position: absolute;
  inset: 0;
}

.prompt-bubble {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 550;
  background: var(--surface);
  border: 2px solid var(--border-dark);
  border-bottom-width: 5px;
  border-radius: 24px;
  padding: 12px 24px 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(640px, calc(100vw - 32px));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  animation: promptPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes promptPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(0.95); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.prompt-mascot {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex: none;
}
.hud-photo {
  width: 78px;
  height: 58px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid var(--border);
  flex: none;
}
.prompt-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.prompt-kicker {
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.prompt-place {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-strong);
  line-height: 1.15;
}
.prompt-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.prompt-sub {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 800;
}
.tol-badge {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--green-text);
  background: #eaffd6;
  border: 2px solid #b5f08b;
  padding: 2px 10px;
  border-radius: 99px;
}
.timer-badge {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--red);
  background: var(--red-bg);
  border: 2px solid #ffb3b5;
  padding: 2px 10px;
  border-radius: 99px;
}

.map-helpers {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 550;
  display: flex;
  gap: 8px;
}

/* Duolingo Bottom Action & Feedback Tray */
.lesson-footer {
  flex: none;
  background: var(--surface);
  border-top: 2px solid var(--border);
  padding: 18px 28px;
  z-index: 650;
  transition: background 0.18s, border-color 0.18s;
}
.lesson-footer.state-good {
  background: var(--green-bg);
  border-top-color: #a5ed6e;
}
.lesson-footer.state-warn {
  background: var(--gold-bg);
  border-top-color: #f5d061;
}
.lesson-footer.state-bad {
  background: var(--red-bg);
  border-top-color: #ffadb0;
}

.footer-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex: 1;
}
.lesson-footer.state-good .footer-actions,
.lesson-footer.state-warn .footer-actions,
.lesson-footer.state-bad .footer-actions {
  flex: none;
}

.round-result {
  flex: 1;
  min-width: 260px;
}
.rr-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.rr-msg {
  font-weight: 900;
  font-size: 1.32rem;
  color: var(--green-text);
  margin-bottom: 2px;
}
.lesson-footer.state-warn .rr-msg { color: #b37400; }
.lesson-footer.state-bad .rr-msg { color: var(--red-dark); }

.rr-name { font-size: 0.95rem; color: var(--text-strong); font-weight: 800; }
.dir-hint {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #7c4d00;
  background: rgba(255, 255, 255, 0.75);
  padding: 2px 10px;
  border-radius: 99px;
}
.mode-bonus-pill {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.78rem;
  font-weight: 900;
  color: #1899d6;
  background: #ddf4ff;
  border: 1.5px solid #9ee0ff;
  padding: 2px 10px;
  border-radius: 99px;
}
[data-theme="dark"] .mode-bonus-pill {
  background: #183446;
  border-color: #1899d6;
  color: #49c0f8;
}
.rr-stats { display: flex; gap: 22px; text-align: right; flex: none; }
.rr-stats .hud-label { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); display: block; }
.rr-stats b { font-size: 1.3rem; font-weight: 900; color: var(--text-strong); }
.pts-val { color: var(--green-text) !important; }
.round-result .bar { display: none; }

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPopIn {
  0% { opacity: 0; transform: scale(0.9) translateY(16px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes progressShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

@keyframes gemGleam {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 2px 4px rgba(28, 176, 246, 0.2)); }
  50% { transform: scale(1.14) rotate(4deg); filter: drop-shadow(0 4px 10px rgba(28, 176, 246, 0.55)); }
}

@keyframes crownPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 2px 4px rgba(255, 200, 0, 0.25)); }
  50% { transform: scale(1.12); filter: drop-shadow(0 4px 10px rgba(255, 200, 0, 0.6)); }
}

@keyframes chestBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-7px) scale(1.06, 0.94); }
  50% { transform: translateY(-12px) scale(0.95, 1.08); }
  75% { transform: translateY(-3px) scale(1.03, 0.98); }
}

.bar {
  height: 14px;
  background: #e5e5e5;
  border-radius: 99px;
  overflow: hidden;
  width: 100%;
}
.bar > div {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  position: relative;
  overflow: hidden;
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar > div::after,
.lesson-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: progressShimmer 2.2s infinite ease-in-out;
}

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 2000;
  padding: 16px;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.modal {
  background: var(--surface);
  border: 2px solid var(--border-dark);
  border-bottom-width: 6px;
  border-radius: 26px;
  width: min(580px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.25);
  animation: modalPopIn 0.26s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 1.35rem; }
.end-mascot { width: 46px; height: 46px; object-fit: contain; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 0.86rem; color: var(--muted); font-weight: 800; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 9px; align-items: center; font-size: 0.94rem; font-weight: 800; cursor: pointer; }
.check input { width: auto; accent-color: var(--green); }
input[type="range"] { padding: 0; accent-color: var(--green); }

/* Style & Mode Cards in Game Setup */
.style-cards, .mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.style-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px;
  border-radius: 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.style-card input { position: absolute; opacity: 0; pointer-events: none; }
.style-card:hover { background: var(--surface-soft); }
.style-card:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-bg);
}
.sc-title { font-weight: 900; font-size: 0.92rem; color: var(--text-strong); }
.style-card small { color: var(--muted); font-size: 0.77rem; font-weight: 700; line-height: 1.35; }

/* Tabs & Presets */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-soft);
  padding: 5px;
  border-radius: 16px;
  border: 2px solid var(--border);
  flex-wrap: wrap;
}
.tab {
  flex: 1;
  font: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  background: none;
  color: var(--muted);
  border: 0;
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active {
  background: var(--surface);
  color: var(--blue-dark);
  box-shadow: 0 2px 0 var(--border);
}
.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 12px; }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.preset {
  font: inherit;
  color: var(--text-strong);
  text-align: left;
  cursor: pointer;
  display: flex;
  gap: 11px;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 16px;
  padding: 11px 13px;
}
.preset:hover { background: var(--surface-soft); }
.preset.selected {
  border-color: var(--green);
  background: #f1ffe3;
}
.p-icon { width: 38px; height: 38px; flex: none; display: inline-flex; }
.p-icon svg { width: 100%; height: 100%; }
.preset b { display: block; font-size: 0.9rem; font-weight: 900; margin-bottom: 2px; }
.preset small { color: var(--muted); font-size: 0.77rem; font-weight: 700; }

.progress { display: flex; flex-direction: column; gap: 7px; font-size: 0.86rem; color: var(--muted); }
.progress.indeterminate .bar > div { animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* End Modal */
.rank-badge {
  font-weight: 900;
  font-size: 1rem;
  padding: 6px 16px;
  border-radius: 14px;
  background: var(--gold-bg);
  color: #a87000;
  border: 2px solid var(--gold);
}
.end-score { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 4px 0; }
.end-score .big { font-size: 3.4rem; font-weight: 900; color: var(--green); line-height: 1; }
.record { font-weight: 900; color: var(--orange); margin-top: 4px; }
.end-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.post-lesson-chest {
  background: var(--gold-bg);
  border: 2px solid var(--gold);
  border-bottom-width: 5px;
  border-radius: 20px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.post-lesson-chest:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(255, 200, 0, 0.25);
}
[data-theme="dark"] .post-lesson-chest {
  background: #362e14;
  border-color: #e5a400;
}
.plc-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 220px;
}
.plc-svg {
  width: 48px;
  height: 48px;
  flex: none;
  display: inline-flex;
}
.plc-svg svg {
  width: 100%;
  height: 100%;
  animation: chestBounce 1.8s infinite ease-in-out;
}
.plc-left b {
  display: block;
  font-size: 1.02rem;
  color: var(--text-strong);
  margin-bottom: 2px;
}
.plc-left small {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}
.es-box {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.es-box .hud-label { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); }
.es-box b { font-size: 1rem; font-weight: 900; color: var(--text-strong); }
.end-list { margin: 0; padding: 0 0 0 22px; max-height: 230px; overflow-y: auto; }
.end-list li { padding: 8px 4px; border-bottom: 2px solid var(--border); font-size: 0.93rem; }
.end-list li > * { display: inline-block; }
.end-list li span:first-child { width: 52%; font-weight: 800; color: var(--text-strong); }
.end-list li span.muted { width: 24%; }
.end-list li b { width: 22%; text-align: right; color: var(--green-text); font-weight: 900; }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
  max-width: 390px;
}
.toast {
  background: var(--surface);
  color: var(--text-strong);
  border: 2px solid var(--border-dark);
  border-left: 6px solid var(--blue);
  border-bottom-width: 4px;
  padding: 13px 18px;
  border-radius: 16px;
  font-size: 0.92rem;
  font-weight: 800;
  animation: pop 0.2s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.out { opacity: 0; transform: translateX(20px); }

/* ---------- Mini-Profil, Modal Profilu i Ekran Celebracji Serii (Duolingo) ---------- */
.stat-pill {
  font-family: inherit;
  cursor: pointer;
}
.mini-profile-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mp-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mp-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  display: grid;
  place-items: center;
  padding: 3px;
  flex: none;
}
.mp-avatar svg { width: 100%; height: 100%; }
.mp-info { flex: 1; min-width: 0; }
.mp-name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mp-name-row b { font-size: 1.05rem; color: var(--text-strong); }
.mp-lvl-badge {
  font-size: 0.72rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--blue-bg);
  color: var(--blue-dark);
  border: 2px solid #9ee0ff;
}
.mp-xp-wrap { display: flex; flex-direction: column; gap: 6px; }

/* Dzienny Cel XP i Tarcza Serii */
.quest-side-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quest-badge {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--green-text);
  background: #eaffd6;
  border: 2px solid #b5f08b;
  padding: 2px 10px;
  border-radius: 99px;
}
[data-theme="dark"] .quest-badge {
  background: #1c381f;
  border-color: #46a302;
  color: #78e026;
}
.quest-shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  margin-top: 2px;
}
.freeze-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.freeze-icon {
  font-size: 1.45rem;
}
.freeze-info b {
  display: block;
  font-size: 0.88rem;
  color: var(--text-strong);
}
.freeze-info small {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

/* Konfetti 2D */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2800;
}
.mp-cookie-note {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
  padding: 5px 10px;
  border-radius: 10px;
}

/* Modal Profilu */
.profile-hero {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: center;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 22px;
  padding: 18px;
}
.profile-avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.profile-avatar-big {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 5px;
  display: grid;
  place-items: center;
  padding: 5px;
}
.profile-avatar-big svg { width: 100%; height: 100%; }

.gem-balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-bg);
  color: var(--blue-dark);
  border: 2px solid #9ee0ff;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 900;
}
[data-theme="dark"] .gem-balance-pill {
  background: #183446;
  border-color: #1899d6;
  color: #49c0f8;
}

.avatar-shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}
.av-shop-card {
  font-family: inherit;
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 18px;
  padding: 12px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s, border-color 0.12s;
}
.av-shop-card:hover { transform: translateY(-2px); border-color: var(--blue); }
.av-shop-card.active {
  border-color: var(--green);
  background: #f1ffe3;
}
[data-theme="dark"] .av-shop-card.active {
  background: #1c381f;
  border-color: #58cc02;
}
.av-shop-svg { width: 52px; height: 52px; display: inline-flex; }
.av-shop-svg svg { width: 100%; height: 100%; }
.av-shop-name { font-size: 0.82rem; font-weight: 900; color: var(--text-strong); text-align: center; }
.av-shop-tag {
  font-size: 0.72rem;
  font-weight: 900;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface-soft);
  color: var(--muted);
}
.av-shop-card.active .av-shop-tag {
  background: var(--green);
  color: #ffffff;
}
.av-shop-card.locked .av-shop-tag {
  background: var(--blue-bg);
  color: var(--blue-dark);
}
[data-theme="dark"] .av-shop-card.locked .av-shop-tag {
  background: #183446;
  color: #49c0f8;
}

.shop-svg { width: 38px; height: 38px; flex: none; display: inline-flex; }
.shop-svg svg { width: 100%; height: 100%; }
.chest-modal-card { border-color: var(--blue); }
.gem-number { color: var(--blue); text-shadow: 0 4px 0 rgba(28, 176, 246, 0.22); }

.prof-img-preview-wrap {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 14px;
  display: grid;
  place-items: center;
}
.prof-img-preview-wrap img {
  width: 100%;
  max-width: 720px;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.profile-main-info { display: flex; flex-direction: column; gap: 14px; }
.prof-level-box { display: flex; flex-direction: column; gap: 6px; }

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pstat-box {
  background: var(--surface);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 18px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.pstat-ico { width: 32px; height: 32px; flex: none; display: inline-flex; }
.pstat-ico svg { width: 100%; height: 100%; }
.pstat-box b { display: block; font-size: 1.25rem; font-weight: 900; color: var(--text-strong); line-height: 1.1; }
.pstat-box small { font-size: 0.77rem; color: var(--muted); font-weight: 800; }

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.ach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  background: var(--surface);
}
.ach-card.unlocked {
  border-color: var(--gold);
  background: var(--gold-bg);
}
.ach-card.locked { opacity: 0.55; filter: grayscale(0.9); }
.ach-icon { width: 36px; height: 36px; flex: none; display: inline-flex; }
.ach-icon svg { width: 100%; height: 100%; }
.ach-card b { display: block; font-size: 0.9rem; color: var(--text-strong); }
.ach-card small { font-size: 0.76rem; color: var(--muted); font-weight: 700; }

/* Pełnoekranowa celebracja zwiększenia serii (Duolingo Streak Screen) */
.streak-celebration {
  position: fixed;
  inset: 0;
  background: rgba(19, 31, 36, 0.78);
  backdrop-filter: blur(4px);
  z-index: 2600;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: pop 0.22s ease-out;
}
.sc-card {
  background: var(--surface);
  border: 3px solid var(--orange);
  border-bottom-width: 8px;
  border-radius: 30px;
  padding: 32px 30px 26px;
  width: min(440px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.sc-Burst {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}
.sc-flame-big {
  width: 86px;
  height: 86px;
  display: inline-flex;
  animation: flameBounce 0.9s ease-in-out infinite alternate;
}
.sc-flame-big svg { width: 100%; height: 100%; }
.sc-mascot {
  width: 84px;
  height: 84px;
  object-fit: contain;
}
@keyframes flameBounce {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-6px) scale(1.08); }
}
.sc-number {
  font-size: 3.8rem;
  font-weight: 900;
  color: var(--orange);
  line-height: 1;
  text-shadow: 0 4px 0 rgba(255, 150, 0, 0.22);
}
.sc-card h2 { font-size: 1.55rem; color: var(--text-strong); }
.sc-card p { margin: 0 0 6px; color: var(--muted); font-size: 0.92rem; }
.sc-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  width: 100%;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 12px 10px;
  margin-bottom: 8px;
}
.sc-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--muted);
}
.sc-day b {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}
.sc-day.active { color: var(--orange); font-weight: 900; }
.sc-day.active b {
  background: #fff5e5;
  border-color: var(--orange);
}
[data-theme="dark"] .sc-day.active b {
  background: #382514;
  border-color: var(--orange);
}
[data-theme="dark"] .ach-card.unlocked {
  background: #362e14;
  border-color: #e5a400;
}
[data-theme="dark"] .mp-lvl-badge {
  background: #183446;
  border-color: #1899d6;
  color: #49c0f8;
}

/* ---------- Pełna Responsywność na Telefon i Tablet (Mobile-First UX) ---------- */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

@media (max-width: 960px) {
  .duo-dashboard {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .topbar {
    height: auto;
    min-height: 62px;
    padding: 8px 0;
  }
  .topbar-inner {
    padding: 0 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .duo-stats {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 6px;
    padding-top: 6px;
    border-top: 2px solid var(--border);
  }
  .stat-pill {
    flex: 1;
    justify-content: center;
    padding: 5px 8px;
    font-size: 0.88rem;
  }
  .stat-svg { width: 19px; height: 19px; }

  .folder-layout {
    flex-direction: column-reverse;
  }
  .sidebar {
    width: 100%;
    height: 48%;
    border-right: 0;
    border-top: 2px solid var(--border);
    padding: 12px 14px;
    gap: 8px;
  }
  .folder-map-wrap {
    height: 52%;
  }
  .grid2, .grid3, .end-stats-row {
    grid-template-columns: 1fr;
  }
  .profile-hero {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
  .profile-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  #view-home {
    padding: 16px 12px calc(36px + env(safe-area-inset-bottom, 0px));
  }
  .logo {
    font-size: 1.45rem;
    gap: 7px;
  }
  .logo-img {
    width: 34px;
    height: 34px;
  }
  .topbar-actions {
    gap: 5px;
  }
  .topbar-actions .btn.sm {
    padding: 6px 9px;
    font-size: 0.72rem;
  }
  #profileBtn span[data-i18n="nav_profile_btn"] {
    display: none;
  }
  .lang-toggle-btn {
    min-width: 52px;
    padding: 6px 8px !important;
  }

  /* Karta powitalna na telefonie */
  .unit-header-card {
    padding: 18px;
    border-radius: 20px;
    margin-bottom: 18px;
    gap: 14px;
  }
  .unit-header-card h1 {
    font-size: 1.32rem;
  }
  .unit-header-card p {
    font-size: 0.86rem;
  }
  .unit-header-actions {
    width: 100%;
  }
  .unit-header-actions .btn {
    flex: 1;
  }
  .section-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .home-filters, .home-search {
    width: 100%;
  }
  .folder-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .folder-card {
    padding: 16px;
  }

  /* Widok pakietu na telefonie */
  .sidebar-top {
    gap: 8px;
  }
  .folder-header h2 {
    font-size: 1.15rem;
  }
  .folder-meta {
    font-size: 0.78rem;
  }
  .wiki-card {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 82%;
    display: flex;
    flex-direction: column;
  }
  .wiki-img {
    height: 120px;
  }
  .wiki-body {
    padding: 12px 14px;
  }
  .wiki-extract {
    max-height: 85px;
    font-size: 0.82rem;
  }
  #folderHint {
    display: none;
  }

  /* Widok gry na telefonie (Duolingo Mobile Lesson Layout) */
  .lesson-topbar {
    height: auto;
    min-height: 54px;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .lesson-close {
    font-size: 1.25rem;
    padding: 4px 8px;
  }
  .lesson-progress-wrap {
    flex: 1;
    min-width: 110px;
  }
  .lesson-progress-bar {
    height: 12px;
  }
  .hud-dots {
    display: none;
  }
  .lesson-chips {
    gap: 5px;
  }
  .lesson-chip {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 10px;
    gap: 4px;
  }
  .lesson-chip.gem {
    display: none;
  }
  .chip-svg, .heart-svg {
    width: 16px;
    height: 16px;
  }
  .game-style-pills {
    order: 4;
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
    padding: 3px;
  }
  .style-pill {
    flex: 1;
    text-align: center;
    padding: 4px 6px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  /* Dymek z pytaniem na telefonie — kompaktowy u góry mapy */
  @keyframes promptPopMobile {
    0% { opacity: 0; transform: translateY(-12px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
  }
  .prompt-bubble {
    top: 8px;
    left: 8px;
    right: 8px;
    transform: none;
    max-width: none;
    padding: 9px 12px;
    border-radius: 18px;
    gap: 10px;
    animation: promptPopMobile 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .prompt-mascot {
    width: 40px;
    height: 40px;
  }
  .hud-photo {
    width: 58px;
    height: 46px;
    border-radius: 10px;
  }
  .prompt-kicker {
    font-size: 0.65rem;
  }
  .prompt-place {
    font-size: 1.12rem;
  }
  .prompt-sub {
    font-size: 0.76rem;
  }
  .tol-badge, .timer-badge {
    font-size: 0.68rem;
    padding: 1px 7px;
  }

  /* Pływające przyciski podpowiedzi na mapie */
  .map-helpers {
    left: 8px;
    right: 8px;
    bottom: 10px;
    gap: 6px;
    flex-wrap: wrap;
    pointer-events: none;
  }
  .map-helpers .btn {
    pointer-events: auto;
    padding: 7px 10px;
    font-size: 0.72rem;
    border-radius: 12px;
  }

  /* Dolna szuflada wyniku i przycisku strzału na telefonie */
  .lesson-footer {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .footer-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .rr-main {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .rr-msg {
    font-size: 1.08rem;
  }
  .rr-name {
    font-size: 0.85rem;
    line-height: 1.35;
  }
  .rr-stats {
    width: 100%;
    justify-content: space-between;
    text-align: left;
    border-top: 1.5px solid rgba(0, 0, 0, 0.08);
    padding-top: 6px;
  }
  .rr-stats b {
    font-size: 1.1rem;
  }
  .footer-actions {
    width: 100%;
    gap: 8px;
  }
  .footer-actions #guessBtn {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.88rem;
  }

  /* Modale na telefonie (Bottom-Sheet / Pełna szerokość) */
  .modal-backdrop {
    padding: 8px;
    align-items: flex-end;
  }
  .modal, .modal.wide {
    width: 100%;
    max-height: calc(100dvh - 16px);
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px;
    gap: 12px;
  }
  .modal-head h3 {
    font-size: 1.12rem;
  }
  .style-cards, .mode-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .style-card {
    padding: 10px;
  }
  .sc-title {
    font-size: 0.83rem;
  }
  .style-card small {
    font-size: 0.71rem;
  }
  .preset-grid {
    grid-template-columns: 1fr;
  }
  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .tab {
    font-size: 0.78rem;
    padding: 8px 6px;
    text-align: center;
  }
  .end-score .big {
    font-size: 2.5rem;
  }
  .modal-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .modal-foot .btn {
    width: 100%;
  }
  .modal-foot.between {
    flex-direction: column-reverse;
  }

  /* Toasty na telefonie */
  #toasts {
    left: 12px;
    right: 12px;
    bottom: 14px;
    max-width: none;
  }
}

/* ---------- Skróty Klawiszowe i KBD ---------- */
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
}
kbd {
  font-family: inherit;
  font-weight: 900;
  font-size: 0.82rem;
  background: var(--surface);
  color: var(--text-strong);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 10px;
  padding: 4px 10px;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ---------- Historia Rozgrywek (Match History Table) ---------- */
.history-table-wrap {
  width: 100%;
  overflow-x: auto;
}
.history-table {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 580px;
}
.ht-header {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.8fr 1.4fr 0.9fr 1.4fr;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.ht-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.8fr 1.4fr 0.9fr 1.4fr;
  align-items: center;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.86rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.ht-row:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
}
.ht-pack {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ht-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  text-transform: capitalize;
}
.ht-ico {
  display: inline-flex;
  width: 18px;
  height: 18px;
}
.ht-ico svg {
  width: 100%;
  height: 100%;
}
.rank-sm {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 8px;
}
.empty-history-box {
  background: var(--surface-soft);
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
}
