:root {
  /* Light mode (default) */
  --bg-primary: #f9f9f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f7f7f7;
  --text-primary: #000000;
  --text-secondary: #666666;
  --border-color: #ddd;
  --card-border: #ddd;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-heavy: rgba(0, 0, 0, 0.18);
  --input-bg: #fff;
  --card-hover: #f5f5f5;
}

body.dark-mode {
  /* Dark mode */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --text-primary: #d0d0d0;
  --text-secondary: #999;
  --border-color: #444;
  --card-border: #333;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-heavy: rgba(0, 0, 0, 0.5);
  --input-bg: #333;
  --card-hover: #3d3d3d;
}

body {
  font-family: system-ui, Arial;
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

body.no-scroll {
  overflow: hidden;
}

header {
  flex: 0 0 auto;
  padding: 12px;
  display: flex;
  gap: 8px;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
}

#q {
  flex: 1;
  padding: 10px;
  font-size: 16px;
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

header button {
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.2s;
}

@media (hover: hover) {
header button:hover {
  opacity: 0.9;
}
}

#btnAbout { margin-left: 0; }
/* Main Layout with Sidebar */
.main-layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;          /* the grid fills whatever is left under the header, however tall the header is */
  overflow: hidden;
}

/* Category Sidebar */
.category-sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 20px 0;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 0 20px 16px 20px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 12px;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  text-align: left;
}

@media (hover: hover) {
.category-btn:hover {
  background: #f5f5f5;
  color: var(--text-primary);
}
}

.category-btn.active {
  background: #5865f2;
  color: #fff;
}

.category-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

/* Results Container */
.results-container {
  flex: 1;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-content: start;
  overflow-y: auto;
}

#results { padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); grid-auto-rows: min-content; align-content: start; gap: 12px; }
.card {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  background: var(--bg-secondary);
  transition: background 0.2s, border-color 0.3s;
}

@media (hover: hover) {
.card:hover {
  background: var(--card-hover);
}
}
.card img {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  object-fit: contain;
}
.name { font-weight: 600; overflow-wrap: anywhere; }
.card > div { min-width: 0; }
.small { font-size: 12px; opacity: 0.7; }


/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.hidden { display: none; }

.modal {
  position: relative;
  width: min(520px, calc(100vw - 24px));
  background: var(--bg-secondary);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

.modalTop {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

#modalImg {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  object-fit: contain;
}

#infoModalImg {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  object-fit: contain;
}

.modalTitle {
  font-weight: 800;
  font-size: 20px;
  color: var(--text-primary);
}

.modalSub {
  font-size: 13px;
  opacity: 0.75;
  margin-top: 4px;
  color: var(--text-secondary);
}

.modalBtns {
  display: grid;
  gap: 10px;
}

.modalBtns button {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
}

@media (hover: hover) {
.modalBtns button:hover {
  background: var(--card-hover);
}
}

.modalClose {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.7;
  color: var(--text-primary);
}
@media (hover: hover) {
.modalClose:hover { opacity: 1; }
}

/* ---- TREE OVERLAY ---- */
.tree {
  position: fixed;
  inset: 0;
  background: var(--bg-secondary);
  z-index: 9999;
}

.tree.hidden {
  display: none;
}

.treeTopbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.tree-legend {
  margin-left: auto;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  gap: 4px;
}

.treeTopbar button {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  vertical-align: middle;
}

.treeTitle {
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
}

.treeViewport {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  user-select: none;
  background: var(--bg-primary);
  overflow: hidden;
  cursor: grab;
}

.treeViewport:active {
  cursor: grabbing;
}

.treeWorld {
  position: absolute;
  left: 0;
  top: 0;
  width: 3000px;
  height: 3000px;
}

.treeNode {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--bg-secondary);
  width: 180px;
  height: 60px;
  box-shadow: 0 6px 16px var(--shadow);
  pointer-events: auto;
  z-index: 10;
  box-sizing: border-box;
  overflow: hidden;
  cursor: default;
}

.treeNode img {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  image-rendering: pixelated;
  object-fit: contain;
}

.treeNode > div {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
}

.treeNode > div > div:first-child {
  font-weight: 800;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* boxes with only a name (no station line) have room for a third line */
.treeNode > div > div:first-child:only-child { -webkit-line-clamp: 3; }

/* Increase z-index on hover */
@media (hover: hover) {
.treeNode:hover {
  z-index: 1000;
}
}

/* Timeline styles */
.timeline-page {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 10000;
  overflow-y: auto;
}

.timeline-page.hidden {
  display: none;
}

.timeline-header {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  border-bottom: 2px solid #ddd;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 100;
}

.timeline-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

.timeline-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.timeline-stage {
  margin-bottom: 60px;
}

.stage-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #f0f0f0;
  padding: 20px 24px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stage-header h2 {
  margin: 0 0 8px 0;
  font-size: 28px;
  font-weight: 800;
  color: #f0f0f0;
}

.stage-header p {
  margin: 0;
  opacity: 0.85;
  font-size: 16px;
}

.stage-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 0 8px;
}

.timeline-item {
  background: var(--bg-secondary);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  cursor: pointer;
  color: var(--text-primary);
}

@media (hover: hover) {
.timeline-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow);
  border-color: #667eea;
  background: var(--card-hover);
}
}

.timeline-item img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.timeline-item-info {
  flex: 1;
  min-width: 0;
}

.timeline-item-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-item-type {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Stage-specific colors */
.stage-prehardmode .stage-header {
  background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
}

.stage-hardmode .stage-header {
  background: linear-gradient(135deg, #fc4a1a 0%, #f7b733 100%);
}

.stage-plantera .stage-header {
  background: linear-gradient(135deg, #7F00FF 0%, #E100FF 100%);
}

.stage-golem .stage-header {
  background: linear-gradient(135deg, #f12711 0%, #f5af19 100%);
}

.stage-moonlord .stage-header {
  background: linear-gradient(135deg, #360033 0%, #0b8793 100%);
}

.milestone {
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.milestone-icon {
  font-size: 24px;
}

.milestone-text {
  font-weight: 600;
  color: #856404;
}
/* Toggle Switch for Settings */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(26px);
}


/* Timeline Dark Mode Updates */
.timeline-header {
  border-bottom: 1px solid var(--border-color);
}

.timeline-header button {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

@media (hover: hover) {
.timeline-header button:hover {
  opacity: 0.9;
}
}

/* Simple scrollbar color changes */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
::-webkit-scrollbar {
  width: 12px;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 6px;
}

@media (hover: hover) {
html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

/* Firefox */
html,
body,
* {
  scrollbar-color: var(--border-color) var(--bg-primary);
}

/* Info "i" on tree cards: the original see-through blue circle, with a properly centered i.
   It fades in when the mouse is over the card (touch screens have no hover, so it stays visible there). */
.item-info-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  background: rgba(102, 126, 234, 0.1);
  border: 1.5px solid rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .18s ease, transform .12s ease, background .12s ease, border-color .12s ease;
  z-index: 100;
  pointer-events: auto;
  color: #667eea;
}
.item-info-icon svg { display: block; width: 12px; height: 12px; }
@media (hover: hover) {
  .treeNode:hover .item-info-icon { opacity: 1; }
  .item-info-icon:hover { background: rgba(102, 126, 234, 0.22); border-color: rgba(102, 126, 234, 0.55); transform: scale(1.1); }
}
@media (hover: none) {
  .item-info-icon { opacity: 1; }
}
.item-info-icon:active { transform: scale(0.94); }

/* Info Modal Styling */
.info-modal {
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

#infoModalContent {
  margin-top: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  max-height: 60vh;
  overflow-y: auto;
}

.info-modal-content {
  margin-top: 16px;
  line-height: 1.6;
  color: var(--text-primary);
}

.info-modal-content ul {
  list-style-type: disc;
}

.info-modal-content li {
  margin: 4px 0;
}

/* Ensure info modal is above everything */
#infoModalBackdrop {
  z-index: 20000 !important;
}

/* When inside tree overlay, still appear above */
#treeOverlay #infoModalBackdrop {
  position: fixed;
  z-index: 20000 !important;
}

/* Modal info icon - positioned like the close button but on the left */
.modal-info-icon {
  position: absolute;
  top: 10px;
  right: 40px;
  width: 20px;
  height: 20px;
  background: rgba(102, 126, 234, 0.1);
  border: 1.5px solid rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #667eea;
  z-index: 10;
}

.modal-info-icon svg {
  display: block;
  width: 11px;
  height: 11px;
}

@media (hover: hover) {
.modal-info-icon:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.5);
  transform: scale(1.15);
}
}

.modal-info-icon:active {
  transform: scale(0.95);
}

/* ========== Subcategory Styles ========== */

.cat-group {
  margin-bottom: 2px;
}

.cat-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
  user-select: none;
  position: relative;
}

@media (hover: hover) {
.cat-item:hover {
  background: var(--card-hover);
}
}

.cat-item.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
}

.cat-item.active .cat-count {
  color: rgba(255, 255, 255, 0.9);
}

.cat-icon {
  font-size: 18px;
  margin-right: 12px;
  min-width: 24px;
  text-align: center;
}

.cat-name {
  flex: 1;
  font-size: 14px;
}

.cat-count {
  font-size: 12px;
  opacity: 0.6;
  margin-left: 8px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  min-width: 28px;
  text-align: center;
}

.cat-item.active .cat-count {
  background: rgba(255, 255, 255, 0.2);
}

.cat-toggle {
  margin-left: 8px;
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-secondary);
  opacity: 0.7;
}

.cat-item.expanded .cat-toggle {
  transform: rotate(90deg);
}

.cat-subs {
  margin-left: 20px;
  padding-left: 16px;
  border-left: 2px solid var(--border-color);
  margin-top: 4px;
  margin-bottom: 8px;
}

.cat-sub-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.15s;
  user-select: none;
  margin-bottom: 2px;
}

@media (hover: hover) {
.cat-sub-item:hover {
  background: var(--card-hover);
  color: var(--text-primary);
}
}

.cat-sub-item.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
}

.cat-sub-item.active .cat-sub-count {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.2);
}

.cat-sub-name {
  flex: 1;
}

.cat-sub-count {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 8px;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

/* Timeline category menu */
.timeline-menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 24px 0;
  padding: 0 32px;
}
.timeline-menu-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
@media (hover: hover) {
.timeline-menu-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow);
}
}
.timeline-menu-card.soon { opacity: 0.55; }
.tm-icon { font-size: 40px; line-height: 1; width: 56px; text-align: center; }
.tm-info { flex: 1; min-width: 0; }
.tm-name { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.tm-desc { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.tm-arrow { font-size: 28px; color: var(--text-secondary); }
.timeline-soon {
  text-align: center;
  padding: 80px 20px;
  font-size: 20px;
  color: var(--text-secondary);
}

/* Popups opened from the timeline must sit above it (timeline page is z-index 10000) */
#modalBackdrop { z-index: 15000; }
#treeOverlay { z-index: 10500; }

/* Info popup content */
.info-line { margin-top: 10px; font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.info-line strong { color: var(--text-primary); }
.info-related-label { margin: 16px 0 6px; font-weight: 600; font-size: 14px; color: var(--text-primary); }
.info-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.info-chip {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
@media (hover: hover) {
.info-chip:hover { background: var(--card-hover); }
}

/* ================= MOBILE / TOUCH SUPPORT ================= */

/* Lets the crafting tree be dragged and pinch-zoomed by touch */
.treeViewport { touch-action: none; }

#btnCategories { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  header { flex-wrap: wrap; }
  #q { flex: 1 1 100%; order: -1; }
  header button { flex: 1; padding: 10px 8px; font-size: 14px; }
  #btnSettings, #btnAbout { margin-left: 0; }
  #btnCategories { display: block; }

  /* page = header on top, grid fills the rest and scrolls by itself */
  body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
  header { flex: 0 0 auto; }
  .main-layout {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: hidden;
  }
  .results-container, #results {
    box-sizing: border-box;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  /* sidebar becomes a slide-in drawer */
  .category-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px; max-width: 80vw;
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .category-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }
  .sidebar-backdrop.open {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1500;
  }

  .treeTitle { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tree-legend { display: none !important; }
}

/* No grey tap flash, no double-tap delay */
* { -webkit-tap-highlight-color: transparent; }
button, .card, .cat-item, .cat-sub-item, .treeNode { touch-action: manipulation; }
.treeViewport, .treeViewport * { touch-action: none; }

/* ================= CORRUPTION vs CRIMSON compare page ================= */
.cmp { max-width: 960px; margin: 0 auto; }

.cmp-head, .cmp-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.cmp-head { border-bottom: 2px solid var(--border-color); }
.cmp-head-cell { text-align: center; padding: 8px 8px 16px; }
.cmp-head-cell:first-child, .cmp-col:first-child { border-right: 2px solid var(--border-color); }

.cmp-title { font-size: 32px; font-weight: 800; line-height: 1.1; }
.cmp-title.crimson { color: #e11d48; }
.cmp-title.corruption { color: #9333ea; }
.cmp-tag { margin-top: 4px; font-size: 13px; color: var(--text-secondary); }

.cmp-section { margin-top: 22px; }
.cmp-label {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.cmp-col { padding: 0 10px; min-width: 0; }

.cmp-fact { font-size: 14px; line-height: 1.4; color: var(--text-primary); text-align: center; align-self: center; }

.cmp-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
@media (hover: hover) {
  .cmp-item:hover { background: var(--card-hover); }
}
.cmp-ico {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cmp-ico img { max-width: 36px; max-height: 36px; image-rendering: pixelated; }
.cmp-text { min-width: 0; text-align: center; }
.cmp-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.cmp-note { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

.cmp-pick-title { font-weight: 800; font-size: 16px; text-align: center; margin-bottom: 6px; }
.cmp-pick-title.crimson { color: #e11d48; }
.cmp-pick-title.corruption { color: #9333ea; }
.cmp-pick-list { margin: 0; padding: 0; list-style-position: inside; text-align: center; font-size: 14px; line-height: 1.5; color: var(--text-primary); }

.cmp-footnote {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .cmp-title { font-size: 24px; }
  .cmp-col { padding: 0 4px; }
  .cmp-item { gap: 6px; padding: 6px 4px; }
  .cmp-ico { flex-basis: 28px; width: 28px; height: 28px; }
  .cmp-ico img { max-width: 28px; max-height: 28px; }
  .cmp-name { font-size: 13px; }
  .cmp-note { font-size: 11px; }
  .cmp-fact { font-size: 13px; }
  .cmp-pick-list { font-size: 13px; }
}

/* ================= NPC pages ================= */
.npc-head { text-align: center; padding: 0 8px 18px; border-bottom: 2px solid var(--border-color); }
.npc-ico { height: 72px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.npc-ico img { max-width: 72px; max-height: 72px; image-rendering: pixelated; object-fit: contain; }
.npc-name { font-size: 32px; font-weight: 800; line-height: 1.1; color: #667eea; }
.npc-text { max-width: 620px; margin: 0 auto; text-align: center; font-size: 15px; line-height: 1.5; color: var(--text-primary); }
.npc-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 10px; }
.npc-items .cmp-item { padding: 8px 12px; }
.npc-note { text-align: center; font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.npc-rows { max-width: 620px; margin: 0 auto; }
.npc-row { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 10px; text-align: center; }
.npc-linkwrap { text-align: center; margin-top: 26px; }
.npc-wiki {
  display: inline-block;
  padding: 10px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}
.tm-icon img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; vertical-align: middle; }

@media (max-width: 768px) {
  .npc-name { font-size: 24px; }
  .npc-text { font-size: 14px; }
  .npc-items .cmp-item { padding: 6px 8px; }
}

/* ================= NPC menu: even grid of cards ================= */
.timeline-menu.tm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.tm-grid .timeline-menu-card {
  flex-direction: column;
  justify-content: flex-start;
  text-align: center;
  gap: 8px;
  padding: 18px 12px;
}
.tm-grid .tm-icon { width: auto; height: 52px; display: flex; align-items: center; justify-content: center; }
.tm-grid .tm-info { flex: 0 1 auto; width: 100%; }
.tm-grid .tm-name { font-size: 16px; }
.tm-grid .tm-desc {
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tm-grid .tm-arrow { display: none; }

@media (max-width: 768px) {
  .timeline-menu.tm-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 12px; }
  .tm-grid .timeline-menu-card { padding: 14px 8px; }
  .tm-grid .tm-name { font-size: 14px; }
  .tm-grid .tm-desc { font-size: 11px; }
}

/* ============================================================
   ARMOR + CLASS PAGES
   ============================================================ */
.cmp.arm { max-width: 980px; }
.arm-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0 10px; }
.arm-chip {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border-color);
  background: var(--bg-secondary); color: var(--text-primary); font-size: 14px; font-weight: 600; cursor: pointer;
}
.arm-chip.active { background: #667eea; border-color: #667eea; color: #fff; }
.arm-legend { text-align: center; font-size: 12px; color: var(--text-secondary); max-width: 640px; margin: 0 auto 6px; line-height: 1.4; }

/* one armor row: name | pieces | defense | bonus */
.arm-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.1fr) minmax(120px, 1.4fr) 110px minmax(160px, 2fr);
  align-items: center; gap: 14px;
  padding: 12px 10px; border-bottom: 1px solid var(--border-color);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .arm-row:hover { background: var(--card-hover); } }
.arm-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.arm-sub { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.arm-pieces { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.arm-pieces img { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; }
.arm-def { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--text-secondary); }
.arm-shield { display: inline-flex; }
.arm-num { font-size: 18px; font-weight: 800; color: var(--text-primary); }
.arm-bar { flex-basis: 100%; height: 5px; border-radius: 3px; background: var(--bg-tertiary); overflow: hidden; }
.arm-bar-fill { position: relative; height: 100%; background: #667eea; border-radius: 3px; }
.arm-bar-low { position: absolute; left: 0; top: 0; bottom: 0; background: #4c5fd0; border-radius: 3px; }
.arm-bonus-text { font-size: 13px; line-height: 1.4; color: var(--text-primary); }
.arm-note { font-size: 12px; line-height: 1.4; color: var(--text-secondary); margin-top: 3px; }

/* class pages */
.cls-icon { font-size: 52px; line-height: 1; margin-bottom: 6px; }
.cls-about { margin-top: 16px; }
.cls-sub { margin: 14px 0 2px; padding-left: 10px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }

@media (max-width: 768px) {
  .arm-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name def" "pieces pieces" "bonus bonus";
    gap: 8px 12px; padding: 12px 6px;
  }
  .arm-name { grid-area: name; }
  .arm-def { grid-area: def; width: 92px; }
  .arm-pieces { grid-area: pieces; }
  .arm-bonus { grid-area: bonus; }
  .arm-pieces img { width: 26px; height: 26px; }
}

/* armor set popup: all pieces in a row */
.info-set-icons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0 0 14px; padding: 12px; border-radius: 10px; background: var(--bg-tertiary); }
.info-set-icons img { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; }
.info-set-hero { display: flex; justify-content: center; margin: 0 0 14px; padding: 12px; border-radius: 10px; background: var(--bg-tertiary); }
.info-set-hero img { height: 120px; width: auto; max-width: 100%; object-fit: contain; image-rendering: pixelated; }

/* ============================================================
   HEADER: smaller search + new buttons
   ============================================================ */
#q { flex: 0 1 300px; min-width: 120px; }

/* Crimson vs Corruption: pixel-art terrain. Crimson dirt + red grass vs corrupted dirt + purple grass, each trying to convert the other */
#btnEvil {
  position: relative; overflow: hidden; isolation: isolate;
  border: 2px solid #12061a; color: #fff; padding: 15px 24px; min-width: 270px;
  background: #2a1a3a;
}
.evil-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0;
  image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none;
}
#btnEvil .evil-label {
  position: relative; z-index: 2; letter-spacing: .02em;
  display: grid; grid-template-columns: 1fr auto 1fr; column-gap: .35em; align-items: center; width: 100%;
  text-shadow: -1px -1px 0 #12061a, 1px -1px 0 #12061a, -1px 1px 0 #12061a, 1px 1px 0 #12061a, 0 2px 0 #12061a, 0 0 8px rgba(0,0,0,.6);
}

#btnEvil .ev-l { text-align: right; }
#btnEvil .ev-r { text-align: left; }
#btnEvil .ev-v { text-align: center; }

@media (max-width: 768px) {
  #q { flex: 1 1 100%; }
  #btnEvil { flex: 2 1 160px; }
}

/* ============================================================
   BOSS PAGES
   ============================================================ */
.cmp.boss { max-width: 980px; }
.boss-colheads { border-bottom: 2px solid var(--border-color); padding-bottom: 8px; }
.boss-colhead { text-align: center; font-weight: 800; font-size: 16px; color: var(--text-primary); }
.boss-colhead.bag { color: #b45309; }
.boss-badge { text-align: center; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #b45309; margin: 6px 0 2px; }
.boss-badge.plain { color: var(--text-secondary); font-weight: 700; margin-top: 12px; }

/* the (i) button on a boss popup: same look as the item popup's, a bit easier to tap */
.modal-info-icon.boss-more { width: 28px; height: 28px; top: 8px; right: 44px; }
.modal-info-icon.boss-more svg { width: 14px; height: 14px; }

/* ============================================================
   TERRARIA ICONS (replace the old emojis)
   ============================================================ */
img.tr-icon { image-rendering: pixelated; object-fit: contain; vertical-align: middle; }
.cat-icon { display: inline-flex; align-items: center; justify-content: center; }
.cat-icon img.tr-icon { width: 26px; height: 26px; }
.cat-sub-item { display: flex; align-items: center; gap: 8px; }
.cat-sub-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; min-width: 20px; height: 20px; }
.cat-sub-icon img.tr-icon { width: 20px; height: 20px; }
.tm-icon img.tr-icon { width: 44px; height: 44px; }
.cls-icon img.tr-icon { width: 56px; height: 56px; }
.cls-icon { display: flex; align-items: center; justify-content: center; }

/* bosses with no Treasure Bag: one centered column */
.cmp-cols.boss-single { grid-template-columns: 1fr; max-width: 520px; margin-left: auto; margin-right: auto; }
.cmp-cols.boss-single .cmp-col { border: none; }

/* biome + plant pages */
.cmp.biome, .cmp.herbs, .cmp.potions, .cmp.bestiary { max-width: 980px; }
.herb-facts { text-align: center; font-size: 13px; line-height: 1.5; color: var(--text-secondary); margin: 2px auto 6px; max-width: 640px; }
.cmp.potions .potion-grid { display: grid; justify-content: stretch; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cmp.potions .cmp-note { white-space: normal; }

/* ---- readable wiki text ---- */
.info-text { margin-top: 10px; }
.info-text p { margin: 0 0 9px; font-size: 14px; line-height: 1.55; color: var(--text-secondary); }
.info-text p:last-child { margin-bottom: 0; }
.info-text .info-lead { font-size: 15px; color: var(--text-primary); font-weight: 600; padding-bottom: 9px; border-bottom: 1px solid var(--border-color); }

/* ---- tiny item icons inside text ---- */
.mini-list { display: flex; flex-wrap: wrap; gap: 5px 6px; align-items: center; }
.mini-item {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 4px;
  font: inherit; font-size: 12px; line-height: 1.2; color: var(--text-primary);
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 999px;
}
button.mini-item { cursor: pointer; }
button.mini-item:hover { background: var(--card-hover); }
.mini-ico { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; flex: none; }
.mini-ico img { max-width: 20px; max-height: 20px; image-rendering: pixelated; object-fit: contain; }
.mini-station { font-size: 12px; color: var(--text-secondary); }
.info-chip .mini-ico { vertical-align: middle; margin-right: 2px; }

/* ---- herb cards ---- */
.herb-card {
  margin-top: 18px; padding: 14px 16px 16px; border: 2px solid var(--border-color); border-radius: 14px;
  background: var(--bg-secondary); box-shadow: 0 2px 0 rgba(0,0,0,.08);
}
.herb-card .herb-facts { margin: 8px auto 10px; }
.herb-used { margin: 8px 0 12px; }
.herb-used-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); text-align: center; margin-bottom: 6px; }
.herb-used .mini-list { justify-content: center; }
.herb-card .herb-seed { margin-top: 4px; border-top: 1px dashed var(--border-color); padding-top: 12px; }
.cmp-note .mini-list { justify-content: center; }

/* ---- vertical icon columns in the item info popup (stations, drops, shops) ---- */
.icon-col { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.icon-col.scroll { max-height: 260px; overflow-y: auto; padding-right: 4px; }
.icon-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-secondary); }
.icon-row-ico { width: 32px; height: 32px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.icon-row-ico img { max-width: 32px; max-height: 32px; object-fit: contain; image-rendering: pixelated; }
.icon-row-name { flex: 1; font-size: 14px; color: var(--text-primary); }
.icon-row-note { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

.inline-ico-name { display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; }
.inline-ico-name img { width: 20px; height: 20px; object-fit: contain; image-rendering: pixelated; }

/* ---- herbs: flush with the page, just a gap between plants ---- */
.herb-card { margin-top: 38px !important; padding: 0 !important; border: none !important; background: transparent !important; box-shadow: none !important; }
.herb-card .herb-seed { border-top: none !important; padding-top: 0 !important; margin-top: 10px; }
.herb-brew { text-align: center; font-size: 13px; color: var(--text-secondary); margin: 2px 0 10px; }

/* ---- potion pages: clean left-aligned list ---- */
.pot-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 22px 40px; margin-top: 10px; }
.pot-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 6px 4px; border-radius: 10px; }
.pot-row:hover { background: var(--card-hover); }
.pot-ico { width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.pot-ico img { max-width: 40px; max-height: 40px; image-rendering: pixelated; object-fit: contain; }
.pot-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.pot-ing, .pot-station { font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.pot-ing .inline-ico-name { margin: 0 1px; }
@media (max-width: 768px) { .pot-list { grid-template-columns: 1fr; gap: 14px; } }

/* ---- modifiers ---- */
.cmp.mods { max-width: 980px; }
.mod-bullet { font-size: 14px; line-height: 1.55; color: var(--text-secondary); margin: 6px 0; padding-left: 14px; position: relative; }
.mod-bullet::before { content: ""; position: absolute; left: 0; top: .6em; width: 5px; height: 5px; border-radius: 50%; background: var(--text-secondary); }
.mod-note { font-size: 13px; color: var(--text-secondary); margin: 2px 0 10px; }
.mod-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 32px; }
.mod-row { display: flex; flex-direction: column; padding: 4px 0 4px 10px; border-left: 3px solid var(--border-color); }
.mod-row.good { border-left-color: #3fa66b; }
.mod-row.bad { border-left-color: #d9534f; }
.mod-row.meh { border-left-color: #999; }
.mod-name { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.mod-effect { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }

/* ---- About / welcome popup ---- */
.about-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 10000; padding: 12px; }
.about-modal { position: relative; width: min(620px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column; background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.about-x { position: absolute; top: 8px; right: 12px; border: none; background: none; font-size: 28px; line-height: 1; color: var(--text-secondary); cursor: pointer; }
.about-tabs { display: flex; gap: 6px; padding: 14px 52px 0 18px; border-bottom: 1px solid var(--border-color); }
.about-tab { border: none; background: none; padding: 8px 12px; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-secondary); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.about-tab.active { color: var(--text-primary); border-bottom-color: #667eea; }
.about-body { overflow-y: auto; padding: 8px 22px 6px; }
.about-pane { display: none; }
.about-pane.active { display: block; }
.about-pane h2 { margin: 14px 0 6px; font-size: 22px; }
.about-pane h3 { margin: 18px 0 4px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); }
.about-pane p, .about-list { font-size: 14px; line-height: 1.6; color: var(--text-secondary); margin: 6px 0; }
.about-lead { font-size: 15px !important; color: var(--text-primary) !important; }
.about-list { padding-left: 20px; }
.about-list li { margin: 7px 0; }
.about-list b { color: var(--text-primary); }
.about-pane a { color: #667eea; }
.about-foot { padding: 12px 22px 16px; border-top: 1px solid var(--border-color); text-align: right; }
.about-ok { padding: 10px 20px; border: none; border-radius: 10px; font: inherit; font-weight: 600; color: #fff; cursor: pointer; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }

/* ---- Expert / Master drop rates (gold and orange, like the wiki) with a hover note ---- */
.rate-expert, .rate-master { position: relative; font-weight: 700; cursor: help; border-bottom: 1px dotted currentColor; outline: none; }
.rate-expert { color: #b8860b; }
.rate-master { color: #d9480f; }
:root[data-theme="dark"] .rate-expert, body.dark .rate-expert, .dark-mode .rate-expert { color: #f2c14e; }
:root[data-theme="dark"] .rate-master, body.dark .rate-master, .dark-mode .rate-master { color: #ff8c5a; }
.rate-expert::after, .rate-master::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  white-space: nowrap; padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 1.3;
  background: #111; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4); pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .12s; z-index: 5;
}
.rate-expert:hover::after, .rate-expert:focus::after, .rate-master:hover::after, .rate-master:focus::after { opacity: 1; visibility: visible; }

/* ---- tidy scrollbars (one scrollbar per popup, thin and quiet) ---- */
#infoModalContent, .about-body, .icon-col { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }
#infoModalContent::-webkit-scrollbar, .about-body::-webkit-scrollbar { width: 8px; }
#infoModalContent::-webkit-scrollbar-thumb, .about-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 8px; }
#infoModalContent::-webkit-scrollbar-track, .about-body::-webkit-scrollbar-track { background: transparent; }

/* ---- Bestiary ---- */
.bst-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin: 14px 0 8px; }
.bst-search { flex: 1 1 240px; max-width: 360px; padding: 9px 12px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--input-bg); color: var(--text-primary); font: inherit; font-size: 14px; }
.bst-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.bst-pill { padding: 7px 14px; border: 1px solid var(--border-color); border-radius: 999px; background: var(--bg-tertiary); color: var(--text-primary); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.bst-pill.active { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-color: transparent; }
.bst-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.bst-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px 10px; border-radius: 12px; cursor: pointer; text-align: center; }
.bst-card:hover { background: var(--card-hover); }
.bst-ico { width: 64px; height: 64px; display: inline-flex; align-items: center; justify-content: center; }
.bst-ico img { max-width: 64px; max-height: 64px; image-rendering: pixelated; object-fit: contain; }
.bst-name { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.25; }
.bst-empty { text-align: center; color: var(--text-secondary); padding: 30px 0; display: none; }
.icon-row.clickable { cursor: pointer; }
.icon-row.clickable:hover { background: var(--card-hover); }

/* "uses" tree: station folders and "load more" cards follow the light/dark theme */
.treeNode.treeGroup { background: var(--bg-tertiary); border: 2px solid var(--border-color); cursor: pointer; }
.treeNode.treeGroup:hover { background: var(--card-hover); }
.treeNode.treeLoadMore { background: var(--bg-tertiary); border: 2px dashed var(--text-secondary); cursor: pointer; font-style: italic; justify-content: center; color: var(--text-primary); }
.treeNode.treeGroup .treeSub { font-size: 12px; font-weight: 400; color: var(--text-secondary); }

.treeNode.treeGroup { padding-right: 30px; }
.treeToggle { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 20px !important; line-height: 1 !important; font-weight: bold; color: #667eea; flex: none !important; width: auto !important; -webkit-line-clamp: unset !important; display: block !important; }

/* blue Info button next to the X in the item popup */
.modal-info-btn {
  position: absolute; top: 9px; right: 46px; height: 28px; padding: 0 14px;
  border: none; border-radius: 999px; cursor: pointer; z-index: 10;
  font: inherit; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 2px 6px rgba(102, 126, 234, .45);
  transition: transform .12s ease, box-shadow .12s ease;
}
.modal-info-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(102, 126, 234, .55); }
.modal-info-btn:active { transform: translateY(0); }
#modalBackdrop .modalTop { padding-right: 110px; }

.treeNode > div.item-info-icon { flex: none; display: flex; overflow: visible; -webkit-line-clamp: unset; }

.treeNode { padding: 6px 30px 6px 12px; }
.dark-mode .item-info-icon { color: #9db0ff; border-color: rgba(157, 176, 255, 0.5); background: rgba(102, 126, 234, 0.18); }

/* hide the placeholder emoji in the sidebar until the real Terraria picture is ready (no flash on refresh) */
.cat-icon:not(.has-img):not(.icon-failed) { font-size: 0; width: 26px; height: 26px; }
.cat-sub-icon:not(.has-img):not(.icon-failed) { font-size: 0; }

/* Header buttons with an item icon: Timeline (Platinum Watch), Field Guide (Compass), About (Life Crystal), Settings (Mana Crystal) */
#btnTimeline, #btnGuide, #btnAbout, #btnSettings {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: #fff; border: none;
}
#btnTimeline { background: linear-gradient(135deg, #5b7499 0%, #2f3f5e 100%); }
#btnGuide { background: linear-gradient(135deg, #a8743a 0%, #6b4423 100%); }
#btnAbout { background: linear-gradient(135deg, #e5506b 0%, #9b1c3a 100%); }
#btnSettings { background: linear-gradient(135deg, #4d8df5 0%, #223f9e 100%); }
.btn-ico { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; }
.btn-ico img.tr-icon { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 1px 0 rgba(0,0,0,.35)); }

/* quick buttons at the top of the item info popup */
.info-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.info-action-btn {
  padding: 9px 14px; border: none; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #4a56c4 100%);
}
@media (hover: hover) { .info-action-btn:hover { filter: brightness(1.12); } }

/* bug report form (inside the About window) */
.bug-form { display: flex; flex-direction: column; gap: 14px; margin: 14px 0 6px; }
.bug-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.bug-opt { font-weight: 400; color: var(--text-secondary); }
.bug-form textarea, .bug-form input[type="email"] {
  font: inherit; font-weight: 400; font-size: 14px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--bg-tertiary); color: var(--text-primary); resize: vertical;
}
.bug-form textarea:focus, .bug-form input[type="email"]:focus { outline: 2px solid #667eea; outline-offset: 1px; }
.bug-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.bug-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bug-send { padding: 10px 20px; border: none; border-radius: 10px; font: inherit; font-weight: 700; color: #fff; cursor: pointer; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.bug-send:disabled { opacity: .55; cursor: default; }
.bug-status { font-size: 14px; }
.bug-status.ok { color: #3fb27f; }
.bug-status.bad { color: #e5506b; }
.bug-note { font-size: 12px !important; }

/* which Terraria update the site's data matches: same height and corners as the buttons, centered between Field Guide and About */
.game-version {
  margin: 0 auto; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px;
  padding: 0 22px; border-radius: 8px; white-space: nowrap;
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
}
.game-version small { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-secondary); }
.game-version b { font-size: 15px; font-weight: 800; color: var(--text-primary); }
@media (max-width: 768px) { .game-version { display: none; } }