/* ============================================================
   חשבונאוטים — מערכת עיצוב
   כיוון: תא טייס של חללית ישנה. כהה, מתכתי, עם צג מואר.
   חוקים קשיחים: אפס משאבים חיצוניים (חייב לרוץ אופליין),
   גופני מערכת בלבד, וכל ביטוי חשבוני ב-LTR בתוך ממשק RTL.
   ============================================================ */

:root {
  /* חלל עמוק, לא שחור — שחור מוחלט מרגיש זול על מסך זול */
  --void:      #060a16;
  --deep:      #0b1226;
  --panel:     #131d38;
  --panel-hi:  #1c2a4d;
  --line:      #2b3b63;

  --ink:       #eaf0ff;
  --ink-dim:   #93a3c9;
  --ink-faint: #5b6b93;

  /* ענבר הוא הצבע הראשי — הוא של הכפתורים, הכוכבים והצג */
  --amber:     #ffb43a;
  --amber-lo:  #c77d15;
  --cyan:      #3ee0ff;
  --cyan-lo:   #1a8fa8;
  --rose:      #ff5c7a;
  --rose-lo:   #b02f47;
  --lime:      #5ee88a;
  --lime-lo:   #2f9a53;
  --violet:    #a78bfa;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;

  /* גופנים: מה שקיים במערכת. Aharoni ו-Bahnschrift קיימים בחלונות
     ונותנים אופי אמיתי; שאר השרשרת מכסה נייד ומקינטוש. */
  --font-display: 'Aharoni', 'Arial Black', 'Haettenschweiler', 'Impact', system-ui, sans-serif;
  --font-body: 'Gisha', 'Segoe UI', 'Noto Sans Hebrew', 'Arial Hebrew', system-ui, sans-serif;
  --font-num: 'Bahnschrift', 'DIN Alternate', 'Segoe UI Semibold', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  /* חייב להיות על שניהם. overflow-x על body בלבד לא מונע גלילה
     צדדית בנייד — הגלילה קורית על אלמנט ה-html. */
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--void);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  /* מונע הגדלה מקרית בלחיצה כפולה על מסך מגע תוך כדי משחק */
  touch-action: manipulation;
}

/* ---------- שדה כוכבים ---------- */
/* שלוש שכבות בקצבים שונים יוצרות עומק. הכול ב-CSS, בלי תמונות. */

.sky {
  position: fixed;
  inset: -10%;
  z-index: -2;
  background:
    radial-gradient(1.6px 1.6px at 12% 18%, #fff 40%, transparent 41%),
    radial-gradient(1.4px 1.4px at 47% 7%,  #cfe4ff 40%, transparent 41%),
    radial-gradient(1.8px 1.8px at 78% 27%, #fff 40%, transparent 41%),
    radial-gradient(1.2px 1.2px at 32% 62%, #ffe9c2 40%, transparent 41%),
    radial-gradient(1.6px 1.6px at 88% 71%, #fff 40%, transparent 41%),
    radial-gradient(1.3px 1.3px at 62% 88%, #d5e8ff 40%, transparent 41%),
    radial-gradient(1.1px 1.1px at 8%  84%, #fff 40%, transparent 41%),
    radial-gradient(1.5px 1.5px at 95% 45%, #ffd9a3 40%, transparent 41%);
  background-size: 340px 340px;
  animation: drift 140s linear infinite;
  opacity: .75;
}

.sky.slow {
  background-size: 620px 620px;
  animation-duration: 260s;
  animation-direction: reverse;
  opacity: .45;
}

/* זוהר עמום מאחורי הכול, כדי שהרקע לא יהיה שטוח */
.glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 78% 8%,  rgba(62,224,255,.13), transparent 70%),
    radial-gradient(55% 45% at 12% 92%, rgba(255,180,58,.11), transparent 70%);
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-340px, -340px, 0); }
}

/* ---------- שלד ---------- */

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-height: 100vh;
}

.screen { display: none; }
.screen.active {
  display: block;
  animation: screen-in .34s cubic-bezier(.2, .9, .25, 1) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* השהיה מדורגת — הכניסה מרגישה מכוונת ולא כמו הבזק */
.stagger > * { animation: pop-in .4s cubic-bezier(.2, .9, .25, 1) both; }
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .13s; }
.stagger > *:nth-child(4) { animation-delay: .18s; }
.stagger > *:nth-child(5) { animation-delay: .23s; }
.stagger > *:nth-child(6) { animation-delay: .28s; }
.stagger > *:nth-child(7) { animation-delay: .33s; }
.stagger > *:nth-child(8) { animation-delay: .38s; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* ---------- טיפוגרפיה ---------- */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: .01em;
  margin: 0;
  line-height: 1.15;
}

.title {
  font-size: clamp(38px, 11vw, 66px);
  text-align: center;
  color: var(--amber);
  text-shadow: 0 0 26px rgba(255, 180, 58, .38);
  margin-bottom: 2px;
}

.subtitle {
  text-align: center;
  color: var(--ink-dim);
  font-size: 15px;
  letter-spacing: .1em;
  margin: 0 0 26px;
}

.section-title {
  font-size: 22px;
  margin-bottom: 4px;
}

.muted { color: var(--ink-dim); font-size: 14px; }

/* כל ביטוי חשבוני חייב להיות LTR גם בתוך ממשק RTL,
   אחרת 153 − 78 מוצג הפוך ומבלבל. */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

/* ---------- כפתורים ---------- */
/* צל קשיח במקום רך: מרגיש כמו כפתור פיזי שנלחץ פנימה. */

.btn {
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
  color: var(--void);
  background: var(--amber);
  border: none;
  border-radius: var(--r-md);
  padding: 15px 26px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--amber-lo);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { filter: brightness(1.07); }
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--amber-lo);
}

.btn.ghost {
  background: transparent;
  color: var(--ink-dim);
  box-shadow: none;
  border: 2px solid var(--line);
  font-weight: 600;
}
.btn.ghost:hover { color: var(--ink); border-color: var(--ink-faint); }
.btn.ghost:active { transform: translateY(2px); box-shadow: none; }

.btn.cyan { background: var(--cyan); box-shadow: 0 5px 0 var(--cyan-lo); }
.btn.cyan:active { box-shadow: 0 1px 0 var(--cyan-lo); }

.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 22px;
}

/* ---------- לוחות ---------- */

.panel {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}

/* ---------- מסך פתיחה: בחירת אווטאר ---------- */

/* שני כרטיסים בשורה בנייד, שלושה במסך רחב. שלושה בנייד הפכו
   את הכרטיס ל-115px — צר מדי בשביל שם וכוכבים. */
.avatars {
  display: grid;
  /* 132 ולא יותר: ב-320px רוחב התוכן הוא 288, ושני כרטיסים של 148
     כבר לא נכנסים — הרשת הייתה נופלת לעמודה אחת ענקית. */
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.avatar {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 12px 18px;
  text-align: center;
  cursor: pointer;
  transition: transform .16s cubic-bezier(.2,.9,.25,1), border-color .16s, box-shadow .16s;
  -webkit-tap-highlight-color: transparent;
}

.avatar:hover {
  transform: translateY(-5px);
  border-color: var(--av-color, var(--amber));
  box-shadow: 0 10px 30px -12px var(--av-color, var(--amber));
}

/* כל שורה בכרטיס היא block. בלי זה ה-span-ים נזרמים באותה שורה
   והשם נדרס על הטקסט שאחריו. */
.avatar .face {
  display: block;
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 5px 12px rgba(0,0,0,.55));
}

.avatar .name {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.25;
  margin-top: 14px;
  color: var(--ink);
  /* שם ארוך מתקצר במקום לשבור את הכרטיס */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar .meta {
  display: block;
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-top: 5px;
}

/* מונה הכוכבים יושב בזרימה מתחת לשם. קודם הוא היה ממוקם
   אבסולוטית ונחת על האווטאר עצמו. */
.avatar .tally {
  display: block;
  margin-top: 7px;
  font-family: var(--font-num);
  font-size: 14px;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.avatar .tally.none { color: var(--ink-faint); }

.avatar.taken .face { filter: drop-shadow(0 5px 12px rgba(0,0,0,.55)) saturate(1.15); }

/* ---------- מפת העולמות ---------- */
/* הזחה לסירוגין הופכת רשימה אנכית למסלול. */

.worlds { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

.world {
  display: flex;
  align-items: center;
  gap: 15px;
  background: linear-gradient(100deg, var(--panel-hi), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 17px;
  cursor: pointer;
  transition: transform .16s cubic-bezier(.2,.9,.25,1), border-color .16s, box-shadow .16s;
  -webkit-tap-highlight-color: transparent;
}

.world:nth-child(even) { margin-inline-start: clamp(0px, 7vw, 54px); }
.world:nth-child(odd)  { margin-inline-end: clamp(0px, 7vw, 54px); }

.world:not(.locked):hover {
  transform: translateY(-4px);
  border-color: var(--w-color);
  box-shadow: 0 12px 34px -14px var(--w-color);
}

.world .orb {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: var(--void);
  background: radial-gradient(circle at 32% 28%, #fff6, transparent 55%), var(--w-color);
  box-shadow: 0 0 26px -4px var(--w-color), inset 0 -6px 12px rgba(0,0,0,.3);
}

.world .body { flex: 1; min-width: 0; }
.world .wname { font-family: var(--font-display); font-size: 20px; }
.world .wblurb { font-size: 13px; color: var(--ink-dim); margin-top: 1px; }

.world .tally {
  font-family: var(--font-num);
  font-size: 14px;
  color: var(--amber);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.world.locked { opacity: .5; cursor: not-allowed; }
.world.locked .orb {
  background: var(--panel-hi);
  color: var(--ink-faint);
  box-shadow: inset 0 -6px 12px rgba(0,0,0,.3);
}
.world.locked .lockmsg { font-size: 13px; color: var(--ink-faint); margin-top: 5px; }

/* ---------- שלבים בתוך עולם ---------- */

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.level {
  aspect-ratio: 1;
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: transform .16s cubic-bezier(.2,.9,.25,1), border-color .16s;
  -webkit-tap-highlight-color: transparent;
}

.level:not(.locked):hover { transform: translateY(-4px); border-color: var(--w-color); }
.level .num { font-family: var(--font-display); font-size: 28px; }
.level .earned { font-size: 14px; letter-spacing: 2px; }
.level.locked { opacity: .38; cursor: not-allowed; }
.level.locked .num { font-size: 24px; }

/* אריח הדרגה — ממלא את התא החמישי-שישי במידע אמיתי במקום ברווח */
.level.info {
  cursor: default;
  border-style: dashed;
  border-color: var(--line);
  background: transparent;
  gap: 3px;
}
.level.info .num { font-size: 30px; color: var(--w-color, var(--amber)); }
.level.info .muted { font-size: 11px; }

.level.info .meter { display: flex; gap: 3px; margin-top: 3px; }
.level.info .meter i {
  width: 12px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
}
.level.info .meter i.on { background: var(--w-color, var(--amber)); }

.level.boss {
  grid-column: span 3;
  aspect-ratio: auto;
  padding: 16px;
  border-color: var(--rose-lo);
  background: linear-gradient(100deg, #2a1430, var(--panel));
}
.level.boss .num { font-size: 22px; color: var(--rose); }

/* ---------- כוכבים ---------- */

.stars { letter-spacing: 3px; font-size: 15px; }
.star-on  { color: var(--amber); text-shadow: 0 0 10px rgba(255,180,58,.55); }
.star-off { color: var(--ink-faint); opacity: .5; }

/* ---------- סרגל עליון בזמן משחק ---------- */

.hud {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.hud .who { font-size: 26px; line-height: 1; }
.hud .bar-wrap { flex: 1; }

.bar {
  height: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--amber));
  border-radius: 99px;
  transition: width .35s cubic-bezier(.2,.9,.25,1);
}

.hud .count {
  font-family: var(--font-num);
  font-size: 14px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.hearts { font-size: 19px; letter-spacing: 2px; }
.heart-lost { opacity: .22; filter: grayscale(1); }

.timer {
  font-family: var(--font-num);
  font-size: 17px;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
}
.timer.urgent { color: var(--rose); animation: pulse .55s ease-in-out infinite; }

@keyframes pulse {
  50% { transform: scale(1.14); }
}

/* ---------- הצג ---------- */
/* זה הרכיב שהמשחק נזכר בזכותו: מסך מואר עם קווי סריקה. */

.readout {
  position: relative;
  background:
    linear-gradient(180deg, rgba(62,224,255,.07), rgba(0,0,0,.28)),
    var(--deep);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  padding: 34px 18px;
  text-align: center;
  overflow: hidden;
  box-shadow: inset 0 0 60px -18px rgba(62,224,255,.4);
}

/* קווי סריקה — הפרט הקטן שהופך מלבן למסך */
.readout::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255,255,255,.045) 0 1px,
    transparent 1px 4px
  );
}

.readout .expr {
  font-family: var(--font-num);
  font-size: clamp(34px, 11vw, 60px);
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 0 22px rgba(62,224,255,.4);
  letter-spacing: .02em;
  line-height: 1.25;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

.readout .ask {
  font-size: 14px;
  color: var(--cyan);
  letter-spacing: .12em;
  margin-bottom: 12px;
}

.readout.good { border-color: var(--lime); animation: flash-good .5s ease; }
.readout.bad  { border-color: var(--rose); animation: shake .42s ease; }

@keyframes flash-good {
  0%   { box-shadow: inset 0 0 60px -18px rgba(62,224,255,.4); }
  35%  { box-shadow: inset 0 0 90px -6px rgba(94,232,138,.75); }
  100% { box-shadow: inset 0 0 60px -18px rgba(62,224,255,.4); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* ---------- מצב "מה קודם?" ---------- */
/* האסימונים הם צ'יפים; רק האופרטורים לחיצים. */

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  direction: ltr;
  align-items: center;
}

.tok {
  font-family: var(--font-num);
  font-size: clamp(26px, 8vw, 44px);
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  line-height: 1.2;
  transition: all .18s cubic-bezier(.2,.9,.25,1);
}

.tok.num   { color: var(--ink); }
.tok.paren { color: var(--ink-faint); padding-inline: 2px; }

.tok.op {
  color: var(--amber);
  cursor: pointer;
  border: 2px dashed rgba(255,180,58,.35);
  background: rgba(255,180,58,.06);
  -webkit-tap-highlight-color: transparent;
}
.tok.op:hover {
  background: rgba(255,180,58,.19);
  border-style: solid;
  transform: translateY(-3px);
}

.tok.picked {
  background: var(--amber);
  color: var(--void);
  border-color: var(--amber);
  border-style: solid;
}
.tok.wrongpick {
  background: rgba(255,92,122,.22);
  border-color: var(--rose);
  color: var(--rose);
  animation: shake .42s ease;
}

/* שני האופרנדים שנבחרו נדלקים יחד עם האופרטור */
.tok.involved {
  background: rgba(255,180,58,.16);
  color: var(--amber);
  border-radius: 12px;
}

/* ההתכווצות לתוצאה — הרגע שמלמד את הכלל */
.tok.collapsing {
  opacity: 0;
  transform: scale(.35);
  padding-inline: 0;
  margin-inline: -4px;
}

/* ---------- אפשרויות תשובה ---------- */

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-top: 18px;
}

.choice {
  font-family: var(--font-num);
  font-size: 27px;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: 17px 10px;
  cursor: pointer;
  min-height: 62px;
  direction: ltr;
  font-variant-numeric: tabular-nums;
  transition: transform .12s cubic-bezier(.2,.9,.25,1), border-color .14s, background .14s;
  -webkit-tap-highlight-color: transparent;
}

.choice:hover { border-color: var(--cyan); transform: translateY(-3px); }
.choice:active { transform: translateY(1px); }
.choice.right { background: var(--lime); border-color: var(--lime); color: var(--void); }
.choice.wrong { background: var(--rose-lo); border-color: var(--rose); color: #fff; }
.choice:disabled { cursor: default; }
.choice:disabled:hover { transform: none; border-color: var(--line); }
.choice.right:disabled:hover { border-color: var(--lime); }
.choice.wrong:disabled:hover { border-color: var(--rose); }

/* אפשרויות נכון/לא-נכון רחבות יותר — הן טקסט ולא מספר */
.choices.binary { grid-template-columns: 1fr 1fr; }
.choices.binary .choice { font-family: var(--font-body); font-size: 20px; direction: rtl; }

/* ---------- הקלדת תשובה ---------- */

.entry {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.slot {
  font-family: var(--font-num);
  font-size: 40px;
  font-weight: 700;
  color: var(--amber);
  background: var(--deep);
  border: 2px solid var(--line);
  border-bottom-color: var(--amber);
  border-radius: var(--r-md);
  min-width: 172px;
  min-height: 66px;
  display: grid;
  place-items: center;
  direction: ltr;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.slot:empty::before { content: '·'; color: var(--ink-faint); }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  width: 100%;
  max-width: 300px;
  /* מקלדת מספרים היא תמיד משמאל לימין, גם בממשק עברי.
     בלי זה הרשת יורשת RTL מה-body ומקבלים 9 8 7 במקום 7 8 9 —
     הפוך מכל מחשבון ומכל טלפון, ומבלבל את זיכרון השרירים. */
  direction: ltr;
}

.key {
  font-family: var(--font-num);
  font-size: 25px;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  min-height: 54px;   /* יעד מגע נוח */
  cursor: pointer;
  transition: transform .08s ease, background .12s;
  -webkit-tap-highlight-color: transparent;
}
.key:hover { background: var(--panel-hi); }
.key:active { transform: translateY(3px); }
.key.wide { grid-column: span 1; font-size: 19px; font-family: var(--font-body); }
.key.go { background: var(--amber); color: var(--void); border-color: var(--amber); }
.key.go:disabled { opacity: .35; }

/* ---------- משוב ---------- */

.feedback {
  margin-top: 16px;
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.6;
  border: 1px solid var(--line);
  background: var(--panel);
  animation: pop-in .3s cubic-bezier(.2,.9,.25,1) both;
}
.feedback.good { border-color: var(--lime-lo); background: rgba(94,232,138,.09); }
.feedback.bad  { border-color: var(--rose-lo); background: rgba(255,92,122,.09); }
.feedback .lead { font-family: var(--font-display); font-size: 18px; display: block; margin-bottom: 3px; }
.feedback.good .lead { color: var(--lime); }
.feedback.bad .lead  { color: var(--rose); }

/* ---------- מסך סיכום ---------- */

.result-stars { text-align: center; font-size: 54px; letter-spacing: 10px; margin: 10px 0 4px; }
.result-stars span { display: inline-block; animation: star-pop .45s cubic-bezier(.2,1.5,.4,1) both; }
.result-stars span:nth-child(1) { animation-delay: .12s; }
.result-stars span:nth-child(2) { animation-delay: .3s; }
.result-stars span:nth-child(3) { animation-delay: .48s; }

@keyframes star-pop {
  from { opacity: 0; transform: scale(0) rotate(-140deg); }
  to   { opacity: 1; transform: none; }
}

.tally-row {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 16px 0 4px;
  text-align: center;
}
.tally-row .n {
  font-family: var(--font-num);
  font-size: 30px;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.tally-row .l { font-size: 12px; color: var(--ink-dim); letter-spacing: .06em; }

.news {
  margin-top: 16px;
  border: 2px solid var(--amber);
  background: rgba(255,180,58,.1);
  border-radius: var(--r-md);
  padding: 14px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--amber);
}

/* ---------- טפסים וחשבון ---------- */

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 5px;
}

.tab {
  flex: 1;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  border-radius: 11px;
  padding: 11px 8px;
  min-height: 44px;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.tab.active { background: var(--amber); color: var(--void); }
.tab:not(.active):hover { color: var(--ink); }

.field { display: block; margin-bottom: 15px; }
.field > span {
  display: block;
  font-size: 14px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--ink);
  background: var(--deep);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 14px;
  min-height: 48px;
  transition: border-color .16s;
}
.field input:focus {
  outline: none;
  border-color: var(--cyan);
}
.field input[dir="ltr"] { font-family: var(--font-num); letter-spacing: .02em; }

.field .hint {
  display: block;
  font-style: normal;
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-top: 6px;
  line-height: 1.5;
}

/* הודעת פרטיות — נוכחת אבל לא צועקת */
.privacy {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-faint);
}
.privacy strong {
  display: block;
  color: var(--ink-dim);
  margin-bottom: 4px;
  font-size: 13.5px;
}

.msg {
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 13px;
  animation: pop-in .25s cubic-bezier(.2,.9,.25,1) both;
}
.msg.bad  { background: rgba(255,92,122,.12); border: 1px solid var(--rose-lo); color: #ffc4cf; }
.msg.good { background: rgba(94,232,138,.11); border: 1px solid var(--lime-lo); color: #c3f5d5; }
.msg.info { background: rgba(62,224,255,.09); border: 1px solid var(--cyan-lo); color: #c2eefb; }

.grade-row { display: flex; gap: 8px; flex-wrap: wrap; }
.grade-row .grade-opt {
  flex: 1;
  min-width: 96px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-dim);
  background: var(--deep);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 8px;
  min-height: 46px;
  cursor: pointer;
  transition: all .16s;
}
.grade-row .grade-opt.on {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(255,180,58,.1);
}

/* אווטאר בבחירה — מצב נבחר */
.avatar.chosen {
  border-color: var(--av-color, var(--amber));
  box-shadow: 0 0 0 2px var(--av-color, var(--amber)) inset;
}
.avatar.used { opacity: .32; cursor: not-allowed; }

/* ---------- מסך הורה ---------- */

.kid-card {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 17px;
  margin-bottom: 13px;
}

.kid-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 13px;
}
.kid-head .face { font-size: 33px; line-height: 1; }
.kid-head .who-name { font-family: var(--font-display); font-size: 20px; }

.kid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 9px;
  margin-bottom: 13px;
}
.kid-grid .cell {
  background: var(--deep);
  border-radius: var(--r-sm);
  padding: 9px 7px;
  text-align: center;
}
.kid-grid .cell .v {
  font-family: var(--font-num);
  font-size: 21px;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.kid-grid .cell .k { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }

.weak-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.weak-list .chip {
  font-family: var(--font-num);
  font-size: 15px;
  direction: ltr;
  background: rgba(255,92,122,.13);
  border: 1px solid var(--rose-lo);
  color: #ffc4cf;
  border-radius: 8px;
  padding: 4px 9px;
}
.weak-title { font-size: 13px; color: var(--ink-dim); margin-top: 11px; }

/* ---------- שונות ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 44px;
}

/* כתובת המייל היא הטקסט היחיד בסרגל שאורכו לא ידוע מראש.
   בלי ההגבלה הזו כתובת ארוכה דוחפת את כל הסרגל מעבר לרוחב המסך
   ויוצרת גלילה צדדית בכל האתר. */
#family-email {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 12px;
}

/* מתחת ל-420px הסרגל צפוף מדי לארבעה פריטים — המייל מוותר ראשון,
   הוא ממילא מוצג במלואו במסך ההורה. */
@media (max-width: 420px) {
  #family-email { display: none; }
}

/* מסך בחירת השחקן נושם. הוא המסך שנפתח הכי הרבה פעמים ביום,
   והוא כמעט ריק — אין סיבה לדחוס אותו לראש העמוד. */
.picker-head { margin-top: 30px; }
.picker-head .muted { margin-top: 6px; }
#avatar-grid + #players-message:not(:empty) { margin-top: 18px; }
#scr-splash .btn-row { margin-top: 30px; }

/* קבוצת השליטה בצליל — מופע יחיד שנודד בין המסכים */
.controls {
  display: flex;
  gap: 7px;
  flex: none;
  margin-inline-start: auto;   /* תמיד נצמדת לקצה הרחוק של הסרגל */
}

.ctl {
  width: 44px;
  height: 44px;
  font-size: 19px;
  line-height: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color .15s, background .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.ctl:hover { border-color: var(--ink-faint); background: var(--panel-hi); }
.ctl:active { transform: translateY(2px); }

/* כבוי — עמום ועם קו נטוי, כדי שהמצב יהיה ברור גם בלי טקסט */
.ctl.off { opacity: .4; position: relative; }
.ctl.off::after {
  content: '';
  position: absolute;
  inset-inline-start: 8px;
  top: 50%;
  width: 28px;
  height: 2px;
  background: var(--rose);
  transform: rotate(-40deg);
  border-radius: 2px;
}

/* דרגת המוזיקה כנקודות זעירות מתחת לאייקון */
.ctl .lvl {
  position: absolute;
  bottom: 5px;
  inset-inline-start: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 2px;
}
.ctl .lvl i { width: 4px; height: 3px; border-radius: 2px; background: var(--ink-faint); }
.ctl .lvl i.on { background: var(--amber); }
#btn-music { position: relative; padding-bottom: 4px; }

.back {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  padding: 8px 10px;
  min-height: 44px;   /* יעד מגע — נבדק על 375px */
}
.back:hover { color: var(--ink); }

.warn {
  background: rgba(255,180,58,.1);
  border: 1px solid var(--amber-lo);
  color: var(--amber);
  border-radius: var(--r-sm);
  padding: 9px 13px;
  font-size: 13px;
  margin-bottom: 14px;
}

.center { text-align: center; }
.mt { margin-top: 18px; }

/* ---------- כבוד להעדפת תנועה מופחתת ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .sky { animation: none; }
}

/* ---------- מסכים צרים ---------- */

@media (max-width: 380px) {
  .avatars { gap: 9px; }
  .avatar { padding: 12px 4px 10px; }
  .avatar .face { font-size: 34px; }
  .avatar .name { font-size: 15px; }
  .readout { padding: 24px 12px; }
  .choice { font-size: 23px; padding: 14px 8px; min-height: 56px; }
}
