:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #475569;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f1f5f9;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOP DEBUG BAR */
.debug-bar {
  background-color: var(--bg-primary);
  color: var(--text-main);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.2);
  flex-wrap: wrap;
}

.debug-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-title {
  font-weight: 700;
  font-size: 15px;
  color: #60a5fa;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

.badge.state {
  background-color: #065f46;
  border-color: #059669;
  color: #a7f3d0;
  font-weight: 600;
}

/* Player Switcher */
.player-select-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 8px;
  gap: 6px;
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
}

.player-select {
  background: transparent;
  color: var(--text-main);
  border: none;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.player-select option {
  background-color: var(--bg-secondary);
  color: var(--text-main);
}

/* Buttons */
.btn {
  background-color: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn:hover {
  background-color: var(--bg-card);
  border-color: #64748b;
}

.btn.primary {
  background-color: var(--primary);
  border-color: #2563eb;
}
.btn.primary:hover {
  background-color: var(--primary-hover);
}

.btn.success {
  background-color: #059669;
  border-color: #047857;
}

.btn.warning {
  background-color: #d97706;
  border-color: #b45309;
}

.btn.danger {
  background-color: #dc2626;
  border-color: #b91c1c;
}

/* MAIN GAME CONTAINER */
.runner-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  max-width: 1920px;
  margin: 0 auto;
  width: 100%;
}

/* STATUS BAR */
.status-bar-container {
  background-color: white;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  flex-wrap: wrap;
  gap: 12px;
  /* Wie bei BGA sichtbar bleiben: Auswahl-Buttons (z. B. Roomie-Plättchen nach dem Klick auf eine Karte
     am Seitenende des Bretts) sonst außerhalb des sichtbaren Bereichs. Top = Höhe der Debug-Leiste (JS). */
  position: sticky;
  top: calc(var(--debug-bar-h, 56px) + 6px);
  z-index: 900;
  max-height: 45vh;
  overflow-y: auto;
}

.status-bar-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.generalactions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bga-action-btn {
  background-color: #0284c7;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  transition: all 0.15s ease;
}

.bga-action-btn:hover {
  background-color: #0369a1;
}

.bga-action-btn.alert {
  background-color: #e11d48;
}
.bga-action-btn.secondary {
  background-color: #64748b;
}

/* GAME PLAY AREA */
.game-play-area {
  position: relative;
  background-color: transparent;
  width: 100%;
  margin-bottom: 24px;
}

/* PLAYER PANELS */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: start;
  gap: 20px;
}
.game-column { min-width: 0; }
.player-panels-container {
  min-width: 0;
}
#player_boards { display: grid; gap: 12px; }
.bga-player-panel {
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--player-color, #cbd5e1);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 10%);
}
.current-player-board { background: #f8fafc; }
.active-player-board { box-shadow: 0 0 0 2px var(--player-color), 0 2px 6px rgb(0 0 0 / 12%); }
.player-board-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.player-board .avatar { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px; background: #e2e8f0; color: #334155; font-weight: 700; font-size: 12px; }
.player-board .player-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 700; color: var(--player-color); }
.player-active-indicator { color: #0f172a; background: #e2e8f0; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.player-board [hidden] { display: none !important; }
.player_score { display: flex; align-items: center; gap: 5px; font-size: 15px; }
.player_score_value { font-weight: 700; }
.player-board-game-specific-content:not(:empty) { margin-top: 10px; }
.player-board-runner-details:not(:empty) { margin-top: 6px; font-size: 12px; color: #475569; }
@media (max-width: 1000px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  #player_boards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

.bga-player-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid;
  margin: 0 2px;
}

/* TOAST / ALERT */
.toast-container {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
  animation: slideIn 0.2s ease;
  max-width: 400px;
}

.toast.error {
  background-color: #dc2626;
}

.toast.info {
  background-color: #0284c7;
}

.toast.success {
  background-color: #059669;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* MODALS & DRAWERS */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1500;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  overflow: hidden;
}

.modal-header {
  padding: 12px 18px;
  background-color: var(--bg-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 10px 18px;
  background-color: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ACTION FORM STYLING */
.action-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 12px;
}

.action-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.action-name {
  font-weight: 700;
  font-size: 15px;
  color: #0369a1;
  font-family: monospace;
}

.action-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.action-form-label {
  font-size: 13px;
  font-weight: 600;
  width: 120px;
  color: #475569;
}

.action-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}

.action-input:focus {
  border-color: var(--primary);
}

/* DB BROWSER TABLE */
.db-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid #cbd5e1;
  margin-bottom: 12px;
  overflow-x: auto;
}

.db-tab-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
}

.db-tab-btn.active {
  color: #0284c7;
  border-bottom-color: #0284c7;
}

.db-table-wrapper {
  overflow-x: auto;
  max-height: 55vh;
}

.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: monospace;
}

.db-table th, .db-table td {
  border: 1px solid #e2e8f0;
  padding: 6px 10px;
  text-align: left;
}

.db-table th {
  background-color: #f1f5f9;
  position: sticky;
  top: 0;
  color: #1e293b;
}

.db-table tr:hover {
  background-color: #f8fafc;
}

/* NOTIFICATION STREAM */
.notif-item {
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-type {
  font-weight: 700;
  color: #0284c7;
  font-family: monospace;
  margin-right: 6px;
}

.notif-args {
  font-family: monospace;
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 4px;
  white-space: pre-wrap;
}

/* GAMES MANAGER & MULTI-GAME UI */
.modal-box.large {
  max-width: 1000px;
}

.games-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 16px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: #0f172a;
}

.tab-btn.active {
  color: #0284c7;
  border-bottom-color: #0284c7;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.game-card {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.game-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.game-card h4 {
  margin: 0 0 6px 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.game-card .meta {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-card .badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.game-card .badge {
  font-size: 11px;
  padding: 2px 6px;
}

.game-card .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.files-tree {
  max-height: 380px;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  font-family: monospace;
  font-size: 12px;
}

.file-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-bottom: 1px solid #f1f5f9;
}

.file-row:hover {
  background: #e2e8f0;
}


/* Remote-Sitz (Magic Link ?seat=…): nur Spieleransicht, keine Verwaltung */
body.remote #player_select,
body.remote label[for="player_select"],
body.remote #btn_take_active,
body.remote #btn_next_player,
body.remote #btn_open_actions,
body.remote #btn_open_db,
body.remote #btn_open_log,
body.remote #btn_reset_table,
body.remote #btn_new_table,
body.remote #btn_open_games,
body.remote #btn_open_seats,
body.remote #badge_seed,
body.remote #badge_game {
  display: none;
}

/* Sitze-Dialog (Host) */
.seat-row {
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.seat-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.seat-state {
  font-size: 12px;
  color: #64748b;
}

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

.seat-link {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: 12px;
}
