/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: #f4f4f2;
  color: #1a1a1a;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.page { max-width: 480px; margin: 0 auto; padding: 1rem; }
.page-wide { max-width: 960px; margin: 0 auto; padding: 1.2rem; }

/* ── Header ── */
.header { text-align: center; padding: 1.5rem 0 1rem; }
.header h1 { font-size: 24px; font-weight: 700; letter-spacing: 0.03em; }
.header .sub { font-size: 13px; color: #888; margin-top: 4px; font-style: italic; }
.virus-icon { font-size: 48px; display: block; text-align: center; margin-bottom: 0.5rem; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 14px;
  padding: 1.2rem;
  margin-bottom: 0.9rem;
}
.card-label {
  font-size: 11px; color: #aaa;
  text-transform: uppercase; letter-spacing: 0.09em;
  margin-bottom: 0.75rem; font-weight: 500;
}

/* ── Inputs ── */
input[type="text"], input[type="password"] {
  width: 100%; padding: 10px 12px;
  border: 1px solid #ddd; border-radius: 8px;
  font-size: 15px; background: #fafafa; color: #1a1a1a;
  margin-bottom: 0.7rem; outline: none; transition: border-color 0.15s;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: #666; background: #fff;
}
input[type="range"] { width: 100%; accent-color: #1a1a1a; }

/* ── Buttons ── */
.btn {
  display: block; width: 100%; padding: 11px 16px; border-radius: 9px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid #ddd; background: #fff; color: #1a1a1a;
  transition: all 0.15s; margin-top: 7px; text-align: center;
  text-decoration: none;
}
.btn:first-child { margin-top: 0; }
.btn:hover { background: #f5f5f5; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: #1a1a1a; color: #fff; border-color: transparent; }
.btn.primary:hover { background: #333; }
.btn.primary:disabled { background: #ccc; cursor: not-allowed; }
.btn.danger-btn  { background: #fff5f5; color: #c0392b; border-color: #fcc; }
.btn.success-btn { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.btn.warning-btn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.btn.accent-btn  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.btn.sm { padding: 6px 10px; font-size: 12px; width: auto; display: inline-block; margin-top: 0; }

/* ── Stats grid ── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 0.9rem; }
.stat-card { background: #f9f9f9; border-radius: 10px; padding: 0.85rem 1rem; text-align: center; }
.stat-label { font-size: 11px; color: #aaa; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-value.danger  { color: #c0392b; }
.stat-value.success { color: #166534; }
.stat-value.accent  { color: #1d4ed8; }
.stat-value.warning { color: #92400e; }

/* ── Bars ── */
.bar-wrap { margin-bottom: 0.8rem; }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; color: #666; margin-bottom: 4px; }
.bar-track { height: 7px; border-radius: 4px; background: #efefef; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.bar-fill.red    { background: #e74c3c; }
.bar-fill.teal   { background: #16a085; }
.bar-fill.purple { background: #8e44ad; }
.bar-fill.amber  { background: #f39c12; }

/* ── Tabs ── */
.tab-bar { display: flex; border-bottom: 1px solid #eee; margin-bottom: 0.9rem; }
.tab { flex: 1; text-align: center; padding: 10px 4px; font-size: 12px; cursor: pointer; color: #aaa; border-bottom: 2px solid transparent; font-weight: 500; }
.tab.active { color: #1a1a1a; border-bottom-color: #1a1a1a; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Player rows ── */
.player-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
.player-row:last-child { border-bottom: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.pname  { font-size: 13px; flex: 1; }
.mini-bar { width: 52px; height: 4px; border-radius: 2px; background: #efefef; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 2px; background: #e74c3c; transition: width 0.5s; }

/* ── Badges ── */
.badge { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 600; }
.badge.online   { background: #dcfce7; color: #166534; }
.badge.dead     { background: #fee2e2; color: #991b1b; }
.badge.mutation { background: #f3e8ff; color: #6b21a8; margin: 2px; }
.badge.master   { background: #fef3c7; color: #92400e; }
.badge.sain     { background: #f0f9ff; color: #0369a1; }

/* ── Status dot ── */
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.status-dot.alive    { background: #16a34a; }
.status-dot.critical { background: #dc2626; animation: blink 1s infinite; }
.status-dot.dead     { background: #aaa; }

/* ── Event log ── */
.event-log { max-height: 120px; overflow-y: auto; }
.event-item { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f5f5f5; font-size: 12px; }
.event-time { color: #bbb; flex-shrink: 0; font-family: monospace; }

/* ── Share box ── */
.share-box { background: #f9f9f9; border-radius: 10px; padding: 1rem; text-align: center; margin-bottom: 0.9rem; }
.share-code { font-size: 30px; font-weight: 700; letter-spacing: 0.2em; font-family: monospace; }
.share-hint { font-size: 11px; color: #aaa; margin-top: 4px; }

/* ── Waiting player ── */
.waiting-player { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #f9f9f9; border-radius: 8px; font-size: 13px; margin-bottom: 5px; }

/* ── Master controls ── */
.event-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.event-btn-grid .btn { margin-top: 0; }
.speed-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.speed-label { font-size: 13px; color: #666; min-width: 80px; }
.speed-val   { font-size: 13px; font-weight: 600; min-width: 28px; }
.param-row   { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.param-label { font-size: 12px; color: #666; flex: 1; }
.param-val   { font-size: 12px; font-weight: 600; min-width: 20px; text-align: right; }
.target-row  { display: flex; align-items: center; gap: 7px; padding: 7px 0; border-bottom: 1px solid #f0f0f0; }
.target-row:last-child { border-bottom: none; }
.target-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── Effect banner ── */
.effect-banner { display: none; margin-bottom: 0.9rem; padding: 10px 14px; border-radius: 9px; font-size: 13px; font-weight: 500; text-align: center; }

/* ── Stage banner ── */
.stage-banner { display: none; margin-bottom: 0.9rem; padding: 12px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; text-align: center; }

/* ── Toast ── */
.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: #fff; padding: 9px 20px; border-radius: 22px;
  font-size: 13px; font-weight: 500; z-index: 999;
  opacity: 0; transition: opacity 0.25s; white-space: nowrap; max-width: 90vw;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* ── Misc ── */
.divider { height: 1px; background: #f0f0f0; margin: 0.9rem 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.conn-indicator { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #888; margin-bottom: 0.5rem; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: #ccc; }
.conn-dot.connected { background: #16a34a; }
.master-badge { background: #1a1a1a; color: #fff; font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }

/* ── Aide : bouton flottant (FAB) ── */
.help-fab {
  position: fixed; bottom: 18px; right: 18px; z-index: 900;
  width: 46px; height: 46px; border-radius: 50%;
  background: #1a1a1a; color: #fff; border: none;
  font-size: 22px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.help-fab:hover  { background: #333; transform: scale(1.06); }
.help-fab:active { transform: scale(0.96); }

/* ── Aide : overlay + modale ── */
.help-overlay {
  position: fixed; inset: 0; z-index: 950;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  display: none; align-items: flex-end; justify-content: center;
  padding: 0;
}
.help-overlay.show { display: flex; }
.help-modal {
  background: #fff; width: 100%; max-width: 520px;
  max-height: 88vh; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  animation: help-slide-up 0.28s ease;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.2);
}
.help-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; border-bottom: 1px solid #eee; flex-shrink: 0;
}
.help-modal-head h2 { font-size: 17px; font-weight: 700; }
.help-close {
  background: #f2f2f2; border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 14px; cursor: pointer;
  color: #666; flex-shrink: 0; transition: background 0.15s;
}
.help-close:hover { background: #e5e5e5; }
.help-modal-body { padding: 1.2rem; overflow-y: auto; }
.help-modal-body h3 { font-size: 14px; font-weight: 600; margin: 1.1rem 0 0.4rem; color: #1a1a1a; }
.help-modal-body h3:first-child { margin-top: 0; }
.help-modal-body p, .help-modal-body li { font-size: 13.5px; line-height: 1.65; color: #333; }
.help-modal-body ul { padding-left: 1.2rem; margin-bottom: 0.5rem; }
.help-modal-body li { margin-bottom: 0.25rem; }
.help-modal-body a { color: #1d4ed8; }
.help-modal-body table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 12.5px; }
.help-modal-body th { background: #1a1a1a; color: #fff; padding: 6px 9px; text-align: left; font-weight: 600; }
.help-modal-body td { padding: 6px 9px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.help-modal-body tr:last-child td { border-bottom: none; }
.help-tip { margin-top: 1rem; padding: 9px 12px; background: #f9f9f9; border-radius: 9px; font-size: 12.5px; color: #666; }

@media (min-width: 560px) {
  .help-overlay { align-items: center; padding: 1rem; }
  .help-modal { border-radius: 18px; }
}

/* ── Animations ── */
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }
@keyframes help-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
