/* ============================================================
   Points Board — the board
   ------------------------------------------------------------
   The setup screen is assets/classroom-setup.css; this is only
   what happens after Start. Coloured from the shared team
   palette through --team, like Bomb.

   The grid is the whole screen, because it is the thing the
   class reads the game from: which squares are left, who took
   which. A question opens over it and closes back onto it.
   ============================================================ */

.pb-stage {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--cg-stage);
  color: var(--cg-ink);
  grid-template-rows: auto auto 1fr;
  gap: clamp(6px, 1vh, 14px);
  padding: clamp(10px, 1.6vh, 20px);
}
body.is-playing .pb-stage { display: grid; }

/* ---------- scores ---------- */

.pb-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}
.pb-teams {
  display: grid;
  grid-template-columns: repeat(var(--count, 3), minmax(0, 1fr));
  gap: clamp(6px, 1vw, 12px);
}
.pb-team {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: clamp(6px, 1.1vh, 12px) clamp(10px, 1.2vw, 16px);
  border-radius: 14px;
  background: var(--team-soft);
  color: var(--team-ink);
  border: 3px solid transparent;
  transition: border-color .15s, opacity .15s;
}
.pb-team[data-turn="false"] { opacity: .62; }
.pb-team[data-turn="true"] { border-color: var(--team); }
.pb-team-name {
  font-weight: 700;
  font-size: clamp(14px, 2.1vh, 22px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pb-team-score {
  font-weight: 800;
  font-size: clamp(20px, 3.4vh, 38px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--team);
}

.pb-tools { display: flex; align-items: center; gap: clamp(6px, 1vw, 12px); }
.pb-tool {
  width: clamp(34px, 5vh, 44px);
  height: clamp(34px, 5vh, 44px);
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1.5px solid var(--cg-line);
  background: var(--cg-panel);
  color: var(--cg-dim);
  cursor: pointer;
}
.pb-tool:hover { color: var(--cg-ink); border-color: var(--cg-dim); }
.pb-tool[aria-pressed="true"] { color: var(--cg-ink); border-color: var(--cg-ink); }
.pb-tool svg[hidden] { display: none; }

.pb-turn {
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: clamp(15px, 2.4vh, 26px);
  color: var(--team-ink);
  min-height: 1.3em;
}

/* ---------- the grid ---------- */

.pb-board {
  display: grid;
  grid-template-columns: repeat(var(--columns, 5), minmax(0, 1fr));
  grid-template-rows: auto repeat(var(--rows, 5), minmax(0, 1fr));
  gap: clamp(5px, .9vh, 10px);
  min-height: 0;
}

.pb-header {
  display: grid;
  align-content: center;
  gap: 2px;
  text-align: center;
  padding: clamp(6px, 1.2vh, 14px) 8px;
  border-radius: 12px;
  background: var(--cg-ink);
  color: var(--cg-panel);
  min-width: 0;
}
.pb-header small {
  font-size: clamp(10px, 1.4vh, 14px);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .7;
}
.pb-header span {
  font-size: clamp(13px, 2vh, 22px);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
  overflow-wrap: break-word;
  hyphens: auto;
}

.pb-square {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  min-height: 0;
  font: inherit;
  padding: 4px;
  border-radius: 12px;
  border: 2px solid var(--cg-line);
  background: var(--cg-panel);
  color: var(--cg-ink);
  cursor: pointer;
  transition: transform .08s, border-color .12s, background .12s;
}
.pb-value {
  font-size: clamp(22px, 5vh, 56px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.pb-by {
  font-size: clamp(10px, 1.5vh, 15px);
  font-weight: 700;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pb-square:not(:disabled):hover,
.pb-square:not(:disabled):focus-visible {
  border-color: var(--cg-ink);
  transform: scale(1.03);
  outline: none;
}
.pb-square:disabled { cursor: default; }

/* A square someone took keeps their colour, and one nobody got stays as a
   blank. By the end the board is a picture of who won what. */
.pb-square.is-taken { background: var(--team-soft); border-color: var(--team); color: var(--team-ink); }
.pb-square.is-taken .pb-value { opacity: .45; }
.pb-square.is-missed { background: var(--cg-stage); border-style: dashed; }
.pb-square.is-missed .pb-value { opacity: .2; }

/* ---------- a question ---------- */

.pb-question {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vh, 40px);
  background: color-mix(in srgb, var(--cg-stage) 86%, transparent);
  backdrop-filter: blur(3px);
}
.pb-question[hidden] { display: none; }

.pb-q-card {
  width: min(1100px, 100%);
  /* Big on purpose: on television the question fills the screen, and the class
     is reading it from the back of the room. */
  min-height: min(82vh, 720px);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.6vh, 18px);
  padding: clamp(16px, 3vh, 36px);
  border-radius: 22px;
  background: var(--cg-panel);
  border: 4px solid var(--team);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .2);
  animation: pb-open .22s ease-out;
}
@keyframes pb-open {
  from { transform: scale(.94); opacity: 0; }
}
.pb-q-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: clamp(12px, 1.8vh, 17px);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--team-ink);
}
.pb-q-value {
  margin: 0;
  font-size: clamp(30px, 7vh, 72px);
  font-weight: 800;
  line-height: 1;
  color: var(--team);
  font-variant-numeric: tabular-nums;
}
.pb-prompt {
  flex: 1;
  display: grid;
  align-content: center;
  margin: 0;
  font-size: clamp(24px, 5.4vh, 62px);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}

.pb-options {
  display: grid;
  gap: clamp(6px, 1vh, 12px);
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(clamp(52px, 9vh, 104px), auto);
}
@media (max-aspect-ratio: 5/4) { .pb-options { grid-template-columns: 1fr; } }

.pb-option {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.4vh, 14px);
  text-align: left;
  font: inherit;
  font-size: clamp(17px, 2.8vh, 32px);
  font-weight: 600;
  line-height: 1.2;
  padding: clamp(9px, 1.5vh, 18px) clamp(11px, 1.5vh, 20px);
  border-radius: 13px;
  border: 2.5px solid var(--cg-line);
  background: var(--cg-panel);
  color: var(--cg-ink);
  cursor: pointer;
  transition: transform .08s, border-color .12s, background .12s;
}
.pb-option:active { transform: scale(.985); }
.pb-option:hover:not(:disabled) { border-color: var(--team); background: var(--team-soft); }
.pb-option.is-right { border-color: var(--cg-good); background: color-mix(in srgb, var(--cg-good) 14%, var(--cg-panel)); }
.pb-option.is-wrong { border-color: var(--cg-red);  background: color-mix(in srgb, var(--cg-red) 14%, var(--cg-panel)); }
.pb-option:disabled { cursor: default; }

.pb-hint {
  margin: 0;
  font-size: clamp(14px, 2.2vh, 22px);
  font-weight: 700;
  text-align: center;
  min-height: 1.4em;
  color: var(--team-ink);
}
.pb-back { align-self: center; font-size: 17px; padding: 13px 30px; }
.pb-back[hidden] { display: none; }

/* ---------- result ---------- */

.pb-over {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--cg-stage) 88%, transparent);
  backdrop-filter: blur(3px);
}
.pb-over[data-open] { display: grid; }
.pb-over-card {
  width: min(680px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  padding: clamp(24px, 5vh, 52px);
  border-radius: 22px;
  background: var(--cg-panel);
  border: 1px solid var(--cg-line);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .18);
}
.pb-over-crest { font-size: clamp(40px, 9vh, 76px); line-height: 1; }
.pb-over-card h2 { font-size: clamp(26px, 5vh, 46px); margin: 12px 0 18px; color: var(--team, var(--cg-ink)); }
.pb-over-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.pb-standings {
  list-style: none;
  counter-reset: place;
  margin: 0 auto 22px;
  padding: 0;
  display: grid;
  gap: 6px;
  max-width: 460px;
  text-align: left;
}
.pb-standings li {
  counter-increment: place;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--team-soft);
  color: var(--team-ink);
}
.pb-standings li::before { content: counter(place) "."; font-weight: 700; min-width: 1.4em; }
.pb-standings strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-standings span { font-size: 13.5px; opacity: .8; white-space: nowrap; }
.pb-standings .pb-standing-score { font-size: 18px; font-weight: 800; opacity: 1; color: var(--team); font-variant-numeric: tabular-nums; }

/* ---------- narrow screens ----------
   A teacher checks it on a phone before the lesson. The board keeps its grid —
   the grid is the game — and the page scrolls instead of squeezing it. */
@media (max-width: 860px), (max-height: 460px) {
  body.is-playing .pb-stage {
    grid-template-rows: auto auto auto;
    align-content: start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .pb-top { grid-template-columns: 1fr; }
  .pb-tools { justify-content: flex-end; order: -1; }
  .pb-teams { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pb-board { grid-template-rows: auto repeat(var(--rows, 5), 64px); }
  .pb-header small { display: none; }
  .pb-header { padding: 6px 3px; }
  .pb-header span { font-size: 10.5px; }
  .pb-value { font-size: 20px; }
  .pb-by { display: none; }
  .pb-q-card { min-height: 0; }
  .pb-prompt { flex: 0 0 auto; font-size: 21px; }
  .pb-options { grid-template-columns: 1fr; grid-auto-rows: minmax(52px, auto); }
  .pb-option { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .pb-q-card { animation: none; }
  .pb-square { transition: none; }
}
