/* מתחזה — עיצוב משחק מסיבה, ממשק RTL, מותאם למובייל */
@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;700;900&display=swap');

:root {
  --bg-1: #1a1333;
  --bg-2: #2a1a5e;
  --bg-3: #3d1e6d;
  --accent: #ff5ca8;
  --accent-2: #7c5cff;
  --accent-3: #ffd45c;
  --good: #38d39f;
  --bad: #ff6b6b;
  --text: #f5f2ff;
  --muted: #b8afd6;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.12);
  --radius: 20px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Heebo', system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, var(--bg-3), transparent 45%),
              radial-gradient(circle at 85% 90%, var(--accent-2), transparent 40%),
              linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 18px 48px;
  min-height: 100dvh;
}

.screen { display: none; animation: fade 0.35s ease; }
.screen.active { display: block; }
.hidden { display: none !important; }

@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- בית --- */
.hero { text-align: center; padding: 28px 0 20px; }
.logo { font-size: 76px; line-height: 1; filter: drop-shadow(0 6px 16px rgba(0,0,0,.4)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.hero h1 { font-size: 54px; font-weight: 900; letter-spacing: -1px; margin: 6px 0; background: linear-gradient(90deg, var(--accent), var(--accent-3)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.slogan { color: var(--accent-3); font-size: 17px; font-weight: 700; font-style: italic; margin: 2px 0 8px; }
.tagline { color: var(--muted); font-size: 17px; max-width: 420px; margin: 0 auto; }
.foot-note { text-align: center; color: var(--muted); font-size: 14px; margin-top: 20px; }
.privacy-link { color: var(--muted); text-decoration: underline; }
.install-btn { margin-top: 16px; border-color: var(--accent-3); animation: fade .4s ease; }

/* --- כרטיס --- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.stack { display: flex; flex-direction: column; gap: 14px; }
h2 { font-size: 26px; font-weight: 900; }
h3 { font-size: 19px; font-weight: 700; }

/* --- כפתורים --- */
.btn {
  font-family: inherit; font-weight: 700; font-size: 17px;
  border: none; border-radius: 14px; padding: 15px 20px;
  cursor: pointer; color: var(--text); transition: transform .12s ease, filter .12s ease, box-shadow .12s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-lg { font-size: 19px; padding: 17px 22px; }
.btn-primary { background: linear-gradient(120deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 22px rgba(255,92,168,.35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: rgba(255,255,255,.12); border: 1px solid var(--card-border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* --- שדות קלט --- */
.input {
  font-family: inherit; font-size: 17px; color: var(--text);
  background: rgba(0,0,0,.25); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 15px 16px; width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,92,168,.2); }
.input-code { text-align: center; font-size: 30px; font-weight: 900; letter-spacing: 8px; text-transform: uppercase; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b8afd6' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 18px center; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-weight: 700; font-size: 15px; color: var(--muted); }

.divider { text-align: center; color: var(--muted); position: relative; }
.divider::before, .divider::after { content:''; position:absolute; top:50%; width:40%; height:1px; background: var(--card-border); }
.divider::before { right: 0; } .divider::after { left: 0; }
.divider span { background: transparent; padding: 0 10px; font-size: 14px; }

/* --- segmented / switch --- */
.segmented { display: flex; gap: 8px; }
.segmented button { flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--card-border); background: rgba(0,0,0,.2); color: var(--text); font-family: inherit; font-size: 18px; font-weight: 700; cursor: pointer; }
.segmented button.active { background: linear-gradient(120deg, var(--accent), var(--accent-2)); border-color: transparent; }
.switch-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; font-weight: 700; }
.switch-row input { display: none; }
.switch { width: 50px; height: 30px; border-radius: 20px; background: rgba(0,0,0,.3); position: relative; transition: background .2s; flex-shrink: 0; }
.switch::after { content:''; position:absolute; top:3px; right:3px; width:24px; height:24px; border-radius:50%; background:#fff; transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--good); }
.switch-row input:checked + .switch::after { transform: translateX(-20px); }

/* --- מנחה: לובי --- */
.host-topbar { display: flex; gap: 16px; align-items: stretch; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.join-info { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.join-label { color: var(--muted); font-size: 14px; }
.join-url { font-size: 20px; font-weight: 700; word-break: break-all; color: var(--accent-3); margin-bottom: 8px; }
.room-code { font-size: 46px; font-weight: 900; letter-spacing: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.qr-box img { width: 130px; height: 130px; border-radius: 12px; background: #fff; padding: 6px; }
.qr-hint { font-size: 12px; color: var(--muted); }

.players-panel { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.players-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.pill { background: var(--accent-2); border-radius: 20px; padding: 2px 12px; font-size: 16px; font-weight: 700; }
.hint { color: var(--muted); font-size: 14px; }
.players-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.players-grid.compact { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.player-chip { background: rgba(0,0,0,.22); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px; text-align: center; font-weight: 700; position: relative; animation: pop .3s ease; display: flex; flex-direction: column; align-items: center; gap: 4px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.player-chip .avatar { font-size: 26px; }
.player-chip.disconnected { opacity: .4; }
.player-chip.voted { border-color: var(--good); box-shadow: 0 0 0 2px rgba(56,211,159,.3); }
.player-chip .badge-voted { position: absolute; top: -6px; left: -6px; background: var(--good); border-radius: 50%; width: 22px; height: 22px; font-size: 13px; display: grid; place-items: center; }
.player-chip .kick { position: absolute; top: -6px; right: -6px; background: var(--bad); border: none; color: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 12px; line-height: 1; }
.player-chip .score { font-size: 13px; color: var(--accent-3); }

.settings-panel { display: flex; flex-direction: column; gap: 14px; }
.settings-panel h3 { margin-bottom: 2px; }
.settings-summary { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.settings-summary span { background: rgba(0,0,0,.22); border: 1px solid var(--card-border); border-radius: 20px; padding: 6px 14px; font-size: 14px; font-weight: 700; }

.share-row { display: flex; gap: 10px; margin-bottom: 18px; }
.share-row .btn { flex: 1; }
.btn-whatsapp { background: linear-gradient(120deg, #25d366, #128c7e); box-shadow: 0 8px 22px rgba(37,211,102,.3); }

.host-actions { text-align: center; }
.host-actions .btn { max-width: 340px; margin: 0 auto; }

/* --- שלבים ממורכזים --- */
.centered { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 12px; }
.centered .btn { max-width: 340px; }
.big-emoji { font-size: 68px; animation: bob 3s ease-in-out infinite; }
.phase-badge { display: inline-block; background: var(--accent-2); padding: 6px 18px; border-radius: 20px; font-weight: 700; font-size: 15px; }
.phase-vote { background: var(--accent-3); color: #2a1a5e; }
.phase-results { background: var(--good); color: #06281d; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.turn-order { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.turn-order .to-item { background: rgba(0,0,0,.25); border: 1px solid var(--card-border); border-radius: 20px; padding: 8px 14px; font-weight: 700; transition: all .2s; }
.turn-order .to-item.current { background: var(--accent-3); color: #2a1a5e; transform: scale(1.08); box-shadow: 0 0 16px rgba(255,212,92,.45); }
.turn-order .to-item.done { opacity: .45; }

/* --- חיווי תור --- */
.now-playing { font-size: 20px; font-weight: 900; color: var(--accent-3); min-height: 26px; }
.turn-banner { width: 100%; max-width: 380px; background: linear-gradient(120deg, var(--accent-3), #ffb84d); color: #2a1a5e; border-radius: 16px; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; align-items: center; animation: turnPulse 1.2s ease-in-out infinite; }
.turn-banner-text { font-size: 20px; font-weight: 900; }
.turn-banner .btn-turn-done { background: #2a1a5e; color: #fff; padding: 10px 26px; width: auto; font-size: 16px; }
.turn-banner.someone-else { background: rgba(0,0,0,.25); color: var(--text); animation: none; border: 1px solid var(--card-border); }
.turn-banner.someone-else .turn-banner-text { font-size: 16px; font-weight: 700; }
@keyframes turnPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,212,92,.5); } 50% { box-shadow: 0 0 0 10px rgba(255,212,92,0); } }

/* --- שורת דילוג (כפתור קטן בצד + הסבר) --- */
.skip-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.turn-banner .btn-turn-done.mini {
  width: auto; padding: 6px 14px; font-size: 13px; font-weight: 700;
  background: rgba(42,26,94,.12); color: #2a1a5e;
  border: 1px solid rgba(42,26,94,.35); border-radius: 10px;
}
.skip-hint { font-size: 12px; color: #2a1a5e; opacity: .75; font-weight: 700; }

/* --- רמזים כתובים --- */
.clue-input-row { display: flex; gap: 8px; width: 100%; }
.clue-input-row .clue-input { flex: 1; padding: 11px 14px; font-size: 16px; }
.clue-input-row .btn { width: auto; padding: 11px 20px; font-size: 16px; }
.clues-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 460px; }
.clues-list:empty { display: none; }
.clues-title { width: 100%; text-align: center; color: var(--muted); font-size: 13px; font-weight: 700; }
.clue-chip { background: rgba(0,0,0,.25); border: 1px solid var(--card-border); border-radius: 20px; padding: 7px 14px; font-size: 15px; animation: pop .3s ease; }
.clue-chip b { color: var(--accent-3); font-weight: 700; }

/* --- שותפים למתחזה --- */
.role-teammates { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.15); font-size: 15px; font-weight: 700; }
.role-teammates .mate { color: var(--accent-3); }

/* --- ניחוש מילה --- */
.guess-section { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; background: linear-gradient(160deg, rgba(109,30,61,.35), rgba(58,14,34,.25)); border: 1px solid var(--accent); border-radius: 18px; padding: 18px; }
.guess-section .clue-input-row { width: 100%; }
.btn-guess-skip { width: auto; padding: 8px 16px; font-size: 14px; }
.guess-reveal { font-size: 17px; }
.guess-reveal .g-ok { color: var(--good); font-weight: 900; }
.guess-reveal .g-bad { color: var(--muted); }

/* --- הצבעה --- */
.vote-progress { width: 100%; max-width: 420px; }
.vote-progress-bar { height: 12px; background: rgba(0,0,0,.3); border-radius: 20px; overflow: hidden; }
.vote-progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-3)); transition: width .4s ease; }
.vote-progress-text { margin-top: 6px; font-size: 14px; color: var(--muted); }

.vote-list { list-style: none; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.vote-list button { width: 100%; padding: 16px; border-radius: 14px; border: 1px solid var(--card-border); background: rgba(0,0,0,.22); color: var(--text); font-family: inherit; font-size: 18px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: all .12s; }
.vote-list button:hover { border-color: var(--accent); }
.vote-list button.selected { background: linear-gradient(120deg, var(--accent), var(--accent-2)); border-color: transparent; }
.voted-msg { background: rgba(56,211,159,.15); border: 1px solid var(--good); border-radius: 14px; padding: 14px; font-weight: 700; max-width: 420px; }

/* --- כרטיס תפקיד --- */
.role-card { border-radius: 24px; padding: 36px 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow); border: 2px solid var(--card-border); cursor: pointer; user-select: none; -webkit-user-select: none; transition: transform .15s ease, background .2s, border-color .2s; }
.role-card:active { transform: scale(.98); }
.role-card.crew { background: linear-gradient(160deg, #1e5e4a, #0e3a2c); border-color: var(--good); }
.role-card.imposter { background: linear-gradient(160deg, #6d1e3d, #3a0e22); border-color: var(--accent); }
/* מצב מוסתר — נראה זהה לכולם, בלי שום רמז לתפקיד */
.role-card.facedown { background: linear-gradient(160deg, #35256e, #221647); border-color: var(--accent-2); }
.role-emoji { font-size: 60px; }
.role-label { color: var(--muted); font-size: 16px; margin-top: 8px; }
.role-word { font-size: 42px; font-weight: 900; margin: 8px 0; word-break: break-word; }
.role-sub { font-size: 16px; color: var(--muted); }

/* --- תוצאות --- */
.reveal-word { font-size: 22px; }
.reveal-word b { color: var(--accent-3); font-size: 26px; }
.imposter-reveal { font-size: 18px; }
.imposter-reveal .imp { color: var(--accent); font-weight: 900; }
.tally { list-style: none; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.tally li { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,.22); border-radius: 12px; padding: 10px 14px; }
.tally .count { color: var(--accent-3); font-weight: 900; }
.tally li.is-imposter { border: 1px solid var(--accent); }
.scoreboard { width: 100%; max-width: 420px; }
.scoreboard ol { list-style: none; counter-reset: rank; display: flex; flex-direction: column; gap: 8px; }
.scoreboard li { counter-increment: rank; display: flex; justify-content: space-between; background: rgba(0,0,0,.22); border-radius: 12px; padding: 10px 14px; font-weight: 700; }
.scoreboard li::before { content: counter(rank) ". "; color: var(--muted); }
.scoreboard li:first-child { background: linear-gradient(120deg, rgba(255,212,92,.25), transparent); border: 1px solid var(--accent-3); }
.scoreboard li.me { box-shadow: inset 0 0 0 1px var(--accent-2); }
.score-cell { display: flex; align-items: center; gap: 8px; }
.delta { background: var(--good); color: #06281d; border-radius: 12px; padding: 1px 8px; font-size: 13px; font-weight: 900; animation: pop .4s ease; }
.my-score { font-size: 20px; font-weight: 700; color: var(--accent-3); }

/* --- טבלת סבבים (מצטבר סבב-אחרי-סבב) --- */
.rounds-table-wrap { overflow-x: auto; margin-top: 10px; border-radius: 12px; }
.rounds-table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.rounds-table th, .rounds-table td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--card-border); }
.rounds-table th:first-child, .rounds-table td:first-child { text-align: right; position: sticky; right: 0; background: #241b47; }
.rounds-table thead th { color: var(--muted); font-weight: 700; font-size: 13px; }
.rounds-table td:last-child { color: var(--accent-3); }
.rounds-table tr.me td { background: rgba(124,92,255,.15); }
.rounds-table tr.me td:first-child { background: #2e2260; }

.mini-players { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mini-players span { background: rgba(0,0,0,.22); border-radius: 20px; padding: 6px 14px; font-weight: 700; font-size: 14px; }

/* --- באנר חזרה למשחק --- */
.resume-banner { margin-bottom: 16px; border-color: var(--accent-3); display: flex; flex-direction: column; gap: 12px; animation: fade .35s ease; }
.resume-text { font-weight: 700; font-size: 17px; text-align: center; }
.resume-actions { display: flex; gap: 10px; }
.resume-actions .btn { flex: 1; padding: 12px; font-size: 16px; }

/* --- כפתור יציאה --- */
.exit-btn {
  position: fixed; top: 14px; left: 14px; z-index: 50;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.35); border: 1px solid var(--card-border);
  color: var(--muted); font-size: 16px; font-family: inherit; cursor: pointer;
  display: grid; place-items: center; transition: all .15s;
}
.exit-btn:hover { color: var(--text); border-color: var(--bad); }

/* --- כפתור צליל --- */
.sound-btn {
  position: fixed; top: 14px; right: 14px; z-index: 50;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.35); border: 1px solid var(--card-border);
  font-size: 17px; font-family: inherit; cursor: pointer;
  display: grid; place-items: center; transition: all .15s;
}
.sound-btn.muted { opacity: .5; }

/* --- toast --- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(0,0,0,.85); color: #fff; padding: 12px 20px; border-radius: 30px; font-weight: 700; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .host-topbar { flex-direction: column; align-items: center; text-align: center; }
  .qr-box img { width: 160px; height: 160px; }
  .hero h1 { font-size: 46px; }
}
