/* הכרת חניכים. העיצוב הועתק מהאפליקציה "הצוות" (בהשראת iOS ו-Apple HIG), צומצם למה שצריך כאן והורחב.
   בהיר וכהה לפי הגדרת המערכת (prefers-color-scheme). הכהה הוא הכחול-כהה של "הצוות". מימין לשמאל. */
:root {
  --bg: #f5f5f7; --card: #ffffff; --card-2: #f2f2f7; --ink: #0b0b0f; --ink-2: rgba(60,60,67,.82); --muted: #6e6e73;
  --sep: rgba(60,60,67,.13); --hair: rgba(60,60,67,.09); --fill: rgba(118,118,128,.12);
  --glass: rgba(255,255,255,.78); --glass-line: rgba(255,255,255,.5);
  --blue: #007aff; --blue-2: #0062cc; --indigo: #5856d6; --teal: #30b0c7; --green: #34c759; --ok: #1e8e3e; --pink: #ff2d55;
  --orange: #ff9500; --red: #ff3b30; --red-ink: #d70015; --purple: #af52de; --gray: #8e8e93;
  --ok-solid: #1f8f3d; --bad-solid: #d92d20; --seg-on: #ffffff;
  --shadow: 0 .5px 0 rgba(0,0,0,.04), 0 2px 10px rgba(0,0,0,.04); --shadow-lg: 0 4px 18px rgba(0,0,0,.07);
  --r: 20px; --r-sm: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1428; --card: #132240; --card-2: #1a2c50; --ink: #f2f5fb; --ink-2: rgba(226,234,248,.8); --muted: #9aa9c4;
    --sep: rgba(255,255,255,.1); --hair: rgba(255,255,255,.07); --fill: rgba(255,255,255,.08);
    --glass: rgba(10,20,40,.84); --glass-line: rgba(255,255,255,.08);
    --blue: #2f8cff; --blue-2: #1c5fd6; --indigo: #6b6bff; --teal: #3cc6e0; --green: #30d158; --ok: #30d158; --pink: #ff4f7b;
    --orange: #ff9f0a; --red: #ff4d4d; --red-ink: #ff7b7b; --purple: #b36bff; --gray: #8e8e93;
    --ok-solid: #1f8f3d; --bad-solid: #d92d20; --seg-on: #2c4675;
    --shadow: 0 8px 24px rgba(0,0,0,.25); --shadow-lg: 0 8px 30px rgba(0,0,0,.45);
    color-scheme: dark;
  }
  body { background: radial-gradient(120% 60% at 50% 0%, #13274d 0%, var(--bg) 60%) fixed; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Hebrew", system-ui, "Segoe UI", "Rubik", Arial, sans-serif;
  font-size: 17px; line-height: 1.35; letter-spacing: -0.01em; -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
  padding: 0 env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 24px) env(safe-area-inset-left);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
.i { flex: none; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- מעבר בין מסכים ---------- */
#view { animation: enter .32s cubic-bezier(.2,.8,.2,1); }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #view, .sheet-panel, .toast { animation: none !important; } }

/* ---------- כותרת מסך ---------- */
.nav { position: sticky; top: 0; z-index: 20; padding: calc(env(safe-area-inset-top) + 6px) 16px 8px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep); margin: 0 calc(-1 * env(safe-area-inset-right)) 0 calc(-1 * env(safe-area-inset-left)); }
.nav-in { max-width: 720px; margin: 0 auto; }
.nav-row { display: flex; align-items: center; min-height: 44px; gap: 8px; }
.nav-back { display: flex; align-items: center; gap: 2px; background: none; border: 0; color: var(--blue); font-size: 17px; padding: 4px 0; min-height: 44px; cursor: pointer; }
.nav-act { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card-2); color: var(--blue);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.large-title { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; margin: 2px 0 2px; line-height: 1.15; }
.nav-sub { color: var(--muted); font-size: 15px; }

main { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; }

/* ---------- בית ---------- */
.home-head { padding: calc(env(safe-area-inset-top) + 14px) 16px 4px; max-width: 720px; margin: 0 auto; }
.hh-row { display: flex; align-items: center; gap: 12px; }
.hh-text { flex: 1; min-width: 0; }
.hh-sub { color: var(--muted); font-size: 14px; font-weight: 500; }
.home-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; margin: 1px 0 0; line-height: 1.15; }
.icon-btn.plain { background: var(--card); border: .5px solid var(--hair); box-shadow: var(--shadow); color: var(--ink); }
.home-main { padding-top: 14px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { position: relative; border: 0; text-align: right; cursor: pointer; border-radius: 24px; padding: 18px 16px 16px; min-height: 176px;
  display: flex; flex-direction: column; gap: 4px; color: #fff; box-shadow: var(--shadow);
  transition: transform .18s cubic-bezier(.2,.8,.2,1); }
.tile:active { transform: scale(.965); }
.tile .t-ic { width: 48px; height: 48px; border-radius: 15px; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; }
.tile .t-n { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin-top: auto; }
.tile .t-t { font-size: 18px; font-weight: 700; }
.tile .t-s { font-size: 13px; opacity: .92; }
.tile.blue { background: linear-gradient(160deg, #3b8cff, #1c5fd6); }
.tile.pink { background: linear-gradient(160deg, #ff5c7a, #d81f4a); }

.status-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0 0; padding: 9px 14px; border-radius: 14px;
  font-size: 14px; color: var(--ink-2); background: color-mix(in srgb, var(--orange) 16%, var(--card)); border: .5px solid color-mix(in srgb, var(--orange) 40%, transparent); }
.footer { text-align: center; color: var(--muted); font-size: 12px; margin: 28px 0 6px; }

/* ---------- בורר מחלקה ---------- */
.seg { display: flex; background: var(--fill); border-radius: 11px; padding: 3px; margin: 0 0 12px; gap: 2px; }
.seg button, .seg label { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; min-height: 40px; font-size: 15px; font-weight: 500;
  cursor: pointer; color: var(--ink); display: flex; align-items: center; justify-content: center; text-align: center; white-space: nowrap; }
.seg button.on, .seg input:checked + span { background: var(--seg-on); font-weight: 700; box-shadow: 0 3px 8px rgba(0,0,0,.12); }
.seg label { padding: 0; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { flex: 1; align-self: stretch; display: flex; align-items: center; justify-content: center; border-radius: 9px; padding: 8px 4px; }
.seg label input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.seg.big { margin-bottom: 4px; }
.seg.big button { min-height: 44px; font-size: 16px; }

/* ---------- רכיבים כלליים ---------- */
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 8px; }
.section-h h2 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.015em; }
.group { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; border: .5px solid var(--hair); }
.cell { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 60px; position: relative; width: 100%;
  border: 0; background: none; text-align: right; cursor: pointer; color: var(--ink); }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 0; right: 68px; border-top: .5px solid var(--sep); }
.cell.plain + .cell.plain::before, .form .cell + .cell::before { right: 16px; }
button.cell:active, a.cell:active { background: var(--card-2); }
.cell .body { flex: 1; min-width: 0; }
.cell .t { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .s { color: var(--muted); font-size: 13.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .chev { color: var(--muted); opacity: .6; }
.cell .soft { width: 36px; height: 36px; border-radius: 10px; flex: none; background: color-mix(in srgb, var(--c, var(--blue)) 13%, transparent); color: var(--c, var(--blue));
  display: flex; align-items: center; justify-content: center; }
.c-green { --c: var(--green); } .c-pink { --c: var(--pink); } .c-blue { --c: var(--blue); } .c-red { --c: var(--red); } .c-orange { --c: var(--orange); } .c-purple { --c: var(--purple); }
.empty { color: var(--muted); text-align: center; padding: 26px 16px; font-size: 15px; line-height: 1.5; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

.avatar { position: relative; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; flex: none;
  background: linear-gradient(180deg, #a9aeb8, #868b95); letter-spacing: .02em; overflow: hidden; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.08); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sq { border-radius: 26%; }

.btn { border: 0; border-radius: 14px; padding: 12px 18px; min-height: 48px; font-size: 16px; font-weight: 600; cursor: pointer;
  background: var(--blue); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.tinted { background: color-mix(in srgb, var(--c, var(--blue)) 14%, transparent); color: var(--c, var(--blue)); }
.btn.gray { background: var(--fill); color: var(--ink); }
.btn.wide { width: 100%; }
.btn.danger { background: var(--bad-solid); color: #fff; }
.btn.danger-t { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red-ink); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.row-btns { display: flex; gap: 10px; margin: 12px 0 6px; }
.row-btns .btn { flex: 1; }
.add-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--blue); color: #fff; border-radius: 12px; padding: 0 14px; min-height: 44px;
  font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; }

.search { position: relative; margin: 0 0 12px; }
.search input { width: 100%; font: inherit; font-size: 16px; padding: 12px 42px 12px 14px; min-height: 46px; border-radius: 14px; border: .5px solid var(--hair);
  background: var(--card); color: var(--ink); outline: none; -webkit-appearance: none; appearance: none; }
.search input:focus { border-color: var(--blue); }
.search .i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.list-meta { color: var(--muted); font-size: 13px; margin: 0 6px 8px; }

/* ---------- טופס ---------- */
.form .cell { cursor: default; padding: 0 16px 0 0; min-height: 52px; }
.form .cell > label, .form .cell > .lbl { color: var(--muted); font-size: 15px; width: 104px; flex: none; padding: 14px 0; }
.field { width: 100%; font: inherit; font-size: 16px; padding: 14px 16px; border: 0; background: transparent; color: var(--ink); outline: none;
  -webkit-appearance: none; appearance: none; text-align: right; min-width: 0; }
.form .cell .field { padding-right: 0; }
.field[dir="ltr"] { text-align: right; }
.field::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea.field { min-height: 110px; resize: vertical; line-height: 1.45; }
.form .cell.stack { flex-direction: column; align-items: stretch; padding: 0 16px; }
.form .cell.stack > label { width: auto; padding: 12px 0 0; }
.form .cell.stack .field { padding: 6px 0 12px; }
.form .cell.invalid > label { color: var(--red-ink); }
.field-err { color: var(--red-ink); font-size: 14px; margin: 6px 16px 0; font-weight: 600; }
.form-h { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 16px 6px; }
.ph-edit { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 14px; }
.ph-edit .ph-btn { position: relative; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.ph-cam { position: absolute; bottom: 4px; left: 4px; width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px var(--bg); }
.ph-edit .link { border: 0; background: none; color: var(--blue); font-size: 15px; font-weight: 600; cursor: pointer; min-height: 44px; padding: 0 10px; }

/* ---------- כרטיס חניך ---------- */
.profile { text-align: center; padding: 6px 0 4px; }
.profile .big-ph { width: min(220px, 62vw); height: min(220px, 62vw); border-radius: 28px; margin: 0 auto; font-size: 64px; box-shadow: var(--shadow-lg); }
.profile h2 { font-size: 26px; margin: 14px 0 4px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.dept-pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0 4px; }
.quick a, .quick button { background: var(--card); border: .5px solid var(--hair); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 4px; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 14px; font-weight: 600; color: var(--blue); cursor: pointer; }
.quick .wa { color: var(--ok); }
.cell .acts { display: flex; gap: 8px; flex: none; }
.cell .acts a { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c, var(--green)) 13%, transparent); color: var(--c, var(--green)); }
.notes-t { white-space: pre-wrap !important; overflow-wrap: anywhere; line-height: 1.5; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.actions .btn { min-height: 52px; }

/* ---------- גיליון ודיאלוג ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); border: 0; padding: 0; cursor: default; }
.sheet-panel { position: relative; width: 100%; max-width: 560px; background: var(--card); border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px); animation: up .25s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-h { font-size: 19px; font-weight: 700; text-align: center; margin: 0 0 6px; overflow-wrap: anywhere; }
.sheet-s { color: var(--muted); font-size: 15px; text-align: center; margin: 0 0 16px; line-height: 1.45; }
.sheet .btn { width: 100%; margin-top: 10px; }
.dept-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dept-pick .btn { margin-top: 0; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); max-width: calc(100% - 32px);
  background: rgba(30,30,32,.94); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 15px; z-index: 90; animation: enter .25s; text-align: center; }

/* ---------- כניסה ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(env(safe-area-inset-top) + 24px) 20px 40px; max-width: 440px; margin: 0 auto; }
.login .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 18px; display: block; box-shadow: var(--shadow-lg); }
.login h1 { text-align: center; font-size: 30px; margin: 0 0 6px; letter-spacing: -0.025em; }
.login p { text-align: center; color: var(--muted); margin: 0 0 26px; font-size: 15.5px; }
.login label { display: block; font-size: 15px; font-weight: 600; margin: 0 4px 8px; }
.login input { width: 100%; font: inherit; font-size: 20px; text-align: center; letter-spacing: .08em; padding: 14px; border-radius: 16px; border: 1px solid var(--hair);
  background: var(--card); color: var(--ink); outline: none; box-shadow: var(--shadow); min-height: 56px; }
.login input:focus { border-color: var(--blue); }
.login .btn { width: 100%; margin-top: 14px; min-height: 54px; font-size: 17px; }
.login .msg { min-height: 24px; margin-top: 12px; text-align: center; color: var(--red-ink); font-weight: 600; font-size: 15px; }

/* ---------- משחק שמות ---------- */
.game { text-align: center; }
.mode-opts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.mode-opt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: right; border: 2px solid transparent; border-radius: 20px; padding: 14px;
  background: var(--card); box-shadow: var(--shadow); cursor: pointer; color: var(--ink); min-height: 76px; }
.mode-opt.on { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 8%, var(--card)); }
.mode-opt .mo-ic { width: 46px; height: 46px; border-radius: 14px; flex: none; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--blue); }
.mode-opt .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mode-opt b { font-size: 17px; } .mode-opt span { font-size: 13.5px; color: var(--muted); }
.mode-opt .radio { width: 24px; height: 24px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--gray) 60%, transparent); flex: none; }
.mode-opt.on .radio { border: 7px solid var(--blue); }
.game-lbl { text-align: right; font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 4px 8px; }
.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; margin: 2px 0 14px; }
.progress i { display: block; height: 100%; background: var(--blue); border-radius: 3px; transition: width .3s; }
.g-count { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.game-ph { width: min(280px, 74vw); height: min(280px, 74vw); border-radius: 26px; box-shadow: var(--shadow-lg); margin: 0 auto 16px; font-size: 72px; }
@media (max-height: 700px) { .game-ph { width: min(220px, 60vw); height: min(220px, 60vw); } }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { border: 2px solid var(--hair); background: var(--card); color: var(--ink); border-radius: 16px; padding: 12px 10px; min-height: 60px; font-size: 16.5px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow); overflow-wrap: anywhere; line-height: 1.25; }
.opt:active { transform: scale(.97); }
.opt.right { background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; }
.opt.wrong { background: var(--bad-solid); border-color: var(--bad-solid); color: #fff; }
.opt[disabled] { cursor: default; }
.opt.dim { opacity: .7; }
.game-res { font-size: 19px; font-weight: 700; padding: 12px 14px; border-radius: 16px; margin: 14px 0 12px; overflow-wrap: anywhere; }
.game-res.ok { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--ok); }
.game-res.no { background: color-mix(in srgb, var(--red) 13%, transparent); color: var(--ink); }
.reveal-name { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 14px; overflow-wrap: anywhere; min-height: 35px; }
.knew { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.knew .btn { min-height: 56px; font-size: 17px; }
.btn.ok-b { background: var(--ok-solid); color: #fff; }
.btn.no-b { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red-ink); }

.score { width: 150px; height: 150px; margin: 8px auto 10px; position: relative; }
.score svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score .tr { fill: none; stroke: var(--fill); stroke-width: 12; }
.score .bar { fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round; }
.score b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 38px; font-weight: 800; letter-spacing: -0.03em; }
.score-t { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.missed { text-align: right; margin-top: 8px; }
.end-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
