/* Brainbattle theme - a thin layer on top of Bootstrap (dark).
   Colours come from Bootstrap CSS variables so the look stays consistent and flat. */

body { min-height: 100vh; }

.logo { font-size: 1.9rem; font-weight: 600; color: var(--bs-emphasis-color); margin: 0; }
.tagline { color: var(--bs-secondary-color); margin-bottom: 1.5rem; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1rem; }
.wrap.wide { max-width: none; }

/* Cards: padded panels (we put content directly inside, no card-body). */
.card {
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  padding: 1.1rem;
  margin-bottom: 1rem;
}

label { display: block; font-size: 0.85rem; color: var(--bs-secondary-color); margin: 0.7rem 0 0.25rem; }
input, textarea, select {
  width: 100%;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  color: var(--bs-body-color);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
}
textarea { min-height: 120px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Buttons - flat Bootstrap-style. Custom modifier names kept so markup is unchanged. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--bs-primary); color: #fff; border: 1px solid transparent;
  border-radius: var(--bs-border-radius); padding: 0.5rem 1rem;
  font-size: 0.95rem; font-weight: 500; cursor: pointer; line-height: 1.4;
  transition: filter 0.12s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { filter: brightness(0.95); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--bs-secondary); color: #fff; }
.btn.green { background: var(--bs-success); color: #fff; }
.btn.red { background: var(--bs-danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--bs-border-color); color: var(--bs-body-color); }
.btn.ghost:hover { background: var(--bs-tertiary-bg); filter: none; }
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.82rem; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > * { flex: 1; }
.center { text-align: center; }
.muted { color: var(--bs-secondary-color); }
.error { color: var(--bs-danger); margin-top: 0.6rem; min-height: 1.2em; }
.hidden { display: none !important; }

/* ---- Board ---- */
.board { display: grid; gap: 6px; margin-bottom: 1.2rem; }
.cat-head {
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 0.6rem 0.4rem; text-align: center; font-weight: 600;
  text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.4px;
  display: flex; align-items: center; justify-content: center; min-height: 2.8rem;
}
.tile {
  background: var(--bs-primary);
  border: 1px solid transparent; border-radius: var(--bs-border-radius);
  min-height: 3.4rem; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: #fff;
  cursor: default; transition: filter 0.12s ease;
}
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { filter: brightness(1.15); }
.tile.played { background: var(--bs-tertiary-bg); color: transparent; cursor: default; }

/* ---- Players strip ---- */
.players-strip { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.player-cam {
  background: var(--bs-secondary-bg); border: 2px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius); width: 220px; overflow: hidden; transition: border-color 0.15s ease;
}
.player-cam.turn { border-color: var(--bs-primary); }
.player-cam.buzzed { border-color: var(--bs-warning); }
.player-cam.locked { opacity: 0.5; }
.cam-frame { width: 100%; aspect-ratio: 16/9; background: #000; display: block; border: none; }
.cam-frame.placeholder { display: flex; align-items: center; justify-content: center; color: var(--bs-secondary-color); font-size: 0.8rem; }
.player-meta { display: flex; justify-content: space-between; align-items: center; padding: 0.45rem 0.65rem; }
.player-name { font-weight: 600; }
.player-score { font-weight: 700; color: var(--bs-primary); font-size: 1.15rem; }

/* ---- Question box ---- */
.qbox {
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color); border-left: 4px solid var(--bs-primary);
  border-radius: var(--bs-border-radius-lg); padding: 1.5rem; text-align: center; margin-bottom: 1.2rem;
}
.qbox .value { color: var(--bs-primary); font-weight: 700; font-size: 1.2rem; }
.x2-badge { display: inline-block; margin-left: 0.5rem; background: var(--bs-warning); color: #1a1400; font-weight: 800; border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.9rem; }
.qbox .qtext { font-size: 1.5rem; font-weight: 600; margin: 0.9rem 0; line-height: 1.3; }
.qbox .answer { color: var(--bs-success); font-size: 1.2rem; font-weight: 600; margin-top: 0.9rem; }
.qbox img { max-width: 100%; max-height: 320px; border-radius: var(--bs-border-radius); margin: 1rem auto; }
.qbox img.blur-img { transition: filter 0.9s linear; will-change: filter; }
.qbox audio { width: 100%; max-width: 480px; margin: 1rem auto; display: block; }

/* ---- Timer ---- */
.timer { font-size: 2.6rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.timer.buzz { color: var(--bs-primary); }
.timer.answer { color: var(--bs-warning); }
.timer.low { color: var(--bs-danger); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.1); } }

/* ---- Buzz button (compact bar) ---- */
.buzz-btn {
  width: 100%; max-width: 320px; height: 68px; margin: 0.5rem auto; display: block;
  background: var(--bs-danger); color: #fff; border: none; border-radius: var(--bs-border-radius-lg);
  font-size: 1.4rem; font-weight: 700; cursor: pointer; transition: filter 0.1s;
  text-transform: uppercase; letter-spacing: 1px;
}
.buzz-btn:hover { filter: brightness(1.1); }
.buzz-btn:active { transform: scale(0.97); }
.buzz-btn:disabled { background: var(--bs-tertiary-bg); cursor: not-allowed; color: var(--bs-secondary-color); }

/* ---- Player question popup (blurs the board behind it) ---- */
.q-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.q-overlay-inner { width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.q-overlay-inner .qbox { width: 100%; margin: 0; }
.q-overlay-inner .timer { margin: 0; }
.q-overlay-inner .buzz-btn { margin: 0.3rem auto 0; }

/* ---- Podium ---- */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1rem; margin: 2rem 0; flex-wrap: wrap; }
.podium-spot { text-align: center; }
.podium-face { width: 140px; margin: 0 auto 0.4rem; border-radius: var(--bs-border-radius); overflow: hidden; }
.podium-face .cam-frame { border-radius: var(--bs-border-radius); }
.podium-bar {
  background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0;
  width: 140px; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; padding: 1rem 0.5rem; color: var(--bs-body-color);
}
.podium-spot.r1 .podium-bar { height: 230px; border-color: var(--bs-warning); background: var(--bs-warning); color: #1a1400; }
.podium-spot.r2 .podium-bar { height: 185px; }
.podium-spot.r3 .podium-bar { height: 145px; }
.podium-rank { font-size: 2.2rem; font-weight: 800; }
.podium-name { font-weight: 600; margin-top: 0.4rem; }
.podium-score { font-weight: 700; font-size: 1.2rem; }
.medal { font-size: 2rem; }

/* ---- Admin specifics ---- */
.admin-grid { display: grid; grid-template-columns: 1fr 340px; gap: 1.2rem; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.panel-title { font-size: 0.78rem; text-transform: uppercase; color: var(--bs-secondary-color); margin-bottom: 0.6rem; letter-spacing: 0.6px; }
.player-admin { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); padding: 0.7rem; margin-bottom: 0.6rem; }
.player-admin.turn { border-color: var(--bs-primary); }
.player-admin.buzzed { border-color: var(--bs-warning); }
.score-controls { display: flex; gap: 0.3rem; align-items: center; margin-top: 0.4rem; }
.score-controls input { width: 70px; text-align: center; }
.badge { display: inline-block; font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 999px; background: var(--bs-tertiary-bg); color: var(--bs-body-color); margin-left: 0.4rem; font-weight: 500; }
.badge.turn { background: var(--bs-primary); color: #fff; }
.badge.buzzed { background: var(--bs-warning); color: #1a1400; }
.code-pill {
  display: inline-block; background: var(--bs-body-bg); border: 1px dashed var(--bs-primary);
  border-radius: var(--bs-border-radius); padding: 0.35rem 0.9rem; font-size: 1.5rem; font-weight: 700;
  letter-spacing: 4px; color: var(--bs-primary);
}
.join-url { font-size: 0.82rem; color: var(--bs-secondary-color); word-break: break-all; }
.code-box { display: flex; gap: 0.4rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.code-pill.masked { letter-spacing: 8px; }
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.tab-btns { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tab-btns .btn { flex: 1; }
.status-line { color: var(--bs-secondary-color); margin-bottom: 1rem; }

/* ===== Host single-screen layout (fits the viewport, no page scroll) ===== */
.wrap.wide { max-width: none; padding: 0.8rem 1rem; }
.host-stage { display: flex; flex-direction: column; gap: 0.6rem; height: calc(100vh - 84px); overflow: hidden; }
.cams-row { display: flex; gap: 0.6rem; flex-shrink: 0; }
.cams-row .player-cam { flex: 1 1 0; min-width: 0; max-width: 175px; width: auto; }
.play-area { display: flex; gap: 0.8rem; flex: 1; min-height: 0; }
.board-col { flex: 1.6; min-height: 0; display: flex; flex-direction: column; }
.board-col .board { flex: 1; min-height: 0; grid-auto-rows: minmax(0, 1fr); margin-bottom: 0; gap: 5px; }
.board-col .tile, .board-col .cat-head { min-height: 0; }
.board-col .tile { font-size: 1rem; }
.board-col .cat-head { font-size: 0.68rem; padding: 0.3rem 0.25rem; }
.control-col { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; gap: 0.7rem; min-height: 0; overflow-y: auto; }
.card.compact { padding: 0.8rem; margin-bottom: 0; }
.control-col .qbox { padding: 1rem; margin-bottom: 0; }
.control-col .qbox .qtext { font-size: 1.2rem; margin: 0.6rem 0; }
.control-col .qbox img { max-height: 180px; }
.cam-controls { display: flex; gap: 3px; padding: 0 0.5rem 0.5rem; }
.cam-controls .btn { padding: 0.25rem 0.3rem; font-size: 0.72rem; flex: 1; }
@media (max-width: 860px) {
  .host-stage { height: auto; }
  .play-area { flex-direction: column; }
  .control-col { width: auto; }
  .cams-row { flex-wrap: wrap; }
  .cams-row .player-cam { max-width: 160px; }
}

/* ===== Pending join requests ===== */
.pending-item {
  display: flex; align-items: center; gap: 0.5rem; justify-content: space-between;
  background: var(--bs-body-bg); border: 1px solid var(--bs-primary); border-radius: var(--bs-border-radius);
  padding: 0.4rem 0.6rem; margin-bottom: 0.4rem;
}
.pending-item .face-mini { font-size: 1.2rem; }

/* ===== Avatars & face picker ===== */
.avatar-face { display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.cams-row .avatar-face, .player-cam .avatar-face { font-size: 2.4rem; }
.face-picker .fp-toggle { display: flex; gap: 0.4rem; margin: 0.4rem 0 0.6rem; }
.face-picker .fp-toggle button {
  flex: 1; padding: 0.45rem; border-radius: var(--bs-border-radius); border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg); color: var(--bs-body-color); cursor: pointer; font-weight: 500; font-size: 0.9rem;
}
.face-picker .fp-toggle button.sel { background: var(--bs-primary); color: #fff; border-color: var(--bs-primary); }
/* auto-fill so the avatars wrap to fit any container width instead of overflowing */
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 0.4rem; }
.avatar-pick {
  aspect-ratio: 1; min-width: 0; font-size: 1.3rem; border: 2px solid var(--bs-border-color); background: var(--bs-body-bg);
  border-radius: var(--bs-border-radius); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.avatar-pick.sel { border-color: var(--bs-primary); background: var(--bs-tertiary-bg); }

/* ===== Visual question editor ===== */
.cat-edit { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); padding: 0.8rem; margin-bottom: 0.8rem; background: var(--bs-body-bg); }
.cat-edit-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }
.cat-edit-head input { font-weight: 600; }
.q-edit { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); padding: 0.6rem; margin-bottom: 0.5rem; background: var(--bs-secondary-bg); }
.q-edit .q-top { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.q-edit .q-top .q-points { width: 90px; flex: none; }
.q-edit label { margin: 0.4rem 0 0.2rem; }
.q-edit input, .q-edit select, .q-edit textarea { padding: 0.45rem 0.55rem; font-size: 0.9rem; }
.q-edit textarea { min-height: 0; height: 2.4rem; font-family: inherit; font-size: 0.9rem; }
.icon-btn {
  flex: none; background: transparent; border: 1px solid var(--bs-border-color); color: var(--bs-secondary-color);
  border-radius: var(--bs-border-radius); cursor: pointer; padding: 0.4rem 0.6rem; font-size: 0.9rem; line-height: 1;
}
.icon-btn:hover { color: var(--bs-danger); border-color: var(--bs-danger); }
.add-q { width: 100%; margin-top: 0.2rem; }

/* Board-style question editor (looks like the in-game board) */
.editor-board { display: grid; gap: 6px; }
.edit-cat-head { display: flex; gap: 4px; align-items: center; }
.edit-cat-head input { font-weight: 600; padding: 0.4rem 0.5rem; font-size: 0.85rem; }
.edit-cat-head .icon-btn { flex: none; padding: 0.3rem 0.45rem; }
.edit-tile {
  min-height: 3rem; display: flex; align-items: center; justify-content: center;
  background: var(--bs-primary); color: #fff; border-radius: var(--bs-border-radius);
  font-weight: 700; font-size: 1.2rem; cursor: pointer; transition: filter 0.12s ease;
}
.edit-tile:hover { filter: brightness(1.15); }
.edit-tile.empty { background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); border: 1px dashed var(--bs-border-color); }
.edit-tile.blank { background: transparent; cursor: default; }
.edit-add-q {
  background: transparent; border: 1px dashed var(--bs-border-color); color: var(--bs-secondary-color);
  border-radius: var(--bs-border-radius); padding: 0.4rem; cursor: pointer; font-size: 0.8rem;
}
.edit-add-q:hover { border-color: var(--bs-primary); color: var(--bs-body-color); }

/* Modal (question editor) */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-card {
  background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg); padding: 1.2rem; width: 100%; max-width: 440px;
  max-height: 90vh; overflow-y: auto;
}

/* ===== Dedicated podium screen ===== */
.podium-screen { min-height: calc(100vh - 120px); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.podium-actions { display: flex; gap: 0.8rem; margin-top: 1.8rem; flex-wrap: wrap; justify-content: center; }
.waiting-screen { min-height: 50vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1rem; }
.waiting-screen .spinner { font-size: 3rem; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
