/* כל הזכויות שמורות לאושרת רון – הקשר המונטסורי */
/* "אבני היסוד של המספרים": עיצוב משותף לגרסת הילדים (index.html) ולגרסת המורים (morim.html).
   כל עמוד מגדיר את הצבעים שלו במשתנים: --acc --acc-dark --card --card2 --line --ink --soft --gold --pbg --pln --pink
   --goldbg --goldln --s2 --s3 --s5 --s7 --sink --tile --tile1 --ok --okbg --bad --badbg --note */
.mx { direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-weight: 700; }
.mx.wrap { white-space: normal; }
.mx sup { font-size: .62em; line-height: 0; vertical-align: super; font-weight: 800; color: var(--acc); }
.hide { display: none !important; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; min-width: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.row.c { justify-content: center; }
.small { font-size: 15px; color: var(--soft); }
.btn { border: 0; border-radius: 14px; background: var(--acc); color: #fff; padding: 9px 18px; font-size: 18px; font-weight: 600; cursor: pointer; min-height: 46px; }
.btn.g { background: var(--card); color: var(--acc-dark); border: 2px solid var(--acc); }
.btn.sm { padding: 6px 12px; font-size: 16px; min-height: 40px; }
.btn:disabled { opacity: .45; cursor: default; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 7px 14px; font-size: 17px; font-weight: 600; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.chip.done::after { content: '✓'; color: var(--ok); font-weight: 800; }
.chip.on.done::after { color: inherit; }
.fb { text-align: center; border-radius: 14px; }
.fb.show { padding: 8px 12px; margin-top: 8px; }
.fb.ok { background: var(--okbg); } .fb.no { background: var(--note); }
:where(.stage, .exq, .guide, .board, .hgrid, .sv, .bins, .keys, .seg, .yn, .wopts, .mol, .stepper) button { font: inherit; cursor: pointer; }
:where(.btn, .chip, .seg button, .yn button, .wopts button, .keys button, .bin, .hgrid button, .sv button, .stepper button, .atom, .tn.cp, .hole, .tab):focus-visible { outline: 3px solid #b07a12; outline-offset: 2px; }

/* ---- תחנות ההקניה ---- */
.stations { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.lx { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.stage { display: flex; flex-direction: column; gap: 10px; min-height: min(64vh, 600px); }
.sTop, .sVis, .sBot { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sVis { flex: 1; }
.stq { text-align: center; background: var(--card2); border-radius: 16px; padding: 9px 12px; font-size: 19px; font-weight: 500; }
.stq b { color: var(--acc-dark); font-weight: 800; }
.ctl { display: flex; gap: 10px 16px; flex-wrap: wrap; align-items: center; justify-content: center; }
.stepper { display: inline-flex; align-items: center; gap: 8px; direction: ltr; }
.stepper button { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); font-size: 26px; font-weight: 800; line-height: 1; color: var(--acc); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper b { min-width: 54px; text-align: center; font-size: 34px; color: var(--acc-dark); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; direction: ltr; }
.seg button { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 13px; font-weight: 700; color: var(--ink); min-height: 42px; min-width: 46px; }
.seg button.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.seg.rtl { direction: rtl; }
.verdict { text-align: center; border-radius: 14px; padding: 9px 12px; font-size: 19px; background: var(--card2); }
.verdict.p { background: var(--goldbg); border: 2px solid var(--goldln); }
.verdict b { font-weight: 800; }
.guide h2 { font-size: 22px; margin: 0 0 8px; }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.steps li { background: var(--card2); border-radius: 12px; padding: 8px 12px; border-inline-start: 5px solid var(--line); display: grid; grid-template-columns: 26px 1fr; gap: 6px; }
.steps li::before { content: '○'; color: var(--soft); font-weight: 800; }
.steps li.ok { border-inline-start-color: var(--ok); } .steps li.ok::before { content: '✓'; color: var(--ok); }
.steps li.cur { border-inline-start-color: var(--acc); } .steps li.cur::before { content: '←'; color: var(--acc); }
.ask { background: var(--note); border-radius: 14px; padding: 10px 12px; border-inline-start: 5px solid var(--pln); text-align: center; }
.hole { font: inherit; font-weight: 800; border: 3px dashed var(--acc); background: var(--card); color: var(--ink); border-radius: 12px; padding: 4px; text-align: center; direction: ltr; width: 3.2em; font-size: 1em; margin: 0 .1em; }
.hole.ok { border-color: var(--ok); background: var(--okbg); } .hole.no { border-color: var(--bad); background: var(--badbg); }
.rule { margin-top: 10px; border: 3px solid var(--goldln); background: var(--goldbg); border-radius: 16px; padding: 12px; }
.rule .w { font-weight: 800; font-size: 19px; margin-bottom: 4px; }
.rule p { margin: 4px 0; }
.steps.hide + .stEnd .rule { margin-top: 0; }
/* מלבנים */
.rects { flex: 1; display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; justify-content: center; align-content: center; direction: ltr; padding: 6px 0; min-height: 150px; }
.rc { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rc .tiles { display: grid; gap: 2px; }
.rc .tiles i { width: var(--t, 20px); height: var(--t, 20px); border-radius: calc(var(--t, 20px) * .2); background: var(--tile); }
.rc.row1 .tiles i { background: var(--tile1); }
.rc figcaption { font-size: 17px; color: var(--soft); }
.rc.row1 figcaption::after { content: ' (שורה)'; font-weight: 400; }
/* הנפה */
.sv { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; direction: ltr; width: min(100%, calc(100vh - 330px)); min-width: min(100%, 300px); margin: 0 auto; container-type: inline-size; }
.sv button { aspect-ratio: 1; border: 2px solid var(--line); background: #fff; border-radius: 9px; font-weight: 800; font-size: clamp(12px, 4.2cqw, 24px); padding: 0; color: var(--ink); transition: background .25s, color .25s, transform .25s; }
.sv button.p { background: var(--pbg); border-color: var(--pln); color: var(--pink); transform: scale(1.04); }
.sv button.x { color: var(--sink); border-color: transparent; text-decoration: line-through; font-weight: 500; }
.sv button.x2 { background: var(--s2); } .sv button.x3 { background: var(--s3); } .sv button.x5 { background: var(--s5); } .sv button.x7 { background: var(--s7); }
.sv button.x1 { background: var(--card2); }
.sv button.next { outline: 3px dashed var(--acc); outline-offset: 1px; }
.legend { display: flex; gap: 6px 10px; flex-wrap: wrap; justify-content: center; font-size: 15px; }
.legend span { border-radius: 999px; padding: 2px 10px; font-weight: 700; color: var(--ink); }
.legend .l2 { background: var(--s2); } .legend .l3 { background: var(--s3); } .legend .l5 { background: var(--s5); } .legend .l7 { background: var(--s7); } .legend .lp { background: var(--pbg); color: var(--pink); border: 2px solid var(--pln); }
/* עץ הגורמים */
.treebox { flex: 1; display: grid; place-items: center; min-height: 200px; }
.treebox svg { max-height: min(50vh, 480px); width: 100%; margin: 0 auto; }
.tn circle { stroke-width: 3; }
.tn.in circle { fill: var(--card2); stroke: var(--line); }
.tn.pr circle { fill: var(--pbg); stroke: var(--pln); }
.tn.cp circle { fill: #fff; stroke: var(--acc); stroke-dasharray: 6 5; cursor: pointer; }
.tn.cp.sel circle { stroke-width: 5; stroke-dasharray: none; fill: var(--card2); }
.tn text { font-weight: 800; font-size: 22px; text-anchor: middle; dominant-baseline: central; fill: var(--ink); pointer-events: none; }
.tn.pr text { fill: var(--pink); }
.tl { stroke: var(--line); stroke-width: 3; }
.split { text-align: center; background: var(--card2); border-radius: 14px; padding: 8px 10px; }
.split .seg { margin-top: 6px; }
.split .seg button { font-size: 19px; padding: 8px 16px; min-height: 48px; }
.result { text-align: center; font-size: clamp(22px, 3vw, 30px); background: var(--goldbg); border: 2px solid var(--goldln); border-radius: 14px; padding: 8px 10px; }
.result .btn { font-size: 17px; padding: 8px 14px; }
/* בלש הראשוניים */
.bign { font-size: clamp(54px, 9vw, 96px); font-weight: 800; line-height: 1.1; text-align: center; color: var(--acc-dark); direction: ltr; }
.tlog { display: flex; flex-direction: column; gap: 6px; flex: 1; justify-content: flex-start; }
.tlog div { border-radius: 10px; padding: 6px 12px; background: var(--card2); display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.tlog div.y { background: var(--okbg); } .tlog div.stop { background: var(--goldbg); }
.tq { background: var(--note); border-radius: 14px; padding: 10px 12px; text-align: center; border-inline-start: 5px solid var(--pln); }
.tq .tip { font-size: 16px; color: var(--soft); margin-top: 4px; }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.yn button { border: 3px solid var(--line); background: var(--card); border-radius: 18px; padding: 14px 8px; font-size: 21px; font-weight: 800; color: var(--ink); min-height: 56px; }
.yn button.ok { border-color: var(--ok); background: var(--okbg); } .yn button.no { border-color: var(--bad); background: var(--badbg); }
.yn button:disabled { cursor: default; }
.pickn { margin-top: 8px; } .pickn button { font-size: 22px; min-width: 64px; min-height: 52px; padding: 6px 16px; direction: ltr; }
.pickn button:disabled { opacity: .45; } .pickn button.on:disabled { opacity: 1; }

/* ---- תרגול ---- */
.exq { background: var(--card2); border-radius: 18px; padding: 14px 10px; text-align: center; min-height: 210px; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; }
.exq .qt { font-size: 20px; font-weight: 700; }
.exq .gq { font-size: clamp(20px, 2.8vw, 26px); line-height: 1.5; }
.exq .xl { font-size: clamp(28px, 5vw, 46px); line-height: 1.7; white-space: normal; }
.exq .yn { width: min(100%, 560px); }
.wopts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(100%, 640px); direction: ltr; }
.wopts button { border: 3px solid var(--line); background: var(--card); border-radius: 16px; padding: 12px 6px; font-size: clamp(19px, 2.6vw, 26px); font-weight: 800; color: var(--ink); min-height: 56px; direction: ltr; }
.wopts button.ok { border-color: var(--ok); background: var(--okbg); } .wopts button.no { border-color: var(--bad); background: var(--badbg); }
.ladder { display: flex; flex-direction: column; align-items: center; gap: 4px; direction: ltr; }
.ladder .lr { font-size: 20px; font-weight: 700; color: var(--soft); display: grid; grid-template-columns: 70px 28px 44px; gap: 2px; align-items: center; text-align: center; }
.ladder .lr b { color: var(--pink); background: var(--pbg); border: 2px solid var(--pln); border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; }
.ladder .lcur { font-size: clamp(40px, 7vw, 64px); font-weight: 800; color: var(--acc-dark); line-height: 1.15; }
.keys { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; direction: ltr; }
.keys button { width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--pln); background: var(--pbg); color: var(--pink); font-size: 24px; font-weight: 800; }
.keys button.bad { animation: ah-shake .35s; border-color: var(--bad); }
.keys button:disabled { opacity: .4; cursor: default; }
@keyframes ah-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.hints { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.hints .h { background: var(--note); border-radius: 12px; padding: 9px 12px; border-inline-start: 5px solid var(--pln); }
.scard { font-size: clamp(46px, 8vw, 76px); font-weight: 800; line-height: 1; color: var(--pink); background: var(--pbg); border: 4px solid var(--pln); border-radius: 22px; padding: 14px 30px; min-width: 130px; text-align: center; direction: ltr; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; position: relative; z-index: 3; box-shadow: 0 6px 16px rgba(0, 0, 0, .14); }
.scard.drag { cursor: grabbing; box-shadow: 0 14px 28px rgba(0, 0, 0, .25); }
.bins { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.bin { border: 3px dashed var(--line); background: var(--card); border-radius: 18px; padding: 10px 6px; min-height: 104px; color: var(--ink); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.bin b { font-size: clamp(15px, 2.2vw, 20px); } .bin:disabled { cursor: default; border-style: solid; }
.got { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; direction: ltr; }
.got i { font-style: normal; font-weight: 800; background: var(--card2); border-radius: 8px; padding: 1px 8px; } .got i.h { opacity: .6; }
.hgrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; direction: ltr; width: min(100%, 560px); }
.hgrid button { border: 3px solid var(--line); background: var(--card); border-radius: 14px; font-weight: 800; font-size: clamp(20px, 3.4vw, 28px); padding: 10px 0; color: var(--ink); min-height: 54px; }
.hgrid button.p { background: var(--pbg); border-color: var(--pln); color: var(--pink); } .hgrid button.x { color: var(--sink); text-decoration: line-through; background: var(--card2); border-color: transparent; font-weight: 500; }
.hgrid button.lit { outline: 3px dashed var(--acc); outline-offset: 1px; } .hgrid button:disabled { cursor: default; }
.mol { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; direction: ltr; min-height: 60px; font-size: 24px; font-weight: 800; }
.mol .atom { width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--pln); background: var(--pbg); color: var(--pink); font-size: 22px; font-weight: 800; }
.mol .prod { font-size: clamp(30px, 5vw, 44px); color: var(--acc-dark); } .mol .atom:disabled { cursor: default; }

/* מסך רחב או מסך נמוך: ההמחשה עומדת לצד ההסבר, הפקדים והשאלה, כדי שהכול ייכנס במסך אחד בלי גלילה */
@media (min-width: 1100px), (max-height: 700px) and (min-width: 768px) {
  .stage { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-areas: "vis top" "vis bot"; grid-template-rows: auto 1fr; gap: 10px 14px; align-items: start; min-height: 0; }
  .sTop { grid-area: top; } .sVis { grid-area: vis; align-self: center; } .sBot { grid-area: bot; }
  .rects, .treebox { min-height: 0; }
}
@media (min-width: 1100px) { .lx { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); } .stage { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); } .sv { width: min(100%, calc(100vh - 250px)); } .treebox svg { max-height: calc(100vh - 270px); } .exq { min-height: 260px; } }
/* מסך נמוך (למשל 951×530): ההדרכה יורדת אל מתחת לתחנה */
@media (max-height: 700px) {
  .lx { grid-template-columns: minmax(0, 1fr); } .stage { gap: 8px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } .stq { padding: 5px 10px; font-size: 17px; }
  .bign { font-size: clamp(38px, 9vh, 60px); } .stepper button { width: 40px; height: 40px; font-size: 22px; } .stepper b { font-size: 28px; } .exq { min-height: 0; padding: 10px; } .exq .xl { line-height: 1.4; }
  .seg button { min-height: 38px; padding: 4px 11px; } .verdict { padding: 6px 10px; font-size: 17px; } .ask { padding: 7px 10px; } .keys button { width: 50px; height: 50px; font-size: 21px; } .ladder .lr b { width: 32px; height: 32px; } .ladder .lr { font-size: 17px; } .ladder .lcur { font-size: clamp(30px, 7vh, 44px); }
  .scard { font-size: clamp(34px, 9vh, 52px); padding: 8px 24px; } .bin { min-height: 78px; padding: 6px; } .hgrid button { min-height: 44px; padding: 5px 0; font-size: 21px; } .hgrid { gap: 6px; }
}
@media (max-height: 700px) and (min-width: 768px) {
  .sv { width: min(100%, calc(100vh - 110px)); min-width: 260px; } .sv button { font-size: clamp(11px, 4.4cqw, 20px); }
  .treebox svg { max-height: calc(100vh - 90px); } .tlog div { padding: 3px 10px; font-size: 16px; }
}
@media (min-width: 768px) and (max-width: 1099px) { .stage { min-height: 0; } .sv { width: min(100%, 560px); } }
@media (max-width: 767px) {
  .card { padding: 10px; }
  .stage { min-height: 0; } .stq { font-size: 17px; padding: 8px; } .bign { font-size: 46px; } .treebox { min-height: 0; } .treebox svg { max-height: 34vh; } .tlog div { padding: 4px 10px; } .result .btn { padding: 8px 12px; font-size: 16px; }
  .sv { width: 100%; gap: 3px; } .sv button { border-width: 1.5px; border-radius: 7px; }
  .chip { padding: 6px 10px; font-size: 15px; }
  .keys button { width: 54px; height: 54px; font-size: 22px; }
  .bins { gap: 6px; } .bin { padding: 8px 3px; min-height: 92px; } .bin b { font-size: 14px; } .hgrid { gap: 6px; } .hgrid button { min-height: 50px; padding: 6px 0; } .mol .atom { width: 46px; height: 46px; font-size: 20px; }
  .tn text { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .sv button { transition: none; } .keys button.bad { animation: none; } }
