:root {
  color-scheme: light;
  --bg: #fff7ec;
  --card: #ffffff;
  --ink: #23204a;
  --muted: #6f6a8f;
  --line: #ece4f7;
  --primary: #5b4bdb;
  --primary-d: #4535c4;
  --primary-soft: #efecff;
  --orange: #ff8a3d;
  --yellow: #ffc93c;
  --green: #1f9d63;
  --green-soft: #def6e9;
  --red: #d8463f;
  --red-soft: #fde6e4;
  --radius: 20px;
  --shadow: 0 6px 0 #e9dcf5, 0 14px 30px #5b4bdb14;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh;
  background-image: radial-gradient(circle at 10% 0%, #ffe6c7 0, transparent 35%), radial-gradient(circle at 100% 20%, #e8e3ff 0, transparent 30%); background-attachment: fixed; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; }
h3 { font-size: 1.15rem; }
p { line-height: 1.5; }

.app { max-width: 780px; margin: 0 auto; padding: 18px 16px 48px; }
.loading { text-align: center; padding: 80px 0; font-size: 1.2rem; color: var(--muted); }
.center { text-align: center; }
.muted { color: var(--muted); font-size: .95rem; }
.screen.narrow { max-width: 520px; margin: 0 auto; }

/* nagłówek */
.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-size: clamp(2rem, 7vw, 3rem); font-weight: 900; letter-spacing: -.02em; }
.hero h1 span { color: var(--primary); }
.hero p { color: var(--muted); font-size: 1.1rem; margin: .2em 0 0; }
.hero.small { padding: 8px 0 4px; }
.hero.small h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.logo { font-size: 2.6rem; margin-bottom: 6px; }

/* karty, przyciski */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin: 16px 0; border: 1px solid var(--line); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 14px; padding: 13px 20px; font-weight: 800; font-size: 1rem;
  background: var(--primary-soft); color: var(--primary); box-shadow: 0 4px 0 #d9d2ff; transition: transform .08s; text-decoration: none; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9d2ff; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-d); }
.btn.primary:active { box-shadow: 0 1px 0 var(--primary-d); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.big { font-size: 1.2rem; padding: 16px 22px; width: 100%; }
.btn.small { padding: 9px 14px; font-size: .95rem; }
.btn.bad { background: var(--red-soft); color: var(--red); box-shadow: 0 4px 0 #f6c9c5; }
.btn:disabled { opacity: .6; }
.link { background: none; border: 0; color: var(--primary); font-weight: 700; padding: 6px; text-decoration: underline; text-underline-offset: 3px; }
.back { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-weight: 700; color: var(--muted); }
.notice { background: #fff3cd; border: 1px solid #f5d77c; color: #6b5200; padding: 12px 16px; border-radius: 14px; text-align: center; }
.privacy { color: var(--muted); font-size: .88rem; text-align: center; max-width: 560px; margin: 26px auto 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; transition: .25s; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* gracze */
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 22px 0 10px; }
.player { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: var(--shadow); transition: transform .1s; }
.player:hover { transform: translateY(-2px); border-color: #cfc6ff; }
.player b { font-size: 1.2rem; }
.player small { color: var(--muted); }
.player.add { border-style: dashed; background: #fffdf9; }
.avatar { font-size: 1.6rem; line-height: 1; }
.avatar.big { font-size: 3.2rem; display: block; margin-bottom: 4px; }

/* formularze */
.form { display: grid; gap: 12px; }
.form label, .label { font-weight: 800; margin: 0; }
.form input[type=text], .form input:not([type]), .code-input { width: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px; font-size: 1.25rem; background: #fff; }
.form input:focus { outline: none; border-color: var(--primary); }
.code-input { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 800; }
.hint { color: var(--muted); font-size: .9rem; margin: 0; text-align: center; }
.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.av input { position: absolute; opacity: 0; pointer-events: none; }
.av span { display: grid; place-items: center; font-size: 2rem; height: 58px; border-radius: 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; transition: .1s; }
.av input:checked + span { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.08); }
.av input:focus-visible + span { outline: 3px solid var(--yellow); }

/* menu dziecka */
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.me { display: flex; align-items: center; gap: 6px; font-size: 1.05rem; margin-right: auto; }
.chips { display: flex; gap: 6px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 800; }
.chip.hot { background: #fff0e4; border-color: #ffd2b0; color: #c75a12; }
.greet { padding: 18px 2px 0; }
.greet h2 { font-size: clamp(1.6rem, 5vw, 2.1rem); }
.greet p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.type { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.type small { color: var(--muted); font-variant-numeric: tabular-nums; }
.type.on { border-color: var(--primary); background: var(--primary-soft); }
.type.on b { color: var(--primary); }
.modes { display: grid; gap: 12px; }
.mode { display: flex; align-items: center; gap: 16px; text-align: left; border: 0; border-radius: var(--radius); padding: 18px 20px; color: #fff; transition: transform .08s; }
.mode:active { transform: translateY(3px); }
.mode b { display: block; font-size: 1.35rem; }
.mode small { opacity: .92; font-size: .95rem; }
.mode .mi { font-size: 2.2rem; background: #ffffff2e; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 16px; flex: none; }
.mode.train { background: linear-gradient(135deg, #6b5bf0, #5040d4); box-shadow: 0 6px 0 #3d2fb0; }
.mode.challenge { background: linear-gradient(135deg, #ff9a4d, #f2712a); box-shadow: 0 6px 0 #cc5a1c; }
.mode.quiz { background: linear-gradient(135deg, #f0619f, #d4407f); box-shadow: 0 6px 0 #a92d62; }
.mode.weak { background: linear-gradient(135deg, #2bb673, #1c9659); box-shadow: 0 6px 0 #157346; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.tiles button { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--shadow); }
.tiles span { font-size: 1.8rem; }
.tiles small { color: var(--muted); font-size: .82rem; text-align: center; }

/* gra */
.play { max-width: 520px; margin: 0 auto; }
.playbar { display: flex; align-items: center; gap: 10px; }
.progress { flex: 1; height: 14px; background: #fff; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--yellow), var(--orange)); border-radius: 99px; transition: width .3s; }
.play.train .progress div, .play.fix .progress div { background: linear-gradient(90deg, #8f84ff, var(--primary)); }
.play.weak .progress div { background: linear-gradient(90deg, #66d39b, var(--green)); }
.count { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { font-weight: 900; font-size: 1.3rem; color: var(--primary); font-variant-numeric: tabular-nums; background: #fff; border-radius: 12px; padding: 4px 10px; border: 1px solid var(--line); }
.timer.urgent { color: var(--red); animation: pulse 1s infinite; }
.kindlabel { text-align: center; color: var(--muted); font-weight: 700; margin: 14px 0 6px; font-size: .95rem; }
.qcard { background: var(--card); border-radius: 26px; padding: 26px 18px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.qexpr { display: flex; justify-content: center; align-items: center; gap: 12px; font-size: clamp(2.3rem, 10vw, 3.4rem); font-weight: 900; font-variant-numeric: tabular-nums; min-height: 90px; }
.qexpr .op { color: var(--primary); }
.slot { width: 2.6em; min-width: 0; height: 1.5em; font: inherit; font-size: 1em; text-align: center; border: 3px dashed #b9b0ff; border-radius: 16px; background: var(--primary-soft); color: var(--ink); caret-color: var(--primary); padding: 0; }
.slot:focus { outline: none; border-style: solid; border-color: var(--primary); background: #fff; }
.slot.right { border: 3px solid var(--green); background: var(--green-soft); color: var(--green); }
.slot.wrong { border: 3px solid var(--red); background: var(--red-soft); color: var(--red); text-decoration: line-through; }
.slot.shake { animation: shake .35s; }
.feedback { min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; font-size: 1.25rem; font-weight: 800; margin: 8px 0; text-align: center; }
.feedback .good { color: var(--green); animation: pop .3s; }
.feedback .bad { color: var(--red); }
.feedback .muted { font-size: .95rem; font-weight: 600; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; margin: 0 auto; }
.keypad button { border: 0; border-radius: 16px; background: #f4f1ff; font-size: 1.7rem; font-weight: 800; padding: 14px 0; box-shadow: 0 4px 0 #ddd6ff; color: var(--ink); touch-action: manipulation; }
.keypad button:active { transform: translateY(3px); box-shadow: 0 1px 0 #ddd6ff; }
.keypad .kdel { background: #fff0e4; box-shadow: 0 4px 0 #ffd6b8; }
.keypad .kok { background: var(--green); color: #fff; box-shadow: 0 4px 0 #157346; }
.skip { display: block; margin: 14px auto 0; }
.play.quiz .progress div { background: linear-gradient(90deg, #ff9cc7, #e04f8f); }
.qslot { display: inline-grid; place-items: center; color: var(--primary); }
.qslot.right { border: 3px solid var(--green); background: var(--green-soft); color: var(--green); }
.qslot.wrong { border: 3px solid var(--red); background: var(--red-soft); color: var(--red); text-decoration: line-through; }
.pickhint { text-align: center; color: var(--muted); font-weight: 700; margin: 4px 0 12px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 400px; margin: 0 auto; }
.opt { position: relative; border: 2px solid var(--line); background: #f7f5ff; border-radius: 18px; padding: 18px 0; font-size: 2rem; font-weight: 900; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 0 #ddd6ff; color: var(--ink); touch-action: manipulation; transition: transform .08s; }
.opt small { position: absolute; top: 6px; left: 10px; font-size: .75rem; color: #b3abc8; font-weight: 700; }
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 #ddd6ff; }
.opt:disabled { cursor: default; opacity: .55; }
.opt.right { opacity: 1; background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 4px 0 #157346; animation: pop .3s; }
.opt.right small { color: #ffffffaa; }
.opt.wrong { opacity: 1; background: var(--red-soft); border-color: var(--red); color: var(--red); box-shadow: 0 4px 0 #f6c9c5; }

/* wynik */
.result { text-align: center; padding-top: 10px; }
.stars { font-size: 4.2rem; letter-spacing: .1em; margin: 6px 0; }
.star { color: #e7e1f3; display: inline-block; }
.star.on { color: var(--yellow); text-shadow: 0 4px 0 #e6a700; animation: starIn .5s both; }
.score { font-size: 1.3rem; margin: 4px 0 10px; }
.score b { font-size: 2rem; color: var(--primary); }
.pill { display: inline-block; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; margin: 4px; font-weight: 800; }
.newbadges { margin: 16px 0; }
.newbadges .badges { display: flex; flex-wrap: wrap; justify-content: center; }
.newbadges .badge { width: 160px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.mistakes { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; text-align: left; }
.mistakes li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #faf8ff; font-weight: 700; font-variant-numeric: tabular-nums; }
.mistakes li.no { background: var(--red-soft); color: #9f2f29; }
.mistakes li.ok { background: var(--green-soft); color: #14704a; }

/* mapa */
.tmap { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; font-variant-numeric: tabular-nums; }
.tmap span { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; font-size: clamp(.62rem, 2.4vw, .95rem); font-weight: 800; }
.tmap .hd { color: var(--primary); background: transparent; }
.cell.l0, .legend .l0 { background: #f1eef7; color: #b3abc8; }
.cell.l1, .legend .l1 { background: #ffd9bf; color: #a24a0e; }
.cell.l2, .legend .l2 { background: #c8f0d9; color: #1b7a4b; }
.cell.l3, .legend .l3 { background: var(--green); color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: .88rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; }

/* odznaki */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 14px 8px; border-radius: 16px; background: #f6f4fa; border: 2px dashed #e1dbee; display: flex; flex-direction: column; align-items: center; gap: 3px; opacity: .55; filter: grayscale(1); }
.badge.on { background: #fffaf0; border: 2px solid #ffe2a3; opacity: 1; filter: none; }
.badge .bi { font-size: 2rem; font-weight: 900; color: var(--primary); width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: #fff; box-shadow: 0 3px 0 #f0e6cc; }
.badge small { color: var(--muted); font-size: .8rem; }

/* rodzic */
.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.stats4 div { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 8px; text-align: center; box-shadow: var(--shadow); }
.stats4 b { display: block; font-size: 1.8rem; color: var(--primary); }
.stats4 b small { font-size: 1rem; color: var(--muted); }
.stats4 span { font-size: .82rem; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.chart .gl { stroke: #eee9f6; stroke-width: 1; }
.chart .gt { fill: #9a94b5; font-size: 15px; font-weight: 700; text-anchor: end; }
.chart .ln { fill: none; stroke: #c9c1f5; stroke-width: 4; stroke-linejoin: round; }
.chart .pt { stroke: #fff; stroke-width: 2.5; }
.pt.train, .dot.train { fill: var(--primary); background: var(--primary); }
.pt.challenge, .dot.challenge { fill: var(--orange); background: var(--orange); }
.pt.quiz, .dot.quiz { fill: #e04f8f; background: #e04f8f; }
.pt.weak, .pt.fix, .dot.weak { fill: var(--green); background: var(--green); }
.legend .dot { border-radius: 50%; }
.weak { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.wchip { background: #fff0e4; color: #a24a0e; border-radius: 999px; padding: 6px 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hist { display: grid; gap: 6px; }
.hist details { border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.hist summary { display: grid; grid-template-columns: 120px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; list-style: none; }
.hist summary::-webkit-details-marker { display: none; }
.hist details[open] summary { border-bottom: 1px solid var(--line); }
.hist details > p, .hist details > ul { margin: 10px 12px; }
.hist details > ul { margin-bottom: 12px; }
.hd8 { color: var(--muted); font-size: .88rem; }
.hk { font-weight: 700; font-size: .95rem; }
.hs { font-variant-numeric: tabular-nums; }
.hs b { font-size: 1.15rem; color: var(--primary); }
.hst { color: var(--yellow); letter-spacing: 1px; }
.hst span { color: #e7e1f3; }
.share { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr { width: 150px; flex: none; background: #fff; border-radius: 12px; border: 1px solid var(--line); padding: 4px; }
.qr:empty { display: none; }
.qr svg { display: block; width: 100%; height: auto; }
.share-side { flex: 1; min-width: 220px; display: grid; gap: 10px; justify-items: start; }
.linkbox { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #faf8ff; font-size: .85rem; color: var(--muted); }
.bigcode { font-size: 2.2rem; font-weight: 900; letter-spacing: .15em; color: var(--primary); font-variant-numeric: tabular-nums; }
.card.danger { border-color: #f6d6d3; }
.netbar { position: sticky; top: 0; z-index: 30; background: #e6f0ff; color: #24427a; text-align: center; font-weight: 700; font-size: .9rem; padding: 8px 16px; border-bottom: 1px solid #c8dafc; }
.netbar.off { background: #fff3cd; color: #6b5200; border-bottom-color: #f5d77c; }
.install-row { display: flex; align-items: center; gap: 12px; }
.install-row > div { flex: 1; display: flex; flex-direction: column; }
.install-row small { color: var(--muted); }
.install-ic { font-size: 2rem; }
.install-help { margin: 12px 0 0; background: var(--primary-soft); border-radius: 12px; padding: 10px 14px; font-size: .95rem; }
@media (display-mode: standalone) { body { padding-top: env(safe-area-inset-top); } }

/* konfetti i animacje */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(40px); } }
@keyframes starIn { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-4px); } }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .confetti { display: none; } }

@media (max-width: 560px) {
  .app { padding: 12px 16px 40px; }
  .tiles { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .tiles button { padding: 12px 4px; }
  .tiles b { font-size: .88rem; text-align: center; }
  .stats4 { grid-template-columns: 1fr 1fr; }
  .mode { padding: 14px 16px; }
  .mode .mi { width: 48px; height: 48px; font-size: 1.8rem; }
  .hist summary { grid-template-columns: 1fr auto auto; }
  .hd8 { grid-column: 1 / -1; }
  .card { padding: 16px; }
  .qr { width: 130px; }
}
