:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #1e293b;
  --card-2: #273449;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #f59e0b;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Atrybut hidden musi wygrywać z regułami display:* (np. .install-bar, .keypad, .choices) */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "SF Pro Rounded", system-ui, Roboto, sans-serif;
  overscroll-behavior: none;
}

body { user-select: none; -webkit-user-select: none; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: var(--safe-bottom);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  font-size: 20px; color: #fff;
}
.brand-name { letter-spacing: -0.5px; }
.stats { margin-left: auto; display: flex; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); padding: 6px 11px; border-radius: 999px;
  font-weight: 700; font-size: 14px;
}
.pill-ico { font-size: 14px; }

.icon-btn {
  background: var(--card); color: var(--text); border: none;
  width: 38px; height: 38px; border-radius: 12px; font-size: 22px;
  cursor: pointer; display: grid; place-items: center; line-height: 1;
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- Screens ---------- */
main { flex: 1; position: relative; padding: 4px 16px 24px; }
.screen { display: none; animation: fade 0.25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { padding: 8px 4px 18px; }
.hero h1 { font-size: 28px; }
.hero-sub { color: var(--text-dim); margin-top: 4px; }

/* ---------- Karty działów ---------- */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cat-card {
  border: none; text-align: left; cursor: pointer; color: #fff;
  border-radius: var(--radius); padding: 16px; min-height: 118px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform 0.12s ease;
}
.cat-card:active { transform: scale(0.96); }
.cat-card .emoji { font-size: 30px; }
.cat-card .cat-name { font-weight: 800; font-size: 17px; margin-top: 6px; }
.cat-card .cat-stars { font-size: 13px; opacity: 0.9; margin-top: 4px; }
.cat-card::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.badges-row { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  background: var(--card); border-radius: 999px; padding: 8px 12px;
  font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center;
}
.badge.locked { opacity: 0.4; }

/* ---------- Social + wsparcie (stopka) ---------- */
.social {
  margin-top: 22px; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: center; gap: 14px;
}
.social-icons { display: flex; gap: 10px; }
.social-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--card); color: var(--text-dim); text-decoration: none;
  transition: transform .12s ease, color .12s ease, background .12s ease;
}
.social-btn svg { width: 20px; height: 20px; }
.social-btn:hover, .social-btn:focus-visible { color: var(--text); background: var(--card-2); transform: translateY(-2px); }
.social-btn[data-net="facebook"]:hover { color: #1877f2; }
.social-btn[data-net="instagram"]:hover { color: #e1306c; }
.social-btn[data-net="youtube"]:hover { color: #ff0000; }
.social-btn[data-net="tiktok"]:hover { color: #fff; }
.coffee-btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--warn); color: #1f2937; font-weight: 700; font-size: 14px;
  padding: 9px 15px; border-radius: 999px; transition: transform .12s ease, filter .12s ease;
}
.coffee-btn svg { width: 18px; height: 18px; }
.coffee-btn:hover, .coffee-btn:focus-visible { transform: translateY(-2px); filter: brightness(1.05); }
.acc-support { text-decoration: none; }

/* ---------- Wybór poziomu ---------- */
.level-head { text-align: center; padding: 14px 0 20px; }
.level-emoji { font-size: 46px; }
.level-head h2 { font-size: 24px; margin-top: 6px; }
.level-list { display: flex; flex-direction: column; gap: 12px; }
.level-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--card); border: 2px solid transparent; color: var(--text);
  border-radius: 16px; padding: 16px; cursor: pointer; font: inherit;
}
.level-btn:active { transform: scale(0.98); }
.level-btn .lv-num {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.level-btn .lv-info { flex: 1; }
.level-btn .lv-title { font-weight: 700; }
.level-btn .lv-desc { font-size: 13px; color: var(--text-dim); }
.level-btn .lv-stars { color: var(--warn); font-size: 15px; letter-spacing: 1px; }

/* ---------- Quiz ---------- */
.quiz-top { padding: 8px 0 4px; }
.progress { height: 10px; background: var(--card); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.3s ease;
}
.quiz-meta { display: flex; justify-content: space-between; margin-top: 8px; color: var(--text-dim); font-weight: 600; }
.quiz-score { color: var(--warn); }

.question-area { text-align: center; padding: 26px 0 14px; }
.question { font-size: clamp(40px, 12vw, 60px); font-weight: 800; letter-spacing: -1px; }
.answer-display {
  margin: 18px auto 6px; min-width: 160px; min-height: 62px;
  background: var(--card); border-radius: 16px; font-size: 34px; font-weight: 800;
  display: grid; place-items: center; padding: 8px 20px; border: 2px solid var(--card-2);
}
.answer-display.filled { border-color: var(--primary); }
.feedback { min-height: 26px; font-weight: 700; margin-top: 6px; }
.feedback.ok { color: var(--ok); }
.feedback.err { color: var(--err); }

.shake { animation: shake 0.4s; }
@keyframes shake { 0%,100%{transform:none} 20%,60%{transform:translateX(-8px)} 40%,80%{transform:translateX(8px)} }
.pop { animation: pop 0.35s; }
@keyframes pop { 0%{transform:scale(1)} 40%{transform:scale(1.12)} 100%{transform:scale(1)} }

/* ---------- Klawiatura ---------- */
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-width: 340px; margin: 8px auto 0;
}
.key {
  border: none; background: var(--card); color: var(--text);
  font-size: 26px; font-weight: 700; padding: 16px 0; border-radius: 16px;
  cursor: pointer; font-family: inherit;
}
.key:active { transform: scale(0.94); background: var(--card-2); }
.key-util { background: var(--card-2); }
.key-ok { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }

/* ---------- Wybór (porównywanie) ---------- */
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 340px; margin: 20px auto 0; }
.choice-btn {
  border: none; background: var(--card); color: var(--text);
  font-size: 40px; font-weight: 800; padding: 22px 0; border-radius: 18px; cursor: pointer;
}
.choice-btn:active { transform: scale(0.95); }

/* ---------- Wynik ---------- */
.result-card { text-align: center; padding: 30px 20px; background: var(--card); border-radius: 24px; margin-top: 14px; box-shadow: var(--shadow); }
.result-card .stars { font-size: 52px; color: var(--warn); letter-spacing: 6px; }
.result-card h2 { font-size: 26px; margin: 10px 0; }
.result-line { color: var(--text-dim); font-weight: 600; }
.result-points { color: var(--warn); font-size: 22px; font-weight: 800; margin-top: 8px; }
.result-best { color: var(--text-dim); font-size: 14px; margin-top: 6px; min-height: 18px; }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

.btn { border: none; border-radius: 14px; padding: 15px; font-size: 17px; font-weight: 700; cursor: pointer; font-family: inherit; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-ghost { background: var(--card-2); color: var(--text); }
.btn-small { padding: 8px 14px; font-size: 14px; border-radius: 10px; background: #fff; color: var(--primary); }

/* ---------- Install bar ---------- */
.install-bar {
  position: sticky; bottom: 0; margin: 0 12px calc(12px + var(--safe-bottom));
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  padding: 12px 14px; border-radius: 16px; display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); z-index: 30;
}
.install-bar .icon-btn { background: rgba(255,255,255,0.2); color: #fff; width: 30px; height: 30px; font-size: 18px; }

/* ---------- Sound toggle ---------- */
.toggles {
  position: fixed; right: 14px; bottom: calc(14px + var(--safe-bottom));
  z-index: 25; display: flex; flex-direction: column; gap: 10px;
}
.sound-toggle {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--card); color: var(--text); font-size: 20px; box-shadow: var(--shadow);
}
.sound-toggle.off { opacity: 0.55; }
.lang-toggle { font-size: 14px; font-weight: 800; letter-spacing: 0.5px; }
.question { cursor: pointer; }
/* Dostępność: wyraźny fokus z klawiatury */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
/* Dostępność: szanuj preferencję ograniczenia ruchu */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Gry ---------- */
.section-title { margin: 26px 4px 12px; font-size: 20px; font-weight: 800; }
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-card {
  border: none; text-align: left; cursor: pointer; color: #fff;
  border-radius: var(--radius); padding: 16px; min-height: 96px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform 0.12s ease;
}
.game-card:active { transform: scale(0.96); }
.game-card .emoji { font-size: 30px; }
.game-card::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,0.12);
}

/* HUD */
.game-hud { display: flex; justify-content: center; gap: 10px; padding: 6px 0 10px; flex-wrap: wrap; }
.hud-item {
  background: var(--card); border-radius: 999px; padding: 8px 16px;
  font-weight: 800; font-size: 18px; min-width: 76px; text-align: center;
}

/* Na czas / wspólne */
.game-q { text-align: center; font-size: clamp(40px, 12vw, 60px); font-weight: 800; padding: 18px 0 4px; }
.game-combo { text-align: center; min-height: 24px; color: var(--warn); font-weight: 800; font-size: 18px; }
.pop { animation: pop 0.35s; }

/* Spadające liczby */
.fall-track {
  position: relative; height: clamp(240px, 40vh, 360px); margin: 6px 0 14px;
  background: var(--card); border-radius: 18px; overflow: hidden; border: 2px solid var(--card-2);
}
.fall-box {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  padding: 12px 22px; border-radius: 14px; font-size: 30px; font-weight: 800; white-space: nowrap;
  box-shadow: var(--shadow);
}

/* Prawda / Fałsz */
.tf-eq { text-align: center; font-size: clamp(38px, 11vw, 56px); font-weight: 800; padding: 30px 0 8px; }
.tf-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 460px; margin: 10px auto 0; }
.tf-btn { border: none; border-radius: 18px; padding: 26px 0; font-size: 20px; font-weight: 800; color: #fff; cursor: pointer; font-family: inherit; }
.tf-btn:active { transform: scale(0.96); }
.tf-yes { background: linear-gradient(135deg, #22c55e, #16a34a); }
.tf-no  { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* Memory */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 440px; margin: 12px auto 0; }
.mem-card {
  aspect-ratio: 1; border: none; border-radius: 14px; cursor: pointer; font-family: inherit;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  font-size: clamp(15px, 4.4vw, 22px); font-weight: 800; display: grid; place-items: center;
  transition: transform 0.1s ease;
}
.mem-card:active { transform: scale(0.95); }
.mem-card .mem-face { opacity: 0; transition: opacity 0.12s; }
.mem-card.open { background: var(--card-2); }
.mem-card.open .mem-face, .mem-card.done .mem-face { opacity: 1; }
.mem-card.done { background: linear-gradient(135deg, #22c55e, #16a34a); }

/* Gra 2048 */
.g2048-board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  max-width: 440px; margin: 12px auto 0; padding: 10px;
  background: var(--card); border-radius: 18px; border: 2px solid var(--card-2);
  touch-action: none;
}
.g2048-cell {
  aspect-ratio: 1; border-radius: 12px; background: var(--card-2);
  display: grid; place-items: center;
  font-weight: 800; font-size: clamp(18px, 6vw, 30px); color: #fff;
}
.g2048-tile.v2   { background: #64748b; }
.g2048-tile.v4   { background: #475569; }
.g2048-tile.v8   { background: #f59e0b; }
.g2048-tile.v16  { background: #f97316; }
.g2048-tile.v32  { background: #ef4444; }
.g2048-tile.v64  { background: #dc2626; }
.g2048-tile.v128 { background: #14b8a6; font-size: clamp(16px, 5.4vw, 27px); }
.g2048-tile.v256 { background: #0ea5e9; font-size: clamp(16px, 5.4vw, 27px); }
.g2048-tile.v512 { background: #6366f1; font-size: clamp(16px, 5.4vw, 27px); }
.g2048-tile.v1024 { background: #a855f7; font-size: clamp(14px, 4.6vw, 23px); }
.g2048-tile.v2048 { background: linear-gradient(135deg, #facc15, #f59e0b); color: #1e293b; font-size: clamp(14px, 4.6vw, 23px); }
.g2048-tile.vbig { background: linear-gradient(135deg, #22c55e, #16a34a); font-size: clamp(13px, 4.2vw, 21px); }
.g2048-hint { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 12px; }

/* Gra: Wąż matematyczny */
.snake-board {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  gap: 2px; width: 100%; max-width: 360px; aspect-ratio: 1; margin: 8px auto 0;
  background: var(--card-2); padding: 4px; border-radius: 14px; touch-action: none;
}
.snake-cell {
  background: var(--bg); border-radius: 3px;
  display: grid; place-items: center; font-size: clamp(11px, 3vw, 16px); font-weight: 800; color: var(--text-dim);
}
.snake-food { background: var(--warn); color: #1f2937; border-radius: 6px; box-shadow: 0 0 8px rgba(245,158,11,.6); }
.snake-body { background: #34d399; border-radius: 3px; }
.snake-head { background: #10b981; border-radius: 5px; box-shadow: 0 0 8px rgba(16,185,129,.7); }

/* Gra: Samoloty */
.planes-sky {
  position: relative; width: 100%; height: min(48vh, 380px); margin: 8px auto 0;
  overflow: hidden; border-radius: 16px; touch-action: manipulation;
  background: linear-gradient(180deg, #0b3a5b, #0f172a);
}
.plane {
  position: absolute; left: 0; will-change: transform;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.plane-body { font-size: clamp(30px, 9vw, 46px); line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.plane-num {
  min-width: 30px; padding: 2px 8px; border-radius: 999px; font-size: 16px; font-weight: 800;
  background: #fff; color: #0f172a;
}
.plane.boom .plane-body { animation: planeBoom .28s ease forwards; }
.plane.boom .plane-num { background: var(--ok); color: #fff; }
.plane.boom-wrong .plane-num { background: var(--err); color: #fff; }
@keyframes planeBoom { 0% { transform: scale(1); } 50% { transform: scale(1.6); } 100% { transform: scale(0); opacity: 0; } }

/* Powtórka błędów + adaptacyjna trudność */
.review-card { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.level-btn.suggested { border-color: var(--primary); }
.lv-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: var(--primary); color: #fff; vertical-align: middle;
}

/* Gamifikacja: wyzwanie dnia, cele tygodnia */
.daily-card { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.daily-card.done { opacity: 0.6; }
.weekly {
  margin: 18px 0 4px; padding: 14px 16px; background: var(--card);
  border: 1px solid var(--card-2); border-radius: var(--radius);
}
.wk-title { font-weight: 700; margin-bottom: 10px; }
.wk-goal { display: grid; gap: 6px; margin-bottom: 10px; font-size: 13px; color: var(--text-dim); }
.wk-goal:last-child { margin-bottom: 0; }
.wk-bar { height: 8px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.wk-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 999px; }

/* Liga tygodniowa */
.league {
  margin: 18px 0 4px; padding: 14px 16px; background: var(--card);
  border: 1px solid var(--card-2); border-radius: var(--radius);
}
.lg-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lg-title { font-weight: 700; }
.lg-you { font-size: 12px; color: var(--text-dim); }
.lg-intro { font-size: 13px; color: var(--text-dim); margin: 8px 0 12px; line-height: 1.4; }
.lg-join { width: 100%; }
.lg-board { margin: 12px 0 4px; display: grid; gap: 4px; }
.lg-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 10px; background: var(--card-2); font-size: 14px;
}
.lg-row.me { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 700; }
.lg-me-out { margin-top: 6px; }
.lg-rank { text-align: center; font-weight: 700; }
.lg-nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.lg-foot { display: flex; gap: 16px; margin-top: 12px; }

/* Gra: Sortowanie */
.sort-hint { text-align: center; color: var(--text-dim); font-size: 14px; margin: 10px 0 4px; }
.sort-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 440px; margin: 14px auto 0; }
.sort-btn {
  width: 72px; height: 72px; border-radius: 16px; border: 2px solid var(--card-2);
  background: var(--card); color: var(--text); font-size: 24px; font-weight: 800; cursor: pointer;
  transition: transform 0.1s ease;
}
.sort-btn:active { transform: scale(0.94); }
.sort-btn.done { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; border-color: transparent; }
.sort-btn.wrong { background: #ef4444; color: #fff; border-color: transparent; }

/* Synchronizacja postępu — karta spójna z widżetem celów tygodnia */
.sync-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  margin: 12px 0 4px; padding: 14px 16px; font-family: inherit; cursor: pointer;
  background: var(--card); border: 1px solid var(--card-2); border-radius: var(--radius); color: var(--text);
  transition: transform 0.1s ease;
}
.sync-card:active { transform: scale(0.99); }
.sync-card .hc-icon { font-size: 22px; line-height: 1; }
.sync-card .hc-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.sync-card .hc-title { font-weight: 700; font-size: 15px; }
.sync-card .hc-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.sync-card .hc-arrow { color: var(--text-dim); font-size: 24px; font-weight: 700; }

/* Raport rodzica */
.acc-report {
  width: 100%; margin-top: 12px; padding: 11px; border: none; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.acc-report:active { transform: scale(0.99); }
.acc-reminders {
  width: 100%; margin-top: 8px; padding: 11px; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700;
  background: var(--card-2); color: var(--text); border: 1px solid var(--card-2);
}
.acc-reminders.on { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; border-color: transparent; }
.acc-reminders:active { transform: scale(0.99); }
.report { max-width: 560px; margin: 0 auto; }
.report-title { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.rep-h { font-size: 15px; font-weight: 700; margin: 22px 0 10px; }
.rep-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rep-tile { background: var(--card); border: 1px solid var(--card-2); border-radius: 16px; padding: 12px 6px; text-align: center; }
.rep-ico { font-size: 22px; }
.rep-val { font-size: 20px; font-weight: 800; margin-top: 2px; }
.rep-lab { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.rep-mastery, .rep-weaks { background: var(--card); border: 1px solid var(--card-2); border-radius: 16px; padding: 6px 14px; }
.rep-cat, .rep-weak { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--card-2); }
.rep-cat:last-child, .rep-weak:last-child { border-bottom: none; }
.rep-cat-name, .rep-weak span:first-child { font-weight: 600; }
.rep-cat-stars { color: #facc15; letter-spacing: 2px; }
.rep-weak-n { font-size: 13px; color: #f43f5e; font-weight: 700; }
.rep-empty { color: var(--text-dim); padding: 8px 0; margin: 0; }

/* Modal (logowanie / dodawanie dziecka / komunikaty) */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  padding: 24px; background: rgba(15, 23, 42, 0.72); backdrop-filter: blur(4px);
}
.modal-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--card-2);
  border-radius: 22px; padding: 22px; box-shadow: var(--shadow); animation: pop 0.2s;
}
.modal-title { font-size: 20px; font-weight: 800; }
.modal-sub { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin-top: 6px; }
.modal-input {
  width: 100%; margin-top: 16px; padding: 12px 14px; font-size: 16px; font-family: inherit;
  background: var(--bg-soft); color: var(--text); border: 2px solid var(--card-2); border-radius: 12px;
}
.modal-input:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.modal-input + .modal-input { margin-top: 10px; }
.modal-err { color: #f87171; font-size: 13.5px; line-height: 1.5; margin-top: 6px; }
.modal-links { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; align-items: center; }
.modal-link {
  background: none; border: none; color: var(--primary-2); font-family: inherit;
  font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 2px;
}
.modal-link:hover { text-decoration: underline; }
.acc-foot { text-align: center; margin-top: 12px; }

/* Konto rodzica */
.account-card {
  margin: 12px 0 4px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--card-2); border-radius: var(--radius);
}
.acc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.acc-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-logout {
  border: none; background: var(--card-2); color: var(--text-dim);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.acc-children { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.child-chip {
  border: 2px solid var(--card-2); background: var(--card-2); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.child-chip.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; color: #fff; }
.child-chip.add { background: transparent; color: var(--text-dim); }

/* Notka o prywatności */
.privacy { margin: 26px 0 8px; text-align: center; }
.privacy summary {
  display: inline-block; cursor: pointer; color: var(--text-dim);
  font-size: 13px; list-style: none; padding: 4px 8px; border-radius: 8px;
}
.privacy summary::-webkit-details-marker { display: none; }
.privacy summary:hover { color: var(--text); }
.privacy p {
  max-width: 460px; margin: 8px auto 0; color: var(--text-dim);
  font-size: 12.5px; line-height: 1.5; text-align: left;
  background: var(--card); border: 1px solid var(--card-2);
  border-radius: 12px; padding: 12px 14px;
}
.privacy strong { color: var(--text); }
.about-link { background: none !important; border: none !important; padding: 6px 0 0 !important; text-align: center !important; }
.about-link a { color: var(--text-dim); font-size: 12.5px; }
.about-link a:hover { color: var(--text); }

/* Koniec gry (nakładka) */
.game-over {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  padding: 24px; background: rgba(15, 23, 42, 0.75); backdrop-filter: blur(4px);
}
.game-over .result-card { max-width: 360px; width: 100%; margin: 0; }

/* ============================================================
   RESPONSYWNOŚĆ — tablet i desktop
   ============================================================ */

/* --- TABLET (>= 700px) --- */
@media (min-width: 700px) {
  #app { max-width: 780px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  main { padding: 8px 24px 32px; }

  .hero { padding: 16px 4px 22px; }
  .hero h1 { font-size: 34px; }
  .hero-sub { font-size: 17px; }

  .cat-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .cat-card { min-height: 148px; padding: 20px; }
  .cat-card .emoji { font-size: 34px; }
  .cat-card .cat-name { font-size: 19px; }

  .keypad, .choices { max-width: 420px; }
  .key { font-size: 28px; padding: 20px 0; }
  .answer-display { font-size: 38px; min-height: 70px; }

  .game-grid { grid-template-columns: repeat(4, 1fr); }
  .game-card { min-height: 110px; flex-direction: column; align-items: flex-start; justify-content: space-between; }

  .level-list, .result-card { max-width: 620px; margin-left: auto; margin-right: auto; }
  .result-actions { flex-direction: row; justify-content: center; }
  .result-actions .btn { min-width: 200px; }
}

/* --- DESKTOP (>= 1024px): aplikacja jako wyśrodkowane „okno" --- */
@media (min-width: 1024px) {
  body { background: radial-gradient(1200px 700px at 50% -15%, #1e293b, var(--bg) 70%); }
  #app {
    max-width: 1060px;
    min-height: calc(100dvh - 48px);
    margin: 24px auto;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 28px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.55);
  }
  .topbar { position: static; padding: 22px 36px 14px; background: transparent; }
  .brand { font-size: 22px; }
  main { padding: 8px 36px 44px; }

  .hero h1 { font-size: 42px; }
  .cat-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; }
  .cat-card { min-height: 156px; }
  .game-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; }

  /* Ekrany gier wyśrodkowane na desktopie */
  #screen-game { max-width: 720px; margin: 0 auto; }
  .fall-track { height: 380px; }
  .memory-grid { max-width: 520px; }

  /* Quiz w dwóch kolumnach: pytanie po lewej, klawiatura/wybór po prawej */
  #screen-quiz.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-areas:
      "top top"
      "question pad"
      "question choices";
    align-items: center;
    column-gap: 48px;
    max-width: 900px;
    margin: 0 auto;
    padding-top: 24px;
  }
  #screen-quiz .quiz-top { grid-area: top; align-self: start; }
  #screen-quiz .question-area { grid-area: question; padding-top: 0; }
  #screen-quiz .keypad { grid-area: pad; margin: 0; }
  #screen-quiz .choices { grid-area: choices; margin: 0; }
  .question { font-size: clamp(48px, 6vw, 72px); }

  /* Przycisk dźwięku i baner instalacji wyrównane do prawej krawędzi „okna" */
  .toggles { right: max(20px, calc(50% - 530px + 20px)); bottom: 28px; }
  .install-bar { margin: 0 36px calc(20px); max-width: 520px; margin-left: auto; }

  /* Wskazówka o klawiaturze fizycznej */
  #screen-quiz.active::after {
    content: "Wskazówka: możesz odpowiadać klawiaturą (Enter = OK, Backspace = usuń)";
    grid-area: choices; align-self: end; text-align: center;
    color: var(--text-dim); font-size: 13px; margin-top: 8px;
  }
  #screen-quiz.active:has(.choices:not([hidden]))::after { content: none; }
}

/* Duże ekrany desktop (>= 1400px) */
@media (min-width: 1400px) {
  #app { max-width: 1180px; }
  .cat-grid { grid-template-columns: repeat(4, 1fr); gap: 22px; }
}

/* konfetti */
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 100; pointer-events: none; border-radius: 2px; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0.9; } }
