/* Display font: Fredoka lacks some Polish letters (ą ć ę ń ś ź ż), so Polish uses Baloo 2 */
:root {
  --display: 'Fredoka', 'Nunito', sans-serif;
  --bg: #fdf8f1; --panel: #ffffff; --ink: #24303d; --muted: #6b7684; --line: #ece4d8;
  --brand: #ff7a45; --brand2: #2bb3a3; --radius: 14px;
}
:root[lang="pl"] { --display: 'Baloo 2', 'Nunito', sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4, .chip b, .btn { font-family: var(--display); }

/* ---------- app chrome ---------- */
.topbar { display: flex; align-items: center; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; }
.brand .logo { width: 48px; height: 48px; display: block; }
.wordmark { letter-spacing: -.3px; }
.wordmark .wk { color: var(--brand); }
.wordmark .wo { color: var(--brand2); }
.brand b { font-family: var(--display); font-size: 21px; display: block; }
.brand small { color: var(--muted); }

.app { display: grid; grid-template-columns: 380px 1fr; gap: 0; min-height: calc(100vh - 77px); }
.panel { background: #fff; border-right: 1px solid var(--line); padding: 18px 20px 40px; overflow-y: auto; height: calc(100vh - 77px); position: sticky; top: 0; }
.step { margin-bottom: 22px; }
.step h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.step h2 .n { background: var(--brand); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; }
.link { margin-left: auto; background: none; border: 0; color: var(--brand2); font-size: 13px; font-weight: 700; font-family: 'Nunito'; }
label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
input:not([type=checkbox]), select { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; font: 600 15px 'Nunito'; color: var(--ink); background: #fffdf9; }
input:focus, select:focus { outline: 2px solid var(--brand); border-color: transparent; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 600; font-size: 14px; }
label.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 4px; text-align: center; }
.chip b { display: block; font-size: 18px; }
.chip small { color: var(--muted); font-size: 11px; }
.chip.on { border-color: var(--brand); background: #fff1e8; }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 4px; font-weight: 700; font-size: 12px; line-height: 1.2; }
.theme span { display: block; font-size: 26px; margin-bottom: 2px; }
.theme.on { border-color: var(--tc); background: var(--ts); }

.acts { display: flex; flex-direction: column; gap: 6px; }
.act { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); border-radius: 12px; padding: 7px 10px; opacity: .7; }
.act.on { opacity: 1; border-color: #ffd3bf; background: #fffaf6; }
.act .ae { font-size: 22px; }
.act .at { flex: 1; min-width: 0; }
.act .at b { display: block; font-size: 14px; }
.act .at small { color: var(--muted); font-size: 12px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff; font-weight: 800; color: var(--ink); }
.stepper button:hover { border-color: var(--brand); color: var(--brand); }
.stepper span { min-width: 14px; text-align: center; font-weight: 800; }

.previewwrap { padding: 16px 24px; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.summary { font-size: 15px; color: var(--muted); }
.summary b { color: var(--ink); }
.btns { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 12px; padding: 11px 18px; font-size: 16px; font-weight: 600; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 0 #d9551f; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #d9551f; }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; border: 2px solid var(--line); color: var(--ink); }
.tip { font-size: 13px; color: var(--muted); margin: 8px 0 14px; }
.preview { overflow: auto; padding-bottom: 40px; }
#pack { zoom: .62; display: flex; flex-direction: column; align-items: center; gap: 10mm; }
.empty { font: 600 28px var(--display); color: var(--muted); padding: 80px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .panel { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
  .previewwrap { padding: 16px; }
  #pack { zoom: .4; }
}

/* ---------- printable pages ---------- */
.page {
  width: 210mm; height: 297mm; padding: 12mm 14mm 9mm; background: #fff; color: #1f2933;
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  box-shadow: 0 6px 24px rgba(60, 40, 20, .14); border-top: 5mm solid var(--tc);
  font-size: 4.6mm; -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.paper-Letter .page { width: 215.9mm; height: 279.4mm; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; border-bottom: .6mm dashed var(--tc); padding-bottom: 2.5mm; margin-bottom: 3mm; }
.ph h1 { margin: 0; font-size: 9.5mm; color: var(--tc); line-height: 1.1; }
.who { font: 600 5mm var(--display); white-space: nowrap; }
.who i { display: inline-block; width: 45mm; border-bottom: .4mm solid #555; }
.instr { margin: 0 0 4mm; font-size: 5mm; font-weight: 600; line-height: 1.35; }
.content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pf img.pflogo { width: 4.2mm; height: 4.2mm; vertical-align: -1.2mm; margin-right: 1.2mm; }
.pf { display: flex; justify-content: space-between; font-size: 3.2mm; color: #9aa3ad; margin-top: 3mm; }
.content h3 { font-size: 6mm; margin: 3mm 0 2.5mm; color: var(--tc); }
.center { display: flex; justify-content: center; }
.big { font-size: 15mm; line-height: 1; }
.ansbox { display: inline-block; height: 13mm; border: .6mm solid #333; border-radius: 3mm; vertical-align: middle; background: #fff; }
.small { font-size: 3.8mm; line-height: 1.5; }
ol.small { margin: 0; padding-left: 6mm; }

/* maze */
.fill { flex: 1; min-height: 0; display: flex; }
svg.maze { width: 100%; height: 100%; }

/* count */
.countgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(5, minmax(0, 1fr)); overflow: hidden; border: .7mm dashed var(--tc); border-radius: 6mm; padding: 4mm; background: var(--ts); }
.countgrid span { font-size: 13mm; line-height: 1; display: grid; place-items: center; }
.countans { display: flex; justify-content: space-around; margin-top: 3mm; font: 600 9mm var(--display); }
.countans div { display: flex; align-items: center; gap: 3mm; }
.countans.small { font-size: 4.5mm; justify-content: flex-start; gap: 6mm; margin: 0; }

/* patterns */
.patrow { display: flex; align-items: center; gap: 4mm; border: .5mm dashed #d6d0c6; border-radius: 4mm; padding: 4mm; margin-bottom: 4mm; }
.patrow .seq { flex: 1; display: flex; gap: 2mm; align-items: center; }
.patrow span { font-size: 11mm; line-height: 1; }
.age-kid .patrow span { font-size: 8.5mm; }
.patrow .q { width: 13mm; height: 13mm; border: .6mm solid #333; border-radius: 2mm; display: grid; place-items: center; font: 600 8mm var(--display) !important; color: var(--tc); }
.patrow .opts { display: flex; gap: 3mm; background: var(--ts); border-radius: 3mm; padding: 2mm 3mm; }

/* shadow */
.shadow { flex: 1; display: flex; flex-direction: column; justify-content: space-around; }
.srow { display: flex; align-items: center; gap: 4mm; }
.srow .gap { flex: 1; }
.srow .dot { width: 4mm; height: 4mm; border-radius: 50%; background: #333; }
.sil { filter: brightness(0); opacity: .82; }
.snum { font-size: 3.5mm; color: #9aa3ad; width: 4mm; }
.age-kid .srow .big { font-size: 12mm; }

/* odd one out */
.oddrow { display: flex; justify-content: space-around; padding: 4mm 0; border-bottom: .4mm dashed #e2dcd2; }
.oddrow span { font-size: 15mm; width: 26mm; height: 26mm; display: grid; place-items: center; border-radius: 5mm; background: var(--ts); }
.age-kid .oddrow span { font-size: 13mm; width: 23mm; height: 23mm; }

/* word search */
table { border-collapse: collapse; }
.ws td { width: var(--cell); height: var(--cell); text-align: center; vertical-align: middle; font: 700 calc(var(--cell) * .58) var(--display); border: .25mm solid #ddd; }
.wordlist { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2mm 4mm; margin-top: 6mm; font: 600 4.6mm var(--display); }
.age-kid .wordlist { font-size: 5.5mm; grid-template-columns: repeat(4, 1fr); }

/* scramble */
.scramble { flex: 1; display: flex; flex-direction: column; justify-content: space-around; }
.srow2 { display: flex; align-items: center; gap: 5mm; }
.srow2 .num { font: 600 6mm var(--display); color: var(--tc); width: 7mm; }
.big2 { font-size: 11mm; }
.scr { font: 700 7mm var(--display); min-width: 62mm; letter-spacing: .5mm; }
.blanks { display: flex; gap: 2mm; }
.blanks i { width: 8mm; height: 9mm; border-bottom: .6mm solid #333; }

/* cipher */
.key { display: grid; grid-template-columns: repeat(13, 1fr); gap: 1.2mm; background: var(--ts); padding: 3mm; border-radius: 3mm; margin-bottom: 3mm; }
.key span { display: flex; flex-direction: column; align-items: center; font-size: 4mm; background: #fff; border-radius: 1.5mm; padding: 1mm 0; }
.key b { font: 700 5.5mm var(--display); color: var(--tc); }
.code { display: flex; flex-wrap: wrap; gap: 5mm 8mm; margin-bottom: 6mm; }
.cword { display: flex; gap: 1.5mm; }
.cl { display: flex; flex-direction: column; align-items: center; }
.cl b { width: 9mm; height: 11mm; border-bottom: .6mm solid #333; font: 700 7mm var(--display); color: #8a94a0; text-align: center; }
.cl i { font: 600 4mm 'Nunito'; font-style: normal; margin-top: 1mm; }
.hint { margin: 0 0 3mm; font-size: 4.5mm; }

/* quiz */
.quiz { margin: 0; padding-left: 8mm; display: flex; flex-direction: column; justify-content: space-around; flex: 1; }
.quiz li { font-weight: 700; font-size: 5mm; }
.qopts { display: flex; gap: 6mm; flex-wrap: wrap; margin-top: 2mm; font-weight: 600; font-size: 4.6mm; }
.qopts b { display: inline-grid; place-items: center; width: 7mm; height: 7mm; border: .5mm solid var(--tc); border-radius: 50%; margin-right: 1.5mm; color: var(--tc); font-size: 4mm; }

/* sudoku */
.sudokus { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-around; }
.sudokus.mini { flex-direction: row; gap: 4mm; flex-wrap: wrap; justify-content: center; }
.sudoku { border: .9mm solid #222; }
.sudoku td { width: var(--cell); height: var(--cell); border: .3mm solid #aaa; text-align: center; vertical-align: middle; font: 600 calc(var(--cell) * .55) var(--display); }
.sudoku td.given { background: var(--ts); }
.sudoku td.br { border-right: .9mm solid #222; }
.sudoku td.bb { border-bottom: .9mm solid #222; }

/* emoji math */
.mathrow { display: flex; align-items: center; gap: 3mm; font: 600 8mm var(--display); padding: 3mm 0; border-bottom: .3mm dashed #e2dcd2; }
.mathrow b { color: var(--tc); }
.age-little .mathrow { font-size: 9mm; padding: 6mm 0; }
.numv { color: #333; }
.legend { display: flex; gap: 5mm; justify-content: center; margin-bottom: 3mm; }
.legend span { font: 600 8mm var(--display); background: var(--ts); border-radius: 4mm; padding: 2mm 5mm; }

/* bingo */
.bingos { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-around; }
.bingo { border: .8mm solid var(--tc); }
.bingo td { border: .5mm solid var(--tc); text-align: center; vertical-align: middle; padding: 1mm; }
.bingo.n3 td { width: 38mm; height: 33mm; } .bingo.n3 .be { font-size: 14mm; } .bingo.n3 .bt { font-size: 4.2mm; }
.bingo.n4 td { width: 32mm; height: 25mm; } .bingo.n4 .be { font-size: 10mm; } .bingo.n4 .bt { font-size: 3.6mm; }
.bingo.n5 td { width: 28mm; height: 20mm; } .bingo.n5 .be { font-size: 8mm; } .bingo.n5 .bt { font-size: 3.1mm; }
.bt { font-weight: 700; line-height: 1.1; }

/* games */
.ttts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5mm; justify-items: center; }
.ttt { width: 40mm; height: 40mm; }
.grow { flex: 1; min-height: 0; }
svg.dots { width: 100%; height: 100%; max-width: 150mm; }
svg.dots circle { fill: #222; }

/* would you rather */
.wyr { margin: 0; padding-left: 7mm; flex: 1; display: flex; flex-direction: column; justify-content: space-around; }
.wyr li { font-weight: 700; color: var(--tc); }
.wyr li div { color: #1f2933; font-weight: 600; display: inline-flex; align-items: center; gap: 2mm; margin: 1mm 0; }
.wyr li div:nth-child(1) { display: flex; }
.wyr .or { display: inline-block !important; color: var(--tc) !important; margin: 0 3mm !important; font-weight: 800 !important; }
.tick { width: 5mm; height: 5mm; border: .5mm solid #333; border-radius: 50%; flex: none; }

/* doodle & story */
.drawbox { flex: 1; border: .8mm dashed var(--tc); border-radius: 6mm; margin-bottom: 5mm; padding: 4mm; }
.drawbox.short { flex: .6; margin: 4mm 0 0; }
.dp { font: 600 5.5mm var(--display); color: var(--tc); }
.starter { background: var(--ts); border-radius: 4mm; padding: 5mm; font: 600 5.5mm var(--display); line-height: 1.4; margin-bottom: 3mm; }
.lines div { height: 12mm; border-bottom: .35mm solid #b9c0c8; }
.lines.tween div { height: 10.5mm; }

/* cover */
.cover { align-items: center; }
.ring { position: relative; width: 150mm; height: 150mm; margin: 6mm auto 2mm; }
.ring > span { position: absolute; left: 50%; top: 50%; font-size: 15mm; line-height: 1; margin: -7.5mm 0 0 -7.5mm; transform: rotate(var(--a)) translateY(-62mm) rotate(calc(-1 * var(--a))); }
.ctitle { position: absolute; inset: 30mm; border-radius: 50%; background: var(--ts); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font: 700 10.5mm/1.05 var(--display); color: var(--tc); padding: 6mm; }
.ctitle small { font-size: 8mm; color: #1f2933; margin-bottom: 2mm; }
.ctitle em { font-style: normal; font-size: 5mm; color: #1f2933; margin-top: 3mm; }
.dest { font: 600 8mm var(--display); margin-bottom: 4mm; }
.triplog { width: 100%; border: .7mm solid var(--tc); border-radius: 5mm; padding: 2mm 7mm 5mm; }
.triplog h2 { font-size: 7mm; margin: 2mm 0; color: var(--tc); }
.tl { display: flex; align-items: flex-end; gap: 3mm; margin-top: 4mm; font-weight: 700; }
.tl i { flex: 1; border-bottom: .4mm solid #666; min-height: 6mm; font: 600 5mm var(--display); font-style: normal; }
.modes { font-size: 7mm; letter-spacing: 3mm; }
.contents { margin-top: auto; font-size: 4.2mm; text-align: center; color: #555; line-height: 1.6; }
.cover .pf { width: 100%; }

/* answers */
.agrid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 4mm; min-height: 0; }
.acard { border: .4mm solid #e2dcd2; border-radius: 4mm; padding: 3mm 4mm; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.acard h4 { margin: 0 0 2mm; font-size: 5mm; color: var(--tc); }
.abody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.abody svg.maze { flex: 1; min-height: 0; }
.abody .ws { margin: 0 auto; }
.abody .sudoku td { font-size: calc(var(--cell) * .55); }

/* award */
.award { justify-content: center; }
.frame { flex: 1; border: 3mm double var(--tc); border-radius: 8mm; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10mm; background: var(--ts); }
.frame h1 { font-size: 15mm; line-height: 1.1; color: var(--tc); margin: 4mm 0; }
.frame p { font-size: 6mm; margin: 3mm 0; max-width: 150mm; }
.stars { font-size: 12mm; }
.awname { font: 700 13mm var(--display); border-bottom: .6mm solid #333; min-width: 130mm; padding: 2mm 0; margin: 4mm 0; }
.medal { font-size: 26mm; margin: 2mm 0; }
.sign { display: flex; gap: 20mm; margin-top: 8mm; }
.sign div { display: flex; flex-direction: column; font-size: 4.5mm; color: #555; }
.sign i { width: 55mm; border-bottom: .4mm solid #333; height: 10mm; }
.ticons { font-size: 9mm; margin-top: 7mm; letter-spacing: 3mm; }

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .topbar, .panel, .toolbar, .tip { display: none !important; }
  .app { display: block; min-height: 0; }
  .previewwrap, .preview { padding: 0; overflow: visible; }
  #pack { zoom: 1; gap: 0; display: block; }
  .page { box-shadow: none; margin: 0; break-after: page; page-break-after: always; }
  .page:last-child { break-after: auto; page-break-after: auto; }
}
.spread { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: space-around; }
.spread .patrow, .spread .mathrow { margin-bottom: 0; }
.age-little .patrow span { font-size: 13mm; }
.age-kid .code { gap: 8mm 10mm; margin-bottom: 10mm; }
.age-tween .code { gap: 5mm 8mm; margin-bottom: 6mm; }
.age-kid .cl b { width: 11mm; height: 14mm; }
.age-tween .cl b { width: 9.5mm; height: 12mm; }
.age-kid .cl i, .age-tween .cl i { font-size: 5mm; }
#render .page { box-shadow: none; }

/* language picker */
.topbar { justify-content: space-between; gap: 12px; }
.langpick { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 18px; color: var(--ink); }
.langpick select { margin: 0; width: auto; padding: 8px 10px; }

/* crossword */
.cwwrap { flex: 0 0 auto; }
.cw td { width: var(--cell); height: var(--cell); border: .4mm solid #333; position: relative; text-align: center; vertical-align: middle; font: 700 calc(var(--cell) * .55) var(--display); background: #fff; }
.cw td.x { border: 0; background: transparent; }
.cw td i { position: absolute; top: .3mm; left: .6mm; font: 700 calc(var(--cell) * .28) 'Nunito'; font-style: normal; color: var(--tc); line-height: 1; }
.clues { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; margin-top: 5mm; }
.clues h3 { margin: 0 0 2mm; }
.clues ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2mm 5mm; }
.clues li { display: flex; align-items: center; gap: 1.5mm; font: 600 5mm var(--display); }
.clues li b { color: var(--tc); }
.clues .ce { font-size: 11mm; line-height: 1; }
.clues small { font-size: 3.6mm; color: #666; }

/* coloring & dot-to-dot */
.colorpage { flex: 1; min-height: 0; position: relative; display: flex; justify-content: center; }
.colorpage img { height: 100%; max-width: 100%; object-fit: contain; }
.colorpage .ref { position: absolute; right: 0; bottom: 0; font-size: 14mm; background: var(--ts); border-radius: 4mm; padding: 2mm 3mm; }
svg.dotsvg { width: 100%; height: 100%; }
svg.dotsvg circle { fill: #222; } svg.dotsvg circle.first { fill: var(--tc); }
svg.dotsvg text { font-family: 'Nunito', sans-serif; font-weight: 700; fill: #333; }
.dotans { flex: 1; min-height: 0; display: flex; align-items: center; gap: 3mm; }
.dotans svg { height: 100%; max-height: 90mm; flex: 1; }
.dotans span { font-size: 14mm; }
