/* Reflex Tap — activity styles (player + host).
   Source of truth: MASTER_SPEC Part C + DESIGN.md. */

/* ---------- shared stage bits ---------- */

.rh-round, .rp-round {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-soft);
}

.rh-round b, .rp-round b { color: var(--color-accent); }

/* ---------- PLAYER ---------- */

.reflex-player {
  width: 100%;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.rp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.rp-timer {
  font-size: 1.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 4.6ch;
  text-align: right;
  background: var(--color-surface-raised);
  border: var(--border-width-card) solid var(--color-border-input);
  border-radius: var(--radius-chip);
  padding: 0.35rem 0.7rem;
  color: var(--color-text);
}

.rp-timer.low { color: var(--color-danger); border-color: var(--color-danger); }

.rp-next {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-strong);
}

.rp-next b {
  color: var(--color-accent);
  font-size: 1.25rem;
}

.rp-wrongs {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-danger-text-pale);
  min-height: 1.1em;
}

/* Small breathing room: tiles never touch the stage edges (top keeps the
   Next indicator as its spacing). */
.rp-grid {
  display: grid;
  gap: 0.55rem;
  width: 100%;
  padding: 0 0.45rem 0.45rem;
}

.rp-tile {
  aspect-ratio: 1;
  border: none;
  border-radius: var(--radius-tile);
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: 900;
  color: var(--color-on-primary);
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition: transform 0.05s ease, opacity 0.25s ease, box-shadow 0.05s ease;
  -webkit-tap-highlight-color: transparent;
}

.rp-tile:active {
  transform: scale(0.93);
  box-shadow: var(--shadow-button-pressed);
}

.rp-tile:nth-child(5n + 1) { background: var(--palette-1); }
.rp-tile:nth-child(5n + 2) { background: var(--palette-2); }
.rp-tile:nth-child(5n + 3) { background: var(--palette-3); }
.rp-tile:nth-child(5n + 4) { background: var(--palette-4); }
.rp-tile:nth-child(5n) { background: var(--palette-5); }

.rp-tile.cleared {
  opacity: 0.18;
  transform: scale(0.82);
  pointer-events: none;
  box-shadow: none;
}

.rp-tile.wrong {
  animation: rb-shake 0.3s ease;
}

.rp-grid.dense .rp-tile { font-size: 1.05rem; border-radius: var(--radius-input); }
.rp-grid.dense { gap: 0.3rem; }

@keyframes rb-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* countdown + GO + overlays */

.rp-stage {
  position: relative;
  width: 100%;
}

.rp-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-scrim-stage);
  border-radius: var(--radius-card);
  z-index: 5;
}

.rp-countdown b {
  font-size: clamp(5rem, 22vw, 9rem);
  font-weight: 900;
  color: var(--color-accent);
  text-shadow: var(--shadow-pop);
  animation: rb-pop 1s ease infinite;
  font-variant-numeric: tabular-nums;
}

.rp-go {
  font-size: clamp(4rem, 18vw, 7rem);
  font-weight: 900;
  color: var(--color-success);
  text-shadow: var(--shadow-pop-ink);
  animation: rb-go 0.7s ease forwards;
}

/* "Get ready" announcement (BUG-003 scheduling fix): shown between the
   host pressing Start and the 3-2-1, so the pause reads as intentional. */

.rp-ready {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-scrim-stage);
  border-radius: var(--radius-card);
  z-index: 5;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  font-weight: 900;
  color: var(--color-text);
  text-align: center;
  padding: 1rem;
}

.rh-ready {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-scrim-stage);
  border-radius: var(--radius-card);
  z-index: 5;
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 900;
  color: var(--color-text);
  text-shadow: var(--shadow-pop);
  text-align: center;
  padding: 1rem;
}

@keyframes rb-pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes rb-go {
  0% { transform: scale(0.3); opacity: 0; }
  35% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.rp-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--color-scrim-stage-deep);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: var(--radius-card);
  z-index: 6;
  text-align: center;
  padding: 1rem;
}

.rp-overlay .rp-big {
  font-size: clamp(1.8rem, 8vw, 3rem);
  font-weight: 900;
  color: var(--color-text);
}

.rp-overlay .rp-big.gold { color: var(--medal-gold); }
.rp-overlay .rp-big.timesup { color: var(--color-danger-text); }

.rp-overlay .rp-sub {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-soft);
}

.rp-overlay .rp-time {
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--color-accent);
}

/* ---------- HOST ---------- */

/* One-viewport live-show layout: the whole gameplay screen fits the
   projector/browser window. Top bar (round + Next) stays fixed, the stage
   absorbs the remaining height — nothing scrolls. */

.reflex-host {
  width: 100%;
  height: calc(100dvh - 8rem);
  max-height: calc(100dvh - 8rem);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

/* Game locked to one viewport (core adds game-running to <body>): absorb
   the REAL remaining height instead of the fixed 8rem estimate, so the
   game screen exactly fills the projector with no scroll and no clip. */
body.host.game-running .reflex-host {
  height: auto;
  max-height: none;
  flex: 1;
}

.rh-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.rh-top-controls {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.rh-top .btn {
  font-size: 1rem;
  padding: 0.55rem 1.1rem;
  min-height: 2.9rem;
}

.rh-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--color-surface-faint);
  border: var(--border-width-card) solid var(--color-surface-raised-2);
  border-radius: var(--radius-panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.9rem;
  gap: 0.55rem;
  overflow: hidden;
}

.rh-timer {
  font-size: clamp(2.8rem, 9vh, 5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 5ch;
  text-align: center;
  color: var(--color-text);
  line-height: 1;
}

.rh-timer.low { color: var(--color-danger); }

/* W5: TIME'S UP replaces the 0.0 in the timer slot itself — a smaller
   danger-red word in the timer's place, no separate overlay. */
.rh-timer.timesup {
  font-size: clamp(1.8rem, 6vh, 3rem);
  color: var(--color-danger);
  white-space: nowrap;
}

.rh-progress {
  font-size: clamp(1rem, 2.6vh, 1.35rem);
  font-weight: 800;
  color: var(--color-success);
  text-align: center;
}

.rh-instruction {
  font-size: 0.95rem;
  color: var(--color-text-soft);
  text-align: center;
}

.rh-tiles {
  display: grid;
  gap: 0.4rem;
  width: 100%;
  max-width: 40rem;
  flex: 1;
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
}

.rh-tile {
  border-radius: var(--radius-tile-small);
  font-size: clamp(0.9rem, 3vh, 1.6rem);
  font-weight: 900;
  color: var(--color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.rh-tile:nth-child(5n + 1) { background: var(--palette-1); }
.rh-tile:nth-child(5n + 2) { background: var(--palette-2); }
.rh-tile:nth-child(5n + 3) { background: var(--palette-3); }
.rh-tile:nth-child(5n + 4) { background: var(--palette-4); }
.rh-tile:nth-child(5n) { background: var(--palette-5); }

/* The 3-2-1 bomb and the KaBoomz explosion live in the shared module
   (src/activities/shared/bomb.js + css/base.css kb-* rules) — every
   activity's host screen uses the same countdown from one place. */


/* The leaderboard and podium (C7/C8) live in css/base.css - one shared
   implementation for every activity's host screen (Slice 4). */


/* host setup screen (C11) */

.reflex-setup {
  width: 100%;
  background: var(--color-surface);
  border: var(--border-width-card) solid var(--color-border);
  border-radius: var(--radius-panel);
  padding: 1.1rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.rs-title { margin: 0; font-size: 1.4rem; font-weight: 900; color: var(--color-accent); }

.rs-hint { margin: 0; color: var(--color-text-muted); font-size: 0.95rem; }

/* Setup lives on a scrollable page: the round list grows naturally and
   the PAGE scrolls — no small internal scroll box (game-running is off
   here, so the page is free to scroll). */
.rs-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rs-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--color-surface-control);
  border: var(--border-width-card) solid var(--color-border-subtle);
  border-radius: var(--radius-tile);
  padding: 0.6rem 0.8rem;
  font-weight: 700;
}

.rs-label { min-width: 5rem; color: var(--color-accent); }

.rs-row label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }

.rs-row input {
  width: 4.6rem;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.45rem 0.5rem;
  border: var(--border-width-card) solid var(--color-border-strong);
  border-radius: var(--radius-input);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.rs-btn {
  border: none;
  background: var(--color-surface-raised-2);
  color: var(--color-text);
  border-radius: var(--radius-input);
  min-width: 2.4rem;
  height: 2.4rem;
  font-weight: 900;
  cursor: pointer;
}

.rs-btn:hover { background: var(--color-surface-ctrl-hover); }
.rs-btn.remove { color: var(--color-danger-text-soft); }

.rs-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.rs-error { margin: 0; color: var(--color-danger-text-soft); font-weight: 700; min-height: 1.2em; }
