:root {
  --bg: #1D1B2E;
  --bg-2: #2B2745;
  --bg-dark: #121120;
  --paper: #FFFDF7;
  --cream: #F2EDE0;
  --ink: #1B1F24;
  --muted: #6B6878;
  --gold: #F5C542;
  --red: #E0484D;
  --green: #2FBF71;
  --blue: #5B8CFF;
  --display: 'Secular One', 'Assistant', 'Arial Hebrew', sans-serif;
  --body: 'Assistant', 'Segoe UI', 'Arial Hebrew', Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html, body, button { touch-action: manipulation; }
body {
  background: var(--bg) radial-gradient(ellipse at 50% 0%, var(--bg-2) 0%, transparent 65%) no-repeat fixed;
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
input, select {
  font-size: 16px; /* מונע זום אוטומטי באייפון */
  border: 2px solid #d9d2bf; border-radius: 10px; padding: 10px 12px; background: #fff; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.muted { color: var(--muted); }
.muted-light { color: #c9c4e0; font-size: .9rem; }
.center { text-align: center; }
.spacer { flex: 1; }
.error { color: var(--red); min-height: 1.5em; margin: 8px 0 0; font-weight: 600; text-align: center; }
.note { font-size: .88rem; color: var(--muted); margin: 8px 0 0; }

/* כפתורים */
.btn {
  border: 2px solid var(--ink); background: #fff; color: var(--ink); border-radius: 12px;
  padding: 9px 16px; font-weight: 700; cursor: pointer; line-height: 1.2;
  box-shadow: 0 3px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); }
.btn.danger { background: var(--red); color: #fff; }
.btn.good { background: var(--green); color: #fff; }
.btn.big { font-size: 1.1rem; padding: 12px 22px; width: 100%; }
.btn.small { font-size: .88rem; padding: 6px 12px; box-shadow: 0 2px 0 var(--ink); }
.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 4px; font-size: .9rem; }
.link.light { color: #e8e4f7; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.icon-btn:hover { background: #0001; color: var(--red); }
.row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* דף הבית ולובי */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.card-panel {
  width: min(420px, 100%); background: var(--paper); border-radius: 20px; padding: 28px 22px;
  border: 3px solid var(--ink); box-shadow: 0 8px 0 var(--bg-dark);
}
.logo {
  font-family: var(--display); font-weight: 400; font-size: clamp(3rem, 14vw, 4.2rem);
  line-height: 1; margin: 0; text-align: center; color: var(--ink); text-shadow: 3px 3px 0 var(--gold);
}
.logo span { text-shadow: none; }
.tagline { text-align: center; margin: 10px 0 22px; color: var(--muted); font-weight: 600; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; margin-bottom: 4px; font-size: .9rem; }
.or { display: flex; align-items: center; gap: 10px; margin: 22px 0 12px; color: var(--muted); font-size: .9rem; }
.or::before, .or::after { content: ''; flex: 1; height: 2px; background: #e4ddca; }
.join-row { display: flex; gap: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 800; text-align: center; }
.card-panel .link { display: block; margin: 10px auto 0; }
.big-code { font-family: var(--display); font-size: 2.8rem; letter-spacing: .15em; text-align: center; line-height: 1.1; margin: 0 0 12px; }
#shareBtn { display: block; margin: 0 auto; }
.section-title { font-size: 1rem; margin: 22px 0 8px; }
.lobby-players { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.lobby-players li { display: flex; align-items: center; gap: 8px; background: var(--cream); border-radius: 10px; padding: 8px 12px; }
.pname { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #b9b9b9; flex: none; display: inline-block; }
.dot.on { background: var(--green); }
.badge { font-size: .72rem; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--ink); color: #fff; white-space: nowrap; }
.badge.me { background: var(--blue); }
.settings { display: grid; gap: 8px; margin-top: 16px; }
.setting { display: flex; align-items: center; gap: 10px; font-size: .92rem; font-weight: 600; }
.setting > span { flex: 1; }
.setting select { width: auto; padding: 6px 10px; }
.back-link { display: inline-block; margin: -10px 0 14px; font-size: .9rem; font-weight: 700; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--ink); text-decoration: underline; }

/* משחק — בלוק אחד במרכז, בגובה התוכן */
.game {
  display: flex; flex-direction: column; gap: 10px; color: #fff;
  width: min(760px, 100%); margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
}
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar .rx-bar { bottom: auto; top: calc(100% + 6px); }
.fun-slot { display: inline-flex; }
.room-tag { font-family: var(--display); letter-spacing: .12em; background: var(--bg-dark); padding: 2px 10px; border-radius: 8px; direction: ltr; }

.clock {
  align-self: center; font-family: var(--display); font-size: 2.2rem; line-height: 1;
  direction: ltr; font-variant-numeric: tabular-nums; letter-spacing: .04em;
  background: var(--bg-dark); border: 2px solid #ffffff22; border-radius: 14px; padding: 6px 18px;
}
.clock.low { color: var(--red); border-color: var(--red); animation: pulse 1s infinite; }
.clock.paused { color: var(--gold); }
@keyframes pulse { 50% { transform: scale(1.05); } }

/* הכרטיס הסודי */
.secret {
  display: grid; justify-items: center; gap: 2px; width: 100%; cursor: pointer; text-align: center;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 18px;
  padding: 14px 16px; box-shadow: 0 6px 0 var(--bg-dark); font: inherit;
}
.secret.hidden-card { background: repeating-linear-gradient(45deg, #2B2745 0 10px, #332E52 10px 20px); color: #e8e4f7; border-color: #ffffff33; }
.secret.spy { background: #2A0F14; color: #fff; border-color: var(--red); }
.secret .s-emoji { font-size: 2.6rem; line-height: 1.1; }
.secret .s-title { font-family: var(--display); font-size: 1.7rem; line-height: 1.15; }
.secret .s-sub { font-weight: 700; }
.secret .s-hint { font-size: .78rem; opacity: .65; }

/* מי שואל עכשיו */
.ask-bar { background: #00000040; border-radius: 14px; padding: 8px 12px; text-align: center; }
.ask-bar .ask-now { font-weight: 800; }
.ask-bar .ask-now b { color: var(--gold); }
.ask-bar .ask-pick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.ask-bar.mine { background: #F5C54226; outline: 2px solid var(--gold); }
.ask-bar .idea-btn { display: inline-block; margin-top: 6px; font-weight: 700; }
.ask-bar .idea { display: block; margin: 4px auto 0; background: #ffffff14; color: #fff; border: 1px dashed #ffffff55; border-radius: 10px; padding: 5px 12px; font: inherit; font-weight: 600; cursor: pointer; }
textarea { font: inherit; font-size: 16px; width: 100%; border: 2px solid #d9d2bf; border-radius: 10px; padding: 8px 10px; resize: vertical; }
.setting.check { gap: 8px; }
.setting.check input { width: 20px; height: 20px; flex: none; }
.setting.check span { font-weight: 400; }

/* שחקנים */
.players-panel { display: grid; gap: 8px; }
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pl {
  display: grid; gap: 4px; background: #00000045; border: 2px solid transparent; border-radius: 12px; padding: 8px 10px;
}
.pl.asking { border-color: var(--gold); }
.pl .pl-head { display: flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; }
.pl .pl-head span:not(.dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .pl-score { font-size: .8rem; color: #c9c4e0; }
.pl .accuse { font-size: .8rem; padding: 4px 8px; box-shadow: 0 2px 0 var(--ink); }
.btn.spy-guess { background: #2A0F14; color: #fff; border-color: var(--red); box-shadow: 0 3px 0 var(--red); justify-self: center; }

/* רשימת המקומות */
.places-panel { background: #00000030; border-radius: 14px; padding: 8px 10px; }
.panel-title { margin: 0 0 6px; font-size: .95rem; }
.panel-title small { font-weight: 400; opacity: .6; font-size: .75rem; margin-inline-start: 6px; }
.places { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 5px; }
.place {
  display: flex; align-items: center; gap: 6px; background: #ffffff12; color: #fff; border: 1px solid #ffffff22;
  border-radius: 9px; padding: 5px 8px; font-size: .85rem; font-weight: 600; cursor: pointer; text-align: start;
}
.place.out { opacity: .35; text-decoration: line-through; }
.place.pick:hover { background: var(--gold); color: var(--ink); }

/* לוג וצ'אט */
.chat-panel { background: #00000040; border-radius: 14px; padding: 8px 10px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 150px; overflow-y: auto; font-size: .88rem; color: #d6d2ea; display: grid; gap: 2px; }
.log-chat { color: #fff; }
.log-ask { color: #bfb8e6; font-size: .82rem; }
.log-accuse, .log-guess, .log-final { color: var(--gold); font-weight: 700; }
.log-caught { color: #7fe3a8; font-weight: 800; }
.log-spywin { color: #ff9ea1; font-weight: 800; }
.log-round, .log-win { color: var(--gold); font-weight: 800; }
.chat { display: flex; gap: 6px; margin-top: 8px; }
.chat input { padding: 6px 10px; background: #fff; color: var(--ink); }

/* חיבור, מודאל, טוסט */
.conn { position: fixed; top: 0; inset-inline: 0; z-index: 90; text-align: center; background: var(--red); color: #fff; font-weight: 700; padding: 6px; }
.modal { position: fixed; inset: 0; z-index: 80; background: #000a; display: grid; place-items: center; padding: 16px; }
.modal-box {
  position: relative; background: var(--paper); color: var(--ink); border: 3px solid var(--ink);
  border-radius: 18px; padding: 22px 18px 18px; width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  box-shadow: 0 8px 0 var(--bg-dark);
}
.modal-box h2 { margin-top: 0; }
.modal-x { position: absolute; top: 8px; left: 10px; background: none; border: 0; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.big-title { font-family: var(--display); font-weight: 400; font-size: 2.1rem; text-align: center; margin: 0; line-height: 1.2; }
.big-title.red { color: var(--red); }
.big-title.green { color: #1f9d55; }
.reveal-place { text-align: center; font-size: 1.15rem; margin: 6px 0; }
.reveal-place b { font-size: 1.3rem; }
.countdown-note { text-align: center; color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.vote-status { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.vote-status span { background: var(--cream); border-radius: 999px; padding: 2px 10px; font-size: .85rem; font-weight: 700; }
.vote-status span.yes { background: #d6f5e3; }
.vote-status span.no { background: #fde0e1; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-top: 10px; }
.pick-grid .btn { font-size: .9rem; padding: 8px; }
.pick-grid .btn.chosen { background: var(--gold); }
.places.in-modal .place { background: var(--cream); color: var(--ink); border-color: #0002; }
.score-table { width: 100%; border-collapse: collapse; font-size: .95rem; margin-top: 10px; }
.score-table td { padding: 6px 4px; border-top: 1px solid #e8e1cf; }
.score-table tr.mine td { background: #fff3c4; }
.score-table td.num { text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-table td.gain { text-align: center; color: #1f9d55; font-weight: 800; }
.role-list { font-size: .85rem; color: var(--muted); text-align: center; margin: 4px 0 0; }
.toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  z-index: 95; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px;
  font-weight: 600; max-width: min(90vw, 460px); text-align: center; box-shadow: 0 6px 20px #0006;
}

@media (max-width: 480px) {
  .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .places { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clock { font-size: 1.9rem; }
  .secret .s-title { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) { .clock.low { animation: none; } .btn { transition: none; } }
