:root {
  --bg:#0f0c0a;
  --panel:#1c1612;
  --panel-dark:#14100d;
  --gold:#d6a94a;
  --text:#e6e1db;
  --green:#4caf50;
  --red:#f44336;
}

* { box-sizing:border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, Arial, sans-serif;
}

/* ===== LAYOUT ===== */
.app {
  display: grid;
  grid-template-columns: 1fr 360px 300px; /* left = skill tree, middle = char/gear, right = stats */
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
  grid-template-rows: auto 1fr auto; /* top content + filler + bottom enemy */
}

/* ===== PANEL ===== */
.panel {
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  box-shadow: inset 0 0 20px #000;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--gold);
  text-transform: uppercase;
}

/* ===== CHARACTER ===== */
.character-img {
  width: 120px;
  height: 160px;
  margin: 10px auto;
  background: #2a211a;
  border-radius: 10px;
}

/* ===== STAT ALLOCATION ===== */
.stat-allocation {
  margin-top: 10px;
}

.build-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.build-btn {
  flex: 1;
  padding: 6px 10px;
  background: linear-gradient(135deg, #3d2f1f, #2a211a);
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.build-btn:hover {
  background: linear-gradient(135deg, #4d3f2f, #3a312a);
  box-shadow: 0 0 10px rgba(214, 169, 74, 0.3);
  transform: translateY(-1px);
}

.build-btn:active {
  transform: translateY(0);
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider {
  display: grid;
  grid-template-columns: 90px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.slider input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  appearance: none;
  background: linear-gradient(
    to right,
    var(--gold) 0%,
    var(--gold) var(--percent, 0%),
    #2a211a var(--percent, 0%)
  );
}

.slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
}

.slider span:last-child {
  text-align: right;
  font-weight: bold;
  color: var(--gold);
}

/* ===== GEAR ===== */
.gear-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.slot {
  background: var(--panel-dark);
  border-radius: 10px;
  height: 56px;
  border: 1px solid #3a2d22;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  position: relative;
  text-align: center;
}

/* ===== SKILL TREE LEFT ===== */
.skill-tree-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
  position: relative;
  padding: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

#skillTreeCanvas {
  flex: 1;
  display: block;
  background: #0a0a0a;
}

.skill-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(12,14,20,0.9);
  border: 1px solid #3a3d46;
  border-radius: 12px;
  padding: 10px;
  min-width: 240px;
  max-width: 280px;
  backdrop-filter: blur(6px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  z-index: 100;
  font-size: 12px;
}

.skill-overlay h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--gold);
}

.skill-overlay .kv {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin: 4px 0;
  color: var(--text);
}

.skill-overlay .section-title {
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

#skillStatLines .kv {
  justify-content: space-between;
  color: #cfd5e0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 2px 0 4px;
  line-height: 1.3;
}

#skillStatLines .kv strong {
  color: #f4f6fb;
}


.stats-panel {
  grid-column: 3;
  grid-row: 1 / span 2;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 55px);
  overflow-y: auto;
  padding: 18px; /* a bit more padding */
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px 12px;
}

.stat {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  border-bottom: 1px solid #2a221c;
  font-size: 13px; /* slightly bigger font */
  padding: 6px 0; /* more spacing between rows */
}

.stat-category {
  grid-column: 1 / -1;
  margin-top: 10px;
  font-size: 14px;
  font-weight: bold;
  color: var(--gold);
  font-size: 14px; /* category headers slightly bigger */
  margin-top: 14px; /* more spacing before each category */
}

/* ===== ENEMY ===== */
.enemy-panel {
  grid-column: 1 / 3; /* spans left + middle */
  max-width: 520px;
  margin: 0 auto;
}

.enemy-res label {
  display: grid;
  grid-template-columns: 1fr 60px;
  gap: 8px;
  margin-bottom: 6px;
}

/* ===== DROPDOWN ===== */
.dropdown {
  position: absolute;
  top: 0;
  left: 100%;
  width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: #18130f;
  border-radius: 10px;
  padding: 8px;
  z-index: 50;
}

.item-option {
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
}

.item-option:hover {
  background: #2a211a;
}

/* ===== COMPARISON ===== */
#comparisonPanel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 560px; /* slightly wider by default so diffs fit on one line */
  background: #18130f;
  border-radius: 10px;
  padding: 10px;
  display: none;
  z-index: 1000;
} 

/* compact single-line comparison */
#compStats { display:flex; flex-direction:column; gap:6px; }
.comp-line { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 8px; }
.comp-line .stat-name { color:var(--gold); font-weight:600; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width: 260px; }
.comp-line .values { text-align:left; display:flex; align-items:center; gap:6px; white-space:nowrap; overflow:visible; }

/* make the diff parenthetical a single non-wrapping inline block */
.diff { white-space:nowrap; display:inline-block; }
.comp-old { color:#8a857c; margin-right:4px; display:inline-block; }
.comp-new { font-weight:bold; }
.diff.positive { color:var(--green); font-weight:600; margin-left:6px; white-space:nowrap; }
.diff.negative { color:var(--red); font-weight:600; margin-left:6px; white-space:nowrap; }
.arrow { color:#aaa; margin: 0 6px; display:inline-block; }

/* ensure values never wrap and long stat names are truncated on the left */
.comp-line { min-width: 0; }
.comp-line .stat-name { text-overflow: ellipsis; }

.comp-col {
  flex: 1;
}

.comp-col div {
  font-size: 13px;
  margin: 2px 0;
}

.comp-col div span.diff {
  font-weight: bold;
  margin-left: 6px;
}

/* CHARACTER BUTTONS */
.dropdown-wrapper {
  margin-bottom: 8px;
}

#classCharacterSelect select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--panel-dark);
  color: var(--text);
  border: 1px solid #3a2d22;
  font-size: 13px;
}

.char-select { display:flex; gap:8px; flex-wrap: wrap; }
.char-option {
  padding:6px 12px;
  border-radius:8px;
  cursor:pointer;
  background:#2a211a;
  color: var(--text);
  font-weight:bold;
  text-align:center;
}
.char-option.active { background: var(--gold); color:#000; }


/* DROPDOWN RARITY COLORS */
.rarity-common { color: grey; }
.rarity-uncommon { color: green; }
.rarity-rare { color: #2196f3; }
.rarity-epic { color: violet; }
.rarity-legendary { color: yellow; }


/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .app {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
  }

  .stats-panel {
    grid-column: 2;
    grid-row: 1 / 2;
    max-height: 400px;
    position: sticky;
    top: 16px;
  }

  .enemy-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .stats-panel {
    position: static;
    max-height: none;
  }

  .enemy-panel {
    max-width: none;
  }
}