/* Onche Plays Pokémon — Modern Dark Gaming Theme (< 500 lines) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Press+Start+2P&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --bg-app: #0b0f17;
  --bg-card: #131823;
  --bg-card-header: #182030;
  --bg-card-subtle: #1c2436;
  --bg-card-hover: #222c42;
  --border-color: #263248;
  --border-focus: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --color-online: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-badge: #f59e0b;
  --color-trainer: #06b6d4;
  --radius-card: 12px;
  --radius-btn: 8px;
  --radius-badge: 6px;
  --gap-grid: 20px;
}

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

html, body {
  margin: 0; padding: 0; min-height: 100vh;
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(ellipse at 40% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse at 90% 40%, rgba(56, 189, 248, 0.08) 0%, transparent 50%);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==================== BANDEAU LIVE (HEADER) ==================== */
.topic-banner {
  background: var(--bg-card); border-bottom: 1px solid var(--border-color);
  padding: 10px 20px; position: relative; z-index: 10;
}
.topic-banner-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.topic-banner-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topic-badge {
  background: rgba(16, 185, 129, 0.15); color: var(--color-online);
  border: 1px solid rgba(16, 185, 129, 0.4); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: var(--radius-badge);
}
.topic-desc { font-size: 0.88rem; color: var(--text-secondary); }
.topic-link {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent-indigo) 0%, var(--accent-purple) 100%);
  color: #ffffff; text-decoration: none; font-size: 0.85rem; font-weight: 700;
  padding: 6px 14px; border-radius: var(--radius-btn); transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.topic-link:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(168, 85, 247, 0.45); }
.topic-arrow { font-size: 0.75rem; transition: transform 0.15s ease; }
.topic-link:hover .topic-arrow { transform: translateX(2px); }

/* ==================== GRILLE PRINCIPALE ==================== */
.app-container {
  display: grid; grid-template-columns: 1fr; gap: var(--gap-grid);
  max-width: 1400px; margin: 0 auto; padding: 20px 16px 40px;
}
@media (min-width: 900px) {
  .app-container {
    grid-template-columns: minmax(0, 1.4fr) minmax(340px, 390px);
    padding: 24px 20px 40px; align-items: start;
  }
}

/* ==================== CARTES ==================== */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-card); overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; min-width: 0;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-card-header); border-bottom: 1px solid var(--border-color); gap: 10px;
}
.card-title {
  margin: 0; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.05em;
  color: var(--accent-cyan); display: flex; align-items: center; gap: 8px;
}
.card-subtitle { font-size: 0.75rem; font-weight: 400; color: var(--text-secondary); }

/* ==================== COLONNE GAUCHE (JEU & GUIDE) ==================== */
.main-column { display: flex; flex-direction: column; gap: var(--gap-grid); min-width: 0; }
.console-card { padding: 18px; align-items: center; background: #0f131c; border-color: #21293a; }
.gb-bezel {
  width: 100%; max-width: 820px; background: #1f2533; border: 2px solid #141923;
  border-radius: 12px 12px 26px 12px; padding: 14px 18px 16px;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.08), inset 0 -2px 4px rgba(0,0,0,0.6), 0 10px 25px rgba(0,0,0,0.5);
  position: relative;
}
.bezel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 0 4px; }
.bezel-lines { display: flex; flex-direction: column; gap: 3px; }
.line { display: block; width: 32px; height: 2px; border-radius: 1px; }
.line.magenta { background: #ec4899; }
.line.cyan { background: #06b6d4; }
.bezel-title { font-family: 'JetBrains Mono', monospace; font-size: 0.62rem; letter-spacing: 0.08em; color: #94a3b8; font-weight: 700; }
.battery-status { display: flex; align-items: center; gap: 6px; }
.battery-led { width: 8px; height: 8px; background: #ef4444; border-radius: 50%; box-shadow: 0 0 6px #ef4444; }
.battery-label { font-family: 'JetBrains Mono', monospace; font-size: 0.55rem; color: #94a3b8; font-weight: 700; }
.canvas-viewport {
  position: relative; width: 100%; background: #000; border-radius: 6px;
  border: 2px solid #11151e; overflow: hidden; display: flex; justify-content: center; align-items: center;
}
#game-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 160 / 144;
  image-rendering: pixelated; image-rendering: -moz-crisp-edges; image-rendering: crisp-edges;
  background: #8b956d;
}
.screen-glare {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 45%, rgba(0,0,0,0.15) 100%);
}
.bezel-footer { margin-top: 10px; text-align: center; }
.gb-logo {
  font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-style: italic;
  font-size: 0.95rem; letter-spacing: 0.08em; color: #0d1117; text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}
.gb-logo em {
  font-style: normal; font-weight: 800; font-size: 0.8rem;
  background: linear-gradient(90deg, #ec4899, #f59e0b, #10b981, #38bdf8, #8b5cf6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.console-controls-bar {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 820px; margin-top: 14px; padding: 0 4px; gap: 12px; flex-wrap: wrap;
}
.rom-status-wrapper { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-secondary); }
.status-indicator-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.rom-status { font-weight: 600; }
.rom-status.ok { color: var(--color-online); }
.rom-status-wrapper:has(.rom-status.ok) .status-indicator-dot { background: var(--color-online); box-shadow: 0 0 6px var(--color-online); }
.rom-status.error { color: var(--color-danger); }

/* Plein Écran */
.console-card:fullscreen {
  background: #000; border: none; border-radius: 0; padding: 0; width: 100vw; height: 100vh;
  display: flex; justify-content: center; align-items: center;
}
.console-card:fullscreen .gb-bezel {
  max-width: none; width: 100vw; height: 100vh; border: none; border-radius: 0; box-shadow: none; background: #000; padding: 0;
}
.console-card:fullscreen .bezel-header,
.console-card:fullscreen .bezel-footer,
.console-card:fullscreen .console-controls-bar { display: none; }
.console-card:fullscreen .canvas-viewport { width: 100vw; height: 100vh; border: none; border-radius: 0; box-shadow: none; }
.console-card:fullscreen #game-canvas { width: 100%; height: 100%; max-height: 100vh; max-width: calc(100vh * (10 / 9)); margin: 0 auto; }

/* Guide des Commandes */
.guide-card { padding: 0; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 16px; }
.guide-item {
  display: flex; align-items: center; gap: 10px; background: var(--bg-card-subtle);
  border: 1px solid var(--border-color); border-radius: var(--radius-badge); padding: 8px 10px; overflow: hidden;
}
.k-badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.78rem; flex: none;
}
.badge-action {
  width: 26px; height: 26px; background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%);
  color: #ffffff; border-radius: 50%; box-shadow: 0 2px 6px rgba(244, 63, 94, 0.35);
}
.badge-dpad { width: 26px; height: 26px; background: #182030; color: var(--accent-cyan); border: 1px solid var(--border-color); border-radius: 4px; }
.badge-menu { padding: 3px 6px; background: #182030; color: #e2e8f0; border: 1px solid #334155; border-radius: 4px; font-size: 0.65rem; }
.k-info { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.solo-keyboard-tip { border-top: 1px solid var(--border-color); padding: 10px 16px; background: var(--bg-card-header); font-size: 0.78rem; color: var(--text-secondary); }
.tip-label { color: var(--accent-cyan); font-weight: 700; }

/* ==================== PANNEAU LATÉRAL (SIDEBAR) ==================== */
.sidebar-column { display: flex; flex-direction: column; gap: var(--gap-grid); min-width: 0; }
.status-card { padding: 16px; gap: 14px; }
.project-header { border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.project-name {
  margin: 0; font-family: 'Press Start 2P', monospace; font-size: 0.92rem; line-height: 1.4; color: #ffffff;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.project-description { margin: 6px 0 0; font-size: 0.82rem; color: var(--text-secondary); }
.stats-row {
  display: flex; align-items: center; justify-content: space-between; background: var(--bg-card-subtle);
  border: 1px solid var(--border-color); border-radius: var(--radius-btn); padding: 8px 12px; gap: 10px; flex-wrap: wrap;
}
.ws-status { display: inline-flex; align-items: center; gap: 8px; font-size: 0.84rem; font-weight: 700; color: var(--text-secondary); }
.ws-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); }
.ws-status.online { color: var(--color-online); }
.ws-status.online .dot { background: var(--color-online); box-shadow: 0 0 8px var(--color-online); }
.ws-status.offline { color: var(--color-danger); }
.ws-status.offline .dot { background: var(--color-danger); box-shadow: 0 0 8px var(--color-danger); }
.ws-status.connecting .dot { background: var(--color-warning); animation: pulse-dot 1.2s infinite ease-in-out; }
.viewers-badge {
  font-size: 0.8rem; font-weight: 700; color: var(--accent-cyan); background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3); padding: 4px 10px; border-radius: var(--radius-badge); white-space: nowrap;
}
.stats-btn {
  background: rgba(99, 102, 241, 0.15); color: var(--text-primary); border-color: rgba(99, 102, 241, 0.4);
  font-size: 0.78rem; padding: 4px 10px; border-radius: var(--radius-badge);
}
.stats-btn:hover { background: rgba(99, 102, 241, 0.25); border-color: var(--accent-indigo); }
.stats-counter-num { color: var(--accent-cyan); font-family: 'JetBrains Mono', monospace; }
.audio-panel {
  display: flex; align-items: center; gap: 12px; background: var(--bg-card-subtle);
  border: 1px solid var(--border-color); border-radius: var(--radius-btn); padding: 8px 12px;
}
.slider-container { flex: 1; display: flex; align-items: center; }
.volume-slider {
  width: 100%; accent-color: var(--accent-indigo); cursor: pointer; height: 6px; border-radius: 3px; background: var(--border-color);
}
.btn {
  font-family: inherit; font-size: 0.82rem; font-weight: 700; padding: 6px 12px;
  border-radius: var(--radius-btn); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s ease; border: 1px solid transparent;
}
.btn-secondary { background: var(--bg-card-subtle); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-focus); }
.btn-audio { background: #182030; color: var(--accent-cyan); border-color: var(--border-color); white-space: nowrap; }
.btn-audio:hover { background: var(--bg-card-hover); border-color: var(--accent-cyan); }

/* ==================== FIL DES COMMANDES (FEED) ==================== */
.feed-card { min-height: 280px; }
.badge-live-pulse { font-size: 0.72rem; font-weight: 800; color: var(--color-online); animation: pulse-dot 2s infinite ease-in-out; }
.feed { list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.feed-empty, .event-empty { margin: 0; padding: 20px; text-align: center; font-size: 0.82rem; color: var(--text-secondary); font-style: italic; }
.feed-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px;
  background: var(--bg-card-subtle); border: 1px solid var(--border-color); border-radius: var(--radius-badge);
  overflow: hidden; min-width: 0; transition: border-color 0.15s ease;
}
.feed-item:first-child { border-color: var(--accent-indigo); background: rgba(99, 102, 241, 0.12); box-shadow: 0 0 12px rgba(99, 102, 241, 0.2); }
.feed-author {
  color: var(--text-primary); font-weight: 700; font-size: 0.88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0;
}

/* Pastilles */
.pill {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.8rem;
}
.pill[data-key="A"], .pill[data-key="B"] {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%);
  color: #ffffff; box-shadow: 0 2px 6px rgba(244, 63, 94, 0.4);
}
.pill[data-key="UP"], .pill[data-key="DOWN"], .pill[data-key="LEFT"], .pill[data-key="RIGHT"] {
  width: 28px; height: 28px; background: #182030; color: var(--accent-cyan);
  border: 1px solid #2b3952; border-radius: 4px;
}
.pill[data-key="START"], .pill[data-key="SELECT"] {
  padding: 4px 8px; background: #182030; color: #f1f5f9; font-size: 0.72rem;
  border: 1px solid #3b4d6d; border-radius: 4px;
}

/* ==================== BANDEAU DES ÉVÉNEMENTS ==================== */
.event-banner { padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; min-width: 0; }
.event-item {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-badge);
  border-left: 4px solid var(--accent-indigo); background: var(--bg-card-subtle);
  font-size: 0.84rem; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; word-break: break-word;
}
.event-item.fresh { animation: flash-highlight 1.5s ease-out; }
.event-item.kind-capture { border-left-color: var(--color-online); background: rgba(16, 185, 129, 0.1); color: #34d399; }
.event-item.kind-badge { border-left-color: var(--color-badge); background: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.event-item.kind-trainer { border-left-color: var(--color-trainer); background: rgba(6, 182, 212, 0.1); color: #22d3ee; }

/* ==================== MODAL STATISTIQUES ==================== */
.stats-modal {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.stats-modal.hidden { display: none; }
.stats-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(4px); }
.stats-modal-content {
  position: relative; z-index: 1; width: 100%; max-width: 460px; max-height: 85vh;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-card);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.stats-modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.stats-summary-card {
  display: flex; align-items: center; justify-content: space-between; background: var(--bg-card-subtle);
  border: 1px solid rgba(99, 102, 241, 0.4); padding: 10px 14px; border-radius: var(--radius-btn);
}
.stats-summary-label { font-size: 0.84rem; color: var(--text-secondary); font-weight: 600; }
.stats-summary-val { font-size: 1.15rem; font-weight: 800; color: var(--accent-cyan); font-family: 'JetBrains Mono', monospace; }
.stats-section-title { margin: 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); }
.stats-authors-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stats-author-row {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 12px;
  background: var(--bg-card-subtle); border: 1px solid var(--border-color); border-radius: var(--radius-badge); gap: 10px;
}
.stats-author-name {
  font-weight: 700; font-size: 0.85rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.stats-author-count {
  background: rgba(99, 102, 241, 0.15); color: var(--accent-indigo); border: 1px solid rgba(99, 102, 241, 0.3);
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.78rem; padding: 2px 8px; border-radius: var(--radius-badge);
}
.btn-close {
  background: transparent; border: none; color: var(--text-secondary); font-size: 1.1rem; cursor: pointer;
  padding: 4px 8px; border-radius: 4px; transition: all 0.15s ease;
}
.btn-close:hover { color: var(--text-primary); background: var(--bg-card-hover); }

/* ==================== ANIMATIONS ==================== */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.9); }
}
@keyframes flash-highlight {
  0% { background: rgba(99, 102, 241, 0.35); transform: scale(1.01); }
  100% { background: var(--bg-card-subtle); transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .badge-live-pulse, .ws-status.connecting .dot, .event-item.fresh { animation: none; }
}
