:root {
  --bg: #070a0f;
  --surface: #111622;
  --surface-border: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #2563eb;
  --team1: #3b82f6;
  --team2: #ef4444;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  min-height: 100vh;
}

/* Shared Navigation (Capture 1 style) */
.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.25rem;
}

.top-nav a,
.top-nav button.nav-link {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  background: none;
  border: none;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  font-family: inherit;
}

.top-nav a:hover,
.top-nav button.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.top-nav a.active {
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

/* Accueil / Home Page (Capture 1) */
.home-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem 1.5rem 3rem;
}

.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 4vh;
  margin-bottom: 3.5rem;
  text-align: center;
}

.home-title {
  margin: 0 0 4.5rem;
  font-size: clamp(2.4rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.home-dashboard {
  width: 100%;
  max-width: 1060px;
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
}

.dash-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dash-card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background-color 0.15s ease;
}

.btn-link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-link.primary {
  background: var(--accent);
  border-color: var(--accent);
}

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

.lan-box {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.lan-urls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lan-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  color: #e2e8f0;
}

/* Status badge */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.live-badge.connected {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
}

.live-badge.connected .live-dot {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

/* Drawing Page (Capture 2 style) */
.draw-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  background: #000000;
  padding: 0 0.75rem 1.25rem;
  user-select: none;
  -webkit-user-select: none;
}

.page-header {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.25rem;
}

.page-header .top-nav {
  padding: 0.25rem 0;
  gap: 0.9rem;
}

.page-header .top-nav a,
.page-header .top-nav button.nav-link {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
}

.page-header .top-nav a.active {
  color: #ffffff;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.team-tag {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.team-tag.team1 {
  border: 1px solid rgba(59, 130, 246, 0.6);
  color: #93c5fd;
}

.team-tag.team2 {
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}

.canvas-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0.25rem 0 0.75rem;
}

.draw-canvas,
.viz-canvas {
  display: block;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.65);
}

.draw-canvas {
  width: min(92vw, 1120px);
  max-height: 62vh;
  aspect-ratio: 16 / 9;
  cursor: crosshair;
  touch-action: none;
  -webkit-touch-callout: none;
}

/* Controls below canvas (Capture 2 exact structure) */
.controls-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 920px;
  gap: 0.7rem;
}

.size-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.size-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.size-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.size-slider {
  width: 140px;
  height: 6px;
  accent-color: #1677ff;
  cursor: pointer;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 8px 12px;
  width: 100%;
  max-width: 860px;
  padding: 0.2rem 0;
}

@media (max-width: 820px) {
  .palette-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
  }
}

.color-swatch {
  width: 100%;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.color-swatch:hover {
  transform: scale(1.07);
}

.color-swatch.selected {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.75);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.action-btn {
  width: 112px;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid #9ca3af;
  background: #f1f5f9;
  color: #111827;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.action-btn:hover {
  background: #ffffff;
}

.action-btn:active {
  background: #cbd5e1;
}

.extra-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.extra-tools label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.subtle-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}

.subtle-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Visualizer Pages (Régie) */
.viz-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 0 1rem 1.5rem;
}

.viz-single-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.viz-single-wrap .viz-canvas {
  width: min(94vw, 1360px);
  max-height: 84vh;
  aspect-ratio: 16 / 9;
}

.viz-double-grid {
  flex: 1;
  width: 100%;
  max-width: 1800px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: center;
  align-content: center;
}

@media (max-width: 960px) {
  .viz-double-grid {
    grid-template-columns: 1fr;
  }
}

.viz-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.viz-panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.viz-panel .viz-canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
}

/* Clean OBS / Régie mode (?obs=1 or toggled) */
body.obs-mode {
  background: transparent;
}

body.obs-mode .page-header,
body.obs-mode .viz-panel-title,
body.obs-mode .obs-hide {
  display: none !important;
}

body.obs-mode .viz-page {
  background: transparent;
  padding: 0;
}

body.obs-mode .viz-single-wrap {
  min-height: 100vh;
}

body.obs-mode .viz-single-wrap .viz-canvas {
  width: min(100vw, calc(100vh * 16 / 9));
  max-height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

body.obs-mode .viz-double-grid {
  min-height: 100vh;
  padding: 0 1vw;
}
