:root {
  --bg: #15171f;
  --panel: #1f2230;
  --panel2: #181a24;
  --line: #2c3042;
  --line2: #3a3f55;
  --text: #e9ebf5;
  --muted: #8e93ab;
  --accent: #ff5a5f;
  --gold: #ffcf6b;
  --goldBg: rgba(255, 207, 107, 0.12);
  --mint: #5fd6a8;
  --mintBg: rgba(95, 214, 168, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* Header */
header {
  height: 52px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 15px;
  text-decoration: none;
  color: var(--text);
}
.brand .tag {
  background: var(--accent);
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.level-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
select, input, textarea {
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
select:focus, input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 90, 95, 0.2);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover {
  background: var(--line2);
  border-color: var(--muted);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  filter: brightness(1.1);
  background: var(--accent);
  border-color: var(--accent);
}
.btn-success {
  background: #2ea043;
  border-color: #2ea043;
  color: #fff;
}
.btn-success:hover {
  filter: brightness(1.1);
}
.btn-gold {
  background: #d49a20;
  border-color: #d49a20;
  color: #fff;
}
.btn-gold:hover {
  filter: brightness(1.1);
}
.btn-playtest {
  background: #5fd6a8;
  border-color: #5fd6a8;
  color: #0d1020;
  font-weight: 800;
}
.btn-playtest:hover {
  filter: brightness(1.1);
}
.btn-playtest.active {
  background: #ff5a5f;
  border-color: #ff5a5f;
  color: #fff;
}
.btn-cyan {
  background: rgba(0, 210, 255, 0.15);
  border-color: rgba(0, 210, 255, 0.45);
  color: #00d2ff;
  font-weight: 700;
}
.btn-cyan:hover {
  background: rgba(0, 210, 255, 0.28);
  border-color: #00d2ff;
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.35);
  color: #ffffff;
}
.btn-cyan.active {
  background: #00d2ff;
  border-color: #00d2ff;
  color: #0d1020;
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.5);
}
.btn-cyan.loading {
  opacity: 0.7;
  cursor: wait;
}
.btn-icon {
  padding: 6px 9px;
}
.header-spacer { flex: 1; }

/* Main layout */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left sidebar - Tools */
.sidebar-left {
  width: 280px;
  background: var(--panel2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sub-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.sub-tab {
  flex: 1;
  padding: 9px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--panel2);
}
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: none;
}
.tab-content.active {
  display: block;
}

/* Tool Sections & Grids */
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 12px 0 8px;
  font-weight: 700;
}
.section-title:first-child { margin-top: 0; }
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.tile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s;
}
.tile-btn:hover { border-color: var(--line2); }
.tile-btn.active {
  border-color: var(--accent);
  background: rgba(255, 90, 95, 0.12);
  font-weight: 700;
}
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.3);
}

/* Center canvas area */
.center-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
  position: relative;
}
.canvas-statusbar {
  height: 34px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel2);
}
.canvas-statusbar b { color: var(--text); }
.zoom-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.btn-sm {
  padding: 2px 8px;
  font-size: 11px;
  height: 24px;
  line-height: 1.2;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
  padding: 16px;
}
#editorCanvas {
  background: #262b40;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  cursor: crosshair;
  display: block;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 20 / 12;
  transition: width 0.12s ease-out, height 0.12s ease-out;
}

/* Focus Arena Mode (Agrandir la zone de jeu au maximum) */
body.focus-arena-mode .sidebar-left,
body.focus-arena-mode .sidebar-right {
  display: none !important;
}
body.focus-arena-mode .center-area {
  width: 100vw;
  flex: 1;
}
body.focus-arena-mode #editorCanvas {
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 140px);
}
.timeline-bar {
  height: 48px;
  background: var(--panel2);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.timeline-slider {
  flex: 1;
  cursor: pointer;
}

/* Right sidebar - Inspector */
.sidebar-right {
  width: 320px;
  background: var(--panel2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.panel-box {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.panel-box h3 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.field-row {
  margin-bottom: 10px;
}
.field-row:last-child { margin-bottom: 0; }
.field-row label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field-row input[type="text"],
.field-row input[type="number"],
.field-row select,
.field-row textarea {
  width: 100%;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

/* Lists in inspector / left sidebar */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.item-card {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  transition: all 0.15s;
}
.item-card:hover { border-color: var(--line2); }
.item-card.selected {
  border-color: var(--accent);
  background: rgba(255, 90, 95, 0.1);
}
.item-card .item-meta {
  color: var(--muted);
  font-size: 11px;
}
.item-del-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}
.item-del-btn:hover {
  color: var(--accent);
  background: rgba(255, 90, 95, 0.15);
}

/* Solver card */
.solver-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.solver-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 8px;
}
.badge-ok { background: var(--mintBg); color: var(--mint); }
.badge-fail { background: rgba(255, 90, 95, 0.15); color: var(--accent); }
.badge-pending { background: var(--goldBg); color: var(--gold); }

/* Playtest banner */
.playtest-overlay {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(21, 23, 31, 0.92);
  border: 1px solid var(--mint);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 13px;
  font-weight: 700;
}
.playtest-overlay b { color: var(--mint); }

/* Replay Overlay Banner */
.replay-overlay {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 22, 33, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 210, 255, 0.5);
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(0, 210, 255, 0.25);
  pointer-events: auto;
  font-size: 12px;
  font-weight: 700;
  color: #e9ebf5;
  z-index: 20;
}
.replay-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00d2ff;
  box-shadow: 0 0 8px #00d2ff;
  animation: pulseReplay 1s infinite alternate;
}
@keyframes pulseReplay {
  0% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1.15); }
}
.replay-timer {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #00d2ff;
  background: rgba(0, 210, 255, 0.12);
  padding: 2px 7px;
  border-radius: 6px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 12, 17, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: min(680px, 94vw);
  max-height: 85vh;
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}
.modal-body {
  padding: 16px 18px;
  flex: 1;
  overflow-y: auto;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.json-textarea {
  width: 100%;
  height: 360px;
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  resize: vertical;
}

/* Toast */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 220px;
  max-width: 320px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  animation: toastFadeIn 0.25s ease-out;
}
.toast.success { border-left-color: var(--mint); }
.toast.gold { border-left-color: var(--gold); }
@keyframes toastFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Right Sidebar Tabs */
.sidebar-tabs {
  display: flex;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  padding: 10px 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.sidebar-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: var(--panel2);
}
.rtab-content {
  display: none;
}
.rtab-content.active {
  display: block;
}

/* Enemy Tools Grid */
.enemy-tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.enemy-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}
.enemy-tool-btn:hover {
  border-color: var(--line2);
  background: rgba(255, 255, 255, 0.04);
}
.enemy-tool-btn.active {
  border-color: var(--mint);
  background: rgba(95, 214, 168, 0.12);
  color: #fff;
  font-weight: 700;
}
.enemy-tool-btn .tool-icon {
  font-size: 16px;
}
.enemy-tool-btn .tool-name {
  font-size: 11px;
  line-height: 1.2;
}

/* Placement Status Box */
.placement-status-box {
  background: var(--panel);
  border: 1px solid var(--mint);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

/* Placement Mode Floating Banner */
.placement-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(21, 23, 31, 0.95);
  border: 1px solid var(--mint);
  border-radius: 8px;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  z-index: 10;
  animation: toastFadeIn 0.2s ease-out;
}
.placement-banner[hidden] { display: none; }

/* Filter Chips */
.filter-chips {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 8px;
}
.filter-chip {
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.filter-chip:hover {
  color: var(--text);
  border-color: var(--muted);
}
.filter-chip.active {
  background: var(--goldBg);
  color: var(--gold);
  border-color: var(--gold);
}

/* Global Outliner List */
.global-item-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 350px);
  overflow-y: auto;
}
.global-item-card {
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  transition: all 0.15s ease;
}
.global-item-card:hover {
  border-color: var(--line2);
  background: rgba(255, 255, 255, 0.04);
}
.global-item-card.selected {
  border-color: var(--accent);
  background: rgba(255, 90, 95, 0.12);
}
.global-item-card .item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.global-item-card .item-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.global-item-card .item-meta {
  color: var(--muted);
  font-size: 10px;
  font-family: monospace;
}
.global-item-card .item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.global-item-card:hover .item-actions {
  opacity: 1;
}
.badge-count {
  background: var(--panel);
  border: 1px solid var(--line2);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}

/* Outils ennemis : Selection en pleine largeur, raccourcis clavier */
#tab-enemies .enemy-tool-btn[data-etool="select"] { grid-column: 1 / -1; flex-direction: row; }
.enemy-tool-btn kbd {
  font: 600 9px/1 ui-monospace, monospace;
  padding: 2px 4px;
  margin-left: 3px;
  border-radius: 4px;
  border: 1px solid var(--line2);
  color: var(--muted);
}

/* Salles d'un niveau double */
.room-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel2); border-bottom: 1px solid var(--line); font-size: 12px; }
.room-bar-title { font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; }
.room-tabs { display: flex; gap: 4px; }
.room-tab { white-space: nowrap; appearance: none; border: 1px solid var(--line2); background: var(--panel); color: var(--muted); border-radius: 8px; padding: 4px 12px; font: 700 12px system-ui, sans-serif; cursor: pointer; }
.room-tab:hover { color: var(--text); border-color: var(--muted); }
.room-tab.active { background: var(--goldBg); color: var(--gold); border-color: rgba(255, 207, 107, 0.55); }
.room-hint { margin-left: auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.room-bar .btn { white-space: nowrap; flex: none; }
.room-note { margin: 6px 0 10px; padding: 7px 10px; border-radius: 8px; background: var(--goldBg); color: var(--gold); font-size: 11.5px; border: 1px solid rgba(255, 207, 107, 0.3); }

/* ===== Refonte : barre du haut, menus, palette, panneau Niveau ===== */
[hidden] { display: none !important; }
.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn { height: 34px; padding: 0 14px; border-radius: 8px; font-size: 13px; }
.btn.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.btn-icon { width: 34px; padding: 0; justify-content: center; }
.btn.btn-icon.btn-sm { width: 26px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(255, 255, 255, .07); border-color: transparent; color: var(--text); }
.btn-ghost.danger:hover { color: var(--accent); }
.btn-block { width: 100%; justify-content: center; }
.btn-playtest.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.btn-playtest .ico { fill: currentColor; }

header { height: 56px; gap: 10px; padding: 0 14px; }
.brand { gap: 8px; }
.brandName { font: 800 14px/1 system-ui, sans-serif; letter-spacing: .12em; }
.brand .tag { background: rgba(255, 90, 95, .16); color: #ff8e92; border: 1px solid rgba(255, 90, 95, .35); font-weight: 700; letter-spacing: .04em; }
.level-picker-wrap { gap: 4px; margin-left: 6px; }
#levelSelect { height: 34px; min-width: 220px; max-width: 300px; border-radius: 8px; }
.grp { display: flex; gap: 2px; padding-left: 6px; border-left: 1px solid var(--line); margin-left: 4px; }

.menuWrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 230px; padding: 6px; background: #1b1e2b; border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 14px 36px rgba(0, 0, 0, .5); }
.menu-right { left: auto; right: 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; text-decoration: none; border-radius: 6px; cursor: pointer; }
.menu-item:hover { background: rgba(255, 255, 255, .08); }
.menu-item .ico { color: var(--muted); }
.menu-item.danger, .menu-item.danger .ico { color: #ff8e92; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }

.readyChip { padding: 4px 11px; border-radius: 99px; font-size: 12px; font-weight: 700; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.readyChip.ok { color: var(--mint); border-color: rgba(95, 214, 168, .45); background: var(--mintBg); }
.readyChip.todo { color: var(--gold); border-color: rgba(255, 207, 107, .4); background: var(--goldBg); }
.readyChip.bad { color: #ff8e92; border-color: rgba(255, 90, 95, .45); background: rgba(255, 90, 95, .12); }

/* palette de gauche */
.sub-tab { padding: 11px 2px; font-size: 12px; }
.tab-content { padding: 14px; }
.section-title { margin: 16px 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.tiles-grid { gap: 6px; }
.tile-btn { padding: 8px 10px; gap: 9px; border-radius: 8px; font-weight: 600; text-align: left; }
.tile-btn .swatch { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; }
.tile-btn.active { box-shadow: inset 0 0 0 1px var(--accent); }
.brush-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.brush-mode-btn.active { background: rgba(255, 90, 95, .14); border-color: var(--accent); color: #fff; }
details.help { margin-top: 16px; font-size: 12px; color: var(--muted); }
details.help summary { cursor: pointer; font-weight: 700; color: var(--text); }
details.help ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; }

/* barre d'etat de la carte */
.canvas-statusbar { height: 38px; }

/* panneau de droite */
.sidebar-right { width: 330px; }
.panel-box { padding: 16px; }
.inspector-card { border-top: 3px solid var(--accent); background: var(--panel); }
.inspector-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.inspector-head h3 { margin: 0; color: var(--text); font-size: 13px; text-transform: none; letter-spacing: 0; }
.ready-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.ready { display: flex; align-items: center; gap: 9px; font-size: 13px; line-height: 1.3; }
.ready.ok .ico { color: var(--mint); }
.ready.todo .ico { color: var(--gold); }
.ready.bad .ico { color: #ff8e92; }
.solver-card { display: block; }
.solver-details { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 6px; }
.solver-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.solver-actions .btn-block { margin-top: 0; }
details.fold > summary { cursor: pointer; list-style: none; font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; justify-content: space-between; margin: -2px 0 0; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: ''; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; margin-right: 3px; }
details.fold[open] > summary::after { transform: rotate(-135deg); }
details.fold[open] > summary { margin-bottom: 12px; }
.fold-note { margin: -4px 0 10px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.field-row label { font-weight: 600; }
.grid-3 small { display: block; margin-bottom: 3px; font-weight: 700; }
.m-gold { color: var(--gold); } .m-silver { color: #c9cedd; } .m-bronze { color: #e0925a; } .m-diamond { color: #7fe3ff; font-weight: 700; }
.btn.btn-block { margin-top: 10px; }

@media (max-width: 1280px) { .brandName, .readyChip { display: none; } #levelSelect { min-width: 160px; } }

.sub-tab { font-size: 11.5px; letter-spacing: 0; }
.sidebar-left { width: 290px; }

/* ===== Nettoyage : onglet Selection, pastilles, outils ===== */
.sidebar-right { overflow: hidden; }
.rtab-content { overflow-y: auto; flex: 1; min-height: 0; }
.sidebar-tab { padding: 11px 6px; font-size: 12.5px; }
.sidebar-tabs { flex: none; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; flex: none; }
.dot-enemy { background: #ff5a5f; } .dot-coin { background: #ffcf6b; } .dot-laser { background: #ff3b5c; box-shadow: 0 0 0 2px rgba(255, 59, 92, .25); }
.dot-light { background: #ffe9a8; } .dot-orb { background: #7f8cff; } .dot-boss { background: #a982ff; }
.item-card span b { font-weight: 600; }
.item-card .item-meta { margin-left: 4px; }
.item-del-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; }
.item-del-btn:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.enemy-tool-btn .tool-icon { display: grid; place-items: center; height: 22px; }
.enemy-tool-btn .tool-icon .ico { width: 20px; height: 20px; }
.enemy-tool-btn kbd { opacity: .55; }
.btn .ico { margin-right: 0; }
.field-row label { font-size: 12px; }
.timeline-bar { gap: 10px; }
#inspectorContent .field-row input[type="number"], #inspectorContent .field-row input[type="text"] { height: 32px; }

/* ===== Brouillon, test d'ici, problemes ===== */
.draftState { font-size: 12px; color: var(--muted); white-space: nowrap; padding-left: 10px; }
.draftState.dirty { color: var(--gold); }
.draftState.dirty::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-right: 6px; vertical-align: 1px; }
.draft-banner { display: flex; align-items: center; gap: 10px; padding: 9px 16px; background: rgba(255, 207, 107, .12); border-bottom: 1px solid rgba(255, 207, 107, .35); color: #ffe2a3; font-size: 13px; }
.draft-banner span { flex: 1; }
.status-hint { color: var(--muted); border: 1px solid var(--line2); border-radius: 6px; padding: 1px 7px; font-size: 11px; cursor: help; }
.pt-partial { color: var(--gold); font-weight: 700; font-size: 12px; }
.ready.link { cursor: pointer; border-radius: 6px; margin: -3px -6px; padding: 3px 6px; }
.ready.link:hover { background: rgba(255, 255, 255, .06); }
.ready.link span { text-decoration: underline dotted rgba(255, 255, 255, .3); text-underline-offset: 3px; }
@media (max-width: 1380px) { .draftState { display: none; } }
.canvas-statusbar > span, .canvas-statusbar > label { white-space: nowrap; }
.canvas-statusbar { gap: 12px; }
@media (max-width: 1500px) { .status-hint { display: none; } }

/* ===== Menu de l'editeur : plan de travail (grille du jeu), tuiles au trait noir et ombre dure comme le logo ===== */
.eh { position: fixed; inset: 0; z-index: 200; overflow-y: auto; background-color: #121626;
  background-image: linear-gradient(rgba(130, 150, 220, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(130, 150, 220, .07) 1px, transparent 1px);
  background-size: 20px 20px; }
.eh::before { content: ''; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 0%, transparent 30%, rgba(10, 11, 18, .75) 100%); }
.eh-wrap { position: relative; width: min(1040px, 100%); margin: 0 auto; padding: 26px 24px 70px; }
.eh-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 34px; }
.eh-logo { position: relative; display: inline-flex; align-items: flex-end; padding-top: 6px; }
.eh-words { font: 900 34px/1 system-ui, sans-serif; letter-spacing: -.01em; color: #fff; text-shadow: 3px 3px 0 #0b0c11; }
.eh-tag { margin-left: 10px; margin-bottom: 4px; padding: 2px 10px 3px; font: 900 italic 15px/1.1 system-ui, sans-serif; color: #fff; background: var(--accent); border: 3px solid #0b0c11; box-shadow: 3px 3px 0 #0b0c11; border-radius: 6px; transform: rotate(-4deg); }

.eh-resume { display: flex; align-items: center; gap: 14px; width: 100%; margin-bottom: 22px; padding: 12px 18px; border: 2.5px solid #0b0c11; border-radius: 10px; box-shadow: 4px 4px 0 #0b0c11; background: #1c2032; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.eh-resume:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #0b0c11; }
.eh-resume-k { font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--mint); }
.eh-resume-n { font-weight: 700; font-size: 14px; }
.eh-resume-w { color: var(--muted); font-size: 13px; }
.eh-resume-go { margin-left: auto; font-weight: 800; color: var(--mint); }

.eh-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.eh-cards:has(#ehOfficial[hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 860px) { .eh-cards, .eh-cards:has(#ehOfficial[hidden]) { grid-template-columns: 1fr; } }
.eh-card { display: flex; flex-direction: column; padding: 0; border: 3px solid #0b0c11; border-radius: 12px; box-shadow: 6px 6px 0 #0b0c11; background: #1c2032; color: var(--text); font: inherit; text-align: left; cursor: pointer; overflow: hidden; transition: transform .12s, box-shadow .12s; }
.eh-card:hover { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 #0b0c11; }
.eh-card:active { transform: translate(2px, 2px); box-shadow: 3px 3px 0 #0b0c11; }
.eh-card.on { box-shadow: 6px 6px 0 var(--accent); }
.eh-card.gold.on { box-shadow: 6px 6px 0 var(--gold); }
.eh-art { position: relative; display: block; height: 168px; overflow: hidden; background: #262b40; border-bottom: 3px solid #0b0c11; }
.eh-scene { display: block; width: 100%; height: 100%; }
.eh-gob { animation: ehHop 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.eh-ball { animation: ehBall 2.2s ease-in-out infinite alternate; }
.eh-trail { animation: ehTrail 1.2s linear infinite; }
@keyframes ehHop { 0%, 55%, 100% { transform: none; } 62% { transform: translateY(1px) scale(1.12, .86); } 72% { transform: translateY(-7px) scale(.92, 1.1); } 84% { transform: translateY(0) scale(1.08, .92); } 92% { transform: none; } }
@keyframes ehBall { from { transform: translateY(0); } to { transform: translateY(38px); } }
@keyframes ehTrail { to { stroke-dashoffset: -10; } }
@media (prefers-reduced-motion: reduce) { .eh-gob, .eh-ball, .eh-trail { animation: none; } }
.eh-sticker { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 40px; height: 40px; border: 3px solid #0b0c11; border-radius: 8px; box-shadow: 3px 3px 0 #0b0c11; font: 900 26px/1 system-ui, sans-serif; transform: rotate(6deg); z-index: 3; }
.eh-sticker.red { background: var(--accent); color: #fff; }
.eh-sticker.gold { background: var(--gold); }
.eh-sticker.gold svg { width: 24px; height: 20px; fill: #fff6dc; stroke: #0b0c11; stroke-width: 1.6; stroke-linejoin: round; }
.eh-fan canvas { position: absolute; top: 50%; left: 50%; height: 66%; width: auto; aspect-ratio: 40 / 24; border: 2.5px solid #0b0c11; border-radius: 6px; box-shadow: 3px 3px 0 #0b0c11; image-rendering: pixelated; transition: transform .2s; }
.eh-fan canvas:nth-of-type(1) { transform: translate(-82%, -46%) rotate(-8deg); }
.eh-fan canvas:nth-of-type(2) { transform: translate(-18%, -56%) rotate(7deg); }
.eh-fan canvas:nth-of-type(3) { transform: translate(-50%, -44%) rotate(-1deg); z-index: 2; }
.eh-card:hover .eh-fan canvas:nth-of-type(1) { transform: translate(-92%, -48%) rotate(-11deg); }
.eh-card:hover .eh-fan canvas:nth-of-type(2) { transform: translate(-8%, -58%) rotate(10deg); }
.eh-fan.examples canvas { filter: grayscale(.35) brightness(.9); }
.eh-fan[data-n="1"] canvas:nth-of-type(1) { transform: translate(-50%, -50%) rotate(-3deg); }
.eh-card:hover .eh-fan[data-n="1"] canvas:nth-of-type(1) { transform: translate(-50%, -52%) rotate(-5deg); }
.eh-fan[data-n="2"] canvas:nth-of-type(1) { transform: translate(-72%, -48%) rotate(-7deg); }
.eh-fan[data-n="2"] canvas:nth-of-type(2) { transform: translate(-28%, -52%) rotate(5deg); }
.eh-fan-note { position: absolute; left: 10px; bottom: 8px; z-index: 3; font-size: 11px; font-weight: 700; color: var(--muted); }
.eh-label { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px 16px; }
.eh-label b { font-size: 17px; font-weight: 800; }
.eh-label span { color: var(--muted); font-size: 13px; }
.eh-card.gold .eh-label b { color: var(--gold); }

.eh-panel { margin-top: 34px; }
.eh-panel:empty { display: none; }
.eh-panel h2 { margin: 0 0 12px; font-size: 17px; font-weight: 800; }
.eh-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.eh-panel-head h2 { margin: 0; }
.eh-name { width: min(420px, 100%); height: 38px; margin-bottom: 16px; border-radius: 9px; border: 2px solid #0b0c11 !important; background: #1c2032 !important; }
.eh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.eh-item { display: flex; flex-direction: column; padding: 0; border: 2.5px solid #0b0c11; border-radius: 10px; box-shadow: 4px 4px 0 #0b0c11; background: #1c2032; color: var(--text); font: inherit; text-align: left; cursor: pointer; overflow: hidden; transition: transform .12s, box-shadow .12s; }
.eh-item:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #0b0c11; }
.eh-open { display: flex; flex-direction: column; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.eh-prev { display: block; width: 100%; height: auto; aspect-ratio: 40 / 24; image-rendering: pixelated; border-bottom: 2.5px solid #0b0c11; }
.eh-info { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.eh-info b { font-size: 13.5px; }
.eh-info small { color: var(--muted); font-size: 12px; }
.eh-acts { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 8px 8px; }
.eh-acts .danger:hover { color: #ff8e92; }
.eh-group { margin: 22px 0 10px; font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.eh-empty { color: var(--muted); }
.eh-login { margin-top: 44px; font-size: 13px; color: var(--muted); }
.eh-login summary { cursor: pointer; }
.eh-login form { display: flex; gap: 8px; margin-top: 10px; }
.eh-login input { height: 30px; }
.modeTag { font-size: 11px; font-weight: 800; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 7px; }
.modeTag:empty { display: none; }
body.mode-perso .modeTag { color: #9fd8ff; border-color: rgba(127, 200, 255, .4); }
.ready.info .ico { color: var(--muted); }
.ready.info { color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }


/* ===== Communaute : carte du menu ===== */
.eh-sticker.blue { background: #4b8dff; color: #fff; }
.eh-sticker.blue .ico { width: 20px; height: 20px; }
.eh-sticker.blue svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.2; }
/* carte Communaute : la planete tourne lentement avec ses goobers, les etoiles scintillent */
.eh-planet { transform-box: view-box; transform-origin: 100px 150px; animation: ehSpin 60s linear infinite; }
.eh-star { animation: ehTwinkle 2.4s ease-in-out infinite alternate; }
.eh-star:nth-of-type(2n) { animation-delay: -1.2s; }
@keyframes ehSpin { to { transform: rotate(-360deg); } }
@keyframes ehTwinkle { from { opacity: .25; } to { opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .eh-planet, .eh-star { animation: none; } }
.eh-cards:has(#ehOfficial[hidden]) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.eh-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* outil verrouille (point de controle pour un joueur) : grise, mention « Bientot » */
.tile-btn.locked { opacity: .45; cursor: not-allowed; position: relative; }
.tile-btn.locked::after { content: 'Bientôt'; margin-left: auto; padding: 1px 6px; border-radius: 99px; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; color: #ffcf6b; background: rgba(255,207,107,.12); border: 1px solid rgba(255,207,107,.35); }

/* options reservees a l'admin (niveau secret, boss, vortex, salles multiples) : cachees aux joueurs */
body.not-admin .admin-only { display: none !important; }

/* outil actif de l'onglet Machines */
#btnToolFan.active, #btnToolHatch.active { border-color: var(--accent); color: #fff; background: rgba(255, 90, 95, .16); }

/* ===== Rangement (barre d'outils verticale, une seule liste, panneau de droite unique) ===== */
/* gauche : barre d'outils verticale + options de l'outil choisi */
.sidebar-left { width: 300px; display: grid; grid-template-columns: 62px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.sidebar-left > .sub-tabs { grid-column: 1; grid-row: 1; flex-direction: column; gap: 4px; padding: 10px 6px; border-bottom: 0; border-right: 1px solid var(--line); background: var(--panel); }
.sidebar-left > .tab-content { grid-column: 2; grid-row: 1; padding: 14px 12px; }
.sidebar-left .sub-tab { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 7px; border: 0; border-radius: 10px; font-size: 10px; font-weight: 700; color: var(--muted); }
.sidebar-left .sub-tab .ico { width: 20px; height: 20px; }
.sidebar-left .sub-tab:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.sidebar-left .sub-tab.active { background: rgba(255, 90, 95, .15); color: #fff; border: 0; }
.sidebar-left .sub-tab.active .ico { color: var(--accent); }
.sidebar-left .sub-tab.admin-only { margin-top: auto; }           /* outils admin a part, en bas */
/* plus de listes en double a gauche : la liste des elements est a droite (volet « Elements poses ») */
#coinsList, #enemiesList, #lasersList, #lightsList, #fansList, #hatchesList,
.section-title:has(#enemiesCount), .section-title:has(#lasersCount), .section-title:has(#lightsCount),
.section-title:has(#fansCount), .section-title:has(#hatchesCount), span:has(> #coinsCount) { display: none !important; }

/* droite : un seul panneau ; Niveau quand rien n'est choisi, l'element sinon (bouton ✕ ou Echap pour revenir) */
.sidebar-right > .sidebar-tabs { display: none; }
#outlinerFold summary { font-weight: 700; }
#outlinerFold .global-item-list { max-height: 340px; overflow-y: auto; }

/* haut : le bouton « Verifier » vit dans la carte « Pret a publier ? » ; « Outil » est deja visible a gauche */
#btnSolve { display: none; }
.canvas-statusbar > span:first-child { display: none; }

/* salles : rien a afficher pour un niveau simple (l'admin garde « + Ajouter une salle ») */
#roomBar.single .room-tabs, #roomBar.single .room-hint, #roomBar.single .room-bar-title { display: none; }
#roomBar.single { padding: 4px 12px; justify-content: flex-end; }
body.not-admin #roomBar.single { display: none; }
/* la barre des salles vit dans la barre au-dessus de la carte */
.canvas-statusbar .room-bar { background: none; border: 0; padding: 0; gap: 8px; }
#roomBar.single { padding: 0; }
/* mention « Bientot » posee dans le coin : la case garde la taille des autres */
.tile-btn.locked::after { position: absolute; top: 3px; right: 4px; margin: 0; padding: 0 5px; font-size: 8.5px; line-height: 14px; }
/* medailles : les trois champs tiennent dans le panneau */
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-3 input { min-width: 0; width: 100%; }
/* boutons des lasers : un par ligne dans le panneau etroit */
#tab-lasers > div:has(#btnAddLaserBars) { grid-template-columns: 1fr !important; }
#tab-lasers > div:has(#btnAddLaserBars) > .btn { grid-column: auto !important; justify-content: flex-start; }
/* groupes prets a poser : le texte passe a la ligne plutot que d'etre coupe */
#tab-enemies > div:has(#btnAddSnake) .btn { white-space: normal; text-align: left; justify-content: flex-start; line-height: 1.2; min-width: 0; }
