:root[data-bs-theme="dark"] {
  --bg-app: #090d16;
  --bg-panel: #111726;
  --border-color: #1e2638;
  --canvas-bg: #050811;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --mode-build: #10b981;
  --mode-alert: #f59e0b;
  --mode-panic: #ef4444;
}

:root[data-bs-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-panel: #ffffff;
  --border-color: #e2e8f0;
  --canvas-bg: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #0284c7;
  --mode-build: #059669;
  --mode-alert: #d97706;
  --mode-panic: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  overflow: hidden;
  height: 100dvh;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 10px 14px;
  gap: 10px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 8px;
}
.brand-title { font-weight: 800; font-size: 14px; letter-spacing: 0.8px; color: var(--accent); }
.brand-sub { font-size: 10px; color: var(--text-muted); font-weight: 600; }

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.actions-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}
.live-clock {
  font-size: 11px;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.viewers-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-app); border: 1px solid var(--border-color);
  padding: 4px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.live-dot {
  width: 6px; height: 6px; background: #10b981; border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
}

.btn-tool {
  background: var(--bg-app); border: 1px solid var(--border-color);
  color: var(--text-main); padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn-tool:hover { opacity: 0.8; }

.main-layout { display: flex; gap: 14px; flex-grow: 1; min-height: 0; }

.game-column {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 8px;
  padding: 8px; position: relative; min-height: 0; overflow: hidden;
}

.canvas-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-height: 0;
  width: 100%;
}

canvas#tetrisCanvas {
  background: var(--canvas-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  height: 100%;
  max-height: calc(100dvh - 165px);
  width: auto;
  aspect-ratio: 10 / 20;
  object-fit: contain;
}

.next-piece-box {
  position: absolute;
  top: 10px;
  right: 14px;
  background: rgba(9, 13, 22, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(4px);
}
.next-piece-box small { font-size: 9px; color: var(--text-muted); font-weight: 700; margin-bottom: 2px; }

.game-over-banner {
  position: absolute; inset: 0; background: rgba(5, 8, 17, 0.88); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  border-radius: 6px; color: #fff; z-index: 10;
}
.countdown-badge {
  background: #ef4444; color: #fff; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
}

.sidebar-column { width: 420px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.panel-card {
  background: var(--bg-panel); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 12px;
}
.panel-header { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat-box {
  background: var(--bg-app); border: 1px solid var(--border-color);
  padding: 6px 8px; border-radius: 6px; display: flex; flex-direction: column;
}
.stat-box small { font-size: 9px; color: var(--text-muted); }
.stat-box span { font-size: 15px; font-weight: 700; }

.badge-mode {
  padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; width: fit-content;
}
.badge-mode.BUILD { background: var(--mode-build); color: #fff; }
.badge-mode.ALERT { background: var(--mode-alert); color: #000; }
.badge-mode.PANIC { background: var(--mode-panic); color: #fff; }

.pick-text {
  font-size: 11px; font-family: monospace; padding: 8px;
  background: var(--bg-app); border: 1px solid var(--border-color); border-radius: 6px; margin-top: 4px;
}

/* Transparencia total de tablas */
.history-table,
.history-table tr,
.history-table td,
.history-table th,
.table {
  --bs-table-bg: transparent !important;
  background-color: transparent !important;
  background: transparent !important;
  color: inherit !important;
}
.history-table { font-size: 11px; font-family: monospace; }
.history-table th { color: var(--text-muted); font-weight: 600; }

.mobile-stats-bar {
  display: flex; justify-content: space-around; width: 100%; max-width: 300px;
  margin-top: 6px; background: var(--bg-app); padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--border-color);
}
.mstat { display: flex; flex-direction: column; align-items: center; }
.mstat small { font-size: 8px; color: var(--text-muted); text-transform: uppercase; }
.mstat b { font-size: 12px; }

/* Offcanvas Móvil traslúcido para ver el juego de fondo */
.offcanvas {
  background: rgba(9, 13, 22, 0.40) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-left: 1px solid var(--border-color);
}
[data-bs-theme="light"] .offcanvas {
  background: rgba(241, 245, 249, 0.50) !important;
}
.offcanvas-body, .offcanvas-header {
  background: transparent !important;
}




/*Agregado!*/
.sidebar-column .table-responsive {
  max-height: 320px;
  overflow-y: auto;
}