/* ==========================================================================
   Cluedo Companion - Stijlen (Mobiel-eerst, Hoog Contrast, Touch-vriendelijk)
   ========================================================================== */

:root {
  --bg-main: #0a0e14;
  --bg-surface: #121822;
  --bg-surface-elevated: #1a2332;
  --bg-surface-card: #151d2a;
  --border-subtle: #243042;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --gold-primary: #f59e0b;
  --gold-hover: #d97706;
  --gold-glow: rgba(245, 158, 11, 0.25);

  /* Matrix Statussen */
  --state-empty-bg: rgba(255, 255, 255, 0.03);
  --state-empty-border: #232f3e;

  --state-yes-text: #10b981;
  --state-yes-bg: rgba(16, 185, 129, 0.16);
  --state-yes-border: #059669;

  --state-no-text: #ef4444;
  --state-no-bg: rgba(239, 68, 68, 0.16);
  --state-no-border: #dc2626;

  --state-maybe-text: #38bdf8;
  --state-maybe-bg: rgba(56, 189, 248, 0.16);
  --state-maybe-border: #0284c7;

  --danger-bg: #dc2626;
  --danger-hover: #b91c1c;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.6);
}

/* Basis Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}

/* Hoofdcontainer */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ==========================================================================
   Header & Navigatie
   ========================================================================== */
.app-header {
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  background: rgba(18, 24, 34, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #fef08a, var(--gold-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Knoppen algemeen */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
  user-select: none;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-primary), #d97706);
  color: #121822;
  box-shadow: 0 2px 10px var(--gold-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #fbbf24, var(--gold-primary));
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: #243042;
}

.btn-accent {
  background: #2563eb;
  color: #ffffff;
}

.btn-accent:hover {
  background: #1d4ed8;
}

.btn-danger {
  background: var(--danger-bg);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 1.1rem;
}

.btn-icon.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #34d399;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--gold-primary);
  color: #0b0f14;
}

/* ==========================================================================
   Schermen / Views
   ========================================================================== */
.view {
  display: none;
  flex: 1;
  padding: 1rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}

.view.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Scherm 1: Spelopzet (Setup)
   ========================================================================== */
.setup-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  margin: auto 0;
}

.setup-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.setup-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

/* Spelers selector */
.player-count-pills {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.pill-btn {
  padding: 0.65rem 0;
  text-align: center;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn.active {
  background: var(--gold-primary);
  color: #0b0f14;
  border-color: var(--gold-primary);
  box-shadow: 0 2px 8px var(--gold-glow);
}

/* Medespelers aliassen invoer */
.alias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.alias-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
}

.alias-box label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.alias-box input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--gold-primary);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.35rem 0.5rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.alias-box input:focus {
  outline: none;
  border-color: var(--gold-primary);
}

.setup-footer {
  margin-top: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-start-game {
  width: 100%;
  padding: 0.9rem;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
}

.btn-resume {
  width: 100%;
  padding: 0.75rem;
  border: 1px dashed var(--gold-primary);
  background: rgba(245, 158, 11, 0.08);
  color: var(--gold-primary);
}

.setup-admin-link {
  text-align: center;
  margin-top: 0.5rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.5rem;
}

.btn-link:hover {
  color: var(--gold-primary);
}

/* ==========================================================================
   Scherm 2: Het Notitieblok (Matrix)
   ========================================================================== */
#notepad-view {
  display: none;
  flex: 1;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 0;
  max-width: 100%;
  width: 100%;
}

#notepad-view.active {
  display: flex;
}

.notepad-toolbar {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  z-index: 40;
}

.notepad-actions-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.notepad-actions-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Matrix Table Container */
.matrix-container {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2rem;
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 320px;
}

/* Sticky Headers: exact top: 0 in matrix-container */
.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #151d28;
  color: var(--text-main);
  padding: 0.65rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  border-bottom: 2px solid var(--border-subtle);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Sticky Eerste Kolom (Kaartnaam) */
.matrix-table th.col-card,
.matrix-table td.col-card {
  position: sticky;
  left: 0;
  z-index: 20;
  background: #111721;
  text-align: left;
  padding: 0.6rem 0.75rem;
  min-width: 160px;
  max-width: 210px;
  border-right: 2px solid var(--border-subtle);
  box-shadow: 3px 0 6px -2px rgba(0,0,0,0.5);
}

.matrix-table thead th.col-card {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 35;
  background: #161e2a;
}

.matrix-table thead th.col-self {
  background: #192738;
  color: #60a5fa;
  border-left: 2px solid #2563eb;
  border-right: 2px solid #2563eb;
}

.matrix-table td.col-self {
  background: rgba(37, 99, 235, 0.05);
  border-left: 1px solid rgba(37, 99, 235, 0.25);
  border-right: 1px solid rgba(37, 99, 235, 0.25);
}

/* Categorie Sectie Header Rijen */
.category-row td {
  background: linear-gradient(90deg, #1c2636, #121a24) !important;
  color: var(--gold-primary);
  font-weight: 800;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0.65rem 0.75rem;
  border-top: 2px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.category-row td .category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  position: sticky;
  left: 0.75rem;
}

/* Kaartrijen */
.card-row {
  border-bottom: 1px solid rgba(36, 48, 66, 0.6);
  transition: background-color 0.1s ease;
}

.card-row:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.card-cell-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Verdachte markeer knop */
.btn-suspect-mark {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-suspect-mark:hover {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
}

.btn-suspect-mark.active {
  background: var(--gold-primary);
  color: #000;
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
}

.card-row.is-suspect {
  background-color: rgba(245, 158, 11, 0.08) !important;
}

.card-row.is-suspect .card-title {
  color: #fbbf24;
  font-weight: 700;
}

/* Matrix Interactieve Cellen */
.matrix-cell {
  text-align: center;
  vertical-align: middle;
  padding: 0;
  width: 58px;
  min-width: 54px;
  border-bottom: 1px solid rgba(36, 48, 66, 0.6);
  border-right: 1px solid rgba(36, 48, 66, 0.4);
}

.cell-trigger {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
  border: none;
  background: var(--state-empty-bg);
  transition: background-color 0.12s, transform 0.08s;
  user-select: none;
}

.cell-trigger:active {
  transform: scale(0.92);
}

/* Cellen statussen (Groen Vinkje, Rood Kruis, Blauw Vraagteken) */
.cell-trigger[data-state=""] {
  color: transparent;
}

.cell-trigger[data-state="yes"] {
  background-color: var(--state-yes-bg);
  color: var(--state-yes-text);
  box-shadow: inset 0 0 0 2px var(--state-yes-border);
}

.cell-trigger[data-state="no"] {
  background-color: var(--state-no-bg);
  color: var(--state-no-text);
  box-shadow: inset 0 0 0 2px var(--state-no-border);
}

.cell-trigger[data-state="maybe"] {
  background-color: var(--state-maybe-bg);
  color: var(--state-maybe-text);
  box-shadow: inset 0 0 0 2px var(--state-maybe-border);
}

/* ==========================================================================
   Modals & Popups
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 10, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.2s ease-in-out;
  overflow: hidden;
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-card);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  background: var(--bg-surface-card);
}

/* Beschuldiging Scherm / Modal */
.accusation-slots {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}

.accusation-slot {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slot-meta {
  display: flex;
  flex-direction: column;
}

.slot-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 700;
}

.slot-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  margin-top: 0.15rem;
}

.slot-value.empty {
  color: var(--text-dim);
  font-style: italic;
  font-weight: 500;
  font-size: 0.95rem;
}

.slot-icon {
  font-size: 1.8rem;
  opacity: 0.8;
}

.accusation-banner {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.35;
  margin-top: 0.75rem;
}

.accusation-banner.complete {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--gold-primary);
  color: #fbbf24;
}

.accusation-banner.incomplete {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #bae6fd;
}

/* Admin Beheer Lijst */
.config-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.config-item-info h4 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.config-item-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.config-item-actions {
  display: flex;
  gap: 0.4rem;
}

/* Toast Meldingen */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toastIn 0.25s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PWA Online/Offline Indicator */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.status-dot.offline {
  background-color: #ef4444;
}

/* ==========================================================================
   Responsive Optimalisaties (Tablet & Desktop)
   ========================================================================== */
@media (min-width: 640px) {
  .setup-card {
    padding: 2.25rem;
  }

  .matrix-table th.col-card,
  .matrix-table td.col-card {
    min-width: 220px;
    max-width: 280px;
  }

  .matrix-cell {
    width: 72px;
    min-width: 65px;
  }
}
