/* ── Triple-Twenty — Global Styles ── */
:root {
  --bg: #0d0f14;
  --bg2: #151821;
  --bg3: #1e2230;
  --border: #2a2f3d;
  --border2: #363d52;
  --text: #e8eaf0;
  --text2: #8b92a8;
  --text3: #5a6178;
  --primary: #f97316;
  --primary-dark: #c2580e;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #a855f7;
  --card-radius: 12px;
  --gap: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo { color: var(--primary); font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.top-right { display: flex; align-items: center; gap: 10px; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); display: inline-block; }
.user-avatar { width: 24px; height: 24px; border-radius: 50%; }
.user-badge { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text2); }
main { min-height: calc(100vh - 48px); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text); font-size: 0.875rem;
  cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { background: var(--border2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--bg3); border-color: var(--border2); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn-warning { background: var(--yellow); border-color: var(--yellow); color: #000; font-weight: 600; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 1rem; border-radius: 10px; }

/* ── Card ── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--card-radius); padding: 20px;
}

/* ── Forms ── */
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 0.9rem; width: 100%;
  outline: none; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label { font-size: 0.82rem; color: var(--text2); display: block; margin-bottom: 5px; }
.form-group { margin-bottom: 16px; }
.hint { font-size: 0.8rem; color: var(--text3); }
.error-msg { color: var(--red); font-size: 0.82rem; margin-top: 6px; }

/* ── Status dots ── */
.status-dot, .conn-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }
.dot-waiting { background: var(--text3); }

/* ── Confidence pills ── */
.conf-high, .conf-high { background: var(--green); color: #fff; }
.conf-medium { background: var(--yellow); color: #000; }
.conf-low { background: var(--red); color: #fff; }
.conf-corrected { background: var(--blue); color: #fff; }
.conf-remote { background: var(--purple); color: #fff; }

/* ══════════════════════════════
   LOBBY
══════════════════════════════ */
.lobby { max-width: 960px; margin: 0 auto; padding: 32px 16px; }
.lobby-hero { text-align: center; margin-bottom: 32px; }
.dart-icon { font-size: 3.5rem; margin-bottom: 8px; }
.lobby-hero h1 { font-size: 2.5rem; font-weight: 800; color: var(--primary); }
.lobby-hero .subtitle { color: var(--text2); margin-top: 6px; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── PvP Video panel (tt-rtc.js) ── */
.tt-rtc {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 14px;
  margin: 14px 0;
  position: relative;
}
.tt-rtc-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.tt-rtc-title {
  font-size: 0.86rem; font-weight: 700; color: var(--text);
  letter-spacing: 0.04em;
}
.tt-rtc-status {
  font-size: 0.7rem; padding: 3px 8px; border-radius: 12px;
  background: rgba(255,255,255,0.05); color: var(--text2);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.tt-rtc-status[data-state="connected"] { background: rgba(34,197,94,0.15); color: var(--green); }
.tt-rtc-status[data-state="connecting"] { background: rgba(234,179,8,0.15); color: var(--yellow); }
.tt-rtc-status[data-state="error"] { background: rgba(239,68,68,0.15); color: var(--red); }
.tt-rtc-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px; min-height: 40px;
}
.tt-rtc-tile {
  position: relative; aspect-ratio: 4 / 3;
  background: #000; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
}
.tt-rtc-tile video, .tt-rtc-tile audio { width: 100%; height: 100%; object-fit: cover; }
.tt-rtc-tile-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 800; color: var(--text2);
  background: linear-gradient(135deg, var(--bg3), var(--bg2));
}
.tt-rtc-tile video[style*="display: block"] ~ .tt-rtc-tile-placeholder,
.tt-rtc-tile.cam-off .tt-rtc-tile-placeholder { display: flex; }
.tt-rtc-tile-name {
  position: absolute; left: 6px; bottom: 6px;
  font-size: 0.7rem; color: #fff;
  background: rgba(0,0,0,0.55); padding: 2px 6px; border-radius: 4px;
}
.tt-rtc-tile.mic-off::after {
  content: "🔇"; position: absolute; right: 6px; top: 6px;
  font-size: 0.9rem; background: rgba(0,0,0,0.5);
  padding: 2px 4px; border-radius: 4px;
}
.tt-rtc-local-pip {
  position: absolute; right: 12px; top: 38px;
  width: 110px; aspect-ratio: 4/3;
  border-radius: 8px; overflow: hidden;
  border: 2px solid var(--primary);
  background: #000; z-index: 2;
}
.tt-rtc-local-pip video { width: 100%; height: 100%; object-fit: cover; }
.tt-rtc-pip-name {
  position: absolute; left: 4px; bottom: 4px;
  font-size: 0.62rem; color: #fff;
  background: rgba(0,0,0,0.55); padding: 1px 4px; border-radius: 3px;
}
.tt-rtc-controls {
  display: flex; gap: 8px; align-items: center; margin-top: 10px;
  flex-wrap: wrap;
}
.tt-rtc-controls .btn.off { opacity: 0.55; text-decoration: line-through; }
.tt-rtc-hint {
  font-size: 0.7rem; color: var(--text3); margin-top: 6px;
}

/* ── Platform-wide tally banner ── */
.platform-tally {
  margin: 12px 0 24px;
  padding: 18px 18px 20px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(249,115,22,0.10), rgba(168,85,247,0.08) 60%, var(--bg2));
  border: 1px solid var(--border2);
}
.ptally-headline {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px;
  margin-bottom: 14px;
}
.ptally-eyebrow {
  font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text3); font-weight: 700;
}
.ptally-headline-num {
  font-size: 2.4rem; font-weight: 900; color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.ptally-headline-label { font-size: 0.85rem; color: var(--text2); }
.ptally-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.ptally-card {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 10px;
}
.ptally-card[data-mode="301"]     { border-left: 3px solid var(--blue); }
.ptally-card[data-mode="501"]     { border-left: 3px solid var(--green); }
.ptally-card[data-mode="cricket"] { border-left: 3px solid var(--purple); }
.ptally-card-summary { border-left: 3px solid var(--primary); }
.ptally-mode-label {
  font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text3); font-weight: 700; margin-bottom: 4px;
}
.ptally-card-num {
  font-size: 1.4rem; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.ptally-card-sub {
  font-size: 0.72rem; color: var(--text2); margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.ptally-card-rows {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 0.8rem; color: var(--text); font-variant-numeric: tabular-nums;
}
.ptally-card-rows span { color: var(--primary); font-weight: 700; }
@media (max-width: 720px) {
  .ptally-grid { grid-template-columns: repeat(2, 1fr); }
  .ptally-headline-num { font-size: 1.9rem; }
}

/* ── ML accuracy banner ── */
.ml-accuracy {
  margin: 0 0 24px;
  padding: 16px 18px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(59,130,246,0.10), rgba(34,197,94,0.06) 60%, var(--bg2));
  border: 1px solid var(--border2);
}
.mla-headline {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px;
  margin-bottom: 12px;
}
.mla-eyebrow {
  font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text3); font-weight: 700;
}
.mla-headline-num {
  font-size: 2rem; font-weight: 900; color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.mla-headline-label { font-size: 0.85rem; color: var(--text2); }
.mla-trend {
  font-size: 0.78rem; padding: 3px 8px; border-radius: 12px;
  font-weight: 700; margin-left: auto;
}
.mla-trend-up { background: rgba(34,197,94,0.18); color: var(--green); }
.mla-trend-down { background: rgba(239,68,68,0.18); color: var(--red); }
.mla-trend-flat { background: rgba(255,255,255,0.06); color: var(--text2); }
.mla-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.mla-card {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.mla-card-summary { border-left: 3px solid var(--primary); }
.mla-card-label {
  font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text3); font-weight: 700; margin-bottom: 4px;
}
.mla-card-num {
  font-size: 1.3rem; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.mla-card-sub { font-size: 0.7rem; color: var(--text2); margin-top: 3px; }
.mla-card-rows {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 0.78rem; color: var(--text); font-variant-numeric: tabular-nums;
}
.mla-card-rows span { color: var(--primary); font-weight: 700; }
@media (max-width: 720px) {
  .mla-grid { grid-template-columns: repeat(2, 1fr); }
  .mla-headline-num { font-size: 1.6rem; }
}

/* ── Lobby pitch / trust section ── */
.lobby-pitch { margin: 8px 0 32px; }
.pitch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.pitch-card {
  background: var(--bg2, #151a21);
  border: 1px solid var(--border, #2a2f38);
  border-radius: 12px;
  padding: 16px 16px 14px;
}
.pitch-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 6px 0 4px;
  color: var(--text, #e6edf3);
}
.pitch-card p {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text2, #9aa4b2);
  margin: 0;
}
.pitch-icon { font-size: 1.4rem; line-height: 1; }
.pitch-fineprint {
  font-size: 0.76rem !important;
  color: var(--text3, #6e7681) !important;
  margin-top: 10px !important;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.pitch-card-wide {
  grid-column: 1 / -1;
  border-color: #3a3050;
  background: linear-gradient(135deg, rgba(91,70,140,0.12), rgba(21,26,33,1) 60%);
}
@media (max-width: 720px) {
  .pitch-grid { grid-template-columns: 1fr; }
  .pitch-fineprint {
  font-size: 0.76rem !important;
  color: var(--text3, #6e7681) !important;
  margin-top: 10px !important;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.pitch-card-wide { grid-column: auto; }
}

.new-game-card { grid-column: 1 / -1; }
.join-card, .leaderboard-shortcut { }

.mode-select, .cam-type-row { display: flex; gap: 8px; margin-top: 6px; }
.mode-btn, .cam-type-btn {
  flex: 1; padding: 8px; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text); border-radius: 8px;
  cursor: pointer; font-size: 0.9rem; transition: all 0.15s;
}
.mode-btn.active, .cam-type-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.cam-creds-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player-input { margin-bottom: 8px; }
.join-row { display: flex; gap: 8px; margin-top: 12px; }
.join-row input { font-size: 1.2rem; letter-spacing: 4px; text-align: center; }
.leaderboard-shortcut { display: flex; flex-direction: column; justify-content: space-between; }
.leaderboard-shortcut h2 { margin-bottom: 8px; }
.leaderboard-shortcut .hint { margin-bottom: 16px; flex: 1; }

/* Invite Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; text-align: center;
  max-width: 420px; width: 90%;
}
.modal-card h2 { font-size: 1.5rem; margin-bottom: 8px; }
.invite-code {
  font-size: 2.5rem; font-weight: 900; letter-spacing: 10px;
  color: var(--primary); background: var(--bg3);
  border-radius: 10px; padding: 12px 20px; margin: 16px 0;
}
.invite-url-row { display: flex; gap: 8px; margin-bottom: 16px; }
.invite-url-row input { font-size: 0.8rem; color: var(--text2); }
.qr-wrap { display: flex; justify-content: center; margin: 12px 0; }
.qr-wrap img, .qr-wrap canvas { border-radius: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* ══════════════════════════════
   SCOREBOARD (TV)
══════════════════════════════ */
.scoreboard-tv {
  min-height: 100vh; background: #050608;
  display: flex; flex-direction: column;
  color: #fff;
}
.tv-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: rgba(0,0,0,0.6);
  border-bottom: 2px solid var(--primary);
}
.tv-logo { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.tv-mode { font-size: 0.85rem; background: var(--primary); color: #fff; padding: 3px 10px; border-radius: 20px; font-weight: 700; }
.tv-meta { display: flex; align-items: center; gap: 12px; }
.live-badge { color: var(--red); font-size: 0.8rem; font-weight: 700; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.tv-camera-strip {
  display: flex; gap: 16px; padding: 16px 24px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.tv-camera-wrap {
  position: relative; width: 340px; flex-shrink: 0;
  border-radius: 10px; overflow: hidden; background: #0a0a0a;
  aspect-ratio: 4/3;
}
.tv-cam-img { width: 100%; height: 100%; object-fit: cover; display: none; }
.tv-cam-placeholder {
  position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  color: var(--text3); gap: 8px; font-size: 1.5rem;
}
.tv-dart-overlay { position: absolute; top: 8px; left: 8px; display: flex; flex-direction: column; gap: 4px; }
.tv-confidence { position: absolute; bottom: 8px; right: 8px; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.tv-throw-panel { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.throw-label { font-size: 0.7rem; letter-spacing: 2px; color: var(--text3); font-weight: 700; }
.tv-dart-badges { display: flex; gap: 10px; flex-wrap: wrap; }
.tv-dart-badge {
  background: var(--bg3); border: 1px solid var(--border2);
  padding: 8px 14px; border-radius: 8px; font-size: 0.95rem; font-weight: 600;
}
.tv-dart-badge.empty { color: var(--text3); }
.throw-total-row { display: flex; align-items: baseline; gap: 8px; }
.throw-total-label { font-size: 0.7rem; color: var(--text3); letter-spacing: 2px; }
.throw-total-val { font-size: 2rem; font-weight: 900; color: var(--primary); }
.tv-last-analyzed { font-size: 0.75rem; color: var(--text3); }

.tv-players {
  display: flex; gap: 16px; padding: 16px 24px; flex: 1; align-items: stretch;
}
.tv-player-card {
  flex: 1; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: all 0.3s;
}
.tv-player-card.active-player {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(249,115,22,0.3);
  background: rgba(249,115,22,0.08);
}
.tv-player-name { font-size: 1.1rem; font-weight: 700; color: var(--text2); }
.tv-big-score { font-size: 4rem; font-weight: 900; color: var(--text); line-height: 1; }
.tv-score-label { font-size: 0.7rem; color: var(--text3); letter-spacing: 2px; }
.tv-turn-arrow { font-size: 0.75rem; font-weight: 700; color: var(--primary); min-height: 1.2em; }
.tv-cricket-marks { width: 100%; }
.tv-mark-row { display: flex; justify-content: space-between; padding: 2px 0; }
.tv-mark-num { color: var(--text2); font-weight: 600; }
.tv-mark-dots { color: var(--primary); letter-spacing: 2px; }
.tv-cricket-pts { font-size: 1.2rem; font-weight: 700; color: var(--primary); }

.tv-history-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: var(--bg);
  border-top: 1px solid var(--border); font-size: 0.8rem;
}
.history-label { color: var(--text3); font-weight: 700; letter-spacing: 2px; font-size: 0.7rem; flex-shrink: 0; }
.history-ticker { color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tv-winner-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.tv-winner-card { text-align: center; }
.winner-trophy { font-size: 5rem; animation: bounce 0.5s infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-10px); } }
.tv-winner-card h1 { font-size: 4rem; font-weight: 900; color: var(--primary); }
.winner-name { font-size: 2.5rem; font-weight: 700; margin-top: 8px; }

/* ══════════════════════════════
   CAMERA (HOST)
══════════════════════════════ */
.camera-host { display: flex; flex-direction: column; height: calc(100vh - 48px); }
.camera-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: var(--bg2); border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 12px;
}
.cam-header-left { display: flex; align-items: center; gap: 10px; }
.cam-header-center { display: flex; align-items: center; gap: 8px; }
.cam-header-right { display: flex; align-items: center; gap: 10px; }
.dart-icon-sm { font-size: 1.2rem; }
.mode-pill { background: var(--primary); color: #fff; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.invite-pill { font-size: 0.82rem; color: var(--text2); background: var(--bg3); padding: 4px 10px; border-radius: 8px; }

.camera-body { display: flex; flex: 1; overflow: hidden; gap: 0; }
.cam-feed-col {
  display: flex; flex-direction: column;
  width: 52%; border-right: 1px solid var(--border);
  background: #080a0e;
}
.cam-game-col { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.cam-feed-wrap {
  flex: 1; position: relative; background: #050608;
  display: flex; align-items: center; justify-content: center;
}
.cam-placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text3); font-size: 1.2rem; }
.cam-placeholder > div:first-child { font-size: 3rem; }
#phoneVideo { width: 100%; height: 100%; object-fit: cover; }
#ipCamImg { width: 100%; height: 100%; object-fit: contain; }
.confidence-pill { position: absolute; bottom: 10px; right: 10px; padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; display: none; }

.cam-source-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg2); border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.auto-label { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text2); cursor: pointer; }
.auto-label input { width: auto; }
.cam-info { font-size: 0.82rem; color: var(--text2); }
.cam-ai-status { padding: 6px 14px; font-size: 0.75rem; color: var(--text3); background: var(--bg2); border-top: 1px solid var(--border); }

/* Player cards in host view */
.cam-players { display: flex; gap: 10px; flex-wrap: wrap; }
.cam-player-card {
  flex: 1; min-width: 100px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; text-align: center; transition: all 0.2s;
}
.cam-player-card.active-player { border-color: var(--primary); background: rgba(249,115,22,0.1); }
.cam-player-name { font-size: 0.85rem; font-weight: 600; color: var(--text2); display: flex; align-items: center; justify-content: center; gap: 6px; }
.cam-player-connected { font-size: 0.7rem; color: var(--text3); }
.cam-big-score { font-size: 2rem; font-weight: 900; }
.cam-score-label { font-size: 0.65rem; color: var(--text3); letter-spacing: 1px; }
.cam-cricket-pts { font-size: 0.9rem; color: var(--primary); font-weight: 600; }

/* Analysis card */
.cam-analysis-card {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 10px; padding: 14px;
}
.analysis-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; }
.confidence-badge { padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; }
.analysis-darts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.dart-result-badge { background: var(--bg2); border: 1px solid var(--border); padding: 6px 12px; border-radius: 8px; font-size: 0.9rem; }
.analysis-total { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.analysis-note { font-size: 0.8rem; color: var(--text3); margin-bottom: 10px; }
.analysis-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Correction panel */
.correction-panel { background: var(--bg3); border: 1px solid var(--yellow); border-radius: 10px; padding: 14px; }
.correction-panel h4 { margin-bottom: 10px; color: var(--yellow); }
.correction-dart-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.correction-dart-row label { width: 50px; flex-shrink: 0; color: var(--text2); }
.correction-dart-row input, .correction-dart-row select { width: auto; flex: 1; }
.correction-total { font-size: 1rem; font-weight: 600; margin: 10px 0 8px; }
.correction-actions { display: flex; gap: 8px; margin-top: 8px; }
.corrections-count { font-size: 0.78rem; color: var(--text3); margin-top: 8px; }

/* History table */
.cam-history h4 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.history-count { font-size: 0.8rem; color: var(--text3); }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.history-table th { color: var(--text3); padding: 5px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.history-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.dart-list { color: var(--text2); font-size: 0.78rem; }
.conf-xs { padding: 1px 5px; border-radius: 6px; font-size: 0.65rem; font-weight: 700; }

/* ══════════════════════════════
   REMOTE CONTROLLER
══════════════════════════════ */
.remote-app {
  min-height: 100vh; background: var(--bg);
  max-width: 480px; margin: 0 auto;
}
.remote-screen { display: flex; flex-direction: column; min-height: 100vh; padding: 16px; gap: 16px; }
.remote-hero { text-align: center; padding: 24px 0 8px; }
.remote-hero .dart-icon { font-size: 2.5rem; }
.remote-hero h2 { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.remote-join-card { }
.join-code-display {
  font-size: 2rem; font-weight: 900; letter-spacing: 8px; color: var(--primary);
  text-align: center; margin-bottom: 12px;
}
.join-status { color: var(--text2); font-size: 0.85rem; text-align: center; min-height: 1.2em; margin-top: 6px; }

/* Player screen */
.remote-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.remote-player-name { font-size: 1.1rem; font-weight: 700; }
.remote-game-mode { font-size: 0.78rem; background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 10px; }
.conn-indicator { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--text2); }

.remote-score-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; text-align: center;
  position: relative;
}
.remote-score-label { font-size: 0.72rem; letter-spacing: 2px; color: var(--text3); margin-bottom: 4px; }
.remote-big-score { font-size: 4.5rem; font-weight: 900; line-height: 1; color: var(--text); }
.remote-turn-banner {
  margin-top: 12px; background: var(--primary); color: #fff;
  border-radius: 8px; padding: 8px; font-weight: 700;
  font-size: 1rem; letter-spacing: 1px;
  animation: glow 1s infinite alternate;
}
@keyframes glow { from { box-shadow: 0 0 5px var(--primary); } to { box-shadow: 0 0 20px var(--primary); } }

.remote-round-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
}
.remote-round-label { font-size: 0.7rem; letter-spacing: 2px; color: var(--text3); margin-bottom: 10px; }
.remote-dart-badges { display: flex; gap: 8px; margin-bottom: 8px; }
.remote-dart-badge {
  flex: 1; background: var(--bg3); border: 1px solid var(--border2);
  padding: 8px; border-radius: 8px; text-align: center; font-size: 0.85rem; font-weight: 600;
}
.remote-dart-badge.empty { color: var(--text3); }
.remote-round-total { font-size: 0.9rem; color: var(--text2); }
.remote-round-total strong { color: var(--primary); }

.remote-analysis-feed {
  background: var(--bg2); border: 1px solid var(--blue);
  border-radius: 12px; padding: 14px;
}
.analysis-feed-header { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: 600; }
.conf-pill { padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; }
.remote-analysis-darts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.remote-analysis-total { font-size: 0.9rem; margin-bottom: 10px; }
.remote-analysis-total strong { color: var(--primary); }
.remote-correction-toggle { margin-top: 8px; }
.remote-correction-form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.remote-correction-form .hint { margin-bottom: 8px; }
.remote-correction-form textarea { margin: 8px 0; }

.remote-all-players {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px;
}
.all-players-label { font-size: 0.7rem; letter-spacing: 2px; color: var(--text3); margin-bottom: 10px; }
.all-player-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.all-player-row:last-child { border-bottom: none; }
.all-player-row.active-row { color: var(--primary); }
.all-player-indicator { width: 14px; font-size: 0.7rem; color: var(--primary); }
.all-player-name { flex: 1; font-weight: 600; }
.all-player-score { font-size: 0.9rem; color: var(--text2); }

.remote-chat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; flex-shrink: 0;
}
.remote-chat-messages { height: 100px; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.chat-msg { font-size: 0.82rem; }
.chat-from { font-weight: 700; color: var(--primary); }
.chat-text { color: var(--text2); }
.remote-chat-input-row { display: flex; border-top: 1px solid var(--border); }
.remote-chat-input-row input { border: none; border-radius: 0; background: var(--bg3); }
.remote-chat-input-row .btn { border-radius: 0; border: none; border-left: 1px solid var(--border); }

/* ══════════════════════════════
   LEADERBOARD
══════════════════════════════ */
.leaderboard-app { max-width: 900px; margin: 0 auto; padding: 28px 16px; }
.lb-header { text-align: center; margin-bottom: 24px; }
.lb-header h1 { font-size: 2rem; font-weight: 800; }
.lb-header .subtitle { color: var(--text2); margin: 6px 0 14px; }

.lb-stats-bar { display: flex; gap: 16px; margin-bottom: 24px; }
.lb-stat {
  flex: 1; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px; text-align: center;
}
.lb-stat span { display: block; font-size: 2rem; font-weight: 900; color: var(--primary); }
.lb-stat label { font-size: 0.78rem; color: var(--text3); margin-top: 2px; }

.lb-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 1px; }
.lb-tab {
  padding: 8px 16px; border: none; background: none;
  color: var(--text2); cursor: pointer; font-size: 0.9rem; border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent; transition: all 0.15s;
}
.lb-tab:hover { color: var(--text); }
.lb-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.lb-tab-content { display: none; }
.lb-tab-content.active { display: block; }
.lb-loading, .lb-empty { color: var(--text3); text-align: center; padding: 40px; }

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th { color: var(--text3); font-size: 0.78rem; letter-spacing: 1px; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.lb-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.lb-table tr:hover td { background: var(--bg2); }
.rank-num { font-size: 1.1rem; }
.player-name-cell { font-weight: 600; }
.wins { color: var(--green); font-weight: 700; }
.losses { color: var(--text3); }
.win-rate-pill { background: var(--bg3); border: 1px solid var(--border2); padding: 2px 8px; border-radius: 10px; font-size: 0.82rem; }
.top-1 td { color: #ffd700; }
.top-2 td { color: #c0c0c0; }
.top-3 td { color: #cd7f32; }

.recent-game-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
}
.rg-left { display: flex; align-items: center; gap: 10px; }
.rg-mode { background: var(--bg3); border: 1px solid var(--border2); padding: 2px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.rg-players { font-weight: 600; }
.rg-right { display: flex; align-items: center; gap: 10px; }
.rg-winner { font-size: 0.9rem; }
.rg-date { font-size: 0.8rem; color: var(--text3); }

.h2h-search { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.h2h-search span { color: var(--text3); font-weight: 700; flex-shrink: 0; }
.h2h-result-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.h2h-score-row { display: flex; align-items: center; justify-content: center; gap: 32px; margin-bottom: 20px; }
.h2h-player { text-align: center; }
.h2h-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.h2h-wins { font-size: 3rem; font-weight: 900; color: var(--primary); }
.h2h-vs { font-size: 1rem; color: var(--text3); font-weight: 700; }
.h2h-game-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }

.learning-hero { text-align: center; padding: 24px 0; }
.learning-count { font-size: 4rem; font-weight: 900; color: var(--primary); }
.learning-label { color: var(--text2); margin-bottom: 8px; }
.correction-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.corr-row { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.corr-label { font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; flex-shrink: 0; }
.ai-label { background: var(--red); color: #fff; }
.fix-label { background: var(--green); color: #fff; }
.corr-darts { font-size: 0.88rem; color: var(--text2); }
.corr-note { font-size: 0.82rem; color: var(--text3); font-style: italic; margin: 4px 0; }
.corr-time { font-size: 0.75rem; color: var(--text3); }

/* ══════════════════════════════
   TV FEEDS ROW — Per-player cameras
══════════════════════════════ */
.tv-feeds-row {
  display: flex; gap: 12px; padding: 12px 24px;
  background: #080a0e; border-bottom: 1px solid var(--border);
}
.tv-feed-slot {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  transition: all 0.3s;
}
.tv-feed-slot.active-feed .tv-feed-wrap {
  border-color: var(--primary);
  box-shadow: 0 0 14px rgba(249,115,22,0.4);
}
.tv-feed-name {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 1px;
  color: var(--text3); text-align: center;
}
.tv-feed-wrap {
  position: relative; background: #050608;
  border-radius: 8px; border: 1px solid var(--border);
  overflow: hidden; aspect-ratio: 4/3;
  display: flex; align-items: center; justify-content: center;
}
.tv-feed-img { width: 100%; height: 100%; object-fit: cover; }

/* Per-player face-cam PiP layered over the dartboard feed.
   Empty slot is invisible; once tt-rtc injects a <video>, the box appears.
   Position: bottom-right by default; move to bottom-left for the active
   player so the turn arrow / score doesn't overlap the face. */
.tv-facecam {
  position: absolute; right: 6px; bottom: 6px;
  width: 28%; aspect-ratio: 4 / 3;
  border-radius: 6px; overflow: hidden;
  background: transparent;
  border: 0; pointer-events: none;
  z-index: 3;
}
.tv-facecam:has(video) {
  background: #000;
  border: 2px solid rgba(249,115,22,0.7);
  box-shadow: 0 2px 8px rgba(0,0,0,0.55);
}
.tv-facecam video.tt-rtc-slot-video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.tv-facecam.cam-off video.tt-rtc-slot-video { display: none; }
.tv-facecam.cam-off:has(audio) {
  background: rgba(0,0,0,0.6);
  border: 2px solid var(--border2);
}
.tv-facecam.cam-off:has(audio)::after {
  content: '🎤'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.tv-facecam.mic-off::before {
  content: '🔇'; position: absolute; right: 4px; top: 4px;
  font-size: 0.85rem; background: rgba(0,0,0,0.65);
  padding: 1px 4px; border-radius: 4px; z-index: 4;
}
.tv-feed-placeholder {
  color: var(--text3); font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.tv-feed-conf {
  position: absolute; bottom: 4px; right: 4px;
  font-size: 0.62rem; font-weight: 700; padding: 1px 6px;
  border-radius: 8px;
}
.tv-feed-darts {
  display: flex; gap: 4px;
}
.tv-feed-darts .tv-dart-badge {
  flex: 1; font-size: 0.72rem; padding: 4px 6px; text-align: center;
}
.tv-conn-count {
  font-size: 0.75rem; color: var(--green);
}

/* ══════════════════════════════
   REMOTE CAMERA CARD
══════════════════════════════ */
.remote-camera-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.rcam-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.rcam-title { font-weight: 600; font-size: 0.9rem; }
.rcam-status { font-size: 0.75rem; color: var(--text3); }
.rcam-status.dot-green { color: var(--green); }
.rcam-status.dot-yellow { color: var(--yellow); }
.rcam-status.dot-red { color: var(--red); }
.rcam-status.dot-waiting { color: var(--text3); }
.rcam-feed-wrap {
  position: relative; background: #050608;
  min-height: 180px; display: flex;
  align-items: center; justify-content: center;
}
.rcam-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; color: var(--text3); font-size: 0.9rem; padding: 24px;
}
.rcam-placeholder span:first-child { font-size: 2rem; }
.rcam-confidence {
  display: none; position: absolute; bottom: 6px; right: 6px;
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 10px;
}
.rcam-controls {
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: var(--bg3);
}
.rcam-action-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: var(--bg3);
}
.rcam-last-analyzed { font-size: 0.72rem; color: var(--text3); margin-left: auto; }

/* ══════════════════════════════
   REMOTE MANUAL SCORE ENTRY
══════════════════════════════ */
.remote-manual-entry {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 12px; padding: 14px;
}
.manual-entry-label {
  font-size: 0.7rem; letter-spacing: 2px; color: var(--text3);
  margin-bottom: 12px; font-weight: 700;
}
.manual-dart-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.manual-dart-row label { width: 44px; flex-shrink: 0; font-size: 0.8rem; }
.manual-dart-row .manual-seg { width: 64px; flex-shrink: 0; }
.manual-dart-row .manual-ring { flex: 1; }
.manual-total-row {
  font-size: 0.95rem; color: var(--text2);
  margin: 10px 0 2px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.manual-total-row strong { color: var(--primary); font-size: 1.1rem; }

/* Join screen cam source choice */
.cam-source-choice { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ══════════════════════════════
   LOBBY — LIVE EVENTS SECTION
══════════════════════════════ */
.live-section {
  max-width: 1200px;
  margin: 0 auto 32px;
  padding: 0 16px;
}
.live-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.live-section-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}
.live-badge-lg {
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 700;
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}
.live-count {
  font-size: 0.8rem;
  color: var(--text3);
  margin-left: auto;
}

/* Live empty state */
.live-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px;
  background: var(--bg2);
  border: 1px dashed var(--border2);
  border-radius: var(--card-radius);
  color: var(--text3);
  text-align: center;
}

/* Grid of live game cards */
.live-games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Individual live game card */
.live-game-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.live-game-card:hover {
  border-color: var(--border2);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.lgc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.lgc-mode {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--primary);
}
.lgc-status {
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: auto;
}
.status-active {
  color: var(--green);
  animation: pulse 1.5s infinite;
}
.status-waiting {
  color: var(--text3);
}
.lgc-rounds {
  font-size: 0.72rem;
  color: var(--text3);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 8px;
}

/* Camera thumbnail */
.lgc-feed-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: #050608;
  overflow: hidden;
}
.lgc-feed-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lgc-feed-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text3);
  font-size: 0.8rem;
}
.lgc-feed-placeholder span:first-child { font-size: 1.8rem; }

.lgc-dart-overlay {
  position: absolute;
  bottom: 6px;
  left: 6px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.lgc-dart-badge {
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
}

/* Scoreboard strip */
.lgc-scoreboard {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.lgc-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.lgc-player.lgc-active-player {
  background: rgba(249,115,22,0.12);
}
.lgc-player-name {
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lgc-player-score {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}
.lgc-active-player .lgc-player-score {
  color: var(--primary);
}
.lgc-turn-dot {
  font-size: 0.65rem;
  color: var(--primary);
  flex-shrink: 0;
}

/* Last round line */
.lgc-last-round {
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
.lgc-last-round strong { color: var(--primary); }

/* Card action buttons */
.lgc-actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg3);
}
.lgc-actions .btn { flex: 1; justify-content: center; }

/* ── Lobby layout adjustments ── */
.lobby {
  max-width: 100%;
  padding: 0;
}
.lobby-hero {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 16px;
  text-align: center;
}
.lobby-grid {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 40px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.lobby-side-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.join-card .join-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.new-game-card { }

@media (max-width: 760px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
  .live-games-grid {
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════
   TOP BAR — user menu
══════════════════════════════ */
.dash-btn { gap: 4px; }
.user-menu-wrap { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 5px 10px; border-radius: 8px;
  cursor: pointer; font-size: 0.85rem;
}
.user-menu-btn:hover { background: var(--border2); }
.user-menu-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-chevron { font-size: 0.65rem; color: var(--text3); }
.user-avatar { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }
.user-avatar-lg { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }

.user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; min-width: 220px; z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: none; flex-direction: column; overflow: hidden;
}
.user-dropdown.open { display: flex; }
.user-dropdown-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.user-dropdown-name  { font-weight: 700; font-size: 0.9rem; }
.user-dropdown-email { font-size: 0.75rem; color: var(--text3); }
.dropdown-item {
  display: block; padding: 10px 16px; text-decoration: none;
  color: var(--text); font-size: 0.875rem; transition: background 0.1s;
}
.dropdown-item:hover { background: var(--bg3); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-item-danger { color: var(--red); }
.dropdown-item-danger:hover { background: rgba(239,68,68,0.1); }

/* ══════════════════════════════
   GLOBAL TURN TOAST
══════════════════════════════ */
#turnToastContainer {
  position: fixed; top: 60px; right: 16px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.tt-toast {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
  min-width: 280px; max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  display: flex; align-items: flex-start; gap: 12px;
  pointer-events: all;
  opacity: 0; transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
}
.tt-toast-visible { opacity: 1; transform: translateX(0); }
.tt-toast-turn   { border-color: var(--primary); }
.tt-toast-info   { border-color: var(--blue); }
.tt-toast-body   { flex: 1; }
.tt-toast-msg    { font-weight: 700; font-size: 0.95rem; }
.tt-toast-sub    { font-size: 0.8rem; color: var(--text2); margin-top: 2px; }
.tt-toast-actions { display: flex; gap: 8px; margin-top: 10px; }
.tt-toast-btn {
  display: inline-block; padding: 5px 12px; border-radius: 7px;
  font-size: 0.8rem; text-decoration: none; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text); cursor: pointer;
}
.tt-toast-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.tt-toast-close {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 0.85rem; padding: 0; flex-shrink: 0;
}
.tt-toast-close:hover { color: var(--text); }

/* Mini toast (inline feedback) */
.mini-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--bg2); border: 1px solid var(--border);
  padding: 8px 18px; border-radius: 20px; font-size: 0.85rem;
  opacity: 0; transition: all 0.3s; z-index: 9999; pointer-events: none;
}
.mini-toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════════════════════════
   DASHBOARD
══════════════════════════════ */
.dashboard { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }

.dash-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 16px;
}
.dash-header-left { display: flex; align-items: center; gap: 16px; }
.dash-avatar { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--primary); }
.dash-header h1 { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.dash-email { font-size: 0.8rem; color: var(--text3); margin-top: 2px; }
.dash-header-right { display: flex; gap: 10px; }

.dash-stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.dash-stat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; text-align: center;
}
.dash-stat span { display: block; font-size: 2rem; font-weight: 900; color: var(--primary); line-height: 1; }
.dash-stat label { font-size: 0.72rem; color: var(--text3); margin-top: 4px; display: block; }

.dash-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.dash-tab {
  padding: 8px 18px; background: none; border: none; color: var(--text2);
  cursor: pointer; font-size: 0.9rem; border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0; transition: all 0.15s;
}
.dash-tab:hover { color: var(--text); }
.dash-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.dash-tab-content { display: none; }
.dash-tab-content.active { display: block; }
.dash-loading, .dash-empty { padding: 40px; text-align: center; color: var(--text3); }

.dash-section { margin-bottom: 20px; }
.dash-section-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 1.5px;
  padding: 4px 0 8px; color: var(--text3);
}
.section-active  .dash-section-label { color: var(--green); }
.section-waiting .dash-section-label { color: var(--yellow); }
.section-finished,.section-archived  { opacity: 0.7; }

/* ── Game row — responsive layout ── */
.dash-game-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 8px;
  transition: border-color 0.2s;
}
.dash-game-row:hover { border-color: var(--border2); }
.my-turn-row {
  border-color: var(--primary) !important;
  box-shadow: 0 0 16px rgba(249,115,22,0.2);
  background: rgba(249,115,22,0.05);
}
.dg-left  { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.dg-name  { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-meta  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dg-status { font-size: 0.75rem; font-weight: 600; }
.status-active   { color: var(--green); animation: pulse 1.5s infinite; }
.status-waiting  { color: var(--yellow); }
.status-idle     { color: #b58cff; }
.status-finished { color: var(--text3); }
.status-archived { color: var(--text3); }
.section-idle    { color: #b58cff; }
.dg-mode   { font-size: 0.72rem; color: var(--primary); font-weight: 700; }
.dg-rounds { font-size: 0.72rem; color: var(--text3); }
.dg-time   { font-size: 0.72rem; color: var(--text3); margin-left: auto; }
.dg-scores { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.82rem; }
.dg-player { color: var(--text2); }
.dg-player-active { color: var(--primary); font-weight: 700; }
.dg-turn-banner {
  display: inline-block; background: var(--primary); color: #fff;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 1px;
  padding: 3px 10px; border-radius: 6px; animation: glow 1s infinite alternate;
}

/* Actions: single column of buttons, right-aligned */
.dg-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 90px;
  max-width: 110px;
}
.dg-actions .btn {
  width: 100%;
  justify-content: center;
}

/* On wider screens, let actions sit in a row if there's space */
@media (min-width: 600px) {
  .dg-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    min-width: unset;
    max-width: unset;
  }
  .dg-actions .btn {
    width: auto;
  }
}

/* Settings */
.settings-card { }
.settings-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer;
  gap: 12px;
}
.toggle-row:last-of-type { border-bottom: none; }
.toggle-row > span { flex: 1; }
.toggle-row strong { display: block; font-size: 0.9rem; }
.toggle-row .hint  { display: block; margin-top: 2px; }
.toggle-input { display: none; }
.toggle-slider {
  width: 42px; height: 24px; background: var(--bg3);
  border: 1px solid var(--border2); border-radius: 12px;
  position: relative; flex-shrink: 0; cursor: pointer; transition: background 0.2s;
}
.toggle-slider::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; background: var(--text3);
  border-radius: 50%; transition: transform 0.2s, background 0.2s;
}
.toggle-input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle-input:checked + .toggle-slider::after { transform: translateX(18px); background: #fff; }
.settings-row { display: flex; flex-direction: column; gap: 6px; }
.save-confirm { font-size: 0.85rem; }

/* ══════════════════════════════
   KICK/PLAYER MODAL
══════════════════════════════ */
.kick-player-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.kick-player-row:last-child { border-bottom: none; }
.kick-player-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.linked-badge   { font-size: 0.68rem; background: var(--green);  color:#fff; padding:1px 6px; border-radius:6px; }
.unlinked-badge { font-size: 0.68rem; background: var(--text3);  color:#fff; padding:1px 6px; border-radius:6px; }

/* dash-empty flex */
.dash-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; }

/* section-label colours */
.section-active  { color: var(--green)  !important; }
.section-waiting { color: var(--yellow) !important; }

/* ══════════════════════════════
   MISSING / SUPPLEMENTAL STYLES
══════════════════════════════ */
.corr-seg {
  width: 64px; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 6px 8px; border-radius: 6px;
  font-size: 0.88rem; text-align: center;
}
.corr-ring {
  flex: 1;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 6px 8px; border-radius: 6px;
  font-size: 0.88rem;
}
.ng-player { display: block; width: 100%; margin-bottom: 8px; }
.h2h-history { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 8px; }
.learning-stats { }
.manual-dart-inputs { display: flex; flex-direction: column; gap: 6px; }
.rcam-status.dot-green  { color: var(--green);  }
.rcam-status.dot-yellow { color: var(--yellow); }
.rcam-status.dot-red    { color: var(--red);    }
#joinCode { text-transform: uppercase; }
#hostedEmpty, #joinedEmpty { flex-direction: column; align-items: center; gap: 10px; padding: 40px; text-align: center; }

/* ── Toast icon slot ── */
.tt-toast-icon { font-size: 1.4rem; flex-shrink: 0; line-height: 1; padding-top: 2px; }

/* ══════════════════════════════
   BUST BANNER
══════════════════════════════ */
.bust-banner {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--red); color: #fff;
  font-size: 1.2rem; font-weight: 800; text-align: center;
  padding: 12px; letter-spacing: 1px;
  animation: burstIn 0.2s ease-out; z-index: 20;
}
@keyframes burstIn { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }

.tv-game-title {
  font-size: 0.9rem; font-weight: 600; color: var(--text2);
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lgc-title {
  flex: 1; font-size: 0.78rem; font-weight: 600; color: var(--text2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}

/* ══════════════════════════════
   REMOTE — cricket marks
══════════════════════════════ */
.remote-cricket-marks { width: 100%; margin: 8px 0 4px; }
.rcm-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
.rcm-row:last-child { border-bottom: none; }
.rcm-num  { color: var(--text2); font-weight: 700; min-width: 36px; }
.rcm-dots { color: var(--primary); letter-spacing: 3px; font-size: 1rem; }

/* ══════════════════════════════
   RESPONSIVE — global breakpoints
══════════════════════════════ */
@media (max-width: 600px) {
  /* Stats bar: 2x2 grid on small phones */
  .dash-stats-bar {
    grid-template-columns: 1fr 1fr;
  }

  /* Game row: stack info and actions vertically */
  .dash-game-row {
    grid-template-columns: 1fr;
  }
  .dg-actions {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: unset;
    max-width: unset;
  }
  .dg-actions .btn {
    width: auto;
    flex: 1 1 auto;
  }

  /* Header: stack on very small screens */
  .dash-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .dash-header-right {
    width: 100%;
    justify-content: flex-end;
  }

  /* Tabs: smaller padding */
  .dash-tab { padding: 8px 12px; font-size: 0.82rem; }

  /* Modal: full-width on mobile */
  .modal-card { padding: 24px 16px; }

  /* Lobby responsive */
  .lobby-grid { grid-template-columns: 1fr; }
  .new-game-card { grid-column: auto; }

  /* Camera body stacks */
  .camera-body { flex-direction: column; }
  .cam-feed-col { width: 100%; border-right: none; border-bottom: 1px solid var(--border); height: 55vw; min-height: 200px; flex: none; }

  /* TV views */
  .tv-camera-strip { flex-direction: column; }
  .tv-camera-wrap { width: 100%; }
  .tv-players { flex-direction: column; }

  /* Leaderboard */
  .lb-stats-bar { flex-direction: column; }
}

@media (max-width: 400px) {
  /* Very small: single-column stats */
  .dash-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-stat span { font-size: 1.6rem; }
}

/* ══════════════════════════════
   CAMERA — SPLIT / SAME-LOCATION MODE
══════════════════════════════ */

/* Source bar layout tweak */
.cam-source-bar { flex-wrap: wrap; gap: 8px; }
#singleControls, #splitControls { display: flex; align-items: center; gap: 8px; }
.same-loc-label { font-size: 0.85rem; background: var(--bg3); border: 1px solid var(--border2); padding: 5px 10px; border-radius: 6px; gap: 6px; }

/* Split feed container — mirrors .cam-feed-wrap sizing */
.cam-split-wrap {
  flex: 1;
  position: relative;
  background: #050608;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  min-height: 180px;
}

/* Each half */
.cam-split-half {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  transition: background 0.2s;
}
.cam-split-half.split-analyzing {
  background: rgba(249, 115, 22, 0.15);
}

/* Player label strip at bottom of each half */
.split-label {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* Corner confidence badge per half */
.split-conf {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  z-index: 10;
}

/* Crop guide — subtle dashed box showing active area */
.split-crop-indicator {
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 6px;
  pointer-events: none;
  z-index: 5;
}

/* Divider line between halves */
.cam-split-divider {
  width: 2px;
  background: var(--primary);
  opacity: 0.7;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
.cam-split-divider::before {
  content: '⟷';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.6rem;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Split analysis cards sit side by side on wider screens */
.split-analysis-card {
  border-left: 3px solid var(--primary);
}
#analysisCardLeft  { border-left-color: var(--blue); }
#analysisCardRight { border-left-color: var(--green); }

@media (max-width: 600px) {
  /* On mobile the split-wrap stacks the halves vertically */
  .cam-split-wrap { flex-direction: column; }
  .cam-split-divider { width: 100%; height: 2px; }
  .cam-split-divider::before { content: '⟵⟶'; top: 50%; left: 50%; }
}

/* ══════════════════════════════
   CAMERA v2 — FULL REDESIGN
══════════════════════════════ */

/* Whole page is the camera — fill viewport, no scroll */
.camera-host {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);   /* 48px = top-bar */
  background: #050608;
  overflow: hidden;
}

/* ── Top bar ── */
.cam-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(13,15,20,0.95);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
  z-index: 30;
}
.cam-top-left  { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cam-top-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cam-game-title {
  font-size: 0.85rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.cam-status-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.72rem; color: var(--text2);
}
.cam-icon-btn {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; flex-shrink: 0; transition: background 0.15s;
}
.cam-icon-btn:hover { background: var(--border2); }

/* ── Feed area — fills all available vertical space ── */
.cam-feed-area {
  flex: 1;
  position: relative;
  background: #050608;
  overflow: hidden;
  min-height: 0;
}

/* Feed wrap now fills the area */
.cam-feed-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050608;
}
.cam-feed-wrap video,
.cam-feed-wrap #phoneVideo {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.cam-feed-wrap #ipCamImg {
  width: 100%; height: 100%;
  object-fit: contain;
  display: none;
}

/* ── Start overlay — centred on top of feed ── */
.cam-start-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,6,8,0.82);
  backdrop-filter: blur(4px);
}
.cam-start-inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 32px 24px;
}
.cam-start-icon { font-size: 3rem; opacity: 0.6; }
.cam-start-info { font-size: 0.85rem; color: var(--text2); }

/* ── HUD — overlaid on the live feed ── */
.cam-hud {
  position: absolute; inset: 0; z-index: 15;
  display: flex; flex-direction: column;
  justify-content: space-between;
  pointer-events: none;      /* clicks pass through to video by default */
}
.cam-hud > * { pointer-events: all; }

/* Score strip at the top of the feed */
.hud-scores {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, transparent 100%);
}
.hud-player {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 6px 8px;
  position: relative; transition: all 0.2s;
}
.hud-player.hud-active {
  background: rgba(249,115,22,0.25);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(249,115,22,0.35);
}
.hud-player-name {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.5px;
  color: rgba(255,255,255,0.7); text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.hud-player-score {
  font-size: 1.7rem; font-weight: 900; line-height: 1; color: #fff;
}
.hud-player.hud-active .hud-player-score { color: var(--primary); }
.hud-score-unit { font-size: 0.6rem; font-weight: 400; color: rgba(255,255,255,0.5); margin-left: 2px; }
.hud-conn-dot {
  width: 6px; height: 6px; border-radius: 50%;
  position: absolute; top: 5px; right: 5px;
  background: transparent;
  transition: background 0.3s;
}

/* Turn banner — thin strip at bottom of scores */
.hud-turn-banner {
  text-align: center;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 1px;
  color: var(--primary); background: rgba(0,0,0,0.55);
  padding: 4px 0;
  display: none;
}

/* Confidence badge floating top-right */
.hud-conf {
  position: absolute; top: 8px; right: 10px; z-index: 5;
  font-size: 0.65rem; font-weight: 700; padding: 2px 8px;
  border-radius: 10px;
}

/* Result card — slides up from bottom of feed */
.hud-result-card {
  margin: 0 8px 8px;
  background: rgba(13,15,20,0.9);
  border: 1px solid var(--border2);
  border-radius: 12px; padding: 12px 14px;
  backdrop-filter: blur(8px);
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.hud-result-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.hud-result-label { font-size: 0.65rem; font-weight: 700; letter-spacing: 1.5px; color: var(--text3); }
.hud-result-badge { font-size: 0.65rem; font-weight: 700; padding: 1px 7px; border-radius: 8px; }
.hud-result-darts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.hud-dart-badge {
  background: var(--bg3); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 7px;
  font-size: 0.82rem; font-weight: 700; color: var(--text);
}
.hud-dart-badge em { font-style: normal; color: var(--primary); margin-left: 3px; font-size: 0.75rem; }
.hud-result-total { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.hud-result-note  { font-size: 0.72rem; color: var(--text3); margin-bottom: 8px; }
.hud-result-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Bust banner */
.bust-banner {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 25;
  background: var(--red); color: #fff;
  font-size: 1.4rem; font-weight: 900; text-align: center;
  padding: 14px; letter-spacing: 2px;
  animation: burstIn 0.2s ease-out;
}

/* ── Control bar ── */
.cam-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(13,15,20,0.97);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  z-index: 30;
}
.cam-ctrl-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cam-ctrl-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cam-ctrl-group { display: flex; align-items: center; gap: 6px; }
.cam-capture-btn { font-size: 0.85rem; padding: 7px 14px; }

.cam-ctrl-toggle {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; font-size: 0.78rem; color: var(--text2);
  background: var(--bg3); border: 1px solid var(--border2);
  padding: 5px 10px; border-radius: 6px;
  user-select: none;
}
.cam-ctrl-toggle input { display: none; }
.cam-ctrl-toggle input:checked ~ .cam-ctrl-toggle-label { color: var(--primary); font-weight: 700; }
.cam-ctrl-toggle-label { pointer-events: none; }

.cam-ai-chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.72rem; color: var(--text3);
}
.ai-chip-dot { font-size: 0.75rem; }
.ai-chip-time { font-variant-numeric: tabular-nums; }

/* ── Expandable panel (drawer below control bar) ── */
.cam-panel {
  max-height: 45vh;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  flex-shrink: 0;
  z-index: 25;
}
.cam-panel-scores {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.panel-player-card {
  flex: 1; min-width: 80px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; text-align: center;
  transition: all 0.2s;
}
.panel-player-card.active-player { border-color: var(--primary); background: rgba(249,115,22,0.08); }
.cam-panel-meta { font-size: 0.72rem; color: var(--text3); padding: 4px 0; }

/* ── Share modal links ── */
.share-link-row {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin-bottom: 10px;
}
.share-link-label { font-weight: 700; font-size: 0.9rem; margin-bottom: 2px; }
.share-link-sub   { font-size: 0.75rem; color: var(--text3); margin-bottom: 8px; }
.share-link-actions { display: flex; gap: 6px; align-items: center; }
.share-link-actions input { font-size: 0.72rem; color: var(--text2); flex: 1; }

/* ── Landscape: 1fr 1fr grid — camera | scoring ──
   Applies to any landscape viewport (phones included) so the dartboard
   feed and the scoring drawer sit side-by-side. */
@media (orientation: landscape) {
  .camera-host {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "top    top"
      "feed   panel"
      "ctrl   ctrl";
    height: 100vh;
  }
  .cam-top-bar     { grid-area: top;   }
  .cam-feed-area   { grid-area: feed;  height: auto; min-height: 0; }
  .cam-panel       {
    grid-area: panel;
    max-height: none;
    height: 100%;
    border-top: none;
    border-left: 1px solid var(--border);
    width: auto;
  }
  .cam-control-bar { grid-area: ctrl;  }
}

/* On wider landscape screens (tablet/desktop) the scoring side can be
   a touch narrower so the camera feed gets more room. */
@media (min-width: 1024px) and (orientation: landscape) {
  .camera-host {
    grid-template-columns: 1.4fr 1fr;
  }
}

/* ── Small phones: compact control bar ── */
@media (max-width: 420px) {
  .cam-game-title { max-width: 110px; }
  .cam-capture-btn { padding: 7px 10px; font-size: 0.78rem; }
  .hud-player-score { font-size: 1.4rem; }
}

/* Skip camera button */
.cam-skip-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  font-size: 0.75rem;
  padding: 5px 14px;
}
.cam-skip-btn:hover { color: var(--text2); border-color: var(--border2); background: transparent; }

/* ══════════════════════════════
   CAMERA TUNING PANEL
══════════════════════════════ */

/* Active state for icon buttons */
.cam-icon-btn-active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

/* Tuning panel — slides in over the feed from the right */
.tuning-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(300px, 88vw);
  background: rgba(13,15,20,0.97);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInRight 0.2s ease-out;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.tuning-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tuning-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}
.tuning-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.tuning-close:hover { color: var(--text); background: var(--bg3); }

.tuning-rows {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Individual control row */
.tune-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tune-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tune-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.3px;
}
.tune-value {
  font-size: 0.72rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}

/* Range slider */
.tune-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  padding: 0;
  border: none;
}
.tune-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(249,115,22,0.5);
}
.tune-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}

/* Toggle option buttons */
.tune-options {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tune-opt {
  flex: 1;
  padding: 5px 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-size: 0.72rem;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: all 0.12s;
  min-width: 0;
}
.tune-opt:hover { background: var(--border2); color: var(--text); }
.tune-opt.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Empty state */
.tune-empty {
  color: var(--text3);
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 8px 0;
}

/* ══════════════════════════════
   BOARD FRAMING GUIDE
══════════════════════════════ */

.board-guide {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.board-guide-svg {
  width: min(85%, 85vh);
  height: min(85%, 85vh);
  max-width: 480px;
  max-height: 480px;
  filter: drop-shadow(0 0 8px rgba(249,115,22,0.3));
}
.board-guide-label {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  color: rgba(255,255,255,0.75);
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 10px;
  white-space: nowrap;
  pointer-events: none;
}

/* ══════════════════════════════
   UNIFIED SCORE ENTRY FORM
══════════════════════════════ */

/* Panel is always visible — no toggle needed for the entry card.
   IMPORTANT: keep max-height so the camera feed retains its space.
   In portrait, cap the panel at ~45vh and let it scroll internally.
   In landscape the media query below switches to side-by-side. */
.cam-panel {
  max-height: 45vh;
  overflow-y: auto;
}

/* Guarantee the feed area keeps a usable size even when the score
   entry card is open on small/short screens. */
.cam-feed-area {
  min-height: 220px;
}

@media (orientation: portrait) and (max-height: 720px) {
  .cam-panel { max-height: 38vh; }
}



/* Score entry card */
.score-entry-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 14px;
}

.score-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.score-entry-who {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.score-entry-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text3);
  flex-shrink: 0;
}
.score-entry-player {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-entry-source {
  flex-shrink: 0;
}

/* Source badge */
.entry-source-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}
.entry-source-manual { background: var(--bg3);   color: var(--text3); border: 1px solid var(--border2); }
.entry-source-ai     { color: #fff; }  /* inherits conf-* colour */
.entry-source-edited { background: var(--yellow); color: #000; }

/* Dart input rows */
.dart-entry-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.dart-entry-row {
  display: grid;
  grid-template-columns: 42px 1fr 1fr 36px;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
}
/* AI-filled row: subtle orange tint */
.dart-row-ai {
  border-color: rgba(249,115,22,0.35);
  background: rgba(249,115,22,0.06);
}
/* Edited/corrected row: subtle yellow tint */
.dart-row-edited {
  border-color: rgba(234,179,8,0.4);
  background: rgba(234,179,8,0.05);
}

.dart-entry-num {
  font-size: 0.68rem;
  color: var(--text3);
  font-weight: 600;
  white-space: nowrap;
}
.dart-seg-input {
  padding: 6px 8px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  width: 100%;
  -moz-appearance: textfield;
}
.dart-seg-input::-webkit-inner-spin-button,
.dart-seg-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.dart-seg-input:focus { border-color: var(--primary); outline: none; }

.dart-ring-select {
  padding: 6px 4px;
  font-size: 0.78rem;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text2);
  width: 100%;
}
.dart-ring-select:focus { border-color: var(--primary); outline: none; }

.dart-entry-score {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
}

/* Footer: total + actions */
.score-entry-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.score-entry-total {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text2);
}
.score-entry-total strong {
  font-size: 1.4rem;
  color: var(--text);
  margin: 0 2px;
}
.score-entry-remaining {
  font-size: 0.8rem;
  color: var(--text3);
  font-weight: 400;
}
.score-entry-actions {
  display: flex;
  gap: 6px;
}

/* AI note bar (shown when AI pre-filled the form) */
.score-entry-ai-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text3);
  flex-wrap: wrap;
}
#aiNoteText { flex: 1; font-style: italic; }

/* Correction note textarea (appears when editing AI result) */
.correction-note-row {
  margin-top: 8px;
}
.correction-note-row textarea {
  font-size: 0.82rem;
  resize: vertical;
  min-height: 52px;
}

/* ══════════════════════════════════
   QUICK-TAP SCORING PAD
   Replaces the number/select dart rows. Big thumb targets.
   ══════════════════════════════════ */

.quick-entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.learn-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none;
  background: var(--bg3); border: 1px solid var(--border2);
  padding: 6px 10px; border-radius: 999px;
  font-size: 0.78rem; color: var(--text2);
  transition: all 0.15s;
}
.learn-toggle input { display: none; }
.learn-toggle:has(input:checked) {
  background: rgba(249,115,22,0.18);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}
.learn-toggle-label { pointer-events: none; }

.ai-status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; color: var(--text3);
  background: var(--bg3); border: 1px solid var(--border2);
  padding: 4px 9px; border-radius: 999px;
}
.ai-status-dot { font-size: 0.7rem; }
.ai-status-dot.dot-green { color: var(--green); }
.ai-status-dot.dot-red   { color: var(--red); }
.ai-status-dot.dot-yellow{ color: var(--yellow); }

/* Committed dart slots */
.dart-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.dart-slot {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px;
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer; color: var(--text);
  transition: all 0.12s;
}
.dart-slot:hover { border-color: var(--border2); }
.dart-slot.slot-active {
  border-color: var(--primary);
  background: rgba(249,115,22,0.10);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.18);
}
.dart-slot.slot-filled { border-color: rgba(34,197,94,0.5); }
.dart-slot-num {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 1px;
  color: var(--text3); text-transform: uppercase;
}
.dart-slot-value {
  font-size: 1.15rem; font-weight: 900; font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.dart-slot.slot-filled .dart-slot-value { color: var(--primary); }

/* Multiplier row */
.tap-pad { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.tap-mult-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.tap-mult {
  padding: 10px 6px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 8px; cursor: pointer; color: var(--text2);
  font-size: 0.82rem; font-weight: 700; letter-spacing: 0.5px;
  transition: all 0.1s;
}
.tap-mult:hover { border-color: var(--primary); }
.tap-mult[aria-pressed="true"] {
  background: rgba(249,115,22,0.2); color: var(--primary);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.tap-mult-miss { color: var(--text3); }
.tap-mult-miss[aria-pressed="true"] {
  background: rgba(239,68,68,0.18); color: var(--red); border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}

/* Segment grid — 5 cols x 4 rows + 2 bull buttons */
.tap-seg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.tap-seg {
  padding: 11px 4px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; color: var(--text);
  font-size: 0.95rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform 0.06s, background 0.1s, border-color 0.1s;
}
.tap-seg:hover { border-color: var(--primary); }
.tap-seg:active { transform: scale(0.95); background: rgba(249,115,22,0.22); }
.tap-seg-bull  { grid-column: span 2; background: var(--bg3); color: var(--yellow); }
.tap-seg-dbull { grid-column: span 3; background: rgba(239,68,68,0.15); color: #ff6b6b; border-color: rgba(239,68,68,0.4); }

/* Flash feedback when a dart is committed */
.tap-seg.tap-flash { animation: tapFlash 0.28s ease-out; }
@keyframes tapFlash {
  0%   { background: var(--primary); color: #fff; transform: scale(1.08); }
  100% { background: var(--bg2); color: var(--text); transform: scale(1); }
}

.tap-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Compact tap pad on short landscape screens */
@media (orientation: landscape) and (max-height: 500px) {
  .tap-seg { padding: 8px 2px; font-size: 0.85rem; }
  .tap-mult { padding: 7px 4px; font-size: 0.72rem; }
  .dart-slot { padding: 6px 4px; }
  .dart-slot-value { font-size: 1rem; }
}


/* ── AI Trigger Log (camera page) ── */
.ai-log-panel {
  margin: 16px 0;
  background: var(--bg2, #151a21);
  border: 1px solid var(--border, #2a2f38);
  border-radius: 10px;
  overflow: hidden;
}
.ai-log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border, #2a2f38);
}
.ai-log-header h4 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text2, #9aa4b2);
  letter-spacing: 0.5px;
  margin: 0;
}
.ai-log-body { padding: 10px 14px 12px; }
.ai-log-legend {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  font-size: 0.72rem;
  color: var(--text3, #6e7681);
  margin-bottom: 10px;
}
.ai-log-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ai-log-list {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 220px; overflow-y: auto;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.76rem;
}
.ai-log-empty {
  color: var(--text3, #6e7681);
  font-style: italic;
  padding: 6px 0;
}
.ai-log-row {
  display: grid;
  grid-template-columns: 70px 54px 140px 1fr auto;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 5px;
  align-items: center;
}
.ai-log-row:hover { background: rgba(255,255,255,0.03); }
.ail-time   { color: var(--text3, #6e7681); }
.ail-src    { color: var(--text2, #9aa4b2); }
.ail-detail { color: var(--text, #e6edf3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ail-ms     { color: var(--text3, #6e7681); font-size: 0.7rem; }
.ail-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
}
.ail-ok    { background: rgba(80,200,120,0.18); color: #6ee89e; }
.ail-empty { background: rgba(200,200,80,0.15); color: #d4d47a; }
.ail-off   { background: rgba(160,130,200,0.18); color: #b69bd6; }
.ail-err   { background: rgba(230,90,90,0.18);  color: #f08585; }
@media (max-width: 680px) {
  .ai-log-row { grid-template-columns: 58px 48px 1fr auto; }
  .ail-src { display: none; }
}


/* ── Round lock hint (shown when all 3 darts committed) ── */
.round-lock-hint {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: rgba(80,200,120,0.10);
  border: 1px solid rgba(80,200,120,0.30);
  border-radius: 8px;
  color: #6ee89e;
  font-size: 0.82rem;
  text-align: center;
}
.round-lock-hint strong { color: #a8f5c2; }
.slot-tray-locked {
  /* When the tray is full, soften the slot look so it reads as a review state */
  opacity: 0.92;
}
.slot-tray-locked.slot-active {
  /* Keep the active-slot indicator a little brighter so users can see what
     they'll overwrite if they tap a number anyway */
  outline: 2px solid rgba(255, 200, 80, 0.5);
  outline-offset: 1px;
}


/* ── Audience Multiplexer ── */
.audience-app {
  min-height: 100vh;
  padding: 12px 16px 18px;
  background: #0a0d12;
  color: var(--text, #e6edf3);
  box-sizing: border-box;
}
.audience-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.audience-header h1 {
  font-size: 1.25rem; color: var(--primary, #58a6ff); margin: 0;
}
.audience-meta { color: var(--text3, #6e7681); font-size: 0.82rem; }
.audience-empty { text-align: center; padding: 60px 20px; color: var(--text2); }
.audience-empty code {
  background: var(--bg2, #151a21); padding: 2px 6px; border-radius: 4px;
  font-size: 0.9em; color: var(--primary, #58a6ff);
}

.audience-grid {
  display: grid;
  gap: 10px;
  height: calc(100vh - 80px);
}
/* 1 up: full bleed */
.audience-grid-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
/* 2 up: side by side */
.audience-grid-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
/* 3 up: one big, two small */
.audience-grid-3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.audience-grid-3 .audience-tile:first-child {
  grid-row: span 2;
}
/* 4 up: 2x2 */
.audience-grid-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.audience-tile {
  background: var(--bg2, #151a21);
  border: 1px solid var(--border, #2a2f38);
  border-radius: 10px;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;  /* allow children to shrink */
}
.atile-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border, #2a2f38);
  font-size: 0.82rem;
}
.atile-mode {
  color: var(--primary, #58a6ff);
  font-weight: 700;
  font-size: 0.72rem;
}
.atile-title {
  flex: 1; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.atile-status { font-size: 0.72rem; font-weight: 600; }
.atile-feed-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.atile-feed-img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Per-player face-cam strip — own row between dartboard feed and scoreboard.
   Collapses to zero height when no peer has joined (slots stay transparent
   until tt-rtc injects a <video>; on big tiles the row is reserved). */
.atile-facecam-strip {
  display: flex; gap: 4px;
  padding: 4px 8px;
  background: rgba(0,0,0,0.25);
  border-top: 1px solid var(--border, #2a2f38);
  flex: 0 0 auto;       /* don't steal feed space */
  min-height: 0;
  overflow-x: auto;     /* if many players, allow horizontal scroll */
}
.atile-facecam-strip:empty { display: none; }
.atile-facecam {
  /* Size by aspect-ratio off the row height, not by flex stretching —
     so a single-player game shows one 128px-wide tile, not a stretched bar. */
  flex: 0 0 auto;
  height: 72px; width: 116px;
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.08);
  border-radius: 4px; overflow: hidden;
}
.atile-facecam:has(video.tt-rtc-slot-video) {
  background: #000;
  border: 1px solid rgba(249,115,22,0.7);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.atile-facecam video.tt-rtc-slot-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.atile-facecam.cam-off video.tt-rtc-slot-video { display: none; }
.atile-facecam-name {
  position: absolute; left: 4px; bottom: 2px;
  font-size: 0.62rem; line-height: 1;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.55);
  padding: 2px 4px; border-radius: 3px;
  pointer-events: none;
}
.atile-facecam:not(:has(video.tt-rtc-slot-video)) .atile-facecam-name {
  color: var(--text3, #6e7681);
  background: transparent;
}
.atile-feed-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text3, #6e7681);
  font-size: 0.9rem;
}
.atile-scoreboard {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.02);
  border-top: 1px solid var(--border, #2a2f38);
  flex: 0 0 auto;
}
.atile-player {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 4px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.03);
  min-width: 70px;
}
.atile-player-active {
  background: rgba(88,166,255,0.18);
  outline: 1px solid rgba(88,166,255,0.4);
}
.atile-pname {
  font-size: 0.72rem;
  color: var(--text2, #9aa4b2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 90px;
}
.atile-pscore {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text, #e6edf3);
}
.atile-lastround {
  font-size: 0.74rem;
  color: var(--text3, #6e7681);
  padding: 4px 10px 6px;
  flex: 0 0 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Small screens: always stack */
@media (max-width: 720px) {
  .audience-grid, .audience-grid-1, .audience-grid-2, .audience-grid-3, .audience-grid-4 {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    height: auto;
  }
  .audience-grid-3 .audience-tile:first-child { grid-row: auto; }
  .audience-tile { min-height: 220px; }
}


/* ── Remote/Controller Tap Pad ── */
.remote-tap-entry {
  background: var(--bg2, #151a21);
  border: 1px solid var(--border, #2a2f38);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
}
.tap-entry-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.tap-entry-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.5px;
  color: var(--text3, #6e7681);
}
.tap-entry-state {
  font-size: 0.82rem; font-weight: 600; padding: 3px 8px;
  border-radius: 999px;
}
.state-mine    { background: rgba(80,200,120,0.2);  color: #6ee89e; }
.state-other   { background: rgba(180,180,180,0.1); color: #9aa4b2; }
.state-waiting { background: rgba(230,200,80,0.15); color: #d4d47a; }
.state-idle    { background: rgba(160,130,200,0.18); color: #b69bd6; }
.state-done    { background: rgba(100,100,100,0.15); color: #9aa4b2; }

.rtap-slots {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 10px;
}
.rtap-slot {
  background: var(--bg3, #1c2230);
  border: 1px solid var(--border, #2a2f38);
  border-radius: 8px;
  padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center;
  min-height: 60px;
  cursor: pointer;
  transition: all 0.15s;
}
.rtap-slot.slot-active {
  border-color: var(--primary, #58a6ff);
  outline: 2px solid rgba(88,166,255,0.3);
}
.rtap-slot.slot-filled {
  background: rgba(88,166,255,0.08);
}
.rtap-slot-num {
  font-size: 0.68rem; color: var(--text3, #6e7681); text-transform: uppercase;
}
.rtap-slot-value {
  font-size: 1.3rem; font-weight: 700; color: var(--text, #e6edf3); margin-top: 2px;
}
.rtap-mult-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 4px; margin-bottom: 6px;
}
.rtap-mult {
  background: var(--bg3, #1c2230);
  border: 1px solid var(--border, #2a2f38);
  color: var(--text, #e6edf3);
  padding: 8px 4px;
  font-weight: 600; font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}
.rtap-mult.active {
  background: var(--primary, #58a6ff);
  border-color: var(--primary, #58a6ff);
  color: #000;
}
.rtap-mult-miss.active {
  background: #c94c4c; border-color: #c94c4c; color: white;
}
.rtap-seg-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  margin-bottom: 10px;
}
.rtap-seg {
  background: var(--bg3, #1c2230);
  border: 1px solid var(--border, #2a2f38);
  color: var(--text, #e6edf3);
  padding: 10px 0;
  font-weight: 700; font-size: 0.95rem;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.08s;
}
.rtap-seg:active { transform: scale(0.94); background: rgba(88,166,255,0.2); }
.rtap-seg-bull { background: rgba(220,60,60,0.18); }
.rtap-total-row {
  text-align: right; font-size: 0.88rem; color: var(--text2, #9aa4b2);
  margin-bottom: 10px;
}
.rtap-total-row strong {
  color: var(--text, #e6edf3); font-size: 1.1rem;
}
.rtap-actions {
  display: grid; grid-template-columns: auto auto 1fr; gap: 6px;
}
.rtap-actions .btn-primary { padding: 10px; font-weight: 700; }


/* ── Controller / remote small AI status line ── */
.rcam-ai-status {
  font-size: 0.78rem;
  padding: 6px 10px;
  border-top: 1px solid var(--border, #2a2f38);
  color: var(--text3, #6e7681);
  background: rgba(255,255,255,0.02);
}
.rcam-ai-status.ai-seen  { color: #6ee89e; }
.rcam-ai-status.ai-empty { color: #d4d47a; }
.rcam-ai-status.ai-off   { color: #b69bd6; }

/* ══════════════════════════════
   OPPONENT VIEW BOXES
   Compact frame+darts strip rendered on host (camera.ejs) and
   controller (remote.ejs). Hidden when there are no opponent tiles.
   ══════════════════════════════ */
.opp-strip {
  display: flex; gap: 6px; padding: 6px 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: #080a0e; border-bottom: 1px solid var(--border);
}
.opp-strip:empty { display: none; }
.opp-tile {
  flex: 0 0 auto; width: 92px;
  display: flex; flex-direction: column; gap: 3px;
}
.opp-frame-wrap {
  position: relative; background: #050608;
  border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; aspect-ratio: 4/3;
  display: flex; align-items: center; justify-content: center;
}
.opp-frame { width: 100%; height: 100%; object-fit: cover; display: none; }
.opp-frame.has { display: block; }
.opp-frame-empty {
  color: var(--text3); font-size: 1.2rem; opacity: 0.6;
}
.opp-darts { display: flex; gap: 2px; }
.opp-dart {
  flex: 1; font-size: 0.6rem; font-weight: 700;
  padding: 2px 3px; text-align: center;
  background: rgba(34,197,94,0.18); color: var(--green);
  border-radius: 3px;
  white-space: nowrap; overflow: hidden;
}
.opp-dart.empty { background: rgba(255,255,255,0.04); color: var(--text3); }

/* Confidence rings on the frame box. The yellow box flags medium-confidence
   AI calls so the player/host can spot uncertain reads at a glance and feed
   corrections back into the training set. */
.opp-tile.conf-high     .opp-frame-wrap { border-color: var(--green);  box-shadow: 0 0 6px rgba(34,197,94,0.35); }
.opp-tile.conf-medium   .opp-frame-wrap { border-color: var(--yellow); box-shadow: 0 0 8px rgba(234,179,8,0.55); }
.opp-tile.conf-low      .opp-frame-wrap { border-color: var(--red);    box-shadow: 0 0 8px rgba(239,68,68,0.55); }
.opp-tile.conf-manual   .opp-frame-wrap { border-color: var(--blue); }
.opp-tile.conf-unavailable .opp-frame-wrap {
  border-color: var(--text3); box-shadow: none;
}
.opp-tile.conf-unavailable .opp-frame { opacity: 0.45; filter: grayscale(0.6); }
.opp-tile.conf-unavailable::after {
  content: '⚠ AI off'; display: block;
  font-size: 0.55rem; color: var(--text3);
  text-align: center; margin-top: 2px;
}

/* Host feed (camera.ejs) — yellow boxing on the live feed when the AI
   call on it was uncertain. Inset shadow so the glow lands inside the
   absolutely-positioned wrapper without disturbing layout. */
.cam-feed-wrap.conf-high     { box-shadow: inset 0 0 0 3px var(--green),  inset 0 0 18px rgba(34,197,94,0.35); }
.cam-feed-wrap.conf-medium   { box-shadow: inset 0 0 0 3px var(--yellow), inset 0 0 22px rgba(234,179,8,0.55); }
.cam-feed-wrap.conf-low      { box-shadow: inset 0 0 0 3px var(--red),    inset 0 0 22px rgba(239,68,68,0.55); }
.cam-feed-wrap.conf-manual   { box-shadow: inset 0 0 0 3px var(--blue); }
.cam-feed-wrap.conf-unavailable {
  box-shadow: inset 0 0 0 3px var(--text3);
}

/* Controller (remote.ejs) camera card — same visual language. */
.remote-camera-card.conf-high     { box-shadow: 0 0 0 2px var(--green),  0 0 18px rgba(34,197,94,0.3); }
.remote-camera-card.conf-medium   { box-shadow: 0 0 0 2px var(--yellow), 0 0 22px rgba(234,179,8,0.55); }
.remote-camera-card.conf-low      { box-shadow: 0 0 0 2px var(--red),    0 0 22px rgba(239,68,68,0.55); }
.remote-camera-card.conf-manual   { box-shadow: 0 0 0 2px var(--blue); }
.remote-camera-card.conf-unavailable {
  box-shadow: 0 0 0 2px var(--text3);
  opacity: 0.85;
}
