/* =========================================================================
   NAINES : GLOIRE, MORT & BUTIN — STYLE DARK FANTASY MOBILE-FIRST & DESKTOP
   ========================================================================= */

:root {
  --bg-deep: #0f0a07;
  --bg-panel: #1a120d;
  --bg-card: #241912;
  --bg-card-hover: #2f2017;
  --border-stone: #3d2c1e;
  --gold: #fbbf24;
  --gold-strong: #d97706;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --danger: #f43f5e;
  --success: #4ade80;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  max-width: 1440px;
  margin: 0 auto;
}

/* ================= TOP BAR ================= */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #271a11 0%, #160e09 100%);
  border-bottom: 1px solid var(--border-stone);
  flex-shrink: 0;
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.4px;
}

.stage-pill {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fde68a;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.resource-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.res-chip {
  background: rgba(15, 10, 7, 0.75);
  border: 1px solid var(--border-stone);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.76rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.res-chip.gold { color: #fde047; }
.res-chip.mithril { color: #38bdf8; }
.res-chip.dust { color: #c084fc; }
.res-chip.glory { color: #fb923c; }
.res-chip.squad { color: #4ade80; }
.res-chip.mf { color: #34d399; }

.top-actions {
  display: flex;
  gap: 5px;
}

.icon-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-stone);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ================= BATTLE STAGE & CONTROLS ================= */
.battle-stage-wrapper {
  flex-shrink: 0;
  background: #120c08;
  border-bottom: 2px solid var(--border-stone);
}

.canvas-container {
  width: 100%;
  height: 220px;
  position: relative;
}

#battle-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.battle-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: #1b130d;
  border-top: 1px solid var(--border-stone);
}

.battle-left-controls,
.battle-right-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.fighting-indicator {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  padding: 4px 8px;
  background: rgba(251, 191, 36, 0.12);
  border-radius: 6px;
}

/* ================= BUTTONS & INPUTS ================= */
button {
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
  color: #fff;
  font-weight: 700;
  border: 1px solid #fde047;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.btn-primary:disabled,
.btn-chip:disabled,
.btn-cmd:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-chip,
.btn-cmd {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-stone);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-chip.active {
  background: rgba(245, 158, 11, 0.24);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-chip.danger,
.btn-cmd.danger {
  border-color: #9f1239;
  color: #fda4af;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.74rem;
  border-radius: 5px;
  background: var(--gold-strong);
  color: #fff;
  border: 1px solid var(--gold);
  font-weight: 700;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

.select-dark,
.input-dark {
  background: #120c08;
  color: var(--text-main);
  border: 1px solid var(--border-stone);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.8rem;
}

/* ================= MAIN TAB PANEL ================= */
.tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: var(--bg-deep);
}

.panel-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.section-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-stone);
  border-radius: 10px;
  padding: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.section-card h2 {
  font-size: 1.02rem;
  color: var(--gold);
}

.section-card h3 {
  font-size: 0.94rem;
  color: var(--gold);
  margin-bottom: 6px;
}

.section-card h4 {
  font-size: 0.85rem;
  color: #fde68a;
  margin: 8px 0 6px;
}

.section-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ================= DOORS / CHOICES ================= */
.doors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.door-card {
  background: var(--bg-card);
  border: 1px solid var(--border-stone);
  border-radius: 9px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 7px;
}

.door-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.18);
}

.door-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
}

.door-badge {
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
}

.door-desc {
  font-size: 0.77rem;
  color: var(--text-muted);
}

.door-rewards {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 0.74rem;
}

.door-rewards span {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 5px;
}

.artifact-hint {
  color: #fde047;
  border: 1px solid #d97706;
}

/* ================= SYNERGIES & LOG ================= */
.synergy-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.synergy-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid transparent;
  opacity: 0.65;
  font-size: 0.76rem;
}

.synergy-item.active {
  opacity: 1;
  background: rgba(16, 185, 129, 0.14);
  border-color: #10b981;
}

.syn-icon {
  font-size: 1.2rem;
}

.battle-log-box {
  background: #110b07;
  border: 1px solid var(--border-stone);
  border-radius: 7px;
  padding: 8px;
  height: 185px;
  overflow-y: auto;
  font-size: 0.76rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memorial-list {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ================= SQUAD & MAIDEN SHEET ================= */
.squad-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 10px;
}

.maiden-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 460px;
  overflow-y: auto;
}

.maiden-card {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  cursor: pointer;
}

.maiden-card.selected {
  border-color: var(--gold);
  background: var(--bg-card-hover);
}

.maiden-avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #120c08;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.braid-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid #fff;
}

.maiden-meta {
  flex: 1;
  min-width: 0;
}

.maiden-name-row,
.maiden-sub-row,
.maiden-pos-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.pos-pill {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.pos-pill.on {
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
}

.maiden-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.maiden-header-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.formation-row-selector {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.78rem;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 7px;
}

.equip-grid-8 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.equip-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border-radius: 8px;
  border: 1px dashed var(--border-stone);
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.equip-slot.filled {
  border-style: solid;
}

.slot-icon {
  font-size: 1.35rem;
}

.slot-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 0.74rem;
}

.slot-text strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-score {
  font-size: 0.68rem;
  color: #fde68a;
}

.stats-and-powers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats-box,
.powers-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  padding: 8px;
}

.stat-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 10px;
  font-size: 0.75rem;
}

.stat-rows > div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 2px;
}

.art-bonus {
  color: #fbbf24;
}

.power-pill {
  font-size: 0.74rem;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--gold);
  margin-bottom: 5px;
}

.power-pill.artifact { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.power-pill.unique { border-left-color: #fb923c; }
.power-pill.set { border-left-color: #10b981; background: rgba(16, 185, 129, 0.12); }

/* ================= LOOT INVENTORY & CARDS ================= */
.loot-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.loot-target-maiden,
.salvage-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.76rem;
}

.chk-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 7px;
}

.pill {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-stone);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.74rem;
  cursor: pointer;
}

.pill.active {
  background: rgba(251, 191, 36, 0.22);
  border-color: var(--gold);
  color: #fff;
}

.loot-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 8px;
}

.loot-card {
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
}

.loot-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loot-icon {
  font-size: 1.45rem;
}

.loot-title-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 0.76rem;
}

.loot-title-block strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loot-stats-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stat-tag {
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.42);
  padding: 2px 5px;
  border-radius: 4px;
  color: #e2e8f0;
}

.stat-tag.perfect {
  color: #fde047;
  border: 1px solid rgba(251, 191, 36, 0.55);
}

.loot-special {
  font-size: 0.7rem;
  padding: 3px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
}

.loot-special.artifact { color: #fde047; }
.loot-special.unique { color: #fdba74; }
.loot-special.set { color: #6ee7b7; }

.loot-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.score-diff.up { color: #4ade80; font-weight: 700; }
.score-diff.down { color: #f87171; }

/* ================= FORGE, RUNES & CODEX ================= */
.anvil-preview {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border-stone);
  border-radius: 8px;
}

.anvil-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.big-icon {
  font-size: 1.8rem;
}

.anvil-actions,
.merge-grid,
.craft-buttons-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.runes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.rune-card {
  display: flex;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  padding: 9px;
}

.rune-symbol {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 800;
  flex-shrink: 0;
}

.rune-body {
  flex: 1;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rune-top {
  display: flex;
  justify-content: space-between;
}

.codex-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.codex-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-stone);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
}

.sets-showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
}

.set-card {
  background: var(--bg-card);
  border: 1px solid var(--border-stone);
  border-radius: 8px;
  padding: 9px;
  font-size: 0.74rem;
}

.set-card ul {
  list-style: none;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ================= BOTTOM NAVIGATION ================= */
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: #160e09;
  border-top: 1px solid var(--border-stone);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
}

.nav-tab.active {
  color: var(--gold);
  background: rgba(251, 191, 36, 0.12);
  border-top: 2px solid var(--gold);
}

.nav-icon {
  font-size: 1.1rem;
}

/* ================= MODAL & TOAST ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal-wrapper {
  width: 100%;
  max-width: 520px;
}

.modal-card {
  background: var(--bg-panel);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.75);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.toast-banner {
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #241912;
  color: #fff;
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  z-index: 120;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.toast-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-legendary { border-color: #fbbf24; color: #fde047; }
.toast-danger { border-color: #f43f5e; color: #fda4af; }
.toast-success { border-color: #22c55e; color: #86efac; }

/* ================= RESPONSIVE MOBILE ADAPTATIONS ================= */
@media (max-width: 860px) {
  .two-col-grid,
  .squad-layout,
  .stats-and-powers-grid {
    grid-template-columns: 1fr;
  }

  .canvas-container {
    height: 175px;
  }

  .maiden-list {
    max-height: 210px;
  }
}
