body.board {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
body.board .topbar { flex-shrink: 0; }
body.board main {
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* ---- rules overlay ---- */
button.rules-btn {
  padding: 6px 14px;
  font-size: 0.95rem;
  background: rgba(255,255,255,0.08);
}
.rules-backdrop {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(0, 0, 0, 0.6);
}
.rules-overlay {
  position: fixed; inset: 0; z-index: 111;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; pointer-events: none;
}
.rules-overlay .rules-inner {
  pointer-events: auto;
  max-width: 720px; width: 100%; max-height: 90vh;
  background: var(--panel-solid);
  border: 2px solid var(--accent); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.rules-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.rules-head h2 { margin: 0; color: var(--accent); }
.rules-body { padding: 18px 24px 24px; overflow-y: auto; line-height: 1.5; }
.rules-body section { margin-bottom: 18px; }
.rules-body h3 { color: var(--accent); font-size: 1rem; text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 6px; }
.rules-body ol { padding-left: 20px; }
.rules-body ol li { margin-bottom: 6px; }
.rules-body ul { padding-left: 20px; margin: 4px 0 0; }

/* ---- lobby QR grid ---- */
.lobby { text-align: center; }
.lobby h1 { margin-bottom: 8px; }
.qr-grid {
  display: grid; gap: 20px; margin: 18px 0;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.qr-cell {
  background: #fff; color: #111; border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative;
}
.qr-cell img { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; }
.qr-cell .slot-label {
  display: inline-block;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 8px 18px;
  background: var(--accent);
  color: #211a04;
  border-radius: 10px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}
.qr-cell .slot-label:hover { background: var(--accent-2); color: #fff; }
.qr-cell .slot-label:active { transform: translateY(1px); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.qr-cell .team-pill {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 800; color: #fff;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.qr-cell .status { font-size: 0.9rem; color: #555; }
.qr-cell.joined .status { color: var(--good); font-weight: 700; }

/* ---- play header ---- */
.play {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.play-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 4px 2px;
}
.active-info { text-align: left; }
.active-label { color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; }
.active-name  { font-size: 2.2rem; font-weight: 800; color: var(--fg); }
.active-team  { color: var(--accent); font-weight: 700; }
.active-category {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
}
/* Revealed subject chip — only shown on the board after a turn ends. */
.revealed-card {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 18px; margin-left: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
  color: #211a04; border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
.revealed-card .rc-label { color: #64748b; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }
.revealed-card .rc-subject { font-weight: 900; font-size: 1.1rem; }

.scores-strip { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.team-score {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 18px; min-width: 110px; text-align: center;
  position: relative;
}
.team-score::before {
  content: ''; display: block; position: absolute; left: 10px; top: 10px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--team-dot, var(--dim));
}
.team-score .tname { color: var(--dim); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; }
.team-score .tscore { font-size: 2.4rem; font-weight: 800; }
.team-score.active { outline: 2px solid var(--accent); }

/* ---- stage (canvas + hourglass) ---- */
.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 0;
}
.sand-timer {
  flex: 0 0 auto;
  width: clamp(120px, 14vw, 220px);
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.5));
}
.hourglass-svg { display: block; width: 100%; height: auto; }
.sand-timer .dg-sand-stream { opacity: 0; }
.sand-timer.running .dg-sand-stream {
  animation: streamFlicker 0.12s steps(2, end) infinite;
}
@keyframes streamFlicker {
  0% { opacity: 0.95; } 50% { opacity: 0.55; } 100% { opacity: 0.95; }
}
.stage-frame {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  position: relative; overflow: hidden;
}
.stage-frame canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; touch-action: none;
}
.timer-readout {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-width: 120px;
}
.timer-readout .time-remaining {
  font-family: "Menlo", ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.8rem, 3.5vw, 3.2rem);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-shadow: 0 0 20px rgba(252, 191, 73, 0.3);
}
.timer-readout .time-remaining.warn {
  color: var(--danger);
  text-shadow: 0 0 24px rgba(239, 71, 111, 0.45);
  animation: warnPulse 1s ease-in-out infinite;
}
.timer-readout .time-remaining.done { color: var(--good); }
.timer-readout .time-label {
  color: var(--dim);
  font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase;
}
@keyframes warnPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.status {
  text-align: center; font-size: 1.1rem;
  min-height: 24px; color: var(--accent);
}

/* ---- winner overlay ---- */
.winner-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #0a0423 radial-gradient(circle at center, rgba(252, 191, 73, 0.35) 0%, #0a0423 65%);
}
.winner-inner {
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 48px 72px;
  border: 2px solid var(--accent);
  border-radius: 20px;
  box-shadow: 0 0 60px rgba(252, 191, 73, 0.55);
}
.winner-label { color: var(--accent); font-size: 2rem; letter-spacing: 0.3em; }
.winner-name  { font-size: 6rem; font-weight: 900; margin: 20px 0; color: #fff;
                text-shadow: 0 2px 20px rgba(0,0,0,0.6); }
.winner-score { font-size: 3rem; color: var(--good); text-shadow: 0 2px 10px rgba(0,0,0,0.6); }

@media (max-width: 900px) {
  .play-top { justify-content: center; }
  .scores-strip { justify-content: center; }
}
