:root {
  --bg: #faf5ec;
  --card-bg: #fffdf8;
  --ink: #453a42;
  --muted: #8c7d86;
  --rose: #c06e82;
  --rose-deep: #a3556a;
  --rose-light: #f0d6dc;
  --lavender: #b7c3e8;
  --lavender-deep: #5b6aa3;
  --lavender-light: #e3e8f7;
  --sage: #8fab8d;
  --sage-deep: #4f6b4d;
  --sage-light: #dbe8da;
  --gold: #d9b969;
  --hairline: #e2d5c4;
  --found: #dbe8da;
  --active: #f3dfa8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Assistant", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  color: var(--ink);
  direction: rtl;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cg opacity='0.16'%3E%3Cpath d='M20 100 C18 85,22 72,20 55' stroke='%238fab8d' stroke-width='1.5' fill='none'/%3E%3Ccircle cx='20' cy='52' r='4' fill='%23c06e82'/%3E%3Ccircle cx='26' cy='58' r='3.4' fill='%23b7c3e8'/%3E%3Cellipse cx='14' cy='80' rx='6' ry='3' fill='%238fab8d' transform='rotate(-30 14 80)'/%3E%3Cpath d='M110 40 C112 55,108 66,110 82' stroke='%238fab8d' stroke-width='1.5' fill='none'/%3E%3Ccircle cx='110' cy='85' r='3.6' fill='%23d9b969'/%3E%3Ccircle cx='104' cy='80' r='3' fill='%23c06e82'/%3E%3Cellipse cx='118' cy='60' rx='5.5' ry='2.6' fill='%238fab8d' transform='rotate(28 118 60)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 140px 140px;
}

header.site-header {
  padding: 2.4rem 1.5rem 1.6rem;
  text-align: center;
}

header.site-header::before {
  content: "";
  display: block;
  width: 120px;
  height: 110px;
  margin: 0 auto 0.2rem;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 110'%3E%3Cpath d='M60 108 C56 90,64 78,58 60 C54 46,66 40,60 24' stroke='%238fab8d' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3Cellipse cx='40' cy='70' rx='16' ry='7' fill='%238fab8d' opacity='0.75' transform='rotate(-28 40 70)'/%3E%3Cellipse cx='80' cy='85' rx='16' ry='7' fill='%238fab8d' opacity='0.75' transform='rotate(28 80 85)'/%3E%3Cellipse cx='46' cy='46' rx='12' ry='5.5' fill='%238fab8d' opacity='0.7' transform='rotate(-22 46 46)'/%3E%3Cg transform='translate(60 20)'%3E%3Ccircle cx='-16' cy='4' r='11' fill='%23c06e82' opacity='0.9'/%3E%3Ccircle cx='14' cy='4' r='11' fill='%23b7c3e8' opacity='0.9'/%3E%3Ccircle cx='0' cy='-10' r='12' fill='%23f0d6dc' opacity='0.95'/%3E%3Ccircle cx='-8' cy='14' r='9' fill='%23f0d6dc' opacity='0.9'/%3E%3Ccircle cx='10' cy='16' r='8' fill='%23c06e82' opacity='0.8'/%3E%3Ccircle cx='0' cy='2' r='6.5' fill='%23d9b969' opacity='0.95'/%3E%3C/g%3E%3C/svg%3E");
}

header.site-header .eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--rose-deep);
  font-weight: 700;
  margin: 0 0 0.3rem;
}

header.site-header h1 {
  margin: 0 0 0.5rem;
  font-family: "Frank Ruhl Libre", serif;
  font-weight: 700;
  font-size: 2.1rem;
  color: var(--rose-deep);
}

header.site-header p.subtitle {
  margin: 0;
  color: var(--muted);
  font-style: italic;
}

header.site-header::after {
  content: "";
  display: block;
  width: 220px;
  height: 16px;
  margin: 1.7rem auto 0;
  background-repeat: no-repeat;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='16'%3E%3Cline x1='0' y1='8' x2='85' y2='8' stroke='%23e2d5c4' stroke-width='1'/%3E%3Cline x1='135' y1='8' x2='220' y2='8' stroke='%23e2d5c4' stroke-width='1'/%3E%3Ccircle cx='102' cy='8' r='2.6' fill='%23c06e82' opacity='0.7'/%3E%3Ccircle cx='94' cy='8' r='1.8' fill='%238fab8d' opacity='0.7'/%3E%3Ccircle cx='110' cy='8' r='1.8' fill='%23b7c3e8' opacity='0.7'/%3E%3C/svg%3E");
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--sage-deep);
  text-decoration: none;
  font-weight: 600;
}
.back-link:hover { text-decoration: underline; }

.participant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.4rem 1.1rem;
}

.participant-card {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 1.9rem 1rem 1.4rem;
  text-align: center;
  color: var(--ink);
  font-family: "Frank Ruhl Libre", serif;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--rose);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  background: radial-gradient(120% 90% at 15% 0%, var(--rose-light), var(--card-bg) 65%);
  box-shadow: 0 3px 8px rgba(69,58,66,0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.participant-card::before {
  content: "";
  position: absolute;
  top: -6px;
  right: -6px;
  width: 44px;
  height: 44px;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 52'%3E%3Cg transform='translate(36 16) rotate(20)'%3E%3Cellipse cx='-6' cy='6' rx='8' ry='3.6' fill='%238fab8d' opacity='0.75'/%3E%3Ccircle cx='0' cy='0' r='5.5' fill='%23c06e82' opacity='0.9'/%3E%3Ccircle cx='7' cy='4' r='4.4' fill='%23f0d6dc' opacity='0.95'/%3E%3Ccircle cx='2' cy='7' r='3.4' fill='%23d9b969' opacity='0.9'/%3E%3C/g%3E%3C/svg%3E");
}

.participant-card:nth-child(3n+2) {
  background: radial-gradient(120% 90% at 15% 0%, var(--lavender-light), var(--card-bg) 65%);
}
.participant-card:nth-child(3n+2)::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 52'%3E%3Cg transform='translate(36 16) rotate(20)'%3E%3Cellipse cx='-6' cy='6' rx='8' ry='3.6' fill='%238fab8d' opacity='0.75'/%3E%3Ccircle cx='0' cy='0' r='5.5' fill='%23b7c3e8' opacity='0.9'/%3E%3Ccircle cx='7' cy='4' r='4.4' fill='%23f0d6dc' opacity='0.95'/%3E%3Ccircle cx='2' cy='7' r='3.4' fill='%23d9b969' opacity='0.9'/%3E%3C/g%3E%3C/svg%3E");
}

.participant-card:nth-child(3n) {
  background: radial-gradient(120% 90% at 15% 0%, var(--sage-light), var(--card-bg) 65%);
}
.participant-card:nth-child(3n)::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 52'%3E%3Cg transform='translate(36 16) rotate(20)'%3E%3Cellipse cx='-6' cy='6' rx='8' ry='3.6' fill='%238fab8d' opacity='0.75'/%3E%3Ccircle cx='0' cy='0' r='5.5' fill='%23d9b969' opacity='0.9'/%3E%3Ccircle cx='7' cy='4' r='4.4' fill='%23f0d6dc' opacity='0.95'/%3E%3Ccircle cx='2' cy='7' r='3.4' fill='%23c06e82' opacity='0.9'/%3E%3C/g%3E%3C/svg%3E");
}

.participant-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(69,58,66,0.12);
  border-color: var(--rose);
}

.person-header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.person-header h2 {
  font-family: "Frank Ruhl Libre", serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--rose-deep);
  margin: 0.2rem 0;
}
.person-header .subtitle {
  color: var(--muted);
  font-style: italic;
}

.game-tabs {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.4rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.4rem 0.2rem;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  color: var(--rose-deep);
  border-bottom-color: var(--rose);
}

.game-panel[hidden] { display: none; }

.game-wrap {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 1.6rem 1.4rem;
  box-shadow: 0 10px 30px rgba(69,58,66,0.06);
}

.game-wrap::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  pointer-events: none;
}

.game-progress {
  text-align: center;
  font-weight: 700;
  color: var(--sage-deep);
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

.game-boardrow {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-start;
}

.game-board {
  overflow-x: auto;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.ws-grid {
  display: grid;
  gap: 2px;
  direction: rtl;
  user-select: none;
  touch-action: none;
  width: 100%;
}

.ws-cell {
  aspect-ratio: 1;
  width: auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rose-light);
  border-radius: 6px;
  font-family: "Assistant", sans-serif;
  font-weight: 700;
  font-size: clamp(0.55rem, 2.6vw, 1rem);
  color: var(--rose-deep);
  cursor: pointer;
}

.ws-cell.ws-active { background: var(--active); color: var(--ink); }
.ws-cell.ws-found { background: var(--found); color: var(--sage-deep); }

.ws-target { display: none; }

.ws-play-btn {
  display: block;
  margin: 1.4rem auto 0;
  background: var(--rose);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.8rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.ws-play-btn:hover { background: var(--rose-deep); }

.ws-exit-btn {
  display: none;
  position: absolute;
  top: 1rem;
  right: 1rem;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.game-wrap.ws-playmode {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  background: var(--bg);
}
.game-wrap.ws-playmode::before { display: none; }
.game-wrap.ws-playmode .game-side { display: none; }
.game-wrap.ws-playmode .ws-play-btn { display: none; }
.game-wrap.ws-playmode .ws-exit-btn { display: flex; }
.game-wrap.ws-playmode .ws-target { display: block; text-align: center; margin-bottom: 0.8rem; }
.game-wrap.ws-playmode .ws-nav { display: flex; }
.game-wrap.ws-playmode .game-board { width: 90vw; max-width: 90vw; }
.game-wrap.ws-playmode .ws-cell { font-size: clamp(0.7rem, 3.4vw, 2.2rem); }

.ws-target-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.ws-target-word {
  font-family: "Frank Ruhl Libre", serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--rose-deep);
}
.ws-target-word.ws-target-found {
  color: var(--sage-deep);
  text-decoration: line-through;
}

.ws-nav {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.ws-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--rose-deep);
  cursor: pointer;
}
.ws-nav-btn:hover { background: var(--rose-light); }
.ws-nav-pos {
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Plain CSS triangles instead of "←"/"→" text characters, which the
   browser's bidi algorithm mirrors (flips) inside RTL text. */
.ws-nav-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.ws-nav-arrow-right { border-left: 7px solid currentColor; }
.ws-nav-arrow-left { border-right: 7px solid currentColor; }

.game-side {
  min-width: 220px;
  max-width: 320px;
}

.game-side h3 {
  margin-top: 0;
  font-family: "Frank Ruhl Libre", serif;
  font-weight: 700;
  color: var(--rose-deep);
}

.game-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-list li {
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  font-size: 0.95rem;
}

.game-list li.game-found-item {
  background: var(--found);
  border-color: var(--sage);
  text-decoration: line-through;
  color: var(--sage-deep);
}

.game-list li.game-partial-item {
  background: var(--active);
  border-color: var(--gold);
}

/* Crossword (תשבץ) */

.cw-grid {
  display: grid;
  gap: 2px;
  direction: rtl;
  width: fit-content;
  margin: 0 auto;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
}

.cw-cell {
  position: relative;
  width: 2.2rem;
  height: 2.2rem;
  background: var(--card-bg);
}

.cw-cell.cw-black {
  background: var(--ink);
}

.cw-cell.cw-active {
  background: var(--active);
}

.cw-cell.cw-active .cw-input {
  background: var(--active);
}

.cw-cell.cw-solved,
.cw-cell.cw-solved .cw-input {
  background: var(--found);
}

.cw-number {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 0.55rem;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
}

.cw-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-family: "Assistant", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  padding: 0;
}
.cw-input:focus { outline: 2px solid var(--rose); outline-offset: -2px; }
.cw-input:disabled { color: var(--sage-deep); }

@media (max-width: 700px) {
  /* Board comes before the word bank once they stack (matches the
     play button -> board -> words order on the page). */
  .game-side { width: 100%; max-width: 100%; }
}

@media (max-width: 480px) {
  .cw-cell { width: 1.8rem; height: 1.8rem; }
  .cw-input { font-size: 0.9rem; }
}
