:root {
  --bg-color: #1e1e1e;
  --text-color: #ffffff;
  --container-bg: #2c2c2c;
  --armor-piece-bg: #3c3c3c;
  --hover-bg: #4a4a4a;
  --checkbox-bg: #555;
  --checkbox-checked: #4caf50;
  --save-success: #4caf50;
  --reset-success: #ff9800;
  --footer-text: #777;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  transition: background-color 0.5s ease, color 0.5s ease;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Save toast */
#save-notice {
  position: fixed;
  top: 20px;
  right: 20px;
  color: var(--text-color);
  background-color: var(--save-success);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, background-color 0.3s ease;
  z-index: 1000;
}

.container {
  max-width: 1100px;
  width: 100%;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.container.show {
  opacity: 1;
  transform: translateY(0);
}

small {
  display: block;
  margin-bottom: 20px;
  font-size: 12px;
  color: var(--footer-text);
}

.armor-box {
  background-color: var(--container-bg);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
}

.armor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.armor-piece {
  background-color: var(--armor-piece-bg);
  border-radius: 15px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.armor-piece:hover {
  background-color: var(--hover-bg);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.armor-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 15px;
  width: 100%;
  margin-bottom: 10px;
}

.armor-header h2 {
  font-size: 16px;
  margin: 0;
  white-space: nowrap;
}

.dropdown-group {
  display: flex;
  gap: 10px;
}

select {
  border-radius: 8px;
  padding: 5px;
  border: none;
  background-color: var(--checkbox-bg);
  color: var(--text-color);
}

.enchantments {
  text-align: left;
  margin-top: 10px;
  width: 100%;
}

.enchantment {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.enchantment input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  background-color: var(--checkbox-bg);
  border-radius: 5px;
  margin-right: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.enchantment input[type="checkbox"]:checked {
  background-color: var(--checkbox-checked);
  transform: scale(1.2);
  box-shadow: 0 0 10px var(--checkbox-checked), 0 0 20px var(--checkbox-checked);
}

.enchantment input[type="checkbox"]:not(:checked) {
  transform: scale(1);
}

#reset-btn {
  background-color: #ffeb3b;
  color: #000;
  border: none;
  padding: 10px 20px;
  border-radius: 15px;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.3s ease;

  /* re-center it */
  display: block;
  margin: 0 auto;
}

#reset-btn:hover {
  background-color: #ffe600;
  transform: scale(1.02);
}

#reset-btn:active {
  transform: scale(0.95);
}

#reset-btn.flash {
  background-color: var(--reset-success) !important;
}

/* Theme toggle */
#theme-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  background: none;
  border: 2px solid var(--text-color);
  color: var(--text-color);
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#theme-toggle:hover {
  background: var(--text-color);
  color: var(--bg-color);
}

.footer {
  position: fixed;
  bottom: 10px;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--footer-text);
  opacity: 0.7;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 12px;
  color: #aaa;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* Fancy toggle */
.enable-thorns {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #aaa;
  opacity: 0.8;
  cursor: pointer;
}

.enable-thorns input[type="checkbox"] {
  appearance: none;
  width: 40px;
  height: 20px;
  background-color: var(--checkbox-bg);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.enable-thorns input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: var(--text-color);
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.enable-thorns input[type="checkbox"]:checked {
  background-color: var(--checkbox-checked);
}

.enable-thorns input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.enable-thorns:has(input:disabled) {
  opacity: 0.4;
  color: #666;
  cursor: not-allowed;
}

.designed-by {
  font-size: 12px;
  color: #aaa;
  opacity: 0.8;
}

.disabled-thorns {
  opacity: 0.4;
  color: #666;
  cursor: not-allowed;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.disabled-thorns input {
  pointer-events: none;
}

#toggle-view-btn {
  background: none;
  border: 2px solid var(--text-color);
  color: var(--text-color);
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#toggle-view-btn:hover {
  background: var(--text-color);
  color: var(--bg-color);
}

@media (max-width: 768px) {
  #theme-toggle {
    position: static;
    margin-bottom: 20px;
    padding: 6px 12px;
    font-size: 12px;
  }

  .armor-grid {
    grid-template-columns: 1fr !important;
  }

  .armor-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dropdown-group {
    width: 100%;
    flex-direction: column;
  }

  select {
    width: 100%;
  }

  .footer {
    position: static;
    margin-top: 20px;
    text-align: center;
    opacity: 0.7;
    font-size: 10px;
  }

  body {
    overflow-x: hidden;
  }
}

/* Fade transitions */
.armor-grid.fade-out {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.armor-grid.fade-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.item-icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  vertical-align: middle;
}

/* Footer that pins the button to the bottom of each card */
.item-footer {
  margin-top: auto;
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Enchant button — matches Reset vibe (bold + rounded + hover/press) */
.item-enchant-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 0;
  font-size: 15px;
  font-weight: bold;
  border-radius: 15px;
  border: none;
  background-color: #4caf50;
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.3s ease;
}

.item-enchant-btn:hover:not(:disabled) {
  background-color: #43a047;
  transform: scale(1.02);
}

.item-enchant-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.item-enchant-btn:disabled {
  background-color: #777;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Too expensive state */
.item-enchant-btn.too-expensive {
  background-color: #e53935;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.85;
}

.item-enchant-btn.too-expensive:hover {
  background-color: #e53935;
  transform: none;
}

/* ------------------------
   Two-column layout + XP summary
------------------------ */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  align-items: start;
}

.right-col { width: 100%; }

.xp-summary {
  background: var(--container-bg);
  border-radius: 18px;
  padding: 16px;
  position: sticky;
  top: 18px;
  text-align: left;
}

.xp-title {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 10px;
}

.xp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 8px 0;
}

.xp-big {
  font-size: 28px;
  font-weight: 800;
}

.xp-row.saved {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.xp-saved {
  font-weight: 800;
  font-size: 18px;
  color: var(--checkbox-checked);
}

.xp-mini {
  font-size: 11px;
  color: var(--footer-text);
  margin-top: 10px;
  opacity: 0.9;
}

.xp-breakdown-title {
  margin-top: 14px;
  font-size: 12px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.xp-breakdown {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--footer-text);
}

.xp-itemline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.xp-itemline b {
  color: var(--text-color);
  font-weight: 600;
}

/* Small screen: receipt goes below + stretches */
@media (max-width: 900px) {
  .main-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  .left-col { order: 1; }
  .right-col { order: 2; }

  .xp-summary {
    position: static;
    width: 100%;
  }
}

/* Auto-move receipt to bottom when it would cover content */
.main-layout.receipt-bottom {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.main-layout.receipt-bottom .left-col { order: 1; }
.main-layout.receipt-bottom .right-col { order: 2; }

.main-layout.receipt-bottom .xp-summary {
  position: static;
  width: 100%;
}

/* ------------------------
   Modal (Enchant Plan)
------------------------ */
body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

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

.modal {
  width: min(720px, 100%);
  background: var(--container-bg);
  color: var(--text-color);
  border-radius: 18px;
  padding: 16px 16px 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  text-align: left;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: 2px solid var(--text-color);
  color: var(--text-color);
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--text-color);
  color: var(--bg-color);
}

.modal-subtitle {
  margin: 10px 0 12px;
  font-size: 12px;
  color: var(--footer-text);
}

.modal-steps {
  margin: 0;
  padding-left: 18px;
  max-height: 45vh;
  overflow: auto;
}

.modal-steps li {
  margin: 8px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.modal-btn {
  border: 2px solid var(--text-color);
  background: none;
  color: var(--text-color);
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-btn:hover {
  background: var(--text-color);
  color: var(--bg-color);
}

.modal-btn.primary {
  background: var(--checkbox-checked);
  border-color: var(--checkbox-checked);
  color: #fff;
}

.modal-btn.primary:hover {
  filter: brightness(0.95);
}
