:root {
  --bg: #12141a;
  --panel: #1b1e26;
  --panel-2: #232733;
  --line: #2f3441;
  --text: #e8e9ee;
  --muted: #8d93a5;
  --accent: #5865f2;
  --ok: #3ba55d;
  --err: #ed4245;
  --cost-1: #9aa3b2;
  --cost-2: #22c55e;
  --cost-3: #3b82f6;
  --cost-4: #a855f7;
  --cost-5: #f5b70a;
  --hex: 78px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  width: 100%;
}
textarea { resize: vertical; }
button {
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
}
button:hover { border-color: var(--muted); }
button.primary, a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  padding: 8px 16px;
  display: inline-block;
}
button.primary:disabled { opacity: .6; cursor: progress; }
.big { font-size: 16px; padding: 10px 22px !important; }
button.ghost { background: transparent; }

/* ---------- barre du haut ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.brand span { color: var(--accent); }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex: 1; }
.toolbar select { width: 260px; }
.lang-toggle { display: flex; }
.lang-toggle button { border-radius: 0; padding: 6px 10px; }
.lang-toggle button:first-child { border-radius: 6px 0 0 6px; }
.lang-toggle button:last-child { border-radius: 0 6px 6px 0; }
.lang-toggle button.active { background: var(--accent); border-color: var(--accent); }
.user { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.user img { width: 28px; height: 28px; border-radius: 50%; }
.user a { color: var(--muted); }

.login { max-width: 520px; margin: 12vh auto; text-align: center; }
.login p { color: var(--muted); margin-bottom: 28px; }

/* ---------- mise en page ---------- */
main {
  display: grid;
  /* largeurs fixes, centrées : rien ne s'étire sur un grand écran */
  grid-template-columns: 900px 460px;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  align-items: start;
}
@media (max-width: 1420px) { main { grid-template-columns: minmax(0, 900px); } }

.mode-banner {
  padding: 8px 12px; border-radius: 6px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.mode-banner b { color: var(--text); }
.mode-banner.update { border-color: #b7791f; background: #2a2214; }

/* ---------- plateau hexagonal ---------- */
.board-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px 22px 8px;
}
.board { display: flex; flex-direction: column; align-items: flex-start; }
.board-row { display: flex; gap: 6px; margin-top: calc(var(--hex) * -0.2); }
.board-row:first-child { margin-top: 0; }
.board-row.shifted { margin-left: calc(var(--hex) / 2 + 3px); }
.hex {
  width: var(--hex);
  height: calc(var(--hex) * 1.1547);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: #2a2f3c;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.hex.drop-target { background: #3d4a6b; }
.hex .coord { color: #4b5263; font-size: 11px; }
.hex.unit { cursor: grab; }
.hex.unit .inner {
  position: absolute; inset: 3px;
  clip-path: inherit;
  background-size: cover; background-position: center;
}
.hex.cost-1 { background: var(--cost-1); }
.hex.cost-2 { background: var(--cost-2); }
.hex.cost-3 { background: var(--cost-3); }
.hex.cost-4 { background: var(--cost-4); }
.hex.cost-5 { background: var(--cost-5); }

/* étoiles et objets superposés au plateau (hors clip-path) */
.cell { position: relative; }
.cell .stars {
  position: absolute; top: -2px; left: 0; right: 0; text-align: center;
  color: #ffd54a; font-size: 13px; text-shadow: 0 0 3px #000; pointer-events: none;
  letter-spacing: -1px;
}
.cell .unit-items {
  position: absolute; bottom: 4px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 1px; pointer-events: none;
}
.cell .unit-items img { width: 22px; height: 22px; border: 1px solid #000; border-radius: 3px; }
.cell .unit-name {
  position: absolute; bottom: -16px; left: -10px; right: -10px; text-align: center;
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.board .board-row { padding-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 12px 0 0; }

/* ---------- formulaire ---------- */
.comp-form {
  margin-top: 12px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.comp-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.comp-form .row { display: flex; gap: 12px; align-items: flex-end; }
.grow { flex: 1; }
.tier-picker { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.tier-picker button { width: 40px; font-weight: 700; }
.tier-picker button.active[data-tier="S"] { background: #e53e3e; border-color: #e53e3e; }
.tier-picker button.active[data-tier="A"] { background: #dd6b20; border-color: #dd6b20; }
.tier-picker button.active[data-tier="B"] { background: #d69e2e; border-color: #d69e2e; }
.tier-picker button.active[data-tier="C"] { background: #38a169; border-color: #38a169; }

.augment-box { position: relative; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 2px 8px 2px 2px; color: var(--text); font-size: 13px;
}
.chip img { width: 24px; height: 24px; border-radius: 50%; }
.chip button { border: none; background: none; padding: 0 2px; color: var(--muted); }
.dropdown {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  max-height: 280px; overflow-y: auto;
}
.dropdown div { display: flex; align-items: center; gap: 8px; padding: 5px 8px; cursor: pointer; color: var(--text); }
.dropdown div:hover, .dropdown div.active { background: var(--accent); }
.dropdown img { width: 24px; height: 24px; }

.upload-row { display: flex; align-items: center; gap: 16px; }
.status { flex: 1; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status ul { margin: 0; padding-left: 18px; }

/* ---------- traits ---------- */
.board-area { display: flex; gap: 18px; align-items: flex-start; }
/* traits en colonne à gauche du plateau */
.traits {
  display: flex; flex-direction: column; gap: 5px;
  width: 190px; flex-shrink: 0;
  max-height: 440px; overflow-y: auto;
}
.traits .empty { color: var(--muted); font-size: 12px; padding: 8px 2px; }
.trait {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 8px 3px 3px; font-size: 13px;
}
.trait img { width: 22px; height: 22px; filter: grayscale(1) brightness(.7); }
.trait.active { border-color: #b7791f; background: #2a2214; }
.trait.active img { filter: none; }
.trait .bp { color: var(--muted); font-size: 11px; }
.trait .bp b { color: #ffd54a; }

/* ---------- panneau champions / objets ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.right { display: flex; flex-direction: column; gap: 12px; }
.panel-title {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
}
.panel-body { padding: 10px; }
.filters.compact { gap: 6px; margin-bottom: 8px; }
.filter-row { display: flex; gap: 6px; }
.filter-row > * { flex: 1; min-width: 0; }
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.cost-filter, .kinds { display: flex; gap: 4px; flex-wrap: wrap; }
.cost-filter button, .kinds button { padding: 3px 10px; font-size: 13px; }
.cost-filter button.active, .kinds button.active { background: var(--accent); border-color: var(--accent); }

.pool {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px; max-height: calc(100vh - 330px); min-height: 200px; overflow-y: auto; padding: 2px;
}
.pool.items { grid-template-columns: repeat(auto-fill, 44px); justify-content: start; }
.pool-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: grab; user-select: none;
}
.pool-card img {
  width: 54px; height: 54px; border-radius: 6px; border: 2px solid var(--cost-1);
  display: block;
}
.pool.items .pool-card img { width: 40px; height: 40px; border: 1px solid var(--line); }
.pool-card span {
  font-size: 11px; color: var(--muted); max-width: 64px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pool-card.c1 img { border-color: var(--cost-1); }
.pool-card.c2 img { border-color: var(--cost-2); }
.pool-card.c3 img { border-color: var(--cost-3); }
.pool-card.c4 img { border-color: var(--cost-4); }
.pool-card.c5 img { border-color: var(--cost-5); }
.pool-card.on-board img { opacity: .45; }
.pool-card:hover span { color: var(--text); }

/* noms, étoiles et objets au-dessus des cases de la ligne suivante */
.cell .stars, .cell .unit-items, .cell .unit-name { z-index: 2; }
.cell .unit-name { text-shadow: 0 0 3px #000, 0 0 3px #000; color: #c9cdd8; }

/* ---------- grille de craft (onglet « Craft ») ---------- */
/* cases de taille fixe : la grille ne s'étire pas quand le panneau est large */
.pool.craft { --craft-cell: 44px; gap: 4px; align-items: center; justify-content: start; }
.pool.craft .pool-card img { width: var(--craft-cell); height: var(--craft-cell); }
.pool.craft .craft-head { margin-bottom: 6px; }
.pool.craft .craft-head img { border: 1px solid #b7791f; }
.craft-corner, .craft-empty { width: var(--craft-cell); height: var(--craft-cell); }
.craft-empty { border: 1px dashed var(--line); border-radius: 4px; opacity: .5; }
/* séparation de la ligne de la Poêle */
.pool.craft .craft-pan { margin-top: 8px; }

/* titres de section dans l'onglet « Autres » */
.pool-section {
  grid-column: 1 / -1;
  color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line); padding: 6px 0 4px; margin-top: 4px;
}

.trait > span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* trait mis en avant : le reste est grisé */
.trait { cursor: pointer; }
.trait.focused { outline: 2px solid var(--accent); outline-offset: -1px; }
.cell.dim, .pool-card.dim { opacity: .25; filter: grayscale(1); }
.pool-card.dim:hover { opacity: .6; }

/* objets d'une unité : clic = retirer */
.cell .unit-items img { pointer-events: auto; cursor: pointer; }
.cell .unit-items img:hover { outline: 2px solid var(--err); }

/* menu du clic droit sur une unité */
.unit-menu {
  position: fixed; z-index: 50; min-width: 170px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); padding: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.unit-menu-title { padding: 6px 8px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.unit-menu button { border: none; background: none; text-align: left; padding: 6px 8px; border-radius: 5px; }
.unit-menu button:hover { background: var(--accent); }
.unit-menu button.active { color: #ffd54a; }
.unit-menu .stars-label { color: #ffd54a; letter-spacing: -1px; }
.unit-menu button.danger:hover { background: var(--err); }

/* champions en version compacte, objets affichés en entier en dessous */
.pool.champions {
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px 4px; max-height: 250px; min-height: 0;
}
.pool.champions .pool-card img { width: 42px; height: 42px; }
.pool.champions .pool-card span { font-size: 10px; max-width: 50px; }
.pool.items { max-height: none; min-height: 0; overflow: visible; }

/* formulaire dans la colonne de droite (étroite) : champs empilés */
.right .comp-form { margin-top: 0; }
.right .comp-form .row { flex-direction: column; align-items: stretch; }
.right .comp-form .upload-row { flex-direction: column; align-items: stretch; }
/* champions sous le plateau (colonne large) */
.left > .panel { margin-top: 12px; }
.left .pool.champions { max-height: 300px; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }

/* tailles : champions plus grands, objets plus petits */
.left .pool.champions { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); max-height: 340px; gap: 8px 4px; }
.left .pool.champions .pool-card img { width: 58px; height: 58px; }
.left .pool.champions .pool-card span { font-size: 11px; max-width: 68px; }
.pool.craft { --craft-cell: 36px; gap: 3px; }
.pool.items { grid-template-columns: repeat(auto-fill, 36px); gap: 4px; }
.pool.items .pool-card img { width: 34px; height: 34px; }
