/* Sešit s komiksovými detaily: čtverečkovaný papír, propiska, zvýrazňovač, lepicí papírky.
   Komiks jen v nadpisech, bublině s nápovědou a výbuchu při úspěchu. Jen světlý vzhled. */
:root {
  --paper: #fbf8ef;
  --desk: #e7e1d2;
  --grid: #cfe0f2;
  --margin: #ef9a9a;
  --ink: #1f3a8a;
  --pen: #c2185b;
  --hl: #fff27a;
  --black: #161616;
  --text: #222;
  --muted: #5b5b66;
  --ok: #2e7d32;
  --ok-bg: #9be7b7;
  --bad: #c62828;
  --bad-bg: #ffe3e0;
  --stamp: #e53935;
  --note-y: #fff8b8;
  --note-p: #ffd9e4;
  --note-g: #d6f3e4;
  --tape: #f7b9ccd9;
  --c: 28px;
  --f-hand: 'Patrick Hand', 'Comic Sans MS', 'Segoe Print', cursive;
  --f-note: 'Caveat', 'Segoe Print', cursive;
  --f-comic: 'Bangers', Impact, 'Arial Black', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--text);
  font-family: var(--f-hand);
  font-size: 18px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--ink); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px dashed var(--pen); outline-offset: 2px; }
sup { font-size: .65em; line-height: 0; }

.app {
  position: relative;
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(42px, calc(env(safe-area-inset-left) + 42px));
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--c) var(--c);
  box-shadow: 0 0 30px rgba(0, 0, 0, .08);
}
.app::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(30px + env(safe-area-inset-left));
  width: 2px;
  background: var(--margin);
  pointer-events: none;
}

/* ---------- hlavička ---------- */
.top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.back { width: 44px; height: 44px; margin-left: -10px; display: grid; place-items: center; font-size: 2rem; color: var(--black); text-decoration: none; flex: none; }
.top h1 { flex: 1; min-width: 0; margin: 0; font-family: var(--f-comic); font-weight: 400; font-size: 1.55rem; letter-spacing: .03em; line-height: 1.05; color: var(--black); transform: rotate(-1.5deg); text-wrap: balance; }
.stamp { font-family: var(--f-comic); font-size: 1.1rem; letter-spacing: .04em; color: #fff; background: var(--stamp); padding: 2px 9px; transform: rotate(5deg); flex: none; }
.stamp.ok { background: var(--ok); }

/* ---------- obecné ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 6px 18px;
  border: 0; border-radius: 3px; cursor: pointer; text-decoration: none;
  font-family: var(--f-comic); font-size: 1.35rem; letter-spacing: .05em; color: var(--black);
  background: var(--ok-bg); box-shadow: 2px 3px 0 rgba(0, 0, 0, .18);
}
.btn.alt { background: var(--note-y); }
.btn.pink { background: var(--note-p); }
.btn.ghost { background: transparent; box-shadow: none; text-decoration: underline; font-family: var(--f-hand); font-size: 1.05rem; letter-spacing: 0; color: var(--ink); min-height: 44px; padding: 6px 8px; }
.btn:active { transform: translateY(2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .18); }
.btn[disabled] { opacity: .45; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.note { font-family: var(--f-note); font-size: 1.35rem; color: var(--pen); line-height: 1.1; }
.muted { color: var(--muted); }
.taped { position: relative; background: #fffdf6; padding: 16px 14px 14px; box-shadow: 1px 2px 6px rgba(0, 0, 0, .12); }
.taped::before { content: ''; position: absolute; top: -9px; left: 50%; width: 76px; height: 18px; margin-left: -38px; background: var(--tape); transform: rotate(-3deg); }

/* ---------- obsah (úvod) ---------- */
.home { display: grid; gap: 22px; padding-bottom: 24px; }
.home .hello { font-family: var(--f-note); font-size: 2rem; color: var(--pen); margin: 6px 0 0; line-height: 1; }
.home .title { font-family: var(--f-comic); font-weight: 400; font-size: 2.3rem; letter-spacing: .03em; margin: 0; line-height: 1; transform: rotate(-2deg); color: var(--black); }
.ready { display: grid; gap: 10px; }
.ready p { margin: 0; }
.bar { height: 14px; border: 1.5px solid var(--ink); border-radius: 7px; overflow: hidden; background: #fff; }
.bar i { display: block; height: 100%; background: repeating-linear-gradient(-45deg, var(--ink) 0 3px, transparent 3px 7px); }
.area h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-family: var(--f-comic); font-weight: 400; font-size: 1.45rem; letter-spacing: .03em; color: var(--black); }
.area h2 .num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--black); color: #fff; font-size: 1.05rem; flex: none; }
.types { list-style: none; margin: 0; padding: 0; }
.types a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 2px; color: var(--text); text-decoration: none; border-bottom: 1px dashed #b9c8dc; }
.types a:hover .tt, .types a:focus-visible .tt { background: linear-gradient(transparent 55%, var(--hl) 55%); }
.types .tt { flex: 1; min-width: 0; font-size: 1.12rem; }
.types .next-tag { font-family: var(--f-note); color: var(--pen); font-size: 1.2rem; }
.dots { display: inline-flex; gap: 4px; flex: none; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); }
.dots i.on { background: var(--ink); }
.rstamp { flex: none; font-family: var(--f-comic); font-size: .95rem; letter-spacing: .06em; color: var(--stamp); border: 2.5px solid var(--stamp); border-radius: 5px; padding: 0 6px; transform: rotate(-8deg); opacity: .9; }
.exams { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.exams li { display: flex; gap: 10px; }
.grade { font-family: var(--f-comic); font-size: 1.2rem; width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--stamp); color: var(--stamp); border-radius: 50%; }

/* ---------- typ úlohy ---------- */
.typepage { display: grid; gap: 18px; }
.rule { font-size: 1.12rem; }
.rule h2 { margin: 0 0 6px; font-family: var(--f-comic); font-weight: 400; letter-spacing: .04em; font-size: 1.3rem; }
.sample { font-family: var(--f-note); font-size: 1.35rem; color: var(--ink); }
.bigbtns { display: grid; gap: 14px; }
.bigbtns .btn { min-height: 64px; font-size: 1.7rem; }

/* ---------- procvičování ---------- */
.practice { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.app.is-practice { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.statement { margin: 4px 0 0; font-size: 1.15rem; }
.statement b { color: var(--ink); font-weight: 400; background: linear-gradient(transparent 60%, rgba(255, 242, 122, .7) 60%); }
.progress { height: 8px; border: 1.5px solid var(--ink); border-radius: 5px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: repeating-linear-gradient(-45deg, var(--ink) 0 3px, transparent 3px 6px); transition: width .3s; }
.scene { position: relative; flex: 1 1 auto; min-height: 120px; overflow: auto; padding: 12px 0 8px; display: grid; place-items: center; }
.scene-col { display: grid; justify-items: center; gap: 8px; width: 100%; }
.scene-geo { display: grid; justify-items: center; gap: 6px; width: 100%; }
.say { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 10px; }
.buddy { width: 44px; height: 44px; flex: none; }
.bubble { position: relative; flex: 1; min-width: 0; background: #fff; border: 2.5px solid var(--black); border-radius: 18px; padding: 8px 12px; font-size: 1.08rem; line-height: 1.25; }
.bubble::before { content: ''; position: absolute; left: -15px; bottom: 9px; border: 8px solid transparent; border-right: 13px solid var(--black); }
.bubble::after { content: ''; position: absolute; left: -9px; bottom: 11px; border: 6px solid transparent; border-right: 9px solid #fff; }
.bubble b { font-weight: 400; color: var(--ink); background: linear-gradient(transparent 55%, var(--hl) 55%); }
.bubble .fb { display: block; margin-bottom: 4px; }
.bubble .fb.ok { color: var(--ok); }
.bubble .fb.bad { color: var(--bad); }
.bubble .fb.soft { color: var(--ink); }
.bubble .hint { display: block; margin-top: 4px; font-family: var(--f-note); font-size: 1.3rem; line-height: 1.1; color: var(--pen); }
.bubble .ans { display: block; margin-top: 4px; color: var(--ok); }
.controls { display: grid; gap: 10px; padding-bottom: 2px; }
.controls .tools { display: flex; gap: 8px; justify-content: space-between; align-items: center; min-height: 44px; }

/* klávesnice jako lepicí papírky */
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.key { height: 48px; border: 0; border-radius: 2px; background: var(--note-y); box-shadow: 1px 2px 0 rgba(0, 0, 0, .14); font-size: 1.5rem; cursor: pointer; color: var(--text); touch-action: manipulation; }
.key:nth-child(4n+2) { background: var(--note-p); transform: rotate(-1deg); }
.key:nth-child(4n+3) { background: var(--note-g); transform: rotate(.8deg); }
.key.fn { background: #fff; border: 1.5px solid #c9c2b0; }
.key.go { grid-column: span 4; background: var(--ok-bg); font-family: var(--f-comic); letter-spacing: .06em; font-size: 1.4rem; }
.key.go[disabled] { opacity: .45; }
.key:active { transform: translateY(2px); }

.choices { display: grid; gap: 8px; }
.choices.grid { grid-template-columns: repeat(5, 1fr); }
.choices.two { grid-template-columns: 1fr 1fr; }
.opt { touch-action: manipulation; min-height: 48px; padding: 8px 12px; border: 0; border-radius: 2px; text-align: left; background: #fff; box-shadow: 1px 2px 0 rgba(0, 0, 0, .14), inset 0 0 0 1.5px #cfc8b6; cursor: pointer; font-size: 1.1rem; line-height: 1.2; }
.choices.grid .opt { text-align: center; font-size: 1.5rem; padding: 4px; }
.opt:active { transform: translateY(2px); }
.opt.right { background: var(--ok-bg); box-shadow: inset 0 0 0 2px var(--ok); }
.opt.wrong { background: var(--bad-bg); box-shadow: inset 0 0 0 2px var(--bad); }
.opt[disabled] { cursor: default; }
.tapinfo { font-family: var(--f-note); font-size: 1.4rem; color: var(--pen); text-align: center; }

/* výbuch při úspěchu */
.burst { position: absolute; right: 2px; top: 4px; width: 150px; height: 120px; pointer-events: none; animation: pop .5s ease-out both; transform: rotate(-8deg); z-index: 3; }
.burst polygon { fill: #ffd60a; stroke: var(--black); stroke-width: 3; stroke-linejoin: round; }
.burst text { font-family: var(--f-comic); font-size: 26px; fill: var(--black); letter-spacing: 1px; text-anchor: middle; }
.burst.meh polygon { fill: var(--note-g); }
@keyframes pop { 0% { transform: scale(.6) rotate(-14deg); opacity: 0; } 60% { transform: scale(1.08) rotate(-6deg); opacity: 1; } 100% { transform: scale(1) rotate(-8deg); } }

/* ---------- mřížka pod sebou ---------- */
.colgrid { display: grid; grid-template-columns: repeat(var(--w), var(--c)); font-size: 1.6rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.cell { width: var(--c); height: var(--c); display: grid; place-items: center; position: relative; line-height: 1; }
.cell.line { border-bottom: 2px solid var(--ink); }
.cell.act { background: var(--hl); }
.cell.act::after { content: ''; width: 2px; height: 60%; background: var(--ink); animation: blink 1s steps(1) infinite; }
.cell.sum, .cell.rem { color: var(--pen); }
.cm { position: absolute; right: -.14em; bottom: .02em; }
.carry { position: absolute; top: -.35em; right: .05em; font-size: .5em; color: var(--pen); }
.eq { font-size: 1.45rem; color: var(--ink); }
.eq.res, .eq .res, .res { color: var(--ok); }
.eqv { display: inline-block; min-width: 1.4ch; padding: 0 3px; }
.eqv.act { background: var(--hl); }
.caret { display: inline-block; width: 2px; height: 1em; vertical-align: -.12em; background: var(--ink); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.bignum { font-size: 2rem; color: var(--ink); }
.bignum.ghost { opacity: .45; font-size: 1.5rem; }
.bignum.moved { color: var(--ok); }
.shift-demo { display: grid; justify-items: center; gap: 2px; }
.shift-demo .arrow { font-family: var(--f-note); font-size: 1.35rem; color: var(--pen); }
.shift-demo.fresh .arrow { animation: slide .6s ease-out both; }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
.divwrap { display: flex; align-items: flex-start; }
.divtail { font-size: 1.6rem; line-height: var(--c); color: var(--ink); white-space: nowrap; }
.divtail .q { color: var(--ok); }

/* ---------- dělitelnost ---------- */
.tree { width: 100%; height: auto; }
.tree .node { font-family: var(--f-hand); font-size: 19px; fill: var(--ink); dominant-baseline: middle; }
.tree .node.typing { fill: var(--pen); }
.tree .br { stroke: var(--ink); stroke-width: 1.6; }
.tree .leaf { stroke: var(--black); stroke-width: 2; }
.tree .leaf.grow { animation: pop .45s ease-out both; transform-box: fill-box; transform-origin: center; }
.tree .leaft { fill: #fff; font-family: var(--f-hand); font-size: 15px; text-anchor: middle; dominant-baseline: middle; }
.nd { justify-items: stretch; max-width: 360px; }
.nrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nnum { min-width: 3ch; text-align: right; font-size: 1.35rem; color: var(--ink); }
.eqs { color: var(--muted); }
.balls { display: flex; flex-wrap: wrap; gap: 4px; }
.ball { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--bc); color: #fff; border: 2px solid var(--black); font-size: 1rem; transition: transform .2s; }
.ball.on { transform: scale(1.15); box-shadow: 0 0 0 4px var(--hl); }
.ball.taken { box-shadow: 0 0 0 3px var(--ok-bg); }
.nres { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 1.35rem; color: var(--ink); margin-top: 6px; }
.starnum { display: flex; font-size: 2.3rem; color: var(--ink); }
.starnum .cell { --c: 44px; width: 44px; height: 52px; }
.starnum .star.act { background: var(--hl); color: var(--pen); }
.tagline { font-family: var(--f-note); font-size: 1.5rem; color: var(--pen); }

/* ---------- geometrie ---------- */
.geo { width: 100%; max-width: 380px; height: auto; overflow: visible; touch-action: manipulation; }
.geo.dragging-on { touch-action: none; }
.geo text { font-family: var(--f-hand); }
.geo .sketch { fill: rgba(31, 58, 138, .05); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.geo .sketch.faint { stroke-dasharray: 5 5; opacity: .5; }
.geo .faint { opacity: .55; }
.geo .side-on { stroke: var(--pen); stroke-width: 4; stroke-linecap: round; }
.geo .vlabel { font-size: 19px; fill: var(--text); text-anchor: middle; dominant-baseline: middle; }
.geo .slabel, .geo .alabel { font-size: 14px; fill: var(--pen); text-anchor: middle; dominant-baseline: middle; }
.geo .slabel.ink, .geo .alabel.ink { fill: var(--text); }
.geo .rlabel { font-size: 15px; fill: var(--text); }
.geo .arc { fill: none; stroke: var(--pen); stroke-width: 1.8; }
.geo .ink { stroke: var(--black); fill: none; stroke-width: 1.6; }
.geo .thick { stroke-width: 2.6; }
.geo .circ { stroke: var(--ink); }
.geo .pin { fill: var(--black); }
.geo .vdot { fill: var(--black); }
.geo .vdot.ink { fill: var(--black); stroke: none; }
.geo .tri-done { fill: rgba(255, 242, 122, .5); stroke: var(--black); stroke-width: 2.6; }
.geo .tap-line { stroke: transparent; stroke-width: 28; stroke-linecap: round; cursor: pointer; }
.geo .tap-dot { fill: transparent; cursor: pointer; }
.geo .tap-node { fill: transparent; pointer-events: none; }
.geo .tap-grid { fill: transparent; cursor: crosshair; }
.geo.tapping .tap-dot:hover, .geo.tapping .tap-line:hover { stroke: rgba(255, 242, 122, .6); fill: rgba(255, 242, 122, .45); }
.geo .hint-target { fill: rgba(255, 242, 122, .75) !important; stroke: rgba(255, 214, 10, .8) !important; }
.geo .tapped-bad { fill: rgba(198, 40, 40, .25) !important; stroke: rgba(198, 40, 40, .35) !important; }
.geo .spin { animation: spin 1.2s ease-in-out both; }
@keyframes spin { from { transform: rotate(var(--rot)); } to { transform: rotate(0deg); } }
.geo .spin180 { animation: spin180 1.4s ease-in-out both; }
@keyframes spin180 { from { transform: rotate(0deg); opacity: .35; } to { transform: rotate(180deg); opacity: 1; } }
.geo .helper { stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 6 4; fill: none; }
.geo .helper.solid { stroke-dasharray: none; }
.geo .pt { fill: var(--pen); }
.geo .ptlabel { font-size: 16px; fill: var(--pen); }
.geo .gridline { stroke: var(--grid); stroke-width: 1; }
.geo .shape { fill: rgba(31, 58, 138, .08); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; }
.geo .image { fill: rgba(46, 125, 50, .12); stroke: var(--ok); stroke-width: 2.2; stroke-linejoin: round; }
.geo .cand { fill: #fff; stroke: var(--ink); stroke-width: 1.6; }
.geo .drag { fill: var(--pen); cursor: grab; }
.geo .known { fill: none; stroke: var(--pen); stroke-width: 3.5; stroke-linecap: round; }
.zadani-mini { font-size: 1rem; color: var(--muted); text-align: center; }
.zapis { margin: 0; padding-left: 1.6em; font-size: 1.08rem; color: var(--ink); align-self: start; justify-self: start; }
.zapis li.next { color: var(--muted); }
.ray { display: inline-block; position: relative; padding-top: .25em; }
.ray::before { content: '→'; position: absolute; top: -.55em; left: 0; right: 0; text-align: center; font-size: .8em; line-height: 1; }
.pair { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.pair .geo { width: auto; max-width: 46%; height: auto; }
.pair .geo .vlabel { font-size: 15px; }
.pair .geo .slabel, .pair .geo .alabel { font-size: 12px; }
.data-table { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 1.05rem; color: var(--ink); }
.data-table h3 { margin: 0; font-family: var(--f-comic); font-weight: 400; font-size: 1.15rem; color: var(--black); }

/* v ukázce se nic nepíše, kurzor by mátl */
.learn .cell.act { background: none; }
.learn .cell.act::after, .learn .caret { display: none; }
.learn .eqv.act { background: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
@media (min-width: 520px) {
  body { padding: 18px 0; }
  .app { min-height: calc(100% - 36px); }
  .app.is-practice { height: calc(100% - 36px); }
}
