/* ══════════════════════════════════════════════════
   הטבעות האבודות — אלירן & ירדן
   עיצוב: לילה באולם + זהב. מובייל ראשון, RTL.
   ══════════════════════════════════════════════════ */

:root {
  --ink:        #0d0b14;
  --ink-2:      #16131f;
  --panel:      rgba(30, 25, 44, 0.82);
  --panel-line: rgba(255, 214, 145, 0.18);
  --gold:       #f0c775;
  --gold-2:     #d9a441;
  --gold-soft:  rgba(240, 199, 117, 0.14);
  --rose:       #f2879b;
  --mint:       #7fd6c0;
  --text:       #f6f1e8;
  --text-dim:   #b3a9c2;
  --danger:     #ff7a7a;

  --eliran:     #6fb3f2;
  --yarden:     #f2879b;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* חובה: כללי display שלנו גוברים על ברירת המחדל של [hidden] בדפדפן.
   בלי זה כל שכבה עם display מפורש נשארת על המסך גם כשהיא "מוסתרת". */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--text);
  font-family: "Heebo", "Assistant", "Rubik", -apple-system, "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body::before {
  /* אורות רכים של אולם */
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(90vmax 60vmax at 15% -10%, rgba(217, 164, 65, 0.20), transparent 60%),
    radial-gradient(70vmax 60vmax at 95% 110%, rgba(242, 135, 155, 0.16), transparent 62%),
    linear-gradient(160deg, #100d19 0%, #0d0b14 55%, #14101d 100%);
  z-index: -2;
}

/* dvh עוקב אחרי סרגלי הדפדפן שמופיעים ונעלמים — קריטי באייפון,
   שם אין מסך מלא אמיתי והפריסה חייבת למלא בדיוק את מה שיש */
#app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100dvw;
}

/* ─────────── מסכים ─────────── */
.screen {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  padding: calc(14px + var(--safe-t)) calc(14px + var(--safe-r)) calc(14px + var(--safe-b)) calc(14px + var(--safe-l));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.is-active { display: flex; animation: fadeIn .28s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─────────── פאנל ─────────── */
.panel {
  position: relative;
  width: min(440px, 100%);
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--panel-line);
  border-radius: var(--r-lg);
  padding: 22px 20px 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06);
  text-align: center;
  margin: auto;
}
.panel--narrow { width: min(360px, 100%); }
.panel--wide   { width: min(560px, 100%); }

.crest { font-size: 44px; line-height: 1; filter: drop-shadow(0 4px 14px rgba(240,199,117,.45)); }

.title {
  margin: 8px 0 2px;
  font-size: 30px; font-weight: 800; letter-spacing: -.4px;
  background: linear-gradient(180deg, #fff6e2, var(--gold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title--sm { font-size: 23px; margin-top: 2px; }

.subtitle { margin: 0 0 14px; font-size: 15px; color: var(--gold); letter-spacing: 2px; font-weight: 600; }
.amp { color: var(--rose); font-style: italic; }

.lede { margin: 0 0 14px; color: var(--text-dim); font-size: 14.5px; line-height: 1.6; }
.greet { margin: 0 0 18px; font-size: 14px; color: var(--text-dim); }
.greet b { color: var(--text); }
.footnote { margin: 16px 0 0; font-size: 12.5px; color: var(--text-dim); opacity: .85; line-height: 1.6; }

/* ─────────── שדות ─────────── */
.field {
  width: 100%;
  padding: 14px 16px;
  font: inherit; font-size: 17px;
  text-align: center;
  color: var(--text);
  background: rgba(0,0,0,.34);
  border: 1.5px solid rgba(255,255,255,.12);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  -webkit-user-select: text; user-select: text;
}
.field::placeholder { color: rgba(179,169,194,.55); }
.field:focus { border-color: var(--gold-2); box-shadow: 0 0 0 4px var(--gold-soft); }
.field--code {
  font-size: 32px; font-weight: 800; letter-spacing: 12px;
  text-indent: 12px; text-transform: uppercase;
  font-family: "SF Mono", "Consolas", monospace;
}

.err { margin: 8px 0 0; color: var(--danger); font-size: 13.5px; min-height: 1em; }

/* ─────────── כפתורים ─────────── */
.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 13px 18px;
  font: inherit; font-weight: 700; font-size: 16px;
  color: var(--text);
  background: rgba(255,255,255,.07);
  border: 1.5px solid rgba(255,255,255,.13);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform .12s, filter .18s, opacity .18s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--tiny  { padding: 7px 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-main { font-size: 16.5px; }
.btn-sub  { font-size: 12px; font-weight: 500; color: var(--text-dim); }

.btn--primary {
  color: #2a1c05;
  background: linear-gradient(180deg, #ffdf9e, var(--gold-2));
  border-color: rgba(255,255,255,.35);
  box-shadow: 0 8px 24px rgba(217,164,65,.32);
}
.btn--primary .btn-sub { color: rgba(42,28,5,.72); }
.btn--ghost { background: rgba(240,199,117,.10); border-color: rgba(240,199,117,.36); }
.btn--quiet { background: rgba(255,255,255,.05); font-size: 14px; font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.row   { display: flex; gap: 10px; }
.row > .btn { flex: 1; }

.linkbtn {
  background: none; border: none; padding: 2px 4px;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--gold); text-decoration: underline; cursor: pointer;
}
.linkbtn--center { display: block; margin: 10px auto 0; }

.back {
  position: absolute; inset-inline-start: 12px; top: 12px;
  background: none; border: none; padding: 6px 8px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-dim); cursor: pointer;
}
.back:active { color: var(--text); }

/* ─────────── טעינה ─────────── */
.boot { text-align: center; }
.boot-text { margin-top: 22px; color: var(--text-dim); font-size: 14px; letter-spacing: .5px; }
.rings-spin { position: relative; width: 84px; height: 54px; margin: 0 auto; }
.rings-spin span {
  position: absolute; top: 0; width: 50px; height: 50px;
  border: 4px solid var(--gold); border-radius: 50%;
  animation: ringPulse 1.7s ease-in-out infinite;
}
.rings-spin span:nth-child(1) { inset-inline-start: 0; }
.rings-spin span:nth-child(2) { inset-inline-start: 30px; border-color: var(--rose); animation-delay: .25s; }
.rings-spin--sm { transform: scale(.62); }
@keyframes ringPulse {
  0%,100% { transform: scale(1) rotate(0); opacity: .55; }
  50%     { transform: scale(1.12) rotate(18deg); opacity: 1; }
}

/* ─────────── לובי ─────────── */
.codebox {
  margin: 6px 0 18px; padding: 14px;
  background: rgba(0,0,0,.30);
  border: 1px dashed rgba(240,199,117,.42);
  border-radius: var(--r-md);
}
.codebox-label { display: block; font-size: 12px; color: var(--text-dim); letter-spacing: 1px; }
.codebox-code {
  display: block; margin: 4px 0 10px;
  font-size: 42px; font-weight: 900; letter-spacing: 10px; text-indent: 10px;
  color: var(--gold);
  font-family: "SF Mono", "Consolas", monospace;
  text-shadow: 0 0 26px rgba(240,199,117,.45);
}
.codebox-actions { display: flex; gap: 8px; justify-content: center; }

.slots { display: flex; align-items: center; justify-content: center; gap: 8px; }
.slot {
  flex: 1; padding: 14px 8px;
  background: rgba(255,255,255,.045);
  border: 1.5px solid rgba(255,255,255,.10);
  border-radius: var(--r-md);
  transition: border-color .2s, background .2s;
}
.slot.is-filled { background: rgba(255,255,255,.08); }
.slot.is-ready  { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(127,214,192,.14); }
.slot.is-you    { outline: 2px solid var(--gold); outline-offset: 2px; }

.slot-avatar {
  width: 54px; height: 54px; margin: 0 auto 8px;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 800; color: #17121f;
  border-radius: 50%;
  background: linear-gradient(160deg, #cfd8e6, #8fa2bd);
}
.slot-avatar[data-char="eliran"] { background: linear-gradient(160deg, #9fd0ff, var(--eliran)); }
.slot-avatar[data-char="yarden"] { background: linear-gradient(160deg, #ffc0cd, var(--yarden)); }
.slot.is-empty .slot-avatar { background: rgba(255,255,255,.10); color: rgba(255,255,255,.30); }

.slot-name { font-weight: 700; font-size: 15px; }
.slot-role { font-size: 12px; color: var(--gold); margin-top: 1px; }
.slot-badge {
  margin-top: 7px; display: inline-block;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11.5px; font-weight: 700;
  background: rgba(255,255,255,.08); color: var(--text-dim);
}
.slot.is-ready .slot-badge { background: rgba(127,214,192,.20); color: var(--mint); }
.slot-vs { font-size: 20px; color: var(--rose); font-style: italic; font-weight: 700; }

.modepick { margin-top: 16px; }
.modepick-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.lockednote {
  margin: 14px 0 0; padding: 10px 12px;
  font-size: 12.5px; line-height: 1.55; color: var(--text-dim);
  background: rgba(240,199,117,.08);
  border: 1px solid rgba(240,199,117,.20);
  border-radius: var(--r-sm);
}
.lockednote b { color: var(--gold); }
.hosthint { margin: 10px 0 0; font-size: 12.5px; color: var(--text-dim); }

/* ─────────── מקטעים (טאבים) ─────────── */
.seg {
  display: flex; gap: 6px; padding: 5px;
  background: rgba(0,0,0,.28);
  border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,.08);
}
.seg--tabs { margin: 12px 0 14px; }
.seg-item {
  flex: 1; display: flex; flex-direction: column; gap: 1px;
  padding: 9px 6px;
  font: inherit; color: var(--text-dim);
  background: none; border: none; border-radius: var(--r-sm);
  cursor: pointer; transition: background .18s, color .18s;
}
.seg-item b     { font-size: 14px; font-weight: 700; }
.seg-item small { font-size: 11px; opacity: .8; }
.seg-item.is-on {
  color: #2a1c05;
  background: linear-gradient(180deg, #ffdf9e, var(--gold-2));
  box-shadow: 0 4px 14px rgba(217,164,65,.28);
}
.seg-item:disabled { opacity: .4; cursor: not-allowed; }

/* ─────────── לוח תוצאות ─────────── */
.board { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; text-align: start; }
.board-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 7px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--r-md);
}
.board-row.is-me { border-color: var(--gold); background: rgba(240,199,117,.12); }
.board-rank {
  flex: 0 0 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800;
  background: rgba(255,255,255,.08); border-radius: 50%;
}
.board-row:nth-child(1) .board-rank { background: linear-gradient(160deg,#ffe9ae,#d9a441); color:#2a1c05; }
.board-row:nth-child(2) .board-rank { background: linear-gradient(160deg,#f0f0f5,#a8adb8); color:#22222a; }
.board-row:nth-child(3) .board-rank { background: linear-gradient(160deg,#f0c49b,#b3743f); color:#2a1c05; }
.board-info { flex: 1; min-width: 0; }
.board-names { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-meta  { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.board-score { text-align: end; }
.board-score b     { display: block; font-size: 16px; color: var(--gold); }
.board-score small { font-size: 11px; color: var(--text-dim); }
.board-empty { color: var(--text-dim); font-size: 14px; padding: 26px 0; }

/* ─────────── תוצאות ─────────── */
.scorebig { margin: 12px 0 14px; }
.scorebig span {
  display: block; font-size: 54px; font-weight: 900; line-height: 1;
  background: linear-gradient(180deg,#fff6e2,var(--gold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.scorebig small { font-size: 12px; color: var(--text-dim); letter-spacing: 2px; }
.resgrid { display: flex; gap: 8px; }
.rescell {
  flex: 1; padding: 10px 4px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-md);
}
.rescell b     { display: block; font-size: 18px; }
.rescell small { font-size: 11px; color: var(--text-dim); }
.resnames { margin: 14px 0 0; font-size: 14px; color: var(--gold); font-weight: 600; }

/* ─────────── הוראות ─────────── */
.story {
  padding: 12px 14px; margin-bottom: 14px; text-align: start;
  background: rgba(0,0,0,.24);
  border-inline-start: 3px solid var(--gold-2);
  border-radius: var(--r-sm);
  font-size: 14px; line-height: 1.7; color: var(--text-dim);
}
.story b { color: var(--text); }
.story-hi { color: var(--gold); font-weight: 600; margin-bottom: 0; }
.howto { list-style: none; margin: 0; padding: 0; text-align: start; }
.howto li {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; margin-bottom: 6px;
  background: rgba(255,255,255,.04);
  border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text-dim);
}
.howto b { color: var(--text); }
.howto .ic {
  flex: 0 0 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 17px;
  background: rgba(240,199,117,.14); border-radius: 50%;
}

/* ══════════════════════════════════════════════════
   מסך המשחק
   ══════════════════════════════════════════════════ */
.screen--game { padding: 0; background: #07060c; align-items: stretch; }
#game-canvas { position: absolute; inset: 0;
  /* iOS מתעלם מ-user-scalable=no מאז iOS 10, ו-touch-action על ה-body
     חוסם רק הקשה כפולה. בלי זה שתי אצבעות על שטח המשחק מזמינות
     את המסך באמצע שלב. */
  touch-action: none;
}
#game-canvas canvas { display: block; width: 100% !important; height: 100% !important; }

.hud {
  position: absolute; top: 0; inset-inline: 0;
  display: flex; align-items: center; gap: 7px;
  padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l));
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7,6,12,.72), transparent);
  z-index: 5;
}
.hud-item {
  padding: 5px 12px;
  font-size: 13px; font-weight: 700;
  background: linear-gradient(180deg, rgba(34,27,51,.72), rgba(13,11,20,.72));
  border: 1px solid rgba(240,199,117,.22);
  border-radius: 99px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.07);
}
/* הניקוד קופץ קלות כשהוא עולה — פידבק בלי להסיט מבט */
.hud-score.is-bump { animation: scoreBump .3s ease; }
@keyframes scoreBump {
  50% { transform: scale(1.16); color: #fff6e2; }
}
.hud-timer { font-family: "SF Mono","Consolas",monospace; color: var(--mint); }
.hud-rings { color: var(--gold); }
.hud-score { margin-inline-start: auto; color: var(--gold); }
.hud-btn {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-size: 15px; color: var(--text-dim);
  background: rgba(13,11,20,.62);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 50%; cursor: pointer;
}
.hud-btn:active { transform: scale(.92); }

/* ─── שליטה ─── */
.controls {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 6;
}
/* כל מידות השליטה הן 75% מהגרסה הראשונה, ושקופות יותר —
   כדי שיישאר כמה שיותר מהמשחק גלוי מתחת לאצבעות.

   כאן משתמשים ב-left/right פיזיים ולא ב-inset-inline: המסמך הוא
   RTL, ולכן inset-inline-start נפתר לצד *ימין* — הג׳ויסטיק ישב
   מימין והכפתורים משמאל, הפוך מכל פלטפורמר ומהמפרט. אגודלים
   לא מתהפכים עם שפת הממשק. */
.joystick {
  position: absolute;
  left: calc(16px + var(--safe-l));
  bottom: calc(14px + var(--safe-b));
  width: 99px; height: 99px;
  pointer-events: auto;
  touch-action: none;
}
.joystick-base {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1.5px solid rgba(255,255,255,.13);
  transition: opacity .2s, border-color .2s;
  opacity: .42;
}
.joystick.is-active .joystick-base { opacity: .72; border-color: rgba(240,199,117,.38); }
.joystick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(255,238,205,.52), rgba(217,164,65,.46));
  box-shadow: 0 4px 12px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.34);
  opacity: .82;
  will-change: transform;
}
.joystick.is-active .joystick-knob { opacity: 1; }

.actions {
  position: absolute;
  right: calc(16px + var(--safe-r));
  bottom: calc(14px + var(--safe-b));
  width: 126px; height: 113px;
  pointer-events: none;
}
.abtn {
  position: absolute;
  pointer-events: auto; touch-action: none;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text);
  border: 1.5px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.07);
  opacity: .78;
  cursor: pointer;
  transition: transform .09s, background .12s, opacity .12s;
}
.abtn:active, .abtn.is-down { transform: scale(.90); background: rgba(240,199,117,.30); opacity: 1; }
.abtn--jump     { right: 0;    bottom: 0;    width: 64px; height: 64px; font-size: 22px;
                  background: rgba(240,199,117,.15); border-color: rgba(240,199,117,.36); }
.abtn--attack   { right: 58px; bottom: 33px; width: 48px; height: 48px;
                  background: rgba(242,135,155,.14); border-color: rgba(242,135,155,.34); }
/* גל הברכה של ירדן — זמן המתנה ארוך יותר, אז הכפתור בולט יותר */
.abtn--charm    { background: rgba(242,135,155,.26); border-color: rgba(242,135,155,.6); }
.abtn--interact { right: 4px;  bottom: 69px; width: 45px; height: 45px; font-size: 16px;
                  background: rgba(127,214,192,.12); border-color: rgba(127,214,192,.32); }
/* נדלק כשיש מנוף בהישג יד */
.abtn.is-live {
  opacity: 1;
  background: rgba(127,214,192,.42);
  border-color: var(--mint);
  animation: livePulse 1.1s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(127,214,192,.55); }
  50%      { box-shadow: 0 0 0 9px rgba(127,214,192,0); }
}

/* ─── שכבות במשחק ─── */
/* ─────────── גיליון הסבר (מסך מלא באייפון) ─────────── */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
  background: rgba(6, 5, 11, .72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .2s ease both;
}
.sheet-card {
  position: relative;
  width: min(420px, 100%);
  max-height: 100%; overflow-y: auto;
  padding: 18px 18px 16px;
  text-align: center;
  background: var(--panel);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--panel-line);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.sheet-x {
  position: absolute; inset-inline-end: 10px; top: 10px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font: inherit; font-size: 14px; color: var(--text-dim);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%; cursor: pointer;
}
.sheet-title { margin: 0 0 4px; font-size: 19px; color: var(--gold); }
.sheet-lede  { margin: 0 0 12px; font-size: 13.5px; color: var(--text-dim); line-height: 1.5; }
.sheet-steps { margin: 0 0 10px; padding: 0; list-style: none; text-align: start; }
.sheet-steps li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 6px;
  font-size: 13.5px; line-height: 1.4;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: var(--r-sm);
}
.sheet-num {
  flex: 0 0 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800;
  color: #2a1c05; background: var(--gold);
  border-radius: 50%;
}
/* אייקון השיתוף של iOS מצויר ב-SVG: תו יוניקוד לא מרונדר
   באופן עקבי, והמשתמש צריך לזהות בדיוק את הכפתור במסך שלו */
.sheet-ico {
  display: inline-block; vertical-align: -5px;
  width: 21px; height: 21px; padding: 2px;
  fill: #cfe6ff;
  background: rgba(110,170,240,.20);
  border: 1px solid rgba(140,190,250,.45);
  border-radius: 6px;
}
.sheet-foot { margin: 0 0 12px; font-size: 12px; color: var(--text-dim); opacity: .85; }

/* רמז שקט בתפריט — לא חוסם, לא קופץ */
.iohint {
  margin: 10px 0 0;
  font-size: 12.5px; font-weight: 600;
  color: var(--gold);
  background: none; border: none;
  text-decoration: underline; cursor: pointer;
}

@media (max-height: 460px) and (orientation: landscape) {
  .sheet-card { padding: 12px 14px; }
  .sheet-title { font-size: 16px; }
  .sheet-lede { margin-bottom: 8px; font-size: 12px; }
  .sheet-steps li { padding: 6px 9px; margin-bottom: 4px; font-size: 12.5px; }
  .sheet-foot { margin-bottom: 8px; font-size: 11px; }
}

/* ─────────── הדרכה בשלב הראשון ─────────── */
.tut {
  /* מתחת לרצועת ה-HUD, שנגמרת ב-56px */
  position: absolute; top: 60px; inset-inline: 0; margin: auto;
  width: fit-content; max-width: 88%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 14px;
  background: linear-gradient(180deg, rgba(34,27,51,.94), rgba(13,11,20,.94));
  border: 1.5px solid var(--mint);
  border-radius: 99px;
  box-shadow: 0 8px 26px rgba(0,0,0,.5);
  z-index: 8;
  animation: tutIn .3s cubic-bezier(.2,1.4,.5,1) both;
}
@keyframes tutIn { from { transform: translateY(-10px); opacity: 0; } }
.tut-step {
  flex: 0 0 auto;
  padding: 3px 9px;
  font-size: 11px; font-weight: 800;
  color: #0e1a17; background: var(--mint);
  border-radius: 99px;
}
.tut-text { font-size: 14px; font-weight: 700; white-space: nowrap; }
.tut-skip {
  flex: 0 0 auto;
  padding: 4px 10px; margin-inline-start: 2px;
  font: inherit; font-size: 11.5px; font-weight: 700;
  color: var(--text-dim);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 99px;
  pointer-events: auto; cursor: pointer;
}
/* מסך נמוך: השורה חייבת להישאר שורה אחת */
@media (max-height: 400px) {
  .tut { padding: 6px 8px 6px 11px; }
  .tut-text { font-size: 12.5px; }
}

/* כשההדרכה על המסך הטוסט יורד מתחתיה במקום לשבת עליה */
#tutorial:not([hidden]) ~ .toast { top: 106px; }

/* הפקד שההדרכה מדברת עליו — פועם עד שעושים את הפעולה */
.joystick.is-live .joystick-base {
  opacity: .95;
  border-color: var(--mint);
  animation: livePulse 1.1s ease-in-out infinite;
}
.joystick.is-live .joystick-knob { opacity: 1; }

.toast {
  position: absolute; top: 52px; inset-inline: 0; margin: auto;
  width: fit-content; max-width: 80%;
  padding: 9px 18px;
  font-size: 14px; font-weight: 700; text-align: center;
  background: rgba(13,11,20,.86);
  border: 1px solid rgba(240,199,117,.34);
  border-radius: 99px;
  z-index: 7;
  animation: toastIn .25s ease both;
}

/* ─── סרגל פיתוח ─── */
.btn--dev {
  margin-top: 4px;
  background: rgba(127,214,192,.10);
  border-color: rgba(127,214,192,.35);
  border-style: dashed;
}
.devbar {
  position: absolute; z-index: 9;
  bottom: calc(12px + var(--safe-b)); inset-inline: 0; margin: auto;
  width: fit-content;
  display: flex; align-items: center; gap: 4px;
  padding: 5px 8px;
  background: rgba(7,6,12,.82);
  border: 1px dashed rgba(127,214,192,.45);
  border-radius: 12px;
  pointer-events: auto;
}
.devbar button {
  min-width: 32px; height: 30px;
  font: inherit; font-size: 14px; color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px; cursor: pointer;
}
.devbar button:active { background: rgba(127,214,192,.3); }
.devbar button.is-on { background: rgba(127,214,192,.35); border-color: var(--mint); }
.devbar-label {
  font-family: "SF Mono","Consolas",monospace; font-size: 12px;
  color: var(--mint); padding: 0 4px; min-width: 34px; text-align: center;
}
.devbar-sep { width: 1px; height: 20px; background: rgba(255,255,255,.16); margin: 0 3px; }

/* ─── שלט כניסה לשלב ─── */
.level-card {
  position: absolute; z-index: 8;
  top: 50%; inset-inline: 0; margin: auto;
  transform: translateY(-60%);
  width: fit-content; max-width: 84%;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 16px 40px 12px;
  text-align: center;
  background: linear-gradient(180deg, rgba(34,27,51,.94), rgba(20,16,29,.94));
  border: 1px solid rgba(240,199,117,.45);
  border-radius: 4px;
  box-shadow: 0 18px 50px rgba(0,0,0,.6), inset 0 0 0 4px rgba(240,199,117,.10);
  animation: cardIn .5s cubic-bezier(.2,.9,.3,1) both;
}
/* פינות מסולסלות — נותנות תחושת הזמנה מודפסת */
.level-card::before, .level-card::after {
  content: ''; position: absolute; inset-inline: 10px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240,199,117,.55), transparent);
}
.level-card::before { top: 6px; }
.level-card::after  { bottom: 6px; }
.level-card-num  { font-size: 11px; letter-spacing: 3px; color: var(--text-dim); }
.level-card-name {
  font-size: 26px; font-weight: 800; letter-spacing: -.3px;
  background: linear-gradient(180deg, #fff6e2, var(--gold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.level-card-flourish { font-size: 13px; color: var(--gold-2); line-height: 1; }
.level-card.is-out { animation: cardOut .5s ease both; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(-60%) scale(.9); letter-spacing: 4px; }
}
@keyframes cardOut {
  to { opacity: 0; transform: translateY(-72%) scale(1.04); }
}
@keyframes toastIn { from { opacity:0; transform: translateY(-10px) scale(.94); } }

.overlay {
  position: absolute; inset: 0; z-index: 8;
  display: grid; place-items: center;
  background: rgba(7,6,12,.80);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  animation: fadeIn .2s ease both;
}
.overlay-card {
  padding: 26px 30px; text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--r-lg);
}
.overlay-card h3 { margin: 0 0 6px; font-size: 24px; color: var(--gold); }
.overlay-card p  { margin: 0; font-size: 14px; color: var(--text-dim); }
.overlay-stats { margin-top: 12px; display: flex; gap: 16px; justify-content: center; font-size: 13px; }
.overlay-stats b { color: var(--gold); }

/* ─────────── שכבות מערכת ─────────── */
/* ─────────── כפתור מסך מלא ─────────── */
.fsbtn {
  position: fixed; z-index: 45;
  top: calc(10px + var(--safe-t));
  inset-inline-end: calc(10px + var(--safe-r));
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 17px; color: var(--text);
  background: rgba(30,25,44,.72);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}
.fsbtn:active { transform: scale(.93); }
/* במסך המשחק יש כפתור משלו ב-HUD */
#screen-game.is-active ~ .fsbtn { display: none; }
.fsbtn--mute { inset-inline-end: calc(58px + var(--safe-r)); }
#screen-game.is-active ~ .fsbtn--mute { display: grid; inset-inline-end: auto; inset-inline-start: calc(10px + var(--safe-l)); top: calc(46px + var(--safe-t)); }
.resgap {
  margin: 8px 0 0; padding: 7px 12px;
  font-size: 13px; font-weight: 700; color: var(--gold);
  background: rgba(240,199,117,.10);
  border: 1px solid rgba(240,199,117,.24);
  border-radius: var(--r-sm);
}

/* שיא אישי — שקט כברירת מחדל, זוהר כששוברים אותו */
.resbest {
  margin: 7px 0 0;
  font-size: 12.5px; font-weight: 600;
  color: var(--muted);
}
.resbest.is-record {
  padding: 7px 12px;
  color: #ffe6a0;
  background: rgba(240,199,117,.14);
  border: 1px solid rgba(240,199,117,.34);
  border-radius: var(--r-sm);
  animation: bestpop .5s cubic-bezier(.2,1.4,.5,1) both;
}
@keyframes bestpop {
  from { transform: scale(.86); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ─────────── מד פינג (פיתוח) ─────────── */
.statusbar {
  position: fixed; z-index: 46;
  top: calc(8px + var(--safe-t));
  inset-inline-start: calc(10px + var(--safe-l));
  display: flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 11px; font-weight: 700; line-height: 1;
  color: var(--text-dim);
  background: rgba(7,6,12,.72);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 99px;
  pointer-events: none;
  direction: ltr;
}
.sb-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 7px currentColor;
}
.sb-dot[data-q="ok"]   { background: var(--mint); }
.sb-dot[data-q="mid"]  { background: var(--gold); }
.sb-dot[data-q="bad"]  { background: var(--danger); }
.sb-dot[data-q="off"]  { background: #6b6478; box-shadow: none; }
.sb-sep { opacity: .35; }
/* במשחק ה-HUD תופס את הפינה — מזיזים את המד מתחתיו */
#screen-game.is-active ~ .statusbar { top: calc(42px + var(--safe-t)); }

.netbar {
  position: fixed; top: 0; inset-inline: 0; z-index: 50;
  padding: calc(5px + var(--safe-t)) 10px 5px;
  font-size: 12.5px; font-weight: 700; text-align: center;
  color: #2a1c05; background: var(--gold-2);
}

.snack {
  position: fixed; z-index: 55;
  bottom: calc(20px + var(--safe-b)); inset-inline: 0; margin: auto;
  width: fit-content; max-width: 86%;
  padding: 11px 18px;
  font-size: 14px; text-align: center;
  background: rgba(30,25,44,.96);
  border: 1px solid var(--panel-line);
  border-radius: 99px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: toastIn .22s ease both;
}
.snack--bad { border-color: rgba(255,122,122,.55); color: var(--danger); }

/* ─────────── מסכים קטנים / לרוחב ─────────── */
/* מסך נמוך לרוחב — הטלפון בזמן משחק.
   הכל חייב להיכנס בלי גלילה: אורח לא אמור לגלול כדי למצוא "התחל". */
@media (max-height: 560px) and (orientation: landscape) {
  .screen { padding: 8px calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l)); }
  .panel { padding: 10px 16px 12px; width: min(560px, 100%); }
  .crest { display: none; }               /* המקום חשוב יותר מהקישוט */
  .title { font-size: 20px; margin: 0 0 1px; }
  .title--sm { font-size: 17px; }
  .subtitle { margin-bottom: 6px; font-size: 11.5px; letter-spacing: 1.5px; }
  .lede { margin-bottom: 8px; font-size: 12.5px; line-height: 1.45; }
  .greet { margin-bottom: 8px; font-size: 12.5px; }
  .footnote { margin-top: 8px; font-size: 11px; }
  .stack { margin-top: 8px; gap: 6px; }
  .row { gap: 6px; }
  .btn { padding: 8px 12px; }
  .btn-main { font-size: 14.5px; }
  .btn-sub { font-size: 11px; }
  .field { padding: 10px 14px; font-size: 15px; }
  .codebox { margin: 2px 0 8px; padding: 7px; }
  .codebox-code { font-size: 26px; margin: 2px 0 6px; letter-spacing: 7px; }
  .codebox-label { font-size: 10.5px; }
  .slots { gap: 6px; }
  .slot { padding: 8px 6px; }
  .slot-avatar { width: 34px; height: 34px; font-size: 16px; margin-bottom: 4px; }
  .slot-name { font-size: 13px; }
  .slot-role { font-size: 10.5px; }
  .slot-badge { margin-top: 4px; padding: 2px 8px; font-size: 10px; }
  .lockednote { margin-top: 8px; padding: 7px 10px; font-size: 11px; }
  .modepick { margin-top: 8px; }
  /* 40vh הראו רק שלושה מקומות מתוך 390px של מסך. לוח תוצאות
     שמראה שלוש שורות לא מתפקד כלוח תוצאות. */
  .board { max-height: calc(100dvh - 132px); }
  .scorebig { margin: 6px 0 8px; }
  .scorebig span { font-size: 34px; }
  .resgrid { gap: 6px; }
  .rescell { padding: 6px 4px; }
  .rescell b { font-size: 15px; }
  .howto li { padding: 6px 8px; margin-bottom: 4px; font-size: 12px; }
  .howto .ic { flex-basis: 26px; height: 26px; font-size: 14px; }
  .story { padding: 8px 10px; margin-bottom: 8px; font-size: 12px; line-height: 1.5; }

  /* ההוראות בשתי עמודות — 6 שורות אחת מתחת לשנייה לא נכנסות */
  .howto { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
  .panel--wide { width: min(680px, 100%); }

  /* הלובי: הקוד והשחקנים זה לצד זה במקום זה מתחת לזה */
  #screen-lobby .panel { width: min(660px, 100%); }
  .lobby-top { display: flex; gap: 12px; align-items: center; }
  .lobby-top > .codebox { flex: 0 0 40%; margin: 0; }
  .lobby-top > .slots { flex: 1; }
  .greet { display: none; }
  .btn--dev { padding: 6px 10px; }
  .btn--dev .btn-main { font-size: 12.5px; }

  /* הלובי אחרי שהגרסה המלאה נפתחה — כלומר רוב הערב: בורר הגרסאות
     דחף את "התחל משחק" מתחת לקיפול במסך של 375px. שני הכפתורים
     זה לצד זה, והבורר מכווץ. */
  #screen-lobby .stack { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .modepick { margin-top: 6px; }
  .modepick-label { font-size: 10.5px; }
  .seg-item { padding: 6px 8px; }
  .seg-item b { font-size: 12.5px; }
  .seg-item small { font-size: 10px; }
  .hosthint { margin-top: 6px; font-size: 10.5px; }
  .linkbtn--center { margin-top: 6px; }

  /* מסך התוצאות: ארבעה כפתורים בטור אחד לא נכנסו למסך של 390px,
     ו"שחקו שוב" — הכפתור שמחזיק את המשחק פעיל כל הערב — נפל
     מתחת לקיפול יחד עם "שתפו" ו"לתפריט". שתי עמודות פותרות. */
  #screen-results .stack { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .resnames { margin-top: 8px; font-size: 12.5px; }
  .resgap  { margin-top: 6px; padding: 5px 10px; font-size: 12px; }
  .resbest { margin-top: 5px; font-size: 11.5px; }
  .resbest.is-record { padding: 5px 10px; }
}

/* מסך נמוך במיוחד — מכווצים עוד, ורק אז מרשים גלילה */
@media (max-height: 380px) and (orientation: landscape) {
  .subtitle, .footnote, .btn-sub { display: none; }
  .title { font-size: 17px; }
  .stack { gap: 5px; }
  .btn { padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
