/* ============================================================
   Bomb — the board
   ------------------------------------------------------------
   The setup screen is assets/classroom-setup.css; this is only
   what happens after Start. Sized for a display at the front of
   a room like the other games, and coloured from the shared
   team palette through --team, which classroom-setup.css sets
   for each team's is-* class.

   Up to six teams, so the teams are a strip of cards across the
   top rather than one each side. The bomb is on the left and the
   question on the right; both take the colour of whoever is
   holding it, so the room can see whose problem it is without
   reading anything.
   ============================================================ */

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

/* ---------- the teams ---------- */

.bm-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}
.bm-teams {
  display: grid;
  grid-template-columns: repeat(var(--count, 4), minmax(0, 1fr));
  gap: clamp(6px, 1vw, 12px);
}

.bm-team {
  position: relative;
  display: grid;
  gap: 2px;
  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 .2s, transform .15s;
}
.bm-team-name {
  font-weight: 700;
  font-size: clamp(14px, 2.2vh, 24px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-lives {
  font-size: clamp(15px, 2.4vh, 26px);
  letter-spacing: .08em;
  line-height: 1.1;
  color: var(--team);
}

/* The bomb's badge sits on whoever holds it. It is the one thing on the strip
   that moves, so it is the thing the class follows. */
.bm-badge {
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: clamp(20px, 3.4vh, 34px);
  line-height: 1;
  opacity: 0;
  transform: scale(.4);
  transition: opacity .15s, transform .2s cubic-bezier(.3, 1.6, .6, 1);
}
.bm-team[data-holding="true"] { border-color: var(--team); transform: translateY(-2px); }
.bm-team[data-holding="true"] .bm-badge { opacity: 1; transform: none; }

.bm-team[data-hit="true"] { border-color: var(--team); animation: bm-jolt .5s; }
@keyframes bm-jolt {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* A team that is out stays on the strip — they are still in the room, and the
   bomb visibly skipping them is what tells the class they are gone. */
.bm-team[data-out="true"] { opacity: .38; filter: grayscale(.7); }
.bm-team[data-out="true"] .bm-lives { font-size: clamp(12px, 1.8vh, 17px); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

.bm-tools { display: flex; align-items: center; gap: clamp(6px, 1vw, 12px); }
.bm-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;
}
.bm-tool:hover { color: var(--cg-ink); border-color: var(--cg-dim); }
.bm-tool[aria-pressed="true"] { color: var(--cg-ink); border-color: var(--cg-ink); }
.bm-tool svg[hidden] { display: none; }

/* ---------- the two halves ---------- */

.bm-play {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: clamp(10px, 1.6vw, 24px);
  min-height: 0;
}

/* ---------- the bomb ---------- */

.bm-bomb-side {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  min-height: 0;
  padding: clamp(10px, 2vh, 24px);
  border-radius: 18px;
  background: var(--team-soft, var(--cg-panel));
  transition: background .25s;
}
.bm-bomb {
  width: 100%;
  height: 100%;
  max-height: 60vh;
  min-height: 0;
  overflow: visible;
}
.bm-body { fill: #1d2733; }
.bm-cap { fill: #4a5664; }
.bm-shine { fill: rgba(255, 255, 255, .22); }
.bm-fuse { stroke: #8a6a44; }
.bm-spark { fill: #ffb627; stroke: #ff7a1a; transform-origin: 174px 22px; animation: bm-spark .18s infinite alternate; }
[data-theme="dark"] .bm-body { fill: #05090d; stroke: #3b4a5a; stroke-width: 2; }

@keyframes bm-spark {
  from { transform: scale(.8) rotate(0deg); opacity: .8; }
  to   { transform: scale(1.15) rotate(20deg); opacity: 1; }
}

/* The shake quickens with the ticking. Three speeds and nothing finer, because
   the fuse length is secret and a smooth ramp would give it away. */
.bm-bomb { transform-origin: 46% 62%; animation: bm-wobble 1s ease-in-out infinite; }
.bm-stage[data-level="hurry"] .bm-bomb { animation-duration: .5s; }
.bm-stage[data-level="panic"] .bm-bomb { animation-duration: .2s; }
.bm-stage[data-level="panic"] .bm-body { fill: #3a1d1d; }
.bm-stage[data-level="out"] .bm-bomb,
.bm-stage[data-paused] .bm-bomb,
.bm-stage[data-paused] .bm-spark { animation-play-state: paused; }
@keyframes bm-wobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.bm-holder {
  margin: clamp(6px, 1vh, 12px) 0 0;
  font-size: clamp(18px, 3vh, 34px);
  font-weight: 700;
  color: var(--team-ink, var(--cg-ink));
  text-align: center;
}

/* ---------- the question ---------- */

.bm-ask {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vh, 16px);
  min-height: 0;
  padding: clamp(12px, 2vh, 24px);
  border-radius: 18px;
  background: var(--cg-panel);
  border: 3px solid color-mix(in srgb, var(--team, var(--cg-line)) 45%, transparent);
  transition: border-color .2s;
}
.bm-ask-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  font-size: clamp(11px, 1.6vh, 15px);
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--team-ink);
}
.bm-ask-skill { text-transform: none; letter-spacing: 0; font-weight: 500; opacity: .72; }

.bm-prompt {
  flex: 1;
  display: grid;
  align-content: center;
  min-height: 0;
  margin: 0;
  font-size: clamp(20px, 3.6vh, 42px);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}

.bm-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) { .bm-options { grid-template-columns: 1fr; } }

.bm-option {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.4vh, 14px);
  text-align: left;
  font: inherit;
  font-size: clamp(16px, 2.6vh, 30px);
  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;
}
.bm-option:active { transform: scale(.985); }
.bm-option:hover:not(:disabled) { border-color: var(--team); background: var(--team-soft); }
.bm-option.is-right { border-color: var(--cg-good); background: color-mix(in srgb, var(--cg-good) 14%, var(--cg-panel)); }
.bm-option.is-wrong { border-color: var(--cg-red);  background: color-mix(in srgb, var(--cg-red) 14%, var(--cg-panel)); }
.bm-option:disabled { cursor: default; }

.bm-hint {
  font-size: clamp(13px, 1.9vh, 19px);
  font-weight: 600;
  text-align: center;
  min-height: 1.4em;
  margin: 0;
  color: var(--team-ink);
}

/* Paused: the question is covered, so nobody spends the pause reading it. */
.bm-paused {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  margin: 0;
  border-radius: 15px;
  background: var(--cg-panel);
  font-size: clamp(26px, 5vh, 48px);
  font-weight: 700;
  color: var(--cg-dim);
}
.bm-stage[data-paused] .bm-paused { display: grid; }

/* ---------- the bang ---------- */

.bm-bang {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: color-mix(in srgb, var(--team, var(--cg-red)) 22%, var(--cg-stage));
  animation: bm-flash .45s ease-out;
}
.bm-bang[hidden] { display: none; }
@keyframes bm-flash {
  from { background: #fff3c4; }
}
.bm-bang-card {
  text-align: center;
  padding: clamp(20px, 4vh, 44px);
  border-radius: 22px;
  background: var(--cg-panel);
  border: 3px solid var(--team);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .18);
  width: min(640px, 100%);
}
.bm-bang-word {
  font-size: clamp(44px, 11vh, 110px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: .02em;
  color: var(--team);
  animation: bm-boom .5s cubic-bezier(.2, 1.6, .5, 1);
}
@keyframes bm-boom {
  from { transform: scale(.3); opacity: 0; }
}
.bm-bang-card h2 { font-size: clamp(22px, 4vh, 40px); margin: 12px 0 6px; color: var(--team-ink); }
.bm-bang-line { font-size: clamp(15px, 2.2vh, 20px); color: var(--cg-dim); margin: 0 0 20px; }
.bm-bang.is-out .bm-bang-card h2 { color: var(--team); }

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

.bm-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);
}
.bm-over[data-open] { display: grid; }
.bm-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);
}
.bm-over-crest { font-size: clamp(40px, 9vh, 76px); line-height: 1; }
.bm-over-card h2 { font-size: clamp(26px, 5vh, 46px); margin: 12px 0 6px; color: var(--team, var(--cg-ink)); }
.bm-over-line { font-size: clamp(15px, 2.2vh, 20px); color: var(--cg-dim); margin: 0 0 18px; }
.bm-over-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.bm-standings {
  list-style: none;
  counter-reset: place;
  margin: 0 auto 22px;
  padding: 0;
  display: grid;
  gap: 6px;
  max-width: 440px;
  text-align: left;
}
.bm-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);
}
.bm-standings li::before { content: counter(place) "."; font-weight: 700; min-width: 1.4em; }
.bm-standings strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-standings span { font-size: 13.5px; opacity: .8; white-space: nowrap; }

/* ---------- narrow screens ----------
   Same reasoning as the other games: it belongs at the front of a room, but a
   teacher will open it on a phone first and it must not be unusable. The bomb
   shrinks to a strip and the question goes under it. */
@media (max-width: 860px), (max-height: 460px) {
  body.is-playing .bm-stage {
    grid-template-rows: auto auto;
    align-content: start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bm-top { grid-template-columns: 1fr; }
  .bm-tools { justify-content: flex-end; order: -1; }
  .bm-teams { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bm-play { grid-template-columns: 1fr; min-height: auto; }
  .bm-bomb-side { grid-template-columns: auto 1fr; grid-template-rows: auto; gap: 12px; padding: 10px 14px; }
  .bm-bomb { width: 64px; height: 64px; }
  .bm-holder { margin: 0; font-size: 18px; text-align: left; }
  .bm-prompt { flex: 0 0 auto; font-size: 20px; }
  .bm-options { grid-template-columns: 1fr; grid-auto-rows: minmax(52px, auto); }
  .bm-option { font-size: 17px; }
  .bm-ask-skill { display: none; }
  .bm-bang { position: fixed; inset: 0; border-radius: 0; z-index: 65; padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .bm-bomb, .bm-spark, .bm-bang, .bm-bang-word, .bm-team[data-hit="true"] { animation: none; }
}
