:root {
  --gold: #c9a84c;
  --gold-light: #e8c97a;
  --gold-dark: #8a6a20;
  --copper: #b85c2e;
  --stone: #1a1714;
  --stone-mid: #2d2825;
  --stone-light: #3d3530;
  --stone-surface: #252220;
  --text-primary: #f0e8d8;
  --text-secondary: #a89880;
  --text-muted: #6b5e52;
  --border: rgba(201,168,76,0.2);
  --border-hover: rgba(201,168,76,0.5);
  --floor-fill: rgba(201,168,76,0.18);
  --floor-stroke: rgba(201,168,76,0.35);
  --wall-color: #c9a84c;
  --door-color: #ff9a3c;
  --passage-color: #6ec0ff;
  --calib-color: #2ecc71;
  --radius: 4px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--stone);
  color: var(--text-primary);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(201,168,76,0.03) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(201,168,76,0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}
.app {
  position: relative; z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* ═══ HEADER avec LOGO ═══════════════════════════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.logo-img {
  height: 64px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}
.header-text { flex: 1; min-width: 0; }
.header-brand {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.12em;
  line-height: 1;
}
.header-brand .light { color: var(--text-primary); font-weight: 400; }
.header-title {
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.08em;
  margin-top: 0.35rem;
}
.header-sub {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.88rem;
  margin-top: 2px;
}
@media (max-width: 600px) {
  .header { flex-direction: column; text-align: center; gap: 0.75rem; }
}

/* ═══ LAYOUT principal ═══════════════════════════════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 250px;
  gap: 1rem;
  align-items: start;
}
.tiles-bottom {
  margin-top: 1rem;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}

/* ═══ Panel commun ═══════════════════════════════════════════════════════ */
.panel {
  background: var(--stone-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.panel-title {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* ═══ Toolbar gauche ═════════════════════════════════════════════════════ */
.toolbar { display: flex; flex-direction: column; gap: 0.9rem; }
.tool-group { display: flex; flex-direction: column; gap: 5px; }
.tool {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.6rem;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.tool:hover { border-color: var(--border-hover); color: var(--text-primary); }
.tool.active { background: rgba(201,168,76,0.12); border-color: var(--gold); color: var(--gold); }

/* ─── Règles génériques pour les icônes SVG inline ─── */
/* S'applique à toute classe .icon (toolbar, thèmes, décors, ouvertures...). */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 15px; /* fallback si caractère Unicode toujours présent */
}
.icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon svg .ico-fill        { fill: currentColor; stroke: none; }
.icon svg .ico-accent      { fill: var(--copper); stroke: none; }
.icon svg .ico-accent-line { stroke: var(--copper); fill: none; }

.tool .key { margin-left: auto; font-size: 9px; color: var(--text-muted); border: 1px solid var(--border); padding: 1px 4px; border-radius: 2px; font-family: monospace; }
.tool.active .key { border-color: var(--gold-dark); color: var(--gold-dark); }

/* ─── Tooltip miniature au survol ─── */
.tool-tip {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--stone-mid);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.5rem;
  z-index: 100;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  pointer-events: none;
  width: 130px;
}
.tool:hover .tool-tip { display: block; }
.tool-tip-label {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 4px;
}
.tool-tip-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  font-style: italic;
  margin-top: 4px;
  line-height: 1.3;
}
.tile-mini {
  width: 100%;
  height: 50px;
  display: block;
}

/* Themes & options */
.theme-btn, .toggle-row button, .action-btn {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.15s;
}
.theme-btn:hover, .action-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.theme-btn.active { background: rgba(201,168,76,0.12); border-color: var(--gold); color: var(--gold); }
.action-btn { display: flex; align-items: center; gap: 6px; text-align: left; }
.action-btn.danger:hover { border-color: #c0392b; color: #e74c3c; }
.action-btn.active-pan { background: rgba(201,168,76,0.15); border-color: var(--gold); color: var(--gold); }

.mode-toggle-wrap {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border);
}
.mode-toggle {
  display: flex;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
  max-width: 400px;
}
.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.55rem 0.6rem;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
}
.mode-btn:hover { color: var(--text-primary); }
.mode-btn.active { background: var(--gold); color: var(--stone); }
.mode-explanation {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
}
.mode-explanation strong { color: var(--gold); font-style: normal; }

.rooms-info {
  background: rgba(46,204,113,0.08);
  border: 1px solid rgba(46,204,113,0.25);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  color: #82d4a3;
  font-style: italic;
  margin-bottom: 0.85rem;
  line-height: 1.4;
}
.rooms-info strong { color: #2ecc71; font-style: normal; }

.actions-bar {
  display: flex;
  gap: 4px;
  padding-bottom: 0.55rem;
  border-bottom: 1px dashed var(--border);
}
.action-mini {
  flex: 1;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.3rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.action-mini:hover { border-color: var(--border-hover); color: var(--text-primary); }
.action-mini.danger:hover { border-color: #c0392b; color: #e74c3c; }
.action-mini span { font-size: 11px; }

.toggle-row {
  display: flex;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
  margin-bottom: 4px;
}
.toggle-row button {
  flex: 1;
  background: transparent;
  border: none;
  margin: 0;
  font-size: 0.65rem;
  padding: 0.35rem 0.2rem;
}
.toggle-row button.active { background: var(--gold); color: var(--stone); }
.toggle-row button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ═══ Canvas central ═════════════════════════════════════════════════════ */
.canvas-wrap {
  background: var(--stone-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  overflow: auto;
  max-height: 70vh;
  min-height: 200px;        /* évite l'effondrement au dézoom extrême */
  width: 100%;
  min-width: 0;             /* empêche la colonne grid de déborder */
  box-sizing: border-box;
}
svg.grid { display: block; user-select: none; cursor: crosshair; }
svg.grid.tool-door, svg.grid.tool-passage, svg.grid.tool-decor { cursor: pointer; }
svg.grid.tool-pan { cursor: grab; }
svg.grid.tool-pan.dragging { cursor: grabbing; }

.decor-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.5rem;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: 'Crimson Pro', serif;
  font-size: 0.78rem;
  cursor: pointer;
  margin-bottom: 3px;
  transition: all 0.15s;
  text-align: left;
}
.decor-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.decor-btn.active { background: rgba(255,107,53,0.12); border-color: #ff6b35; color: #ff8c5a; }
.decor-btn.disabled { opacity: 0.35; cursor: not-allowed; }
.decor-btn span:first-child { font-size: 14px; width: 18px; text-align: center; }

.opening-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.5rem;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: 'Crimson Pro', serif;
  font-size: 0.78rem;
  cursor: pointer;
  margin-bottom: 3px;
  transition: all 0.15s;
  text-align: left;
}
.opening-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.opening-btn.active { background: rgba(255,154,60,0.12); border-color: var(--door-color); color: #ffb96e; }
.opening-btn.disabled { opacity: 0.35; cursor: not-allowed; }
.opening-btn span:first-child { font-size: 13px; width: 28px; text-align: center; flex-shrink: 0; }

.canvas-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  border-top: 1px solid var(--border);
  margin-top: 0.4rem;
  padding-top: 0.6rem;
}
.canvas-info .hint { color: var(--text-secondary); }

/* ═══ Sidebar droite : Image controls ═══════════════════════════════════ */
.img-panel-empty {
  text-align: center;
  padding: 1rem 0.4rem;
}
.img-import-btn {
  display: block;
  width: 100%;
  padding: 0.7rem;
  background: rgba(201,168,76,0.1);
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.img-import-btn:hover {
  background: rgba(201,168,76,0.15);
  border-color: var(--gold);
}
.img-import-btn .ic { display: block; font-size: 1.5rem; margin-bottom: 4px; }
.img-empty-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.6rem;
  line-height: 1.4;
}

/* Slider avec nudge */
.slider-row {
  margin-bottom: 0.6rem;
}
.slider-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  font-family: 'Cinzel', serif;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.slider-label .val { color: var(--gold); font-family: monospace; font-size: 11px; }
.slider-control {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nudge-btn {
  width: 22px; height: 22px;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: monospace;
  transition: all 0.1s;
  user-select: none;
}
.nudge-btn:hover { border-color: var(--gold); color: var(--gold); }
.nudge-btn:active { background: rgba(201,168,76,0.15); }
.slider-control input[type=range] {
  flex: 1;
  accent-color: var(--gold);
  height: 4px;
  min-width: 0;
}

.calib-hint {
  background: rgba(46,204,113,0.08);
  border: 1px solid rgba(46,204,113,0.3);
  color: #2ecc71;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.72rem;
  margin: 0.5rem 0;
  text-align: center;
  line-height: 1.4;
}

/* ═══ Tiles list (en bas) ════════════════════════════════════════════════ */
.tiles-bottom .panel { padding: 1.2rem; }
.tiles-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 800px) {
  .tiles-layout { grid-template-columns: 1fr; }
}
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.2rem 1.5rem;
}
.tile-category-block {
  break-inside: avoid;
}
.tile-cat-title {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--gold-dark);
  text-transform: uppercase;
  margin: 0.5rem 0 0.3rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}
.tile-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(201,168,76,0.05);
  font-size: 0.82rem;
}
.tile-row:last-child { border: none; }
.tile-name { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { font-size: 0.7rem; color: var(--text-muted); font-style: italic; }
.tile-qty { font-family: 'Cinzel', serif; font-size: 0.9rem; font-weight: 600; color: var(--gold); min-width: 28px; text-align: right; }
.tile-price { font-size: 0.76rem; color: var(--text-secondary); min-width: 60px; text-align: right; }

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 1.5rem;
  font-size: 0.88rem;
  line-height: 1.7;
}

.summary-panel {
  background: linear-gradient(to bottom, rgba(201,168,76,0.1), rgba(201,168,76,0.04));
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  position: sticky;
  top: 1rem;
}
.summary-panel .lbl { font-size: 10px; letter-spacing: 0.2em; font-family: 'Cinzel', serif; color: var(--text-muted); text-transform: uppercase; }
.summary-panel .val { font-family: 'Cinzel', serif; font-size: 1.7rem; font-weight: 600; color: var(--gold); margin-top: 4px; }
.summary-panel .sub { font-size: 0.82rem; color: var(--text-secondary); margin-top: 4px; }
.cart-btn {
  width: 100%;
  padding: 0.7rem;
  margin-top: 0.9rem;
  background: var(--gold);
  color: var(--stone);
  border: none;
  border-radius: var(--radius);
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.15s;
}
.cart-btn:hover { background: var(--gold-light); }
.cart-btn:disabled { opacity: 0.4; cursor: not-allowed; }


/* ═══ Zoom controls ══════════════════════════════════════════════════════════ */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.zoom-btn {
  background: var(--stone-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: monospace;
  font-size: 13px;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.15s;
  padding: 0;
}
.zoom-btn:hover { border-color: var(--gold); color: var(--gold); }
.zoom-reset { font-size: 11px; }
#zoom-level {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 34px;
  text-align: center;
}
/* Le SVG se redimensionne via width/height CSS — le wrap scrolle avec overflow:auto */
.canvas-wrap {
  overflow: auto;
  position: relative;
}
.canvas-wrap svg {
  display: block;
  /* transform-origin retiré : le zoom passe désormais par width/height, pas transform:scale */
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--stone); }
::-webkit-scrollbar-thumb { background: var(--stone-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* Help footer */
.help {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 1.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.help kbd {
  background: var(--stone-surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* ═══ Taille de la grille ════════════════════════════════════════════════ */
.size-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.65rem;
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.15s;
  flex: 1;          /* s'étire dans la barre horizontale */
  min-width: 0;
}
.size-btn:hover  { border-color: var(--border-hover); color: var(--text-primary); }
.size-btn.active { background: rgba(201,168,76,0.12); border-color: var(--gold); color: var(--gold); }
.size-btn .size-tag {
  font-family: monospace;
  font-size: 0.65rem;
  opacity: 0.7;
}
.size-btn.active .size-tag { opacity: 1; }

/* ═══ Barre taille de grille (sous le canvas) ════════════════════════════ */
.grid-size-bar {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}
.grid-size-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.grid-size-btns {
  display: flex;
  gap: 6px;
}
/* Dans la barre horizontale, les size-btn n'ont pas de margin-bottom */
.grid-size-btns .size-btn { margin-bottom: 0; }
.grid-size-note {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
  line-height: 1.3;
}

/* ═══ Panel "Tuiles déjà possédées" ══════════════════════════════════════ */
.owned-panel {
  background: rgba(201,168,76,0.04);
  border: 1px dashed rgba(201,168,76,0.25);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.9rem;
}
.owned-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.owned-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  user-select: none;
}
.owned-toggle input[type="checkbox"] {
  accent-color: var(--gold);
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}
.owned-hint {
  font-size: 0.67rem;
  color: var(--text-muted);
  font-style: italic;
  padding-left: 22px;
}
.owned-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  margin-top: 0.6rem;
  line-height: 1.4;
}
.owned-empty {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 0.4rem 0;
}
/* Ligne de saisie pour une tuile possédée */
.owned-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 4px 0;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}
.owned-row:last-child { border-bottom: none; }
.owned-row-name {
  font-size: 0.7rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.owned-row-name em {
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.63rem;
  margin-left: 4px;
}
.owned-row-ctrl {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.owned-dec, .owned-inc {
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  width: 22px;
  height: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s;
}
.owned-dec:hover, .owned-inc:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.owned-input {
  background: var(--stone-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-family: monospace;
  width: 40px;
  height: 22px;
  text-align: center;
  padding: 0 2px;
  -moz-appearance: textfield;
}
.owned-input::-webkit-outer-spin-button,
.owned-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.owned-input:focus { outline: none; border-color: var(--gold); }

/* Affichage déduction dans les tile-rows */
.tile-owned-note {
  font-size: 0.65rem;
  color: var(--gold);
  opacity: 0.8;
  margin-top: 2px;
}
.tile-row--owned {
  opacity: 0.55;
}
.tile-row--owned .tile-name {
  text-decoration: line-through;
  text-decoration-color: var(--gold);
}
.tile-qty--owned { color: #2ecc71; }
.tile-price--owned { color: var(--text-muted); }
.qty-needed-total {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 2px;
}
.owned-deduct-banner {
  background: rgba(46,204,113,0.08);
  border: 1px dashed rgba(46,204,113,0.35);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  font-size: 0.75rem;
  color: #2ecc71;
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

/* ═══ Indicateur de sauvegarde ═══════════════════════════════════════════ */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0;
  transition: opacity 0.3s;
  margin-left: auto;
}
.save-indicator.saved { opacity: 1; }
.save-indicator::before { content: '💾'; font-style: normal; }

/* ═══ Bannière mobile ════════════════════════════════════════════════════ */
.mobile-banner {
  display: none; /* affiché par JS si mobile */
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(201,168,76,0.1);
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.mobile-banner strong { color: var(--gold); }
.mobile-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 4px;
  line-height: 1;
}
.mobile-banner-close:hover { color: var(--text-primary); }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--stone-mid);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  z-index: 1000;
  transition: transform 0.3s;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ═══ Vue 3D Isométrique — Three.js ═════════════════════════════════════════ */

/* Le canvas Three.js est positionné en overlay absolu sur le canvas-wrap */
.canvas-wrap { position: relative; }

#three-canvas {
  border-radius: var(--radius);
  cursor: grab;
}
#three-canvas.three-dragging { cursor: grabbing; }

/* En mode 3D : cacher le stage SVG */
.canvas-wrap.view-3d #view3d-stage { visibility: hidden; }

/* Bandeau — reste identique, juste repositionné */
.canvas-wrap.view-3d .view3d-banner { display: block; }

/* ─── Bandeau de mode ─── */
.view3d-banner {
  display: none;
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 17, 14, 0.90);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 5px 16px;
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--gold);
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  animation: banner-in 0.4s ease;
}

@keyframes banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.canvas-wrap.view-3d .view3d-banner { display: block; }

/* ─── Bouton Vue 3D actif ─── */
.zoom-btn.view3d-active {
  background: rgba(201, 168, 76, 0.18);
  border-color: var(--gold);
  color: var(--gold);
}

/* ═══ Label input flottant (double-clic sur une salle) ══════════════════════ */
.label-edit-input {
  display: none;
  position: fixed;
  transform: translate(-50%, -50%);
  z-index: 500;
  background: var(--stone-mid);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.7rem;
  outline: none;
  text-align: center;
  min-width: 140px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.label-edit-input::placeholder { color: var(--text-muted); font-style: italic; }

/* ═══ Comparateur de prix inter-thèmes ══════════════════════════════════════ */
#theme-compare {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  font-size: 0.72rem;
  text-align: left;
}
.cmp-title {
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-align: center;
}
.cmp-row {
  display: grid;
  grid-template-columns: 48px 1fr 36px 30px;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
  border-radius: 2px;
  transition: background 0.1s;
}
.cmp-row.cmp-current { background: rgba(201,168,76,0.08); border-radius: 3px; }
.cmp-name {
  font-size: 0.68rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-current .cmp-name { color: var(--gold); font-weight: 600; }
.cmp-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.cmp-bar {
  height: 100%;
  background: var(--gold-dark);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.cmp-current .cmp-bar { background: var(--gold); }
.cmp-price {
  font-family: monospace;
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
}
.cmp-current .cmp-price { color: var(--gold); }
.cmp-diff {
  font-size: 0.6rem;
  text-align: right;
  white-space: nowrap;
}
.cmp-more { color: #e74c3c; }
.cmp-less { color: #2ecc71; }

/* ═══ Barre de nommage des salles (outil Label) ══════════════════════════════ */
#label-bar {
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(26,23,20,0.96);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  margin-top: 4px;
  animation: label-bar-in 0.18s ease;
  flex-wrap: nowrap;
}
@keyframes label-bar-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.label-bar-icon {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 700;
  flex-shrink: 0;
}
.label-bar-prompt {
  font-size: 0.72rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
#label-input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-primary);
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  outline: none;
  transition: border-color 0.15s;
}
#label-input:focus { border-color: var(--gold); }
#label-input::placeholder { color: var(--text-muted); font-style: italic; font-family: sans-serif; font-size: 0.72rem; letter-spacing: 0; }
.label-bar-btn {
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
  border: 1px solid transparent;
}
.label-bar-btn--ok  { background: rgba(201,168,76,0.18); border-color: var(--gold); color: var(--gold); }
.label-bar-btn--ok:hover { background: rgba(201,168,76,0.32); }
.label-bar-btn--del { background: rgba(192,57,43,0.15); border-color: rgba(231,76,60,0.5); color: rgba(231,76,60,0.8); }
.label-bar-btn--del:hover { background: rgba(192,57,43,0.28); }

/* Supprimer l'ancien floating input */
.label-edit-input { display: none !important; }
