/* מתחזה – עיצוב: ערב מסיבה, כהה, אדום-מתחזה וסגול */
:root {
  --bg: #130f26;
  --bg-2: #1b1536;
  --card: #211a42;
  --card-2: #2b2254;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f1ff;
  --muted: #a99fd0;
  --accent: #ff4d6d;
  --accent-2: #7c5cff;
  --good: #2ee6a6;
  --warn: #ffc857;
  --danger: #ff5a5f;
  --radius: 20px;
  --font: 'Rubik', 'Segoe UI', Arial, sans-serif;
  --font-nq: 'Noto Sans Hebrew', 'Rubik', 'Segoe UI', Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 110% -10%, rgba(124, 92, 255, 0.28), transparent 60%),
    radial-gradient(700px 500px at -20% 110%, rgba(255, 77, 109, 0.18), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body.sheet-open { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0; }
small { font-size: 0.8em; }
s { opacity: 0.6; }

.nq, .big-word { font-family: var(--font-nq); }

#app {
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}

/* ---------- כניסה ---------- */
.enter { animation: enter 0.35s ease both; }
.same .enter { animation: none; }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- פריסה ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .btn { flex: 1; }
.row.tight { gap: 6px; }
.row.tight > .btn { flex: 0 0 auto; }
.center { text-align: center; }
.center-row { justify-content: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin-top: 8px; }
.hint.warn, .warn { color: var(--warn); }
.error { color: var(--danger); text-align: center; }
.section-title { margin-top: 8px; color: var(--muted); font-size: 15px; font-weight: 500; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card > h3 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.card p + p { margin-top: 8px; }

.banner { border-color: rgba(124, 92, 255, 0.5); background: rgba(124, 92, 255, 0.14); }
.banner.warn { border-color: rgba(255, 200, 87, 0.45); background: rgba(255, 200, 87, 0.1); color: var(--text); }
.banner ul { margin: 0; padding-inline-start: 18px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.bottom-bar {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 18px 0 calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}
.bottom-bar.row { flex-direction: row; }
.waiting { text-align: center; color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 16px; }

/* ---------- סרגל עליון ---------- */
.topbar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 0 12px;
}
.topbar h2 { font-size: 19px; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 6px; min-width: 44px; justify-content: flex-end; }
.code-badge { font-family: ui-monospace, monospace; font-size: 14px; letter-spacing: 1px; padding: 4px 10px; border-radius: 999px; background: var(--card-2); color: var(--muted); }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-size: 20px;
  cursor: pointer;
}
.icon-btn.small { width: 34px; height: 34px; font-size: 15px; border-radius: 10px; }
.icon-btn:active { transform: scale(0.94); }

/* ---------- כפתורים ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.15s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ff7a59); color: #fff; box-shadow: 0 10px 30px -10px rgba(255, 77, 109, 0.7); }
.btn.secondary { background: linear-gradient(135deg, var(--accent-2), #5b8cff); color: #fff; box-shadow: 0 10px 30px -12px rgba(124, 92, 255, 0.8); }
.btn.ghost { background: rgba(255, 255, 255, 0.04); border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { min-height: 44px; font-size: 16px; padding: 8px 14px; width: auto; }
.btn.tiny { min-height: 32px; font-size: 14px; font-weight: 500; padding: 4px 10px; width: auto; border-radius: 10px; }
.stack > .btn.small { align-self: center; }
.btn.big { min-height: 84px; justify-content: flex-start; gap: 14px; padding: 14px 20px; text-align: start; }
.btn-emoji { font-size: 34px; line-height: 1; }
.btn-text { display: flex; flex-direction: column; }
.btn-text b { font-size: 21px; }
.btn-text small { font-weight: 400; opacity: 0.85; font-size: 15px; }
.file-btn { margin: 14px 0 8px; }
.card .btn.ghost.small { margin-top: 10px; }
.title-btn { background: none; border: 0; padding: 0; font-size: 18px; font-weight: 700; cursor: pointer; text-align: start; }
.title-btn small { opacity: 0.6; }

/* ---------- שדות ---------- */
input, textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 18px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
input::placeholder, textarea::placeholder { color: rgba(169, 159, 208, 0.6); }
.field-label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 6px; }
.field-label:first-child { margin-top: 0; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; min-width: 0; }
.add-row .btn { flex: 0 0 auto; }
.code-input { text-align: center; letter-spacing: 8px; font-size: 24px; font-weight: 700; direction: ltr; }

/* ---------- צ׳יפים, מתגים ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chip small { opacity: 0.6; }
.chip.on { background: rgba(255, 77, 109, 0.18); border-color: var(--accent); }
.chip.custom { border-style: dashed; }
.chip.custom.on { border-style: solid; }
.chip.ghost { color: var(--muted); }
.chip.big { font-size: 22px; min-height: 52px; padding: 6px 18px; }
.chips.static .chip { cursor: default; }
.chip mark { background: rgba(255, 200, 87, 0.28); color: inherit; border-radius: 6px; padding: 0 4px; }

.seg { display: flex; gap: 4px; padding: 4px; background: rgba(0, 0, 0, 0.25); border-radius: 16px; }
.seg button { flex: 1; min-height: 46px; border: 0; border-radius: 12px; background: none; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card-2); color: var(--text); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 0 0; border: 0; background: none; text-align: start; cursor: pointer; }
.switch { flex: 0 0 auto; width: 48px; height: 28px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); position: relative; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(-20px); }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); font-size: 22px; cursor: pointer; }
.stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper b { font-size: 22px; min-width: 20px; text-align: center; }

.summary { list-style: none; margin: 0 0 12px; padding: 0; }
.summary li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.summary li span { color: var(--muted); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: rgba(46, 230, 166, 0.15); color: var(--good); font-size: 13px; font-weight: 700; }

/* ---------- שחקנים ---------- */
.players { list-style: none; margin: 0; padding: 0; counter-reset: p; }
.players li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.players li:last-child { border-bottom: 0; }
ol.players li::before { counter-increment: p; content: counter(p); width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--card-2); font-size: 13px; color: var(--muted); }
.p-name { flex: 1; font-weight: 500; }
.p-name em { color: var(--muted); font-style: normal; font-weight: 400; }
.players li.offline { opacity: 0.5; }

/* ---------- מסך בית ---------- */
.home { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 36px; padding: 32px 0 calc(24px + env(safe-area-inset-bottom)); }
.logo { text-align: center; }
.logo-emoji { font-size: 84px; line-height: 1; filter: drop-shadow(0 12px 30px rgba(255, 77, 109, 0.45)); animation: bob 3s ease-in-out infinite; }
.logo h1 {
  font-size: clamp(48px, 15vw, 72px);
  font-weight: 800;
  line-height: 1.35;
  margin: 8px 0 4px;
  background: linear-gradient(135deg, #fff, #ffb3c1 45%, #b9a6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ---------- העברת טלפון ---------- */
.pass { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 24px 0; }
.pass-icon { font-size: 64px; animation: bob 2.4s ease-in-out infinite; }
.pass-name { font-size: clamp(32px, 10vw, 46px); font-weight: 800; line-height: 1.2; word-break: break-word; }

/* ---------- כרטיס מתהפך ---------- */
.reveal { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px 0; }
.flip {
  width: min(100%, 340px);
  height: min(60dvh, 460px);
  min-height: 340px;
  padding: 0;
  border: 0;
  background: none;
  perspective: 1200px;
  cursor: pointer;
}
.flip-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform 0.6s cubic-bezier(0.3, 1.3, 0.5, 1); transform-style: preserve-3d; }
.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px;
  border-radius: 28px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
}
.flip-front {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.04) 0 12px, transparent 12px 24px),
    linear-gradient(145deg, var(--accent-2), #3a2a8c);
  font-size: 20px;
  font-weight: 700;
}
.flip-front .q { font-size: 110px; font-weight: 800; line-height: 1; opacity: 0.9; }
.flip-back { transform: rotateY(180deg); background: linear-gradient(160deg, #2b2357, #191333); }
.face { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.face.impostor .big-word { color: var(--accent); }
.flip-back:has(.impostor) { background: linear-gradient(160deg, #4a1430, #1c0f22); border-color: rgba(255, 77, 109, 0.5); }
.role-emoji { font-size: 64px; line-height: 1; }
.role-label { color: var(--muted); font-size: 16px; }
.big-word { display: block; font-size: clamp(34px, 11vw, 56px); font-weight: 800; line-height: 1.45; word-break: break-word; }
.cat-hint { display: inline-block; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-size: 15px; }
.face-note { color: var(--muted); font-size: 14px; font-weight: 400; max-width: 260px; }
.peek-card { padding: 16px 0 20px; }

/* ---------- תורות ורמזים ---------- */
.order { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: o; }
.order li { counter-increment: o; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.order li::before { content: counter(o); font-size: 12px; color: var(--muted); }
.order li em { color: var(--muted); font-style: normal; font-size: 13px; }
.order li.first, .order li.current { border-color: var(--accent); background: rgba(255, 77, 109, 0.16); }
.order li.done { opacity: 0.55; }
.order li.done::after { content: '✓'; color: var(--good); }
.order li.offline { opacity: 0.4; }

.clues { list-style: none; margin: 0; padding: 0; }
.clues li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); animation: enter 0.3s ease both; }
.same .clues li { animation: none; }
.clues li:last-child { border-bottom: 0; }
.clue-name { color: var(--muted); }
.clue-text { font-weight: 700; font-size: 19px; }
.turn-card { border-color: var(--accent); background: linear-gradient(180deg, rgba(255, 77, 109, 0.18), var(--bg-2)); }
.turn-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.typing { display: inline-flex; gap: 6px; margin-top: 10px; }
.typing i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-5px); } }

/* ---------- טיימר ---------- */
.timer { font-size: 56px; font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; line-height: 1.1; margin: 6px 0 10px; }
.timer.low { color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---------- הצבעה ---------- */
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pick {
  min-height: 64px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  word-break: break-word;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.pick:active { transform: scale(0.97); }
.pick.on { border-color: var(--accent); background: rgba(255, 77, 109, 0.2); }
#sheet .pick-list { margin: 12px 0; }

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.breakdown li:last-child { border-bottom: 0; }

.verdict { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; margin: 14px 0; padding: 16px 28px; border-radius: 22px; background: rgba(255, 255, 255, 0.06); animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.verdict b { font-size: 28px; }
.verdict-emoji { font-size: 60px; line-height: 1; }
.verdict.bad { background: rgba(255, 77, 109, 0.18); color: #ffd0d8; }
.verdict.good { background: rgba(46, 230, 166, 0.14); color: #c8ffe9; }
.same .verdict { animation: none; }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
.suspense { font-size: 72px; animation: bob 0.8s ease-in-out infinite; }
.guess-line { margin-top: 6px; font-size: 18px; }

/* ---------- סוף סבב ---------- */
.winner { text-align: center; padding: 18px 12px 8px; }
.winner-emoji { font-size: 76px; line-height: 1; animation: pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.winner h1 { font-size: clamp(30px, 9vw, 40px); font-weight: 800; margin: 8px 0 6px; }
.winner.civilians h1 { color: var(--good); }
.winner.impostors h1 { color: var(--accent); }

.scoreboard { list-style: none; margin: 0; padding: 0; }
.scoreboard li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.scoreboard li:last-child { border-bottom: 0; }
.scoreboard li.you { color: var(--warn); }
.rank { width: 28px; text-align: center; color: var(--muted); }
.sb-name { flex: 1; }
.delta { color: var(--good); font-size: 14px; font-weight: 700; }
.scoreboard b { min-width: 28px; text-align: center; font-size: 19px; }

/* ---------- חדר ---------- */
.invite { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.room-code { font-size: 52px; font-weight: 800; letter-spacing: 10px; direction: ltr; line-height: 1.1; font-variant-numeric: tabular-nums; }
.qr { width: 176px; height: 176px; border-radius: 16px; background: #fff; padding: 8px; }
.link-box { max-width: 100%; padding: 6px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- טעינה ---------- */
.loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--muted); text-align: center; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, 0.12); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- המילים שלי ---------- */
.excel-demo { width: 100%; margin: 14px 0 0; border-collapse: collapse; font-size: 14px; border-radius: 12px; overflow: hidden; }
.excel-demo th, .excel-demo td { padding: 7px 10px; border: 1px solid rgba(255, 255, 255, 0.12); text-align: start; }
.excel-demo th { background: rgba(46, 230, 166, 0.16); color: #c8ffe9; font-weight: 700; }
.excel-demo td { background: rgba(0, 0, 0, 0.2); }
.review-row { display: flex; flex-direction: column; gap: 10px; }
.review-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.review-head b { font-size: 20px; }

/* ---------- עורך ניקוד ---------- */
.nk-letters { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0 14px; }
.nk-letter { min-width: 50px; height: 64px; padding: 0 6px; border: 2px solid var(--line); border-radius: 14px; background: var(--card-2); font-size: 32px; line-height: 1.6; cursor: pointer; }
.nk-letter.sel { border-color: var(--accent); background: rgba(255, 77, 109, 0.2); }
.nk-fixed { min-width: 14px; display: grid; place-items: center; font-size: 28px; color: var(--muted); }
.nk-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin-bottom: 10px; }
.nk-v { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.04); cursor: pointer; font-family: var(--font-nq); }
.nk-v b { font-size: 28px; line-height: 1.5; }
.nk-v small { color: var(--muted); font-size: 12px; }
.nk-v.on { border-color: var(--accent); background: rgba(255, 77, 109, 0.18); }

/* ---------- כללים ---------- */
.rules { margin: 12px 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- גיליון תחתון ---------- */
#sheet { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#sheet.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5, 3, 15, 0.6); backdrop-filter: blur(3px); animation: fade 0.2s ease both; }
.sheet-panel {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 560px);
  max-height: 90dvh;
  overflow-y: auto;
  padding: 22px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.sheet-panel.no-anim { animation: none; }
.sheet-panel > h3 { text-align: center; }
.sheet-text { font-size: 19px; text-align: center; padding: 8px 0; }
.sheet-actions { margin-top: 6px; flex-wrap: wrap; }
@keyframes up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- הודעות וחיבור ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  border-radius: 14px;
  background: #fff;
  color: #130f26;
  font-weight: 700;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  text-align: center;
}
.toast.in { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
#conn {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 90;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--warn);
  color: #2a1c00;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

@media (min-width: 600px) {
  #app { padding: 0 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================
   טלפונים, טאבלטים ומחשבים
   ===================================================================== */

/* משיכה-לרענון הייתה מאבדת משחק באמצע; הקשה כפולה לא מגדילה; לחיצה ארוכה לא מסמנת טקסט */
html, body { overscroll-behavior-y: none; }
button, .btn, .chip, .pick, .flip { touch-action: manipulation; }
.flip, .btn, .chip, .pick, .nk-letter, .nk-v, .seg button, .switch-row {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* מסך הבית */
.home-main { display: flex; flex-direction: column; gap: 12px; }
.home-more { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.home-more .btn { font-size: 15px; min-height: 56px; padding: 8px 6px; line-height: 1.25; }
.home-install { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.tv-card h3 { display: flex; align-items: center; gap: 8px; }

/* עמודות: בטלפון אחת מתחת לשנייה */
.cols { display: flex; flex-direction: column; gap: 12px; }

/* טאבלט */
@media (min-width: 700px) {
  #app { width: min(100%, 640px); }
  .home-main { flex-direction: row; }
  .home-main .btn { flex: 1; }
  .flip { width: 400px; height: min(62dvh, 540px); }
  .big-word { font-size: clamp(40px, 7vw, 64px); }
  .pick-list { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* טאבלט לרוחב ומחשב – שתי עמודות */
@media (min-width: 900px) {
  #app.wide { width: min(100%, 1120px); }
  .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  #app.wide .bottom-bar { width: min(100%, 560px); margin-inline: auto; }
}

/* טלפון לרוחב */
@media (max-height: 520px) and (orientation: landscape) {
  .flip { height: 84dvh; min-height: 0; width: min(100%, 520px); }
  .flip-front .q { font-size: 64px; }
  .role-emoji { font-size: 40px; }
  .home { gap: 18px; padding-top: 12px; }
  .logo-emoji { font-size: 48px; }
  .logo h1 { font-size: 44px; }
}

/* =====================================================================
   מסך משותף (טלוויזיה / מחשב / טאבלט)
   ===================================================================== */
body.board-mode #app, body.board-mode #app.wide { width: 100%; max-width: 1800px; padding: 0 clamp(16px, 3vw, 48px); }
.board { flex: 1; display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: clamp(16px, 3vh, 40px); font-size: clamp(18px, 1.6vw, 28px); }
.bd-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: clamp(12px, 2vh, 24px) 0; }
.bd-brand { display: flex; align-items: center; gap: 12px; font-size: clamp(24px, 2.6vw, 44px); font-weight: 800; }
.bd-logo { font-size: 1.15em; }
.bd-sub { color: var(--muted); font-weight: 500; font-size: 0.6em; padding-inline-start: 16px; border-inline-start: 2px solid var(--line); }
.bd-tools { display: flex; gap: 10px; align-items: center; }
.bd-code { padding: 8px 16px; border-radius: 999px; background: var(--card-2); color: var(--muted); font-size: clamp(16px, 1.4vw, 24px); }
.bd-code b { color: var(--text); letter-spacing: 3px; }
.bd-title { font-size: clamp(28px, 3.4vw, 60px); font-weight: 800; line-height: 1.2; }
.bd-subtitle { font-size: clamp(20px, 2vw, 34px); font-weight: 700; margin-bottom: 16px; }
.bd-muted { color: var(--muted); font-size: clamp(16px, 1.5vw, 26px); }
.bd-hero { font-size: clamp(64px, 9vw, 150px); line-height: 1; }
.bd-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: clamp(12px, 2vh, 28px); }

.bd-lobby { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: clamp(20px, 4vw, 64px); align-items: center; }
.bd-join {
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  background: linear-gradient(180deg, var(--card), var(--bg-2)); border: 1px solid var(--line);
  border-radius: 32px; padding: clamp(20px, 3vw, 44px);
}
.bd-qr { width: clamp(180px, 22vw, 360px); aspect-ratio: 1; background: #fff; border-radius: 24px; padding: 12px; }
.bd-url { font-family: ui-monospace, monospace; color: var(--muted); font-size: clamp(14px, 1.3vw, 22px); overflow-wrap: anywhere; }
.bd-or { color: var(--muted); }
.bd-bigcode { font-size: clamp(56px, 8vw, 140px); font-weight: 800; letter-spacing: 0.12em; direction: ltr; line-height: 1; font-variant-numeric: tabular-nums; }
.bd-players { display: flex; flex-direction: column; gap: 20px; }

.bd-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(130px, 13vw, 220px), 1fr)); gap: clamp(10px, 1.2vw, 20px); width: 100%; }
.bd-center .bd-tiles { max-width: 1200px; }
.bd-tile { display: flex; align-items: center; gap: 12px; padding: clamp(10px, 1vw, 18px); border-radius: 20px; background: var(--card); border: 2px solid var(--line); font-weight: 700; transition: border-color 0.3s, background 0.3s; }
.bd-tile.on { border-color: var(--good); background: rgba(46, 230, 166, 0.12); }
.bd-tile.off { opacity: 0.45; }
.bd-avatar { flex: 0 0 auto; width: clamp(36px, 3vw, 54px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 0.9em; }
.bd-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-check { margin-inline-start: auto; color: var(--good); }

.bd-stage { flex: 1; display: flex; flex-direction: column; gap: clamp(16px, 2.5vh, 32px); }
.bd-turn { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 16px; text-align: center; font-size: clamp(28px, 3.2vw, 56px); font-weight: 800; }
.bd-turn b { color: var(--accent); }
.bd-clues { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 20vw, 340px), 1fr)); gap: clamp(12px, 1.4vw, 24px); }
.bd-clue { display: flex; flex-direction: column; gap: 6px; padding: clamp(14px, 1.5vw, 26px); border-radius: 22px; background: linear-gradient(180deg, var(--card), var(--bg-2)); border: 1px solid var(--line); }
.bd-clue.new { border-color: var(--accent); animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.same .bd-clue.new { animation: none; }
.bd-clue-name { color: var(--muted); font-size: 0.8em; }
.bd-clue-text { font-size: clamp(26px, 2.8vw, 50px); font-weight: 800; line-height: 1.2; word-break: break-word; }
.bd-order { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: auto; }
.bd-order span { padding: 8px 18px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.bd-order span.cur { border-color: var(--accent); background: rgba(255, 77, 109, 0.2); }
.bd-order span.done { opacity: 0.5; }
.bd-order.big { margin-top: 0; }
.bd-order.big span { font-size: clamp(22px, 2.4vw, 40px); padding: 12px 28px; }
.bd-timer { font-size: clamp(72px, 10vw, 180px); text-align: center; margin: auto 0 0; }

.bd-split { flex: 1; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 64px); align-items: center; }
.bd-panel { background: linear-gradient(180deg, var(--card), var(--bg-2)); border: 1px solid var(--line); border-radius: 28px; padding: clamp(18px, 2vw, 36px); }
.bd-bars { display: flex; flex-direction: column; gap: 14px; }
.bd-bar { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 14px; }
.bd-bar-track { height: clamp(18px, 1.8vw, 30px); border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.bd-bar-track span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); animation: grow 0.8s ease both; }
@keyframes grow { from { width: 0; } }
.verdict.big b { font-size: clamp(32px, 4vw, 72px); }
.verdict.big .verdict-emoji { font-size: clamp(72px, 9vw, 150px); }
.bd-word { font-size: clamp(56px, 8vw, 140px); }
.bd-guess, .bd-sub-big { font-size: clamp(20px, 2vw, 36px); }
.board .winner h1 { font-size: clamp(40px, 5vw, 90px); }
.board .winner-emoji { font-size: clamp(72px, 8vw, 140px); }
.board .scoreboard li { font-size: clamp(18px, 1.8vw, 32px); padding: 12px 0; }
.board .cat-hint { font-size: clamp(16px, 1.5vw, 26px); }

/* מסך משותף על טאבלט לאורך / מסך צר – עמודה אחת */
@media (max-width: 899px), (orientation: portrait) {
  .bd-lobby, .bd-split { grid-template-columns: minmax(0, 1fr); }
}
