/* Word Bingo: editor (players + 16 card rows) + play (deck/revealed piles + two boards). */

/* ---- Editor --------------------------------------------------------------- */
.field { max-width: 460px; margin-bottom: 1.5rem; }

.editor-head { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0 .75rem; }
.editor-head h2 { margin: 0; font-size: 1.1rem; }
.editor-head .meta { color: var(--ink-soft); font-weight: 400; font-size: .9rem; }
.editor-head .btn { margin-inline-start: auto; }
.section-hint { color: var(--ink-soft); font-size: .85rem; margin: 0 0 .75rem; }

.editor-grid { display: grid; gap: .75rem; max-width: 620px; }

.player-row {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: .6rem;
  align-items: center;
  max-width: 460px;
  margin-bottom: .5rem;
}
.player-row .player-dot {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: inline-block; background: var(--accent);
}
.player-row .player-dot[data-index="1"] { background: var(--gold); }

.card-item { padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.card-item:last-child { border-bottom: none; padding-bottom: 0; }
.card-row { display: grid; grid-template-columns: 2rem 1fr; gap: .6rem; align-items: center; }
.card-row .card-index { color: var(--ink-soft); font-variant-numeric: tabular-nums; text-align: center; }
.card-row .word-input { font-size: 1.15rem; }
.card-image-row { margin: .4rem 0 0 2.6rem; }

/* ---- Play layout ------------------------------------------------------------ */
/* Growth-only: keeps today's sizes as a floor on typical windows, but keeps
   growing past them on wider ones instead of plateauing. */
.wb-main { max-width: max(1300px, 90vw); }

.scorebar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem 1.1rem; box-shadow: var(--shadow);
}
.scorebar .deck-name { font-weight: 700; font-size: 1.05rem; }
.scorebar .stats { display: flex; gap: 1.25rem; }
.scorebar .stat { color: var(--ink-soft); font-size: .9rem; }
.scorebar .stat strong { color: var(--ink); font-size: 1.15rem; margin-inline-start: .25rem; font-variant-numeric: tabular-nums; }

.wb-status { color: var(--ink-soft); text-align: center; margin: 1rem 0; }

/* Boards on the left, the deck/revealed piles stacked in a column to their
   right (moved 2026-07-19 — they used to be a row above the boards). Gap is
   deliberately tighter than the boards-only layout used before (max 1.75rem,
   not 3rem) — with boards now 30% larger, the wider cap left no room for the
   piles column at common desktop widths (~1280px).
   `flex-wrap: nowrap` (not `wrap`, changed 2026-07-19): once the "New round" /
   "Choose another set" buttons appear in the piles column on a win, that
   column gets wider than the plain Deck/Revealed piles alone, and at typical
   widths that pushed the whole row over — wrapping the piles below the boards
   instead of leaving them beside it. Per explicit user request, horizontal
   scrolling is fine; wrapping is not, so it never wraps and the page scrolls
   instead. `justify-content: flex-start` (not `center`) is required for that
   scrolling to actually work: centering an overflowing flex row clips the
   *start* edge unreachably (there's nothing to scroll left into) while only
   the end overflows into reachable scroll space — flex-start keeps everything
   anchored at the left edge so any overflow is on the right, where a normal
   horizontal scroll can actually reach it. */
.wb-layout {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: clamp(1rem, 2.5vw, 1.75rem);
  flex-wrap: nowrap;
}

/* ---- Piles: deck above revealed, in a column beside the boards ------------- */
.wb-piles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.wb-pile-col { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.wb-pile-label { color: var(--ink-soft); font-size: .85rem; margin: 0; }

/* Shown below the revealed pile on a win, instead of a covering modal — the
   boards (found highlights + the flashing winning line) stay fully visible so
   the teacher can go over them with the students before starting again. */
.wb-newround-col { justify-content: center; }
.wb-newround-actions { display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.wb-newround-actions .btn { white-space: nowrap; }

/* The min(88vw,max(494px,Nvw))-style shapes below preserve today's
   shrink-to-fit behaviour on narrow/typical viewports exactly (unchanged
   until the point where the old fixed ceiling used to kick in), but grow
   past that ceiling on wide windows instead of staying flat forever — the
   per-element Nvw rates are sized so the two boards + the piles column
   below grow in lockstep without outgrowing .wb-main's own growing width. */
.wb-pile {
  position: relative;
  width: clamp(90px, 20vw, max(116px, 10vw));
  height: calc(clamp(90px, 20vw, max(116px, 10vw)) * 1.35 + 26px);
}

#deck-pile { cursor: pointer; }
#deck-pile:hover .wb-card.card-back:last-child { filter: brightness(1.06); }

.wb-card {
  --w: clamp(90px, 20vw, max(116px, 10vw));
  width: var(--w);
  height: calc(var(--w) * 1.35);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  user-select: none;
  position: absolute;
  top: 0; left: 0;
  transition: transform .3s ease;
}

.wb-pile-empty {
  position: absolute;
  top: 0; left: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

/* Face-down back design (reused look from Higher or Lower's pile) */
.card-back {
  background:
    repeating-linear-gradient(45deg, transparent 0 10px, rgba(255,255,255,.06) 10px 20px),
    linear-gradient(150deg, var(--accent), #24534680);
  display: flex; align-items: center; justify-content: center;
}
.card-back::after {
  content: "א";
  /* Tied to the pile card's own --w rather than a separate vw formula, since
     --w is already the responsive source of truth for this card. */
  font-size: calc(var(--w, 116px) * 0.22);
  font-weight: 700;
  color: var(--accent-ink);
  opacity: .8;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 50%;
  width: calc(var(--w, 116px) * 0.303); height: calc(var(--w, 116px) * 0.303);
  display: flex; align-items: center; justify-content: center;
}

/* Face-up card (revealed pile) */
.card-face {
  background: var(--surface);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: .5rem;
  gap: .3rem;
  overflow: hidden;
}
.card-face .word { direction: rtl; font-size: clamp(.85rem, 3vw, max(1.05rem, 1.5vw)); font-weight: 700; text-align: center; line-height: 1.15; }
.card-face .card-image { max-width: 80%; max-height: 55%; object-fit: contain; border-radius: 6px; }

@keyframes wb-flip-in {
  from { transform: rotateY(90deg); opacity: 0; }
  to   { transform: rotateY(0deg); opacity: 1; }
}
.flip-in { animation: wb-flip-in .35s ease both; }

/* ---- Two boards ------------------------------------------------------------- */
.wb-boards {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(1rem, 3vw, 2rem);
  /* nowrap, matching .wb-layout — this container gets squeezed (not just the
     outer row) once the piles column widens on a win, and .wb-boards had its
     own independent flex-wrap that still wrapped the two boards onto separate
     lines even after the outer row stopped wrapping. */
  flex-wrap: nowrap;
}
.wb-board-col { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.wb-board-label { font-weight: 700; margin: 0; }

.wb-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  width: min(88vw, max(494px, 33vw)); /* 494px = the old 30%-larger size, kept as a floor; grows past it on wide windows */
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem;
  box-shadow: var(--shadow);
}

.wb-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: .3rem;
  cursor: pointer;
  overflow: hidden;
  transition: transform .1s ease, border-color .15s ease, background-color .15s ease;
}
.wb-cell:hover { transform: scale(1.04); }
.wb-cell-image { max-width: 70%; max-height: 55%; object-fit: contain; border-radius: 4px; margin-bottom: .15rem; }
.wb-cell-word { font-size: clamp(.75rem, 3.1vw, max(1rem, 1.1vw)); font-weight: 700; text-align: center; direction: rtl; line-height: 1.1; }

.wb-cell.found {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  border-color: var(--accent);
}

@keyframes wb-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
.wb-cell.shake { animation: wb-shake .4s; border-color: var(--danger); }

@keyframes wb-line-flash {
  0%, 100% { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
  50% { background: var(--gold); }
}
.wb-cell.winning { animation: wb-line-flash .5s ease-in-out 3; }

@media (max-width: 560px) {
  .scorebar { justify-content: center; text-align: center; }
}
