@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;700;800&display=swap');

/* ===== עיצוב "פלאייר" =====
   בלוק פתיחה כחול-כהה עם סימני מתמטיקה שקופים, כרטיסים לבנים מעוגלים, כפתורים עגולים.
   צבע הכיתה (--accent) מופיע בכפתורים, בפסים ובבחירות – ראו CLASS_COLORS בקובץ config.js */
:root {
  --hero: #1E1B4B; --ink: #1B1F3B; --yellow: #FFD54A;
  --accent: #2F4BC7; --accent-dark: #213793; --accent-soft: #E7ECFD; --star: #E0A100;
  --navy: var(--ink); --blue: var(--accent-dark); --blue-soft: var(--accent-soft); --gray: #8A90AA; --line: #E1E4F0;
  --green: #1E7B3A; --green-soft: #E3F3E8; --amber: #8A5E00; --amber-soft: #FFF4D2;
  --red: #B03447; --red-soft: #FBE4E8;
  --bg: #EEF0F7; --card: #FFFFFF; --text: #1B1F3B; --muted: #565B7A;
  --shadow: 0 6px 24px rgba(27,31,59,.08);
  --math: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='170' viewBox='0 0 200 170' fill='none' stroke='white' stroke-opacity='.16' stroke-width='8' stroke-linecap='round'%3E%3Cpath d='M30 58h64M62 26v64'/%3E%3Cpath d='M124 108l34 34M158 108l-34 34'/%3E%3Ccircle cx='150' cy='44' r='22'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='150' viewBox='0 0 170 150' fill='none' stroke='white' stroke-opacity='.13' stroke-width='7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 30c20 70 50 70 70 0'/%3E%3Cpath d='M110 90l14 26 30-60h12'/%3E%3Cpath d='M30 120h40'/%3E%3C/svg%3E");
  --q1: #5B21B6; --q2: #C2410C; --q3: #0F766E; --q4: #2F4BC7;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Rubik", "Arial", sans-serif; font-size: 18px; line-height: 1.7; }
main { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }
main.wide { max-width: 1150px; }

/* ---- בלוק הפתיחה (כל h1, וגם .hero) ---- */
h1, .hero {
  margin: 0 0 18px; padding: 24px 22px; border: 0; border-radius: 28px;
  background-color: var(--hero); background-image: var(--math);
  background-repeat: no-repeat; background-position: left -24px top -18px, right -10px bottom -26px;
  color: #fff; font-size: 30px; font-weight: 800; line-height: 1.15;
}
.hero h1 { margin: 0; padding: 0; background: none; border-radius: 0; }
.hero .sub, h1 .sub { display: block; font-size: 16px; font-weight: 400; opacity: .9; margin-top: 8px; line-height: 1.5; }
.hero .muted { color: rgba(255,255,255,.85); }
.tag { display: inline-block; border-radius: 999px; padding: 5px 16px; font-size: 15px; font-weight: 500; background: rgba(255,255,255,.16); color: #fff; }
.tag.y { background: var(--yellow); color: var(--ink); font-weight: 800; }
.hero button.ghost, .hero .btn.ghost { background: rgba(255,255,255,.16); color: #fff; box-shadow: none; }

h2 { margin: 0 0 10px; font-size: 21px; font-weight: 800; color: var(--ink); }
.card { background: var(--card); border: 0; border-radius: 24px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

button, .btn {
  font: inherit; font-weight: 700; background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 12px 22px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.full { width: 100%; padding: 16px; font-size: 20px; }
button.ghost { background: #fff; color: var(--accent-dark); box-shadow: 0 2px 10px rgba(27,31,59,.08); }
button.danger { background: var(--red); }
button:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=password], input[type=number], select {
  font: inherit; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input.answer { width: 100%; direction: ltr; text-align: right; font-size: 21px; border-radius: 16px; }
input.code { width: 100%; text-align: center; font-size: 34px; font-weight: 800; letter-spacing: 8px; text-transform: uppercase; direction: ltr; border: 2px solid var(--accent); border-radius: 18px; }
.err { color: var(--red); font-weight: 700; min-height: 1.5em; }

/* ---- שאלה ---- */
.q-head { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--ink); }
.q-num { width: 48px; height: 48px; flex: none; border-radius: 16px; background: var(--q1); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; }
form .card:nth-of-type(4n+2) .q-num, .qcards .card:nth-of-type(4n+2) .q-num { background: var(--q2); }
form .card:nth-of-type(4n+3) .q-num, .qcards .card:nth-of-type(4n+3) .q-num { background: var(--q3); }
form .card:nth-of-type(4n) .q-num, .qcards .card:nth-of-type(4n) .q-num { background: var(--q4); }
.q-label { font-size: 15px; color: var(--muted); font-weight: 500; }
.stars { color: var(--star); letter-spacing: 2px; margin-right: auto; }
.q-text { margin: 12px 0 14px; font-size: 19px; }
.opt { display: flex; align-items: center; gap: 12px; border: 2px solid var(--line); border-radius: 18px; padding: 11px 16px; margin: 9px 0; cursor: pointer; background: #fff; }
.opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.card.ok { background: var(--green-soft); box-shadow: inset 0 0 0 2px var(--green), var(--shadow); }
.card.bad { background: var(--red-soft); box-shadow: inset 0 0 0 2px var(--red), var(--shadow); }
.card.retry, .card.half { background: var(--amber-soft); box-shadow: inset 0 0 0 2px #D9A21B, var(--shadow); }
.fb { font-weight: 700; margin-top: 8px; }
.fb.ok { color: var(--green); } .fb.bad { color: var(--red); }
.fb.retry-fb, .fb.half { color: var(--amber); }

/* ---- פס השעון בשאלון ---- */
.timer-bar {
  position: sticky; top: 0; z-index: 5; background: var(--hero); color: #fff; border-radius: 0 0 22px 22px;
  padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 4px 16px rgba(27,31,59,.18);
}
.timer-bar #quizTitle { background: rgba(255,255,255,.16); border-radius: 999px; padding: 4px 14px; }
.timer { font-size: 26px; font-weight: 800; color: var(--ink); background: var(--yellow); border-radius: 999px; padding: 2px 18px; direction: ltr; font-variant-numeric: tabular-nums; }
.timer.low { background: #FF8A80; }
.progress { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 5px; margin: 0 2px 16px; }
.progress i { height: 8px; border-radius: 4px; background: #D5D9EA; }
.progress i.on { background: var(--accent); }

/* ---- ציון ---- */
.big-score { font-size: 56px; font-weight: 800; color: var(--accent); text-align: center; line-height: 1.1; direction: ltr; unicode-bidi: isolate; }
.big-score.hi { color: var(--green); } .big-score.mid { color: var(--amber); } .big-score.lo { color: var(--red); }
.score-circle { width: 150px; height: 150px; border-radius: 50%; background: #fff; color: var(--ink); margin: 14px auto 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-circle b { font-size: 50px; font-weight: 800; line-height: 1; direction: ltr; unicode-bidi: isolate; }
.score-circle span { font-size: 14px; color: var(--muted); font-weight: 400; }

.notice { background: #fff; border-radius: 20px; padding: 14px 18px; box-shadow: var(--shadow); }
.notice.warn { background: var(--amber-soft); }
.notice.bad { background: var(--red-soft); }
.notice.y { background: var(--yellow); color: var(--ink); font-weight: 800; }
.bar { height: 9px; background: var(--line); border-radius: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 5px; }
.hi { color: var(--green); } .mid { color: var(--amber); } .lo { color: var(--red); }
.bg-hi { background: #0F766E; } .bg-mid { background: #E0A100; } .bg-lo { background: #C2410C; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 10px; font-weight: 700; font-size: 15px; min-width: 52px; text-align: center; }
.pill.hi { background: var(--green-soft); } .pill.mid { background: var(--amber-soft); } .pill.lo { background: var(--red-soft); }
.na { color: var(--gray); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-size: 16px; }
th { background: var(--bg); position: sticky; top: 0; font-weight: 700; }
th:first-child { border-radius: 0 12px 12px 0; } th:last-child { border-radius: 12px 0 0 12px; }
.scroll { overflow-x: auto; }
.katex { font-size: 1.05em; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- תפריט המורה ---- */
nav.teacher { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
nav.teacher a { color: var(--ink); background: #fff; text-decoration: none; padding: 7px 16px; border-radius: 999px; font-size: 16px; font-weight: 500; box-shadow: 0 2px 10px rgba(27,31,59,.06); }
nav.teacher a.on { background: var(--hero); color: #fff; }
html.embed nav.teacher { display: none; }
.teacher-link { display: block; text-align: center; margin-top: 30px; color: var(--muted); font-size: 14px; text-decoration: none; }

/* שיעורי בית – דיווח עצמי */
.card.hw { background: #fff; box-shadow: inset 0 0 0 2px var(--yellow), var(--shadow); }
.card.hw .q-head .q-num { background: var(--yellow); color: var(--ink); }

@media print {
  h1, .hero { background: none; color: var(--ink); padding: 0 0 6px; border-radius: 0; border-bottom: 3px solid var(--ink); }
  .card { box-shadow: none; border: 1px solid var(--line); }
}
@media (max-width: 480px) { h1, .hero { font-size: 26px; } .hero { padding: 20px 18px; } }

/* שאלת חשיבה, רמז, שאלון אבחון */
.think-tag { background: var(--yellow); color: var(--ink); border-radius: 999px; padding: 2px 12px; font-size: 13px; font-weight: 700; }
.card.think { box-shadow: inset 0 0 0 2px var(--yellow), var(--shadow); }
.hint-btn { background: #fff; color: var(--accent-dark); box-shadow: inset 0 0 0 2px var(--line); padding: 6px 16px; font-size: 15px; font-weight: 500; margin-bottom: 8px; }
.hint { background: var(--amber-soft); border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; font-size: 16px; }
.think-box { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 20px; padding: 14px 18px; box-shadow: inset 0 0 0 2px var(--yellow), var(--shadow); margin-bottom: 16px; }
.think-box b.big { font-size: 30px; font-weight: 800; direction: ltr; unicode-bidi: isolate; }

/* סליידרים: אזור מגע גדול, ובלי שהדפדפן ינסה לגלול את הדף כשנוגעים בהם */
input[type=range] { touch-action: none; height: 36px; cursor: pointer; accent-color: var(--accent); }

/* "עכשיו מניחים את הטלפון בכוורת" – גדול, במרכז, פועם כדי שיראו אותו */
.hive { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: var(--yellow); color: var(--ink); border-radius: 28px; padding: 26px 18px; margin: 4px 0 18px;
  box-shadow: 0 0 0 0 rgba(255,213,74,.7), var(--shadow); animation: hive-pulse 1.4s ease-in-out infinite; }
.hive-icon { font-size: 64px; line-height: 1; animation: hive-wiggle 1.4s ease-in-out infinite; }
.hive-txt { font-size: clamp(28px, 8vw, 40px); font-weight: 800; line-height: 1.2; }
@keyframes hive-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,213,74,.7), var(--shadow); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 14px rgba(255,213,74,0), var(--shadow); }
}
@keyframes hive-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@media (prefers-reduced-motion: reduce) { .hive, .hive-icon { animation: none; } }

/* חלון "בטוחים שרוצים להגיש?" */
.ask-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(27,31,59,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ask { background: #fff; border-radius: 26px; padding: 24px 22px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.ask h2 { font-size: 24px; margin: 0 0 12px; }
.ask-warn { background: var(--red-soft); color: var(--ink); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; }
.ask-nums { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.ask-num { min-width: 46px; min-height: 46px; padding: 0 10px; border-radius: 14px; background: var(--red); font-size: 20px; font-weight: 800; }
.ask-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.ask-btns button { width: 100%; padding: 14px; font-size: 19px; }
.card.missing { box-shadow: inset 0 0 0 3px var(--red), var(--shadow); }

/* ---------- שאלות אינטראקטיביות ---------- */
.hs { direction: ltr; background: #fff; border-radius: 14px; padding: 6px; margin: 8px 0; }
.hs svg { width: 100%; height: auto; display: block; max-width: 420px; margin: 0 auto; touch-action: manipulation; }
.hs [data-spot] { cursor: pointer; }
.hs .spot { fill: #fff; stroke: #2F4BC7; stroke-width: 2.5; }
.hs .spot.on, .hs .on > .spot { fill: #FFD54A; stroke: #1B1F3B; stroke-width: 3; }
.hs .zone { fill: rgba(47, 75, 199, .06); stroke: #C9D0EE; stroke-width: 1.5; }
.hs .zone:hover { fill: rgba(47, 75, 199, .14); }
.hs .zone.on { fill: rgba(255, 213, 74, .75); stroke: #1B1F3B; }
.hs-note { margin-top: 2px; }
.blanks { font-size: clamp(14px, 4.3vw, 20px); margin: 10px 0; line-height: 2.2; text-align: center; white-space: nowrap; overflow-x: auto; }
.blank { width: 2.6em; font: inherit; text-align: center; padding: 2px 4px; border: 2px solid #2F4BC7; border-radius: 10px; margin: 0 3px; }
.match-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px; margin: 10px 0; }
.mk { background: #EEF0F7; border-radius: 12px; padding: 6px 10px; }
.mk b { color: #2F4BC7; margin-left: 6px; }
.match { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.mcard { background: #fff; border: 2px solid #E3E6F2; border-radius: 14px; padding: 6px; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.mcard svg { width: 100%; height: auto; max-width: 220px; }
.mcard label { display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; text-align: center; cursor: pointer; }
.mcard select { font: inherit; font-size: 18px; padding: 8px 10px; min-height: 44px; width: 100%; margin: 0; cursor: pointer; }
.blanks .sup .blank { width: 2.2em; font-size: 15px; padding: 0 2px; vertical-align: super; }
.mcard svg, .q-text svg { direction: ltr; }

/* ===== יחידת הסתברות – תוספות ===== */
.teach-card h2 { display: flex; align-items: center; gap: 10px; }
.teach-card h2 .n { width: 34px; height: 34px; border-radius: 12px; background: var(--q3); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.teach-card p { margin: 6px 0; }
.pics { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; direction: ltr; justify-content: center; }
.coin { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: #FFE9A8; border: 3px solid #D9A21B; font-weight: 800; font-size: 15px; color: var(--ink); }
.pair { display: inline-flex; gap: 4px; background: var(--bg); border-radius: 14px; padding: 5px; }
.pair .coin { width: 40px; height: 40px; font-size: 16px; }
.box { background: var(--bg); border-radius: 18px; padding: 12px 16px; margin: 10px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .box { margin: 0; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }
.tip { background: var(--amber-soft); border-radius: 16px; padding: 10px 14px; margin-top: 10px; font-size: 17px; }
.ex-list { display: grid; gap: 6px; margin-top: 8px; }
.ex { border-radius: 14px; padding: 8px 14px; font-weight: 500; }
.ex.yes { background: var(--green-soft); } .ex.no { background: var(--red-soft); }
table.words { width: auto; margin: 8px 0; }
table.words td, table.words th { white-space: normal; }
ol.steps { padding-right: 22px; margin: 8px 0; }
ol.steps li { margin-bottom: 10px; }
.part-head { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--hero); color: #fff; border-radius: 0 0 22px 22px; padding: 10px 18px; margin: 26px 0 14px; box-shadow: 0 4px 16px rgba(27,31,59,.18); }
.part-head b { font-size: 20px; }
.part-head .score { background: var(--yellow); color: var(--ink); border-radius: 999px; padding: 2px 14px; font-weight: 800; direction: rtl; }
.sol-btn { background: #fff; color: var(--accent-dark); box-shadow: inset 0 0 0 2px var(--line); padding: 6px 16px; font-size: 15px; font-weight: 500; }
.sol { background: #fff; border-radius: 14px; padding: 10px 14px; margin-top: 10px; box-shadow: inset 0 0 0 2px var(--line); line-height: 2; }
.q-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: center; }
.opt.locked { cursor: default; opacity: .75; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); text-decoration: line-through; }
.preview-bar { background: var(--yellow); color: var(--ink); font-weight: 700; border-radius: 16px; padding: 8px 14px; margin-bottom: 14px; text-align: center; }
.lesson-list a.card { display: block; color: inherit; text-decoration: none; }
.lesson-list .card.locked { opacity: .55; }
.lesson-num { display: inline-flex; width: 40px; height: 40px; border-radius: 14px; background: var(--q1); color: #fff; align-items: center; justify-content: center; font-weight: 800; margin-left: 10px; }
.scores { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.book { box-shadow: inset 0 0 0 2px var(--yellow), var(--shadow); }
.m { direction: ltr; unicode-bidi: isolate; font-family: "Rubik", Arial, sans-serif; font-weight: 500; }
.ov { text-decoration: overline; }
table.words th { position: static; }
