/* =========================================================================
   ELITECHESS SPECTATE VIEW — OBSIDIAN BLACK & GOLD EDITION
   Scoped strictly to #view-spectate so global chrome & other views remain untouched.
   ========================================================================= */

#view-spectate {
  --spec-bg-card: #121318;
  --spec-bg-card-elev: #181a21;
  --spec-bg-subtle: rgba(255, 255, 255, 0.04);
  --spec-bg-hover: rgba(255, 255, 255, 0.08);
  --spec-border: rgba(255, 255, 255, 0.09);
  --spec-border-gold: rgba(245, 196, 81, 0.35);
  --spec-text-primary: #f4f5f7;
  --spec-text-secondary: #9ca3af;
  --spec-text-muted: #6b7280;
  --spec-gold: #f5c451;
  --spec-gold-strong: #eab308;
  --spec-gold-ink: #111216;
  --spec-live: #22c55e;
  --spec-danger: #ef4444;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

html[data-theme="theme-charcoal-grey"] #view-spectate {
  --spec-bg-card: #1d2027;
  --spec-bg-card-elev: #252932;
  --spec-bg-subtle: rgba(255, 255, 255, 0.055);
  --spec-border: rgba(255, 255, 255, 0.11);
}

html.light-theme #view-spectate {
  --spec-bg-card: #ffffff;
  --spec-bg-card-elev: #f5f6f8;
  --spec-bg-subtle: rgba(15, 23, 42, 0.04);
  --spec-bg-hover: rgba(15, 23, 42, 0.08);
  --spec-border: rgba(15, 23, 42, 0.12);
  --spec-border-gold: rgba(180, 122, 16, 0.45);
  --spec-text-primary: #111827;
  --spec-text-secondary: #4b5563;
  --spec-text-muted: #6b7280;
  --spec-gold: #c98a12;
  --spec-gold-strong: #b47709;
  --spec-gold-ink: #ffffff;
}

#view-spectate *,
#view-spectate *::before,
#view-spectate *::after {
  box-sizing: border-box;
}

.spec-shell {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 6px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- Top Header (Compact Chess.com Alignment) --- */
.spec-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  height: 38px;
}

.spec-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.spec-back-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 9px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card);
  color: var(--spec-text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.spec-back-btn:hover {
  background: var(--spec-bg-hover);
  border-color: var(--spec-border-gold);
}

.spec-back-btn svg,
.spec-header-action-btn svg {
  width: 17px;
  height: 17px;
}

.spec-title-group {
  min-width: 0;
}

.spec-heading {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--spec-text-primary);
  letter-spacing: -0.01em;
}

.spec-subtitle {
  display: none;
}

.spec-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.spec-header-action-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card);
  color: var(--spec-text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.spec-header-action-btn:hover {
  background: var(--spec-bg-hover);
  border-color: var(--spec-border-gold);
}

/* --- Empty State --- */
.spec-empty-state {
  background: var(--spec-bg-card);
  border: 1px solid var(--spec-border);
  border-radius: 16px;
  padding: 44px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.spec-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(245, 196, 81, 0.12);
  border: 1px solid var(--spec-border-gold);
  color: var(--spec-gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spec-empty-title {
  margin: 4px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--spec-text-primary);
}

.spec-empty-desc {
  margin: 0;
  max-width: 420px;
  font-size: 0.88rem;
  color: var(--spec-text-secondary);
}

.spec-empty-actions {
  margin-top: 8px;
}

/* --- Main Two-Column Arena (Chess.com Balanced Proportions) --- */
.spec-arena-grid {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.spec-board-card,
.spec-sidebar-card {
  background: var(--spec-bg-card);
  border: 1px solid var(--spec-border);
  border-radius: 12px;
  min-width: 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.spec-board-card {
  --spec-board-w: min(calc(100vh - 200px), calc(100vw - 440px), 520px);
  width: var(--spec-board-w);
  flex-shrink: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#spec-board-card.is-flipped #spec-player-top {
  order: 3;
}
#spec-board-card.is-flipped .spec-board-stage {
  order: 2;
}
#spec-board-card.is-flipped #spec-player-bottom {
  order: 1;
}
#spec-board-card.is-flipped .spec-transport-bar {
  order: 4;
}

/* --- Top & Bottom Player Details Bars --- */
.spec-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 12px;
  background: var(--spec-bg-card);
  gap: 10px;
  min-height: 46px;
  box-sizing: border-box;
}

.spec-player-bar-top {
  border-bottom: 1px solid var(--spec-border);
}

.spec-player-bar-bottom {
  border-top: 1px solid var(--spec-border);
}

.spec-player-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.spec-players-header {
  display: none;
}

.spec-player-side {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
  transition: background-color 0.15s ease;
  flex: 1;
  justify-content: flex-start;
}

.spec-player-side:hover {
  background: var(--spec-bg-subtle);
}

.spec-player-black,
.spec-player-white {
  justify-content: flex-start;
}

.spec-avatar-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--spec-bg-card-elev);
  border: 1.5px solid var(--spec-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--spec-text-primary);
}

.spec-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.spec-player-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.spec-player-meta-right {
  align-items: flex-end;
  text-align: right;
}

.spec-player-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.spec-player-name-row-right {
  justify-content: flex-end;
}

.spec-player-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--spec-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spec-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.spec-color-white {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.35);
}

.spec-color-black {
  background: #1f2937;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.spec-player-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--spec-text-secondary);
}

.spec-player-sub-row-right {
  justify-content: flex-end;
}

.spec-player-rating {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.spec-tier-icon {
  display: inline-flex;
  align-items: center;
  color: var(--spec-gold);
}

.spec-tier-icon svg {
  width: 13px;
  height: 13px;
}

.spec-clock-pill {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--spec-bg-card-elev);
  border: 1px solid var(--spec-border);
  color: var(--spec-text-secondary);
  line-height: 1.35;
}

.spec-clock-pill.is-active {
  color: var(--spec-gold);
  border-color: var(--spec-border-gold);
  background: rgba(245, 196, 81, 0.12);
}

.spec-clock-pill.low-time {
  color: var(--spec-danger);
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
}

.spec-captured-row {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 15px;
  font-size: 0.72rem;
  color: var(--spec-text-muted);
  flex-wrap: wrap;
}

.spec-captured-row-right {
  justify-content: flex-end;
}

.spec-cap-piece {
  letter-spacing: -0.03em;
  color: var(--spec-text-secondary);
}

.spec-cap-adv {
  font-weight: 700;
  color: var(--spec-gold);
  font-size: 0.72rem;
  margin-left: 2px;
}

/* Center Match Score & Status */
.spec-match-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 8px;
  flex-shrink: 0;
}

.spec-score-text {
  font-size: 1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--spec-text-primary);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.spec-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.32);
  color: #4ade80;
}

.spec-status-pill.is-ended {
  background: var(--spec-bg-subtle);
  border-color: var(--spec-border);
  color: var(--spec-text-secondary);
}

.spec-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--spec-live);
}

.spec-status-pill.is-ended .spec-live-dot {
  background: var(--spec-text-muted);
}

/* --- Chessboard Stage & Strict 1:1 Aspect Guard --- */
.spec-board-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  background: #0d0e12;
  line-height: 0;
}

#view-spectate #spec-board-frame.chessboard-frame {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: 1 / 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

#view-spectate #spectate-board-mount {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  display: block;
}

#view-spectate #spectate-board-mount .chessboard.board-grid {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 1 / 1 !important;
}

/* --- Bottom Transport Controls --- */
.spec-transport-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 12px;
  background: var(--spec-bg-card-elev);
  border-top: 1px solid var(--spec-border);
  gap: 8px;
  box-sizing: border-box;
  min-width: 0;
}

.spec-transport-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.spec-ctrl-btn {
  width: 38px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card-elev);
  color: var(--spec-text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
  flex-shrink: 0;
}

.spec-ctrl-btn:hover:not(:disabled) {
  background: var(--spec-bg-hover);
  border-color: var(--spec-border-gold);
}

.spec-ctrl-btn:disabled {
  opacity: 0.36;
  cursor: default;
}

.spec-live-toggle-btn {
  height: 36px;
  min-width: 96px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card-elev);
  color: var(--spec-text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  flex-shrink: 0;
}

.spec-live-toggle-btn.is-following {
  border-color: var(--spec-border);
  background: var(--spec-bg-card-elev);
}

.spec-live-toggle-btn.is-paused {
  background: linear-gradient(135deg, #f7cb5e 0%, #dca428 100%);
  border-color: #f7cb5e;
  color: #111216;
  box-shadow: 0 4px 16px rgba(245, 196, 81, 0.25);
}

.spec-live-toggle-btn:hover {
  filter: brightness(1.06);
}

.spec-live-btn-icon {
  display: inline-flex;
  align-items: center;
}

.spec-new-moves-pill {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(17, 18, 22, 0.85);
  color: #f7cb5e;
  font-variant-numeric: tabular-nums;
}

.spec-transport-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.spec-move-readout {
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-subtle);
  color: var(--spec-text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  min-width: 78px;
}

/* --- Right Sidebar Card (Chess.com Proper Width & Matching Height) --- */
.spec-sidebar-card {
  width: 350px;
  max-width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(var(--spec-board-w, 520px) + 140px);
  max-height: calc(100vh - 120px);
}

.spec-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--spec-border);
  padding: 4px 10px 0;
  gap: 4px;
  flex-shrink: 0;
}

.spec-tab-btn {
  position: relative;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--spec-text-secondary);
  font-size: 0.86rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.spec-tab-btn:hover {
  color: var(--spec-text-primary);
}

.spec-tab-btn.active {
  color: var(--spec-text-primary);
}

.spec-tab-btn.active::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -1px;
  height: 2.5px;
  border-radius: 3px 3px 0 0;
  background: var(--spec-gold);
}

.spec-tab-count {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--spec-bg-subtle);
  color: var(--spec-text-secondary);
}

.spec-tab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--spec-gold);
  color: var(--spec-gold-ink);
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spec-tab-panel {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  padding: 16px;
}

.spec-tab-panel.active {
  display: flex;
}

/* Telemetry List */
.spec-telemetry-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.spec-telemetry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
}

.spec-telemetry-key {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--spec-text-secondary);
}

.spec-telemetry-icon {
  display: inline-flex;
  color: var(--spec-text-muted);
}

.spec-telemetry-icon svg {
  width: 15px;
  height: 15px;
}

.spec-telemetry-val {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--spec-text-primary);
  font-variant-numeric: tabular-nums;
}

.spec-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--spec-text-muted);
}

.spec-status-dot.is-live {
  background: var(--spec-live);
}

.spec-divider {
  height: 1px;
  background: var(--spec-border);
  margin: 16px 0;
}

/* Spectators Section */
.spec-spectators-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
}

.spec-spectators-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spec-spectators-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--spec-text-primary);
}

.spec-spectators-count {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--spec-text-primary);
}

.spec-spectators-box {
  background: var(--spec-bg-card-elev);
  border: 1px solid var(--spec-border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 290px;
}

.spec-spectators-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spec-spectator-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--spec-text-primary);
  min-width: 0;
}

.spec-spectator-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(245, 196, 81, 0.14);
  border: 1px solid var(--spec-border);
  color: var(--spec-gold);
  font-size: 0.76rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.spec-spectator-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spec-spectator-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.spec-spectators-more,
.spec-spectators-empty {
  font-size: 0.8rem;
  color: var(--spec-text-muted);
  padding: 4px 2px 2px;
}

/* --- Moves Panel --- */
.spec-moves-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.spec-moves-meta {
  font-size: 0.8rem;
  color: var(--spec-text-secondary);
}

.spec-mini-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card-elev);
  color: var(--spec-text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.spec-mini-btn svg {
  width: 13px;
  height: 13px;
}

.spec-mini-btn:hover {
  border-color: var(--spec-border-gold);
}

.spec-moves-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}

.spec-move-row {
  display: grid;
  grid-template-columns: 38px 1fr 1fr;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}

.spec-move-num {
  font-size: 0.78rem;
  color: var(--spec-text-muted);
  font-variant-numeric: tabular-nums;
  padding-left: 6px;
}

.spec-move-cell {
  border: none;
  background: transparent;
  color: var(--spec-text-primary);
  font-size: 0.84rem;
  font-weight: 500;
  text-align: left;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.spec-move-cell:hover {
  background: var(--spec-bg-hover);
}

.spec-move-cell.active {
  background: rgba(245, 196, 81, 0.18);
  color: var(--spec-gold);
  font-weight: 700;
}

.spec-moves-empty {
  padding: 28px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--spec-text-muted);
}

/* --- Spectator Chat Panel --- */
.spec-chat-panel {
  padding: 12px 14px 14px;
  gap: 10px;
}

.spec-chat-notice {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(245, 196, 81, 0.08);
  border: 1px solid rgba(245, 196, 81, 0.22);
  color: var(--spec-text-secondary);
  font-size: 0.74rem;
  line-height: 1.3;
  flex-shrink: 0;
}

.spec-chat-notice svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--spec-gold);
}

.spec-chat-feed {
  flex: 1 1 auto;
  min-height: 220px;
  max-height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.spec-chat-empty {
  margin: auto 0;
  text-align: center;
  font-size: 0.84rem;
  color: var(--spec-text-muted);
  padding: 20px 10px;
}

.spec-chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--spec-bg-subtle);
}

.spec-chat-msg.is-self {
  background: rgba(245, 196, 81, 0.1);
  border: 1px solid rgba(245, 196, 81, 0.22);
}

.spec-chat-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--spec-bg-card-elev);
  color: var(--spec-gold);
  font-size: 0.74rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.spec-chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spec-chat-msg-body {
  flex: 1 1 auto;
  min-width: 0;
}

.spec-chat-msg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.spec-chat-msg-author {
  font-size: 0.79rem;
  font-weight: 700;
  color: var(--spec-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spec-chat-msg-time {
  font-size: 0.68rem;
  color: var(--spec-text-muted);
  flex-shrink: 0;
}

.spec-chat-msg-text {
  margin-top: 2px;
  font-size: 0.84rem;
  line-height: 1.38;
  color: var(--spec-text-primary);
  word-break: break-word;
}

.spec-chat-emoji-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--spec-bg-card-elev);
  border: 1px solid var(--spec-border);
  flex-wrap: wrap;
}

.spec-emoji-btn {
  width: 32px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spec-emoji-btn:hover {
  background: var(--spec-bg-hover);
  border-color: var(--spec-border);
}

.spec-chat-form {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.spec-chat-emoji-toggle {
  width: 36px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 9px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card-elev);
  color: var(--spec-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.spec-chat-emoji-toggle svg,
.spec-chat-send-btn svg {
  width: 16px;
  height: 16px;
}

.spec-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card-elev);
  color: var(--spec-text-primary);
  font-size: 0.86rem;
  outline: none;
}

.spec-chat-input:focus {
  border-color: var(--spec-gold);
}

.spec-chat-send-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #f7cb5e 0%, #dca428 100%);
  color: #111216;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.spec-chat-send-btn:hover {
  filter: brightness(1.06);
}

/* --- Bottom Promo Banner --- */
.spec-promo-banner {
  background: var(--spec-bg-card);
  border: 1px solid var(--spec-border);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.spec-promo-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.spec-promo-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 11px;
  background: rgba(245, 196, 81, 0.14);
  border: 1px solid var(--spec-border-gold);
  color: var(--spec-gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spec-promo-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--spec-gold);
}

.spec-promo-sub {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--spec-text-secondary);
}

.spec-gold-btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #f7cb5e 0%, #dca428 100%);
  color: #111216;
  font-size: 0.86rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.spec-gold-btn:hover {
  filter: brightness(1.06);
}

/* --- Live Matches Modal --- */
.spec-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2600;
  background: rgba(6, 7, 10, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.spec-modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  background: var(--spec-bg-card);
  border: 1px solid var(--spec-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.spec-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--spec-border);
}

.spec-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--spec-text-primary);
}

.spec-modal-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--spec-text-secondary);
}

.spec-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spec-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--spec-border);
  background: var(--spec-bg-card-elev);
  color: var(--spec-text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.spec-modal-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spec-live-match-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--spec-bg-card-elev);
  border: 1px solid var(--spec-border);
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.spec-live-match-item:hover,
.spec-live-match-item.is-current {
  border-color: var(--spec-border-gold);
}

.spec-live-match-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-live-match-players {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--spec-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spec-live-match-meta {
  font-size: 0.77rem;
  color: var(--spec-text-secondary);
}

/* --- Responsive Breakpoints --- */
@media (max-width: 960px) {
  .spec-shell {
    padding: 12px 12px calc(86px + env(safe-area-inset-bottom, 0px));
  }

  .spec-arena-grid {
    grid-template-columns: 1fr;
  }

  .spec-sidebar-card {
    max-height: none;
  }

  .spec-chat-feed {
    max-height: 300px;
  }

  #view-spectate #spec-board-frame.chessboard-frame {
    width: min(100%, 460px) !important;
  }
}

@media (max-width: 540px) {
  .spec-shell {
    padding: 10px 0 calc(86px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  .spec-header,
  .spec-chat-card {
    margin-left: 10px;
    margin-right: 10px;
  }

  .spec-board-card {
    padding: 10px 0 12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    gap: 10px;
  }

  .spec-players-header,
  .spec-transport-bar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .spec-heading {
    font-size: 1.2rem;
  }

  .spec-subtitle {
    font-size: 0.76rem;
  }

  .spec-header-action-btn span:last-child {
    display: none;
  }

  .spec-header-action-btn {
    padding: 0 10px;
  }

  .spec-players-header {
    grid-template-columns: 1fr auto 1fr;
    gap: 4px;
  }

  .spec-player-side {
    gap: 7px;
    padding: 3px 2px;
  }

  .spec-avatar-wrap {
    width: 32px;
    height: 32px;
    font-size: 0.82rem;
  }

  .spec-player-name {
    font-size: 0.8rem;
  }

  .spec-player-sub-row {
    gap: 4px;
    font-size: 0.72rem;
  }

  .spec-clock-pill {
    padding: 1px 6px;
    font-size: 0.72rem;
  }

  .spec-match-center {
    padding: 0 3px;
  }

  .spec-score-text {
    font-size: 0.85rem;
  }

  #view-spectate #spec-board-frame.chessboard-frame {
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }

  .spec-transport-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .spec-ctrl-btn {
    width: 34px;
    height: 34px;
  }

  .spec-live-toggle-btn {
    height: 34px;
    min-width: 88px;
    padding: 0 11px;
    font-size: 0.78rem;
  }

  .spec-move-readout {
    height: 34px;
    font-size: 0.78rem;
    padding: 0 10px;
  }

  .spec-promo-banner {
    padding: 12px 14px;
  }

  .spec-explore-btn {
    width: 100%;
  }
}
