:root {
  --navy: #1b1f63;
  --navy-2: #2e3da0;
  --bg-1: #c7d0e3;
  --bg-2: #b3bede;
  --surface: #ffffff;
  --border: #ccd4ea;
  --text: #1b1f63;
  --text-soft: #5b6494;
  --danger: #c0392b;
  --danger-dark: #962d22;
  --success: #2e7d32;
  --gold: #a87a20;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 31, 99, 0.15);
  --shadow-lg: 0 10px 30px rgba(27, 31, 99, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Heebo", system-ui, sans-serif;
  color: var(--text);
  direction: rtl;
  text-align: right;
  background-color: var(--bg-1);
  background-image: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.4) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0.4) 75%,
    transparent 75%,
    transparent
  );
  background-size: 46px 46px;
  min-height: 100vh;
  line-height: 1.5;
}

h1,
h2,
h3,
button,
.title-font {
  font-family: "Rubik", "Heebo", system-ui, sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.topbar img.logo-sm {
  width: 63px;
  height: 63px;
  border-radius: 50%;
  border: 2px solid var(--navy);
  background: #fff;
  object-fit: cover;
  flex: none;
}

/* לוגו המועצה - תמיד בצד שמאל (order אחרון), נפרד מתמונת האווטאר של המשתתף.
   בלי border - הטבעת הכחולה כבר חלק מהתמונה החתוכה (assets/logo-icon.jpg) */
.topbar img.logo-council {
  order: 2;
  width: 63px;
  height: 63px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  flex: none;
}

.topbar .titles {
  flex: 1;
  min-width: 0;
}

.topbar .titles h1 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .titles p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-soft);
}

/* ---------- cards / surfaces ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field input[type="text"],
.field textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfcff;
  color: var(--text);
}

.field textarea {
  resize: vertical;
  line-height: 1.4;
}

.field input[type="text"]:focus,
.field textarea:focus {
  outline: 2px solid var(--navy-2);
  outline-offset: 1px;
}

/* ---------- avatar grid ---------- */
.avatar-scroll {
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.avatar-grid {
  /* המיקום נקבע ב-JS (layoutAvatarCells ב-shared.js) - ולא ב-CSS grid/flex -
     כי חישובי auto-rows/auto-fill לא אמינים בגרסאות Safari/iOS עדכניות
     כשיש הרבה תאים. position:relative + height נקבעים דינמית ב-JS. */
}

.avatar-cell {
  box-sizing: border-box;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--border);
  background: #eef1fa;
  cursor: pointer;
  padding: 0;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.avatar-cell:focus-visible {
  outline: 2px solid var(--navy-2);
  outline-offset: 2px;
}

.avatar-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-cell.selected {
  border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(46, 61, 160, 0.25);
}

.avatar-cell.taken {
  cursor: not-allowed;
  border-color: var(--border);
}

.avatar-cell.taken img {
  filter: grayscale(1) brightness(0.85);
}

.avatar-cell.taken .taken-label {
  position: absolute;
  inset: 0;
  background: rgba(27, 31, 99, 0.55);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  line-height: 1.15;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 600;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
  width: 100%;
}

.btn-primary:not(:disabled):hover {
  background: var(--navy-2);
}

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:not(:disabled):hover {
  background: var(--danger-dark);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.85rem;
  border-radius: 9px;
}

.status-msg {
  min-height: 1.2em;
  font-size: 0.88rem;
  color: var(--danger);
  margin-bottom: 8px;
}

/* ---------- contact button (floating) ---------- */
.contact-fab {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 40;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-fab:disabled {
  background: var(--text-soft);
  opacity: 0.85;
}

.leaderboard-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- bingo grid ---------- */
.bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 16px 0;
}

.modal-sheet .trait-label.bingo-status {
  color: var(--success);
  font-weight: 700;
}

.card-preview-scroll {
  max-height: 65vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cell {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  padding: 4px;
  font-size: 0.6rem;
  line-height: 1.15;
  color: var(--text-soft);
  overflow: hidden;
}

.cell.fillable {
  cursor: pointer;
}

.cell .trait {
  display: block;
}

.cell .filled-name {
  display: none;
  font-weight: 700;
  font-size: 0.64rem;
  color: #fff;
  white-space: pre-line;
}

.cell.filled {
  background: var(--navy);
  border-color: var(--navy);
}

.cell.filled .trait {
  display: block;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.52rem;
}

.cell.filled .filled-name {
  display: block;
}

.cell.center {
  background: #fff;
  cursor: default;
  padding: 0;
}

.cell.center img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- קישורים לרשתות חברתיות ---------- */
.social-links {
  margin: 20px 0 90px;
  text-align: center;
}

.social-links-label {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.social-links-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--navy);
  text-decoration: none;
}

.social-link svg {
  width: 22px;
  height: 22px;
}

.social-link:active {
  background: var(--border);
}

/* ---------- banners ---------- */
.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.banner-success {
  background: #e9f5ea;
  border: 1px solid #b9dcbb;
  color: #1e5a22;
}

.banner-info {
  background: #eef1fb;
  border: 1px solid #c9d2f0;
  color: var(--navy);
}

.banner-danger {
  background: #fbeceb;
  border: 1px solid #eec3bf;
  color: var(--danger-dark);
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 60, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 0;
}

.modal-sheet {
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 20px 18px 26px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
}

.modal-sheet h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  color: var(--navy);
}

.modal-sheet .trait-label {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.ack-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 12px;
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.92rem;
  cursor: pointer;
}

.ack-checkbox input {
  width: 20px;
  height: 20px;
  flex: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.modal-actions .btn {
  flex: 1;
}

/* ---------- celebration overlay ---------- */
.celebrate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 31, 99, 0.92);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 80;
  padding: 24px;
}

.celebrate-overlay .big {
  font-size: 3rem;
  margin-bottom: 8px;
}

.celebrate-overlay h2 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.celebrate-overlay p {
  margin: 0 0 22px;
  color: #dfe3ff;
}

/* ---------- admin dashboard ---------- */

.admin-section-title {
  font-size: 1rem;
  color: var(--navy);
  margin: 22px 0 10px;
}

.contact-list .row {
  border-inline-start: 4px solid var(--gold);
}

.roster-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* ---------- leaderboard (טבלת מובילים) ---------- */
.leaderboard-list {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 6px;
}

.leaderboard-row.done {
  border-color: var(--success);
  background: #eef8ef;
}

.leaderboard-row.clickable {
  cursor: pointer;
}

.leaderboard-row.clickable:active {
  background: var(--border);
}

.leaderboard-rank {
  flex: none;
  width: 22px;
  text-align: center;
  font-weight: 700;
  color: var(--text-soft);
  font-family: "Rubik", sans-serif;
}

.leaderboard-row img.avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex: none;
}

.leaderboard-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-status {
  flex: none;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.leaderboard-row.done .leaderboard-status {
  color: var(--success);
  font-weight: 600;
}

.roster-row img.avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  flex: none;
}

.roster-row .main {
  flex: 1;
  min-width: 0;
}

.roster-row .name {
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
}

.roster-row .status {
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-top: 2px;
}

.roster-row .status.done {
  color: var(--success);
  font-weight: 600;
}

.contact-message {
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--gold-soft, #f3e6c9);
  border-inline-start: 3px solid var(--gold);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text);
  white-space: pre-line;
}

.roster-row .actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.inline-edit {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-edit input {
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  width: 130px;
}

.confirm-delete {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff5f4;
  border: 1px solid #f0c6c1;
  border-radius: 10px;
  padding: 8px;
  margin-top: 6px;
}

.confirm-delete input {
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.empty-note {
  color: var(--text-soft);
  font-size: 0.88rem;
  padding: 10px 2px;
}

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}
