/* Bounce Bots. Everything here is prefixed .bb-* and scoped to its own page,
   so the shared design system in styles.css stays untouched. Colours come from
   the site's existing custom properties. */

.bb-status {
  min-height: 1.2rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---- forms ------------------------------------------------------------- */

.bb-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.bb-field label {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bb-field input,
.bb-field select {
  padding: 0.5rem 0.65rem;
  background: var(--brand-soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}

.bb-field input:focus-visible,
.bb-field select:focus-visible {
  outline: none;
  border-color: var(--brand);
}

.bb-modes {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.bb-mode,
.bb-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.92rem;
  cursor: pointer;
}

.bb-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 1rem;
  align-items: end;
}

.bb-bots-setup {
  margin: 0.4rem 0 1rem;
  padding: 0.7rem 0.9rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.bb-bots-setup legend {
  padding: 0 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.bb-field input[type="range"] {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  accent-color: var(--ink);
}

.bb-hint {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0.6rem 0 0;
}

kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--brand-soft);
  font-family: inherit;
  font-size: 0.85em;
}

/* ---- buttons ----------------------------------------------------------- */

.bb-btn {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.bb-btn:hover,
.bb-btn:focus-visible {
  transform: translateY(-1px);
  border-color: var(--brand);
  background: var(--brand-soft);
}

.bb-btn.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
  font-weight: 700;
}

.bb-btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  font-weight: 700;
}

.bb-btn-primary:hover,
.bb-btn-primary:focus-visible {
  background: var(--brand);
  color: var(--bg);
}

.bb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* ---- layout ------------------------------------------------------------ */

.bb-game {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: 1.2rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.bb-board-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem;
}

/* The first bid puts everyone on a clock. That is easy to miss when you are
   staring at the board, so the border flashes once and then holds a muted
   red for as long as the clock is running. */
/* One pulse per second of the bid clock: the flash is at 0% and decays fast,
   leaving most of the cycle at the resting red. That ordering matters -- a CSS
   animation does not advance in a backgrounded tab, so freezing anywhere in the
   long tail leaves the border on the colour it should be showing anyway. */
@keyframes bb-clock-tick {
  0% {
    border-color: #e5484d;
    box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.32);
  }
  22% {
    border-color: rgba(229, 72, 77, 0.45);
    box-shadow: none;
  }
  100% {
    border-color: rgba(229, 72, 77, 0.45);
    box-shadow: none;
  }
}

.bb-board-wrap.is-bidding {
  border-color: rgba(229, 72, 77, 0.45);
  /* The negative delay is set from JS to align the flash with the countdown. */
  animation: bb-clock-tick 1000ms ease-out infinite;
  animation-delay: var(--bb-tick-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  .bb-board-wrap.is-bidding {
    animation: none;
  }
}

#bb-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
}

.bb-side {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.bb-panel {
  margin: 0;
  padding: 0.9rem 1rem;
}

.bb-panel h3 {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- status readout ---------------------------------------------------- */

.bb-headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.bb-round {
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.bb-timer {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bb-timer.is-urgent {
  color: #e5484d;
}

.bb-phase {
  margin: 0.4rem 0 0;
  font-size: 1.02rem;
  line-height: 1.4;
}

.bb-target {
  margin: 0.5rem 0 0;
  font-weight: 700;
  text-transform: capitalize;
}

.bb-note,
.bb-moves {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.bb-code {
  font-family: "Bitter", serif;
  letter-spacing: 0.22em;
  color: var(--ink);
}

/* ---- robot picker ------------------------------------------------------ */

.bb-robots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.bb-robot-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.bb-robot-btn .bb-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--bb-robot, #fff);
}

.bb-robot-btn.is-active {
  border-color: var(--bb-robot, #fff);
  background: var(--brand-soft);
}

/* ---- the stage: steps, board, bid bar ---------------------------------- */

.bb-stage {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  position: sticky;
  top: 1rem;
}

/* Three steps, current one lit. This is the whole game loop in one line. */
.bb-steps {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.bb-steps li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--muted);
  transition: color 200ms ease, border-color 200ms ease, background 200ms ease;
}

.bb-steps li span {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
}

.bb-steps li.is-current {
  color: var(--ink);
  border-color: var(--ink);
  background: var(--brand-soft);
}

.bb-steps li.is-current span {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.bb-steps li.is-done {
  color: var(--muted);
  border-color: var(--line);
}

/* ---- bid bar ----------------------------------------------------------- */

.bb-bidbar,
.bb-proofbar {
  padding: 0.85rem 1rem 0.9rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--panel);
}

.bb-proofbar {
  border-color: var(--line);
}

.bb-bidbar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.bb-bidbar-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.bb-bidbar-clock {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.bb-bidbar-clock.is-urgent {
  color: #e5484d;
}

/* Big targets: bidding is timed, so it must never take aim. */
.bb-numpad {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(2.6rem, 1fr));
  gap: 0.4rem;
}

.bb-num {
  padding: 0.6rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.bb-num:hover:not(:disabled),
.bb-num:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

/* Bids may only ever go down, so anything you cannot claim is visibly out of
   reach. The rule teaches itself. */
.bb-num:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.bb-num.is-mine {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  opacity: 1;
}

.bb-bid-more {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.bb-bid-more label {
  font-size: 0.85rem;
  color: var(--muted);
}

.bb-bid-more input {
  width: 4.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--brand-soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}

.bb-bidbar-state,
.bb-proof-count {
  margin: 0.6rem 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.bb-proof-count {
  font-size: 1.05rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.bb-lead {
  color: var(--ink);
  font-weight: 700;
}

/* ---- players ----------------------------------------------------------- */

.bb-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.bb-player {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--brand-soft);
  font-size: 0.92rem;
}

.bb-player.is-you {
  border-color: var(--line);
}

.bb-player.is-offline {
  opacity: 0.45;
}

.bb-player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bb-bid-chip {
  display: inline-block;
  min-width: 1.9rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* The current low bid is the one everyone is racing. */
.bb-bid-chip.is-lowest {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.bb-bid-chip.is-none {
  color: var(--muted);
  font-weight: 400;
  border-style: dashed;
}

/* A bid landing is news. The row is rebuilt on every render, so the animation
   plays exactly once, on the render where the number actually changed. */
@keyframes bb-bid-landed {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(245, 245, 245, 0.55);
  }
  35% {
    transform: scale(1.14);
    box-shadow: 0 0 0 6px rgba(245, 245, 245, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: none;
  }
}

.bb-bid-chip.is-new {
  animation: bb-bid-landed 620ms ease-out 1;
}

.bb-player.is-new-bid {
  border-color: var(--ink);
}

.bb-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bb-tags {
  grid-column: 1 / -1;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- narrow screens ---------------------------------------------------- */

@media (max-width: 900px) {
  .bb-game {
    grid-template-columns: 1fr;
  }

  .bb-board-wrap {
    position: static;
  }
}
