:root {
  /* Backgrounds */
  --bg-deep: #0f1320;
  --bg-base: #0f1429;
  --bg-surface: rgba(21, 27, 52, 0.95);
  --bg-elevated: #1f274b;
  --bg-recessed: #141a32;

  /* Borders */
  --border-subtle: rgba(43, 54, 102, 0.3);
  --border-default: rgba(43, 54, 102, 0.5);
  --border-strong: #2b3566;
  --border-accent: #6f80ff;

  /* Text */
  --text-primary: #eef1ff;
  --text-secondary: #c8d1ff;
  --text-tertiary: #aab4ff;
  --text-muted: #8b95c0;
  --text-faint: #6b7194;

  /* Accent */
  --accent: #5366d6;
  --accent-hover: rgba(83, 102, 214, 0.9);
  --accent-light: #7c8cff;
  --accent-bg: rgba(124, 140, 255, 0.15);
  --accent-ring: rgba(124, 140, 255, 0.4);

  /* Semantic */
  --success: #7ee08a;
  --danger: #c0392b;
  --danger-hover: #e74c3c;
  --warning: #ffb347;

  /* Layout */
  --nav-width: 200px;
  --panel-width: 320px;
  --topbar-height: 48px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-default: 0.2s ease;
}

* {
  box-sizing: border-box;
}

/* Focus-visible ring for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Thin scrollbars for panels */
.nav-sidebar,
.panel,
.inventory-catalogue,
.bestiary-overlay,
.graphs-overlay,
.asset-explorer-overlay {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.nav-sidebar::-webkit-scrollbar,
.panel::-webkit-scrollbar,
.inventory-catalogue::-webkit-scrollbar,
.bestiary-overlay::-webkit-scrollbar,
.graphs-overlay::-webkit-scrollbar,
.asset-explorer-overlay::-webkit-scrollbar {
  width: 6px;
}

.nav-sidebar::-webkit-scrollbar-thumb,
.panel::-webkit-scrollbar-thumb,
.inventory-catalogue::-webkit-scrollbar-thumb,
.bestiary-overlay::-webkit-scrollbar-thumb,
.graphs-overlay::-webkit-scrollbar-thumb,
.asset-explorer-overlay::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.nav-sidebar::-webkit-scrollbar-track,
.panel::-webkit-scrollbar-track,
.inventory-catalogue::-webkit-scrollbar-track,
.bestiary-overlay::-webkit-scrollbar-track,
.graphs-overlay::-webkit-scrollbar-track,
.asset-explorer-overlay::-webkit-scrollbar-track {
  background: transparent;
}

/* Utility classes */
.input-narrow {
  width: 60px;
}

html,
body {
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: #0f1320;
  color: var(--text-primary);
}

#app {
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* Floating topbar */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(26, 33, 64, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(43, 54, 102, 0.5);
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-project {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

#projectNameLabel {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

#saveIndicator {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status {
  font-size: 0.9rem;
  color: #cfd6ff;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.topbar-actions button {
  padding: 6px 12px;
  font-size: 0.8rem;
  background: rgba(43, 59, 112, 0.8);
  border: 1px solid rgba(43, 54, 102, 0.5);
  color: #ffffff;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.topbar-actions button:hover {
  background: rgba(83, 102, 214, 0.9);
  border-color: rgba(111, 128, 255, 0.7);
}

.topbar-btn {
  padding: 4px 8px !important;
  font-size: 1rem !important;
  min-width: 32px;
  line-height: 1;
}

.topbar-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.save-status {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  min-width: 120px;
  text-align: right;
  flex-shrink: 0;
}

/* Responsive topbar for overlay */
@media (max-width: 900px) {
  .topbar {
    padding: 6px 12px;
  }

  .status {
    font-size: 0.8rem;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 4px 8px;
  }

  .title {
    font-size: 0.85rem;
  }

  .status {
    font-size: 0.75rem;
  }

  .topbar-actions button {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
}

.save-status.ok {
  color: #7ee08a;
}

.save-status.error {
  color: #ff9a9a;
}

.divider {
  margin: 0 8px;
  opacity: 0.6;
}

/* Fullscreen canvas - takes entire viewport */
.canvas-wrap {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  background: #0f1429;
}

#gameCanvas {
  width: 100vw !important;
  height: 100vh !important;
  display: block;
  border: none;
  image-rendering: pixelated;
}

/* Responsive adjustments */
/* Layout-specific media queries consolidated at end of file */

/* Floating inventory catalogue */
.inventory-catalogue {
  position: absolute;
  top: calc(var(--topbar-height) + 12px);
  left: calc(clamp(160px, 15vw, var(--nav-width)) + 32px);
  right: 16px;
  bottom: 16px;
  z-index: 80;
  background: rgba(21, 27, 52, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(43, 54, 102, 0.5);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Responsive inventory catalogue */
@media (max-width: 1200px) {
  .inventory-catalogue {
    padding: 20px;
    gap: 16px;
  }
}

@media (max-width: 900px) {
  .inventory-catalogue {
    padding: 16px;
    gap: 12px;
  }
}

@media (max-width: 600px) {
  .inventory-catalogue {
    padding: 12px;
    gap: 8px;
  }
}

.catalogue-header {
  text-align: center;
  border-bottom: 2px solid #2b3566;
  padding-bottom: 20px;
}

.catalogue-header h1 {
  margin: 0 0 8px 0;
  color: var(--text-secondary);
  font-size: 2.2em;
}

/* Responsive catalogue header */
@media (max-width: 900px) {
  .catalogue-header {
    padding-bottom: 16px;
  }

  .catalogue-header h1 {
    font-size: 1.8em;
  }
}

@media (max-width: 600px) {
  .catalogue-header {
    padding-bottom: 12px;
  }

  .catalogue-header h1 {
    font-size: 1.5em;
  }
}

.catalogue-subtitle {
  margin: 0;
  color: #888;
  font-size: 1.1em;
}

.catalogue-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid #2b3566;
}

/* Responsive catalogue controls */
@media (max-width: 900px) {
  .catalogue-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 0;
  }
}

.control-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Responsive control groups */
@media (max-width: 600px) {
  .control-group {
    gap: 8px;
  }
}

.stats {
  color: #888;
  font-size: 0.9rem;
}

.item-catalogue-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 0; /* Allow proper flex sizing */
}

/* Responsive item grid */
@media (max-width: 1200px) {
  .item-catalogue-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 900px) {
  .item-catalogue-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
  }
}

@media (max-width: 600px) {
  .item-catalogue-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.item-catalogue-grid .item-entry {
  background: var(--bg-elevated);
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.item-catalogue-grid .item-entry:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(83, 102, 214, 0.2);
}

.item-catalogue-grid .item-entry.selected {
  background: #2b3566;
  border-color: var(--accent);
}

.item-info {
  margin-bottom: 12px;
}

.item-name {
  font-weight: bold;
  color: var(--text-secondary);
  font-size: 1.1em;
  margin-bottom: 4px;
}

.item-description {
  color: #aaa;
  font-size: 0.9em;
  margin-bottom: 8px;
  line-height: 1.4;
}

.item-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85em;
  color: #888;
}

.item-type {
  background: #3b4b8e;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: bold;
}

.item-value {
  color: #4CAF50;
  font-weight: bold;
}

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}


/* Left navigation menu */
.nav-sidebar {
  position: absolute;
  top: calc(var(--topbar-height) + 12px);
  left: 16px;
  width: clamp(160px, 15vw, var(--nav-width));
  max-height: calc(100vh - var(--topbar-height) - 32px);
  overflow-y: auto;
  z-index: 90;
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.15), 0 12px 32px rgba(0,0,0,0.25);
}

.nav-sidebar h3 {
  margin: 0 0 12px 0;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-section:last-child {
  margin-bottom: 0;
}

.nav-section h4 {
  margin: 0 0 8px 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}



.hint {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

/* Floating zoom controls */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(21, 27, 52, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(43, 54, 102, 0.6);
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.zoom-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(124, 140, 255, 0.15);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
}

.zoom-btn:hover {
  background: rgba(124, 140, 255, 0.3);
  color: #fff;
}

.zoom-btn:active {
  background: rgba(124, 140, 255, 0.45);
}

.zoom-btn.zoom-reset {
  font-size: 14px;
  margin-left: 4px;
}

.zoom-label {
  min-width: 42px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #a8b4ff;
  letter-spacing: 0.02em;
}

/* Floating sidebar panel */
.panel {
  position: absolute;
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  width: clamp(260px, 25vw, var(--panel-width));
  max-width: calc(100vw - clamp(160px, 15vw, var(--nav-width)) - 48px);
  max-height: calc(100vh - var(--topbar-height) - 32px);
  z-index: 80;
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.15), 0 12px 32px rgba(0,0,0,0.25);
}

/* Responsive panel */
@media (max-width: 1200px) {
  .panel {
    padding: 12px;
    gap: 12px;
  }
}

@media (max-width: 900px) {
  .panel {
    padding: 10px;
    gap: 10px;
  }
}

@media (max-width: 600px) {
  .panel {
    padding: 8px;
    gap: 8px;
    border-radius: 8px;
  }
}

.panel-section h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

/* Responsive typography */
@media (max-width: 600px) {
  .panel-section h2 {
    font-size: 0.9rem;
    margin-bottom: 6px;
  }

  label {
    font-size: 0.75rem;
  }

  input,
  textarea,
  select,
  button {
    font-size: 0.8rem;
  }
}

.controls {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.editor-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.editor-tab {
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(31, 39, 75, 0.8);
  border: 1px solid rgba(43, 54, 102, 0.5);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
}

.editor-tab:hover {
  background: rgba(43, 59, 112, 0.9);
  border-color: rgba(83, 102, 214, 0.7);
  transform: translateX(2px);
}


.editor-tab.active {
  background: var(--accent);
  border-color: #6f80ff;
}

.editor-tab.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.editor-tab.hidden-tab {
  display: none;
}

.preview-hint {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  line-height: 1.5;
}

#gameCanvas.world-mode {
  cursor: pointer;
}

.layer-panel {
  width: 100%;
}

.hidden,
.layer-panel.hidden,
.panel-section.hidden,
.panel.hidden,
.inventory-catalogue.hidden,
.bestiary-overlay.hidden,
.graphs-overlay.hidden {
  display: none !important;
}

/* Graph tooltip styles */
.graph-tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  min-width: 150px;
  max-width: 250px;
}

.graph-tooltip.hidden {
  display: none;
}

.graph-tooltip .tooltip-time {
  font-weight: bold;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--accent-light);
}

.graph-tooltip .tooltip-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}

.graph-tooltip .tooltip-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.graph-tooltip .tooltip-label {
  flex: 1;
  color: #e0e0e0;
}

.graph-tooltip .tooltip-value {
  font-weight: bold;
  color: #fff;
}

.animal-palette-section.hidden,
.food-palette-section.hidden,
.tile-palette-section.hidden {
  display: none;
}

button {
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  background: #2c3b70;
  color: #f2f4ff;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover {
  background: #3b4b8e;
}

button.active {
  background: var(--accent);
}

.editor-tabs .editor-tab {
  background: #1b2347;
}

.editor-tabs .editor-tab:hover {
  background: #2d3a70;
}

.world-grid-hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.world-map-grid {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.world-cell {
  border-radius: 8px;
  border: 1px solid #2b3566;
  background: #141a32;
  color: #cfd6ff;
  font-size: 0.75rem;
  padding: 8px;
  min-height: 48px;
  cursor: pointer;
  text-align: center;
}

.world-cell.empty {
  opacity: 0.6;
}

.world-cell.active {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(124, 140, 255, 0.4);
}

.world-map-info {
  padding: 6px 8px;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 0.8rem;
  color: #dfe5ff;
}

#worldMapPreview {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #2b3566;
  background: #0f1320;
  image-rendering: pixelated;
  max-width: 300px;
}

/* Responsive world map preview */
@media (max-width: 900px) {
  #worldMapPreview {
    max-width: 250px;
  }
}

@media (max-width: 600px) {
  #worldMapPreview {
    max-width: 200px;
    border-radius: 4px;
  }
}

.edge-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

/* Responsive edge buttons */
@media (max-width: 600px) {
  .edge-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }
}

.edge-btn {
  background: var(--bg-elevated);
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 6px 8px;
  color: #dfe5ff;
  font-size: 0.8rem;
  cursor: pointer;
}

.edge-btn.active {
  background: var(--accent);
  border-color: #6f80ff;
}

.edge-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-row.form-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* Responsive form rows */
@media (max-width: 600px) {
  .form-row {
    margin-bottom: 8px;
    gap: 4px;
  }

  .form-row.form-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
}

.form-row input[type="checkbox"] {
  margin-right: 8px;
}

label {
  font-size: 0.8rem;
  color: #cfd6ff;
}

input,
textarea {
  border-radius: 6px;
  border: 1px solid #2b3566;
  background: #0f1320;
  color: #e8ecff;
  padding: 6px 8px;
}

select {
  border-radius: 6px;
  border: 1px solid #2b3566;
  background: #0f1320;
  color: #e8ecff;
  padding: 6px 8px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
  font-size: 0.75rem;
}

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

/* Responsive palette */
@media (max-width: 900px) {
  .palette {
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 6px;
  }
}

@media (max-width: 600px) {
  .palette {
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: 4px;
  }
}

.tile-swatch {
  background: #0f1320;
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  cursor: pointer;
}

.tile-swatch.selected {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(124, 140, 255, 0.4);
}

.tile-preview {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px solid var(--bg-elevated);
}

.tile-label {
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.inventory-list {
  display: grid;
  gap: 8px;
  font-size: 0.85rem;
}

.inventory-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border-radius: 6px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 24, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(520px, 90vw);
  background: #141a32;
  border: 1px solid #33417a;
  border-radius: 12px;
  padding: 16px;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.inventory-slot {
  height: 72px;
  border-radius: 8px;
  border: 1px solid #2b3566;
  background: #0f1320;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  text-align: center;
  padding: 6px;
}

.selected-item {
  height: auto !important;
  min-height: 72px;
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-start !important;
  align-items: center !important;
  padding: 12px !important;
  background: var(--bg-elevated) !important;
  border-color: var(--accent) !important;
}

.item-icon {
  font-size: 2rem;
  margin-right: 12px;
}

.item-details {
  flex: 1;
}

.item-details .item-name {
  color: var(--accent-light);
  font-weight: bold;
  margin-bottom: 4px;
}

.item-details .item-description {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 4px;
  line-height: 1.3;
}

.item-details .item-quantity {
  color: #888;
  font-size: 0.75rem;
}

/* ── Container Overlay ─────────────────────────────────────────────── */

.container-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.container-slot {
  height: 80px;
  border-radius: 8px;
  border: 2px solid #2b3566;
  background: #0f1320;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  text-align: center;
  padding: 6px;
  position: relative;
  cursor: default;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.container-slot.has-item {
  cursor: pointer;
}

.container-slot.has-item:hover {
  background: rgba(83, 102, 214, 0.15);
  border-color: var(--accent-light);
}

.container-slot.empty {
  opacity: 0.3;
}

.container-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: #fff;
}

.container-item-name {
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.container-item-qty {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.65rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.5);
  padding: 1px 4px;
  border-radius: 3px;
}

.container-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Container Editor ──────────────────────────────────────────────── */

.container-editor-empty {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  padding: 6px 0;
}

.container-editor-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.container-editor-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 3px;
}

.container-editor-remove:hover {
  background: rgba(192, 57, 43, 0.2);
}

.container-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.container-add-row select {
  flex: 1;
}

.npc-list {
  display: grid;
  gap: 8px;
  margin-bottom: 0;
  flex: 1;
  overflow: visible;
}

#npcLayerPanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

#npcLayerPanel .npc-hint {
  margin-bottom: 0;
}

.npc-entry {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 0.8rem;
  gap: 8px;
}

.npc-entry.selected {
  background: #2b3a6b;
  box-shadow: 0 0 0 1px rgba(124, 140, 255, 0.6);
}

.npc-entry.editing {
  background: #1f3a5b;
  box-shadow: 0 0 0 2px rgba(90, 159, 255, 0.7);
}

.npc-hint {
  font-size: 0.75rem;
  color: var(--accent-light);
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(124, 140, 255, 0.1);
  border-radius: 6px;
  line-height: 1.4;
}

.npc-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.npc-entry button,
.npc-remove-btn {
  padding: 4px 6px;
  font-size: 0.75rem;
}

.npc-waypoints {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #2b3566;
}

.npc-waypoints-label {
  font-size: 0.7rem;
  color: var(--accent-light);
  font-weight: 600;
  margin-bottom: 6px;
}

.npc-waypoint-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.7rem;
}

.npc-waypoint-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cfd6ff;
}

.waypoint-home-badge {
  background: #3d4a7a;
  color: var(--text-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
}

.npc-waypoint-wait {
  display: flex;
  align-items: center;
  gap: 4px;
}

.npc-waypoint-wait label {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.waypoint-wait-input {
  width: 50px;
  padding: 2px 4px;
  font-size: 0.7rem;
  background: #0f1320;
  border: 1px solid #2b3566;
  border-radius: 4px;
  color: var(--text-primary);
  text-align: right;
}

.waypoint-wait-input:focus {
  outline: none;
  border-color: var(--accent-light);
}

.waypoint-wait-unit {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.waypoint-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.waypoint-save-btn {
  align-self: flex-start;
  padding: 2px 6px;
  font-size: 0.7rem;
  min-width: 24px;
  height: 20px;
}

.npc-waypoint-dialog {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.npc-waypoint-dialog label {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.waypoint-dialog-input {
  width: 100%;
  padding: 6px;
  font-size: 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid #2b3566;
  border-radius: 4px;
  color: var(--text-primary);
  resize: vertical;
  min-height: 50px;
  font-family: inherit;
  line-height: 1.4;
}

.waypoint-dialog-input:focus {
  outline: none;
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(124, 140, 255, 0.2);
}

.waypoint-dialog-input::placeholder {
  color: var(--text-faint);
  font-style: italic;
}

/* NPC Archetype Palette */
.npc-archetype-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(26, 33, 64, 0.4);
  border-radius: 8px;
  border: 1px solid rgba(43, 54, 102, 0.3);
}

.npc-archetype-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  background: rgba(43, 54, 102, 0.3);
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.npc-archetype-btn:hover {
  background: rgba(43, 54, 102, 0.6);
  border-color: rgba(124, 140, 255, 0.4);
}

.npc-archetype-btn.active {
  background: rgba(90, 159, 255, 0.2);
  border-color: #5a9fff;
  box-shadow: 0 0 8px rgba(90, 159, 255, 0.3);
}

.npc-archetype-preview {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  border-radius: 3px;
}

.npc-archetype-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.1;
}

.npc-archetype-btn.active .npc-archetype-label {
  color: #ffffff;
  font-weight: 600;
}

/* NPC Editor Panel */
.npc-empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
}

.npc-empty-state p {
  margin: 0 0 8px 0;
}

.npc-empty-state .hint {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.npc-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.npc-editor.hidden {
  display: none;
}

.npc-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.npc-editor-header h4 {
  margin: 0;
  color: var(--accent-light);
  font-size: 0.95rem;
}

.npc-header {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.npc-header .form-row {
  flex: 1;
  margin: 0;
}

.danger-btn {
  background: #c0392b;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.danger-btn:hover {
  background: #e74c3c;
}

.close-btn {
  background: #555;
  color: #fff;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s;
}

.close-btn:hover {
  background: #777;
}

.animal-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.npc-waypoints-section h4 {
  margin: 0 0 4px 0;
  color: var(--accent-light);
  font-size: 0.9rem;
}

#addWaypointModeBtn {
  background: #2b3566;
  color: #c5ccff;
  border: 1px solid #3b4888;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-bottom: 6px;
}

#addWaypointModeBtn:hover {
  background: #3b4888;
}

#addWaypointModeBtn.active {
  background: #2d6a4f;
  border-color: #40916c;
  color: #b7e4c7;
}

.npc-waypoints-section .hint {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin: 0 0 12px 0;
}

.npc-waypoints-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.npc-waypoint-entry {
  background: #1a2040;
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
}

.waypoint-compact {
  font-size: 0.85rem;
}

.waypoint-summary-section {
  padding: 6px 8px 4px 8px;
  border-bottom: 1px solid #2b3566;
  background: rgba(43, 53, 102, 0.3);
  border-radius: 6px 6px 0 0;
}

.waypoint-summary {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  display: block;
  text-align: center;
}

.waypoint-controls-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 6px 8px;
  gap: 8px;
}

.waypoint-edit-btn, .waypoint-delete-btn {
  padding: 4px 6px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  background: #2b3566;
  color: var(--text-primary);
  min-width: 28px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waypoint-edit-btn:hover, .waypoint-delete-btn:hover {
  background: #3d4a7a;
}

.waypoint-edit-btn {
  background: #2b3566;
}

.waypoint-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #2b3566;
}

.waypoint-details.hidden {
  display: none;
}

.waypoint-position {
  font-weight: 600;
  color: #d7ddff;
}

.waypoint-home-badge {
  color: #2ecc71;
  font-size: 0.9rem;
}

.waypoint-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.waypoint-row label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.waypoint-input {
  width: 70px;
  padding: 4px 8px;
  font-size: 0.85rem;
  background: #0d1530;
  border: 1px solid #2b3566;
  border-radius: 4px;
  color: var(--text-primary);
}

.waypoint-input:focus {
  outline: none;
  border-color: var(--accent-light);
}

.waypoint-row span {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.waypoint-dialog-row {
  flex-direction: column;
  align-items: stretch;
}

.waypoint-dialog-row label {
  margin-bottom: 4px;
}

.waypoint-empty {
  text-align: center;
  padding: 16px;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.waypoint-event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.waypoint-event-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.waypoint-event-item select {
  background: var(--bg-recessed);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.85rem;
}


/* ── RPG Dialog Box ──────────────────────────────────────────────────── */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 24, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
  padding-bottom: 24px;
}

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

.dialog-box {
  width: min(640px, 95vw);
  background: linear-gradient(180deg, #1a1e3a 0%, #111428 100%);
  border: 2px solid #4a5aaa;
  border-radius: 12px;
  padding: 0;
  position: relative;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
}

.dialog-nameplate {
  position: absolute;
  top: -14px;
  left: 16px;
  background: linear-gradient(135deg, #2a3470, #1e2650);
  border: 2px solid #4a5aaa;
  border-radius: 8px;
  padding: 2px 14px;
  font-weight: bold;
  font-size: 0.9rem;
  color: #7ab4ff;
  letter-spacing: 0.5px;
}

.dialog-body {
  padding: 24px 20px 14px;
  min-height: 72px;
  position: relative;
}

.dialog-text {
  margin: 0;
  color: #d7ddff;
  font-size: 1rem;
  line-height: 1.6;
  font-family: inherit;
  white-space: pre-wrap;
}

.dialog-advance {
  position: absolute;
  bottom: 6px;
  right: 14px;
  color: #7ab4ff;
  font-size: 0.85rem;
  animation: dialog-bounce 0.8s ease-in-out infinite;
}

.dialog-advance.hidden {
  display: none;
}

@keyframes dialog-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

.dialog-close-hint {
  display: block;
  width: 100%;
  padding: 6px;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: transparent;
  color: #556;
  font-size: 0.75rem;
  text-align: center;
  cursor: pointer;
  border-radius: 0 0 10px 10px;
}

.dialog-close-hint:hover {
  color: #889;
  background: rgba(255,255,255,0.03);
}

/* ── Sign Editor Panel ──────────────────────────────────────────────── */

.sign-message-panel {
  margin-top: 10px;
  padding: 10px;
  background: rgba(138, 103, 63, 0.1);
  border: 1px solid rgba(138, 103, 63, 0.3);
  border-radius: 8px;
}

.sign-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.sign-panel-title {
  color: #c39a63;
  font-weight: bold;
  font-size: 0.85rem;
}

.sign-panel-coords {
  color: #888;
  font-size: 0.8rem;
  font-family: inherit;
}

.sign-panel-hint {
  margin: 6px 0 0;
  color: #777;
  font-size: 0.78rem;
  line-height: 1.3;
}

.sign-panel-hint code {
  background: rgba(255,255,255,0.08);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.85em;
}

.sign-message-panel textarea {
  width: 100%;
  background: var(--bg-elevated, #1a1e32);
  color: var(--text-primary, #ddd);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
}

.sign-message-panel textarea:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Asset settings panel (unified: ground, bridge, vehicle) */
.tile-properties,
.asset-settings-panel {
  background: #1a2040;
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.tile-properties.hidden,
.asset-settings-panel.hidden {
  display: none;
}

.tile-props-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2b3566;
}

.tile-preview {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 2px solid #3d4a7a;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.tile-props-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-props-name {
  font-weight: 600;
  color: var(--accent-light);
  font-size: 0.9rem;
}

.tile-properties .form-row,
.asset-settings-panel .form-row {
  margin-bottom: 8px;
}

.tile-properties .form-row:last-child,
.asset-settings-panel .form-row:last-child {
  margin-bottom: 0;
}

.tile-properties label,
.asset-settings-panel label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.75rem;
}

.tile-properties input[type="range"],
.asset-settings-panel input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #0f1320;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tile-properties input[type="range"]::-webkit-slider-thumb,
.asset-settings-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--accent-light);
}

.tile-properties input[type="range"]::-moz-range-thumb,
.asset-settings-panel input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--accent-light);
}

.tile-properties select,
.asset-settings-panel select {
  width: 100%;
  font-size: 0.8rem;
}

.reset-props-btn {
  padding: 3px 8px;
  font-size: 0.7rem;
  background: #2b3566;
  border: 1px solid #3d4a7a;
  border-radius: 4px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}

.reset-props-btn:hover {
  background: #3d4a7a;
  color: var(--text-primary);
}

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

.inventory-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.item-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #2b3566;
  border-radius: 4px;
  padding: 8px;
}

.item-list .item-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 4px;
  background: var(--bg-elevated);
  border-radius: 4px;
  cursor: pointer;
}

.item-entry-sprite {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.item-entry .item-actions {
  flex-shrink: 0;
}

.item-list .item-entry:hover {
  background: #2b3566;
}

.item-list .item-entry.selected {
  background: #3b4b8e;
  border: 1px solid var(--accent);
}

.item-info {
  flex: 1;
}

.item-name {
  font-weight: bold;
  color: var(--text-secondary);
}

.item-type {
  font-size: 0.8em;
  color: #888;
}

.item-actions {
  display: flex;
  gap: 4px;
}

.item-editor {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: 4px;
  border: 1px solid #2b3566;
}

.item-editor .form-row {
  margin-bottom: 8px;
}

.item-editor .form-row:last-child {
  margin-bottom: 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.editor-subtabs {
  margin-top: 8px;
  border-top: 1px solid #2b3566;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.editor-subtabs.hidden {
  display: none;
}

.editor-subtabs .editor-tab {
  min-width: 0;
  text-align: center;
}

/* Responsive subtabs */
@media (max-width: 1200px) {
  .editor-subtabs {
    gap: 2px;
  }
}

@media (max-width: 900px) {
  .editor-subtabs .editor-tab {
    font-size: 0.65rem;
    padding: 4px 2px;
  }
}

@media (max-width: 600px) {
  .editor-subtabs .editor-tab {
    font-size: 0.55rem;
    padding: 5px 1px;
    border-radius: 3px;
  }
}

.override-indicator {
  color: #ffb347;
  font-weight: 600;
  font-size: 0.7rem;
}

.override-indicator.hidden {
  display: none;
}

.default-hint {
  font-size: 0.65rem;
  color: var(--text-faint);
  font-weight: 400;
}

.default-hint.modified {
  color: #ffb347;
}

/* Object preview panel (blocking/decor/interactive) */
.object-preview-panel {
  background: #1a2040;
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.object-preview-panel.hidden {
  display: none;
}

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

.object-preview-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.object-preview-name {
  font-weight: 600;
  color: var(--accent-light);
  font-size: 0.9rem;
}

.object-preview-type {
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: capitalize;
}

/* Animal System Panel */
#animalLayerPanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.animal-hint,
.tile-hint {
  font-size: 0.75rem;
  color: var(--accent-light);
  margin-bottom: 0;
  padding: 8px;
  background: rgba(124, 140, 255, 0.1);
  border-radius: 6px;
  line-height: 1.4;
}

.animal-empty-state {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
}

.animal-empty-state p {
  margin: 0 0 8px 0;
}

.animal-empty-state .hint {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.animal-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.animal-editor.hidden {
  display: none;
}

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

.animal-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.animal-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.animal-info-name {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 1rem;
}

.animal-info-species {
  font-size: 0.75rem;
  color: var(--accent-light);
  text-transform: capitalize;
}

.animal-stats {
  background: #1a2040;
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.animal-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.animal-stat-row label {
  min-width: 50px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.animal-stat-bar {
  flex: 1;
  height: 8px;
  background: #0f1320;
  border-radius: 4px;
  overflow: hidden;
}

.animal-stat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.health-fill {
  background: linear-gradient(90deg, #ff4444, #44ff66);
}

.hunger-fill {
  background: linear-gradient(90deg, #ff8844, #ffcc44);
}

.animal-state-badge {
  background: #2b3566;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.animal-state-badge.hunting {
  background: #6b2020;
  color: #ff8888;
}

.animal-state-badge.fleeing {
  background: #6b5020;
  color: #ffcc88;
}

.animal-state-badge.breeding {
  background: #206b40;
  color: #88ffaa;
}

.animal-state-badge.wandering {
  background: #204060;
  color: #88bbff;
}

/* Projects Modal Styles */
.modal-project-item:hover {
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.modal-project-item.current {
  cursor: default;
}

.modal-project-item.current:hover {
  transform: none;
}

/* Log Viewer Styles */
@keyframes log-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.2);
  }
}

.log-notification {
  animation: log-pulse 2s ease-in-out infinite;
}

.log-entry {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.2s;
}

.log-entry:hover {
  background: rgba(255, 255, 255, 0.05);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry-time {
  font-size: 0.75em;
  color: #888;
  margin-bottom: 2px;
}

.log-entry-type {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7em;
  font-weight: bold;
  text-transform: uppercase;
  margin-right: 8px;
  min-width: 60px;
  text-align: center;
}

.log-entry-type.death {
  background: rgba(220, 53, 69, 0.3);
  color: #ff6b6b;
}

.log-entry-type.combat {
  background: rgba(255, 193, 7, 0.3);
  color: #ffc107;
}

.log-entry-type.movement {
  background: rgba(0, 123, 255, 0.3);
  color: #007bff;
}

.log-entry-type.lifecycle {
  background: rgba(40, 167, 69, 0.3);
  color: #28a745;
}

.log-entry-type.system {
  background: rgba(108, 117, 125, 0.3);
  color: #6c757d;
}

.log-entry-message {
  color: #fff;
  font-size: 0.85em;
  line-height: 1.4;
}

.log-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.log-filter-btn {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.2s;
}

.log-filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.log-filter-btn.active {
  background: rgba(0, 212, 255, 0.3);
  border-color: rgba(0, 212, 255, 0.5);
  color: #00d4ff;
}

.log-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  justify-content: space-between;
  align-items: center;
}

.log-clear-btn {
  background: rgba(220, 53, 69, 0.2);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: #ff6b6b;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.2s;
}

.log-clear-btn:hover {
  background: rgba(220, 53, 69, 0.3);
  border-color: rgba(220, 53, 69, 0.5);
}

/* Low Health Warning Indicator */


/* Temperament Badge */
.animal-temperament-badge {
  background: rgba(108, 117, 125, 0.3);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #adb5bd;
  text-transform: capitalize;
}

.animal-temperament-badge.fearful {
  background: rgba(220, 53, 69, 0.3);
  color: #ff6b6b;
}

.animal-temperament-badge.fearless {
  background: rgba(255, 193, 7, 0.3);
  color: #ffc107;
}

.animal-danger-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4444;
  margin-left: 6px;
  border: 1px solid #ff6666;
  box-shadow: 0 0 4px rgba(255, 68, 68, 0.6);
  animation: danger-pulse 1.5s ease-in-out infinite;
}

@keyframes danger-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

.animal-food-chain {
  background: #1a2040;
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 10px;
}

.animal-food-chain h4 {
  margin: 0 0 8px 0;
  color: var(--accent-light);
  font-size: 0.85rem;
}

.animal-chain-row {
  display: flex;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.animal-chain-row label {
  min-width: 70px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chain-list {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.animal-palette-section h4,
.tile-palette-section h4 {
  margin: 0 0 8px 0;
  color: var(--accent-light);
  font-size: 0.85rem;
}

.animal-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.palette-category-header {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  font-weight: 600;
  color: #9fb2ff;
  padding: 6px 0 2px;
  border-bottom: 1px solid #2b3566;
  margin: 0;
}


.animal-swatch-container {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.animal-placement-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.animal-placement-tools button {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.75rem;
}

.animal-placement-tools button.active {
  background: var(--accent);
  border-color: #6f80ff;
}

.animal-swatch {
  background: #0f1320;
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  min-width: 0;
}

.animal-swatch:hover {
  border-color: var(--accent);
  background: #1a2040;
}

.animal-swatch.selected {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(124, 140, 255, 0.4);
  background: var(--bg-elevated);
}

.animal-remove-all {
  background: #c0392b;
  border: 1px solid #a93226;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.animal-remove-all:hover {
  background: #e74c3c;
  border-color: #c0392b;
  transform: scale(1.05);
}

.animal-remove-all:active {
  transform: scale(0.95);
}

.food-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.food-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #2b3566;
  background: #0f1320;
  color: #dfe5ff;
  cursor: pointer;
  transition: all 0.15s;
}

.food-swatch.selected {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(124, 140, 255, 0.4);
  background: var(--bg-elevated);
}

.food-swatch canvas {
  border-radius: 4px;
  image-rendering: pixelated;
}

.food-swatch-name {
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.animal-settings-controls,
.food-settings-controls,
.tile-properties,
.asset-settings-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #2b3566;
  border-radius: 8px;
  background: #101634;
}

.animal-settings-header,
.tile-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.animal-settings-controls h4,
.food-settings-controls h4,
.tile-properties h4,
.asset-settings-panel h4 {
  margin: 0;
  color: var(--accent-light);
  font-size: 0.85rem;
}

.settings-section {
  margin-bottom: 16px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h5 {
  margin: 0 0 8px 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.relationship-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
  padding: 8px;
  background: rgba(43, 59, 112, 0.3);
  border-radius: 4px;
  border: 1px solid rgba(200, 209, 255, 0.2);
}

.relationship-item {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  background: rgba(43, 59, 112, 0.6);
  color: var(--text-secondary);
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid rgba(200, 209, 255, 0.3);
}

.relationship-item.empty {
  color: var(--text-faint);
  background: rgba(43, 59, 112, 0.2);
  border: 1px solid rgba(200, 209, 255, 0.1);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Responsive animal swatches */
@media (max-width: 900px) {
  .animal-swatch-container {
    margin-bottom: 6px;
  }

  .animal-remove-all {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}

@media (max-width: 600px) {
  .animal-swatch {
    padding: 6px;
    gap: 6px;
  }

  .animal-swatch canvas {
    width: 24px;
    height: 24px;
  }

  .animal-remove-all {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  .food-palette {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 6px;
  }
}

.animal-swatch canvas {
  border-radius: 4px;
  image-rendering: pixelated;
}

.animal-swatch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.animal-swatch-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.animal-swatch-category {
  font-size: 0.65rem;
  color: var(--text-faint);
  text-transform: capitalize;
}

.animal-map-list h4 {
  margin: 0 0 8px 0;
  color: var(--accent-light);
  font-size: 0.85rem;
}



.animal-template-section {
  margin-bottom: 2px;
}

.animal-template-header {
  background: #151a2e;
  padding-left: 16px;
  font-size: 0.7rem;
}

.animal-template-header:hover {
  background: #1a1f3a;
}

.animal-template-header.expanded {
  background: #1a1f3a;
  color: var(--accent-light);
}

/* Design tokens defined in :root at top of file */

.editor-tabs-bar,
.editor-tabs,
.editor-subtabs {
  min-width: 0;
}

.editor-tabs {
  background: transparent;
  border: none;
}

.editor-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
}

.editor-tab:hover {
  background: rgba(43, 59, 112, 0.9);
  border-color: rgba(83, 102, 214, 0.7);
  transform: translateX(2px);
}

.editor-tab.active {
  background: var(--accent);
  border-color: var(--border-accent);
  color: white;
  box-shadow: 0 2px 4px rgba(83, 102, 214, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

button:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* Game Menu Styles */
.game-menu {
  width: min(600px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.game-menu-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.game-menu-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.game-menu-section {
  border: 1px solid #33417a;
  border-radius: 8px;
  padding: 16px;
  background: rgba(26, 32, 64, 0.5);
}

.game-menu-section h4 {
  margin: 0 0 12px 0;
  color: var(--accent-light);
  font-size: 1.1rem;
}

.game-menu-inventory {
  display: flex;
  flex-direction: column;
}

.game-menu-inventory .inventory-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.9rem;
  border-bottom: 1px solid #2b3566;
}

.game-menu-inventory .inventory-item:hover {
  background: rgba(124, 140, 255, 0.12);
}

.game-menu-inventory .inventory-item.selected {
  background: rgba(124, 140, 255, 0.2);
}

.game-menu-inventory .inventory-item:last-child {
  border-bottom: none;
}

.game-menu-inventory .inv-item-name {
  flex: 1;
}

.game-menu-inventory .inv-item-qty {
  color: var(--text-faint);
  font-size: 0.85rem;
}

.game-menu-inventory .inv-item-cat {
  color: var(--text-faint);
  font-size: 0.8rem;
  min-width: 50px;
  text-align: right;
}

.game-menu-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-menu-options button {
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid #2b3566;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.game-menu-options button:hover {
  background: #2b3566;
  border-color: var(--accent);
}

.empty-inventory {
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  margin: 20px 0;
}

/* Equipped Item Overlay (persistent on right side) */
.equipped-item-overlay {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  background: rgba(26, 32, 64, 0.95);
  border: 2px solid #4ade80;
  border-radius: 12px;
  padding: 16px;
  min-width: 250px;
  max-width: 300px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.3s ease-out;
}

.equipped-item-overlay .equipped-label {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #4ade80;
  color: #0f1320;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.equipped-item-overlay .item-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  text-align: center;
}

.equipped-item-overlay .item-details {
  text-align: center;
}

.equipped-item-overlay .item-name {
  color: var(--accent-light);
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.equipped-item-overlay .item-description {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 12px;
  line-height: 1.4;
}

.equipped-item-overlay .item-unequip-btn {
  display: block;
  width: 100%;
  background: #2b3566;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text-secondary);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  text-align: center;
}

.equipped-item-overlay .item-unequip-btn:hover {
  background: var(--accent);
  border-color: var(--accent-light);
}

.equipped-item-overlay .item-sprite-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 8px;
}

.equipped-item-overlay .item-category-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #1a2040;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.equipped-item-overlay .item-use-hint {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #a0aad0;
}

.equipped-item-overlay .item-use-hint kbd {
  display: inline-block;
  background: #2b3566;
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Game menu inventory improvements */
.inventory-item {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background 0.15s;
}

.inventory-item:hover {
  background: rgba(124, 140, 255, 0.15);
}

.inventory-item.selected {
  background: rgba(124, 140, 255, 0.25);
}

.inventory-item.equipped {
  border-left: 3px solid #4ade80;
}

.inv-equipped-badge {
  margin-left: auto;
  background: #4ade80;
  color: #1a2040;
  font-size: 0.65rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

@keyframes slideInRight {
  from {
    right: -320px;
    opacity: 0;
  }
  to {
    right: 20px;
    opacity: 1;
  }
}

/* Game Menu Tabs */
.game-menu-tabs {
  display: flex;
  border-bottom: 1px solid #2b3566;
  margin-bottom: 12px;
  gap: 2px;
  flex-shrink: 0;
}

.game-menu-tab {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.game-menu-tab:hover {
  color: var(--text-secondary);
  background: rgba(124, 140, 255, 0.08);
}

.game-menu-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent-light);
}

.game-menu-panel.hidden {
  display: none;
}

/* Equipment panel */
.equipment-section {
  margin-bottom: 16px;
}

.equipment-section h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.equipment-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px dashed #2b3566;
  border-radius: 8px;
  padding: 10px;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.equipment-slot.filled {
  border-style: solid;
  border-color: #4ade80;
  color: var(--text-primary);
}

.game-menu-unequip-btn {
  margin-top: 8px;
  padding: 6px 16px;
  background: var(--bg-elevated);
  border: 1px solid #2b3566;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  width: 100%;
}

.game-menu-unequip-btn:hover {
  background: #2b3566;
  border-color: var(--accent);
}

/* Player overview tab */
.player-overview {
  display: flex;
  flex-direction: row;
  gap: 20px;
  padding: 12px;
  align-items: flex-start;
}

.player-portrait-frame {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid #2b3566;
  border-radius: 8px;
  padding: 8px;
  flex-shrink: 0;
}

#playerPortrait {
  display: block;
  image-rendering: pixelated;
}

#playerStats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-stat-label {
  color: var(--text-faint);
  font-size: 0.85rem;
  min-width: 60px;
}

.player-stat-value {
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

.player-unequip-btn {
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 0.75rem;
  background: rgba(231, 76, 60, 0.25);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.4);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
}

.player-unequip-btn:hover {
  background: rgba(231, 76, 60, 0.45);
}

.stat-bar-track {
  flex: 1;
  height: 14px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid #2b3566;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s;
}

.stat-bar-fill.hp {
  background: linear-gradient(to right, #e74c3c, #2ecc71);
}

.coin-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 2px;
  vertical-align: middle;
}

.coin-icon.gold { background: #ffd700; }
.coin-icon.silver { background: #c0c0c0; }
.coin-icon.bronze { background: #cd7f32; }

/* ============================================
   Script Editor Styles
   ============================================ */

.script-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.script-editor-header h4 {
  margin: 0;
  font-size: 14px;
}

.script-toolbar {
  display: flex;
  gap: 4px;
}

.script-list-section {
  margin-bottom: 12px;
}

.script-list-section label {
  display: block;
  font-size: 11px;
  color: #9fa6c4;
  margin-bottom: 4px;
}

.script-list-select {
  width: 100%;
  background: rgba(15, 19, 32, 0.6);
  color: var(--text-primary);
  border: 1px solid rgba(43, 54, 102, 0.5);
  border-radius: 4px;
  padding: 4px;
  font-size: 12px;
  font-family: inherit;
}

.script-list-select option {
  background: #1a2140;
  color: var(--text-primary);
}

.script-list-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.small-btn {
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(43, 54, 102, 0.5);
  color: #c5ccff;
  border: 1px solid rgba(63, 74, 132, 0.5);
  border-radius: 4px;
  cursor: pointer;
}

.small-btn:hover {
  background: rgba(63, 74, 132, 0.6);
}

.tiny-btn {
  padding: 2px 6px;
  font-size: 10px;
  background: rgba(43, 54, 102, 0.4);
  color: #9fa6c4;
  border: 1px solid rgba(43, 54, 102, 0.4);
  border-radius: 3px;
  cursor: pointer;
}

.tiny-btn:hover {
  background: rgba(63, 74, 132, 0.5);
  color: #c5ccff;
}

.tiny-btn.danger-btn {
  color: #ff6b6b;
}

.tiny-btn.danger-btn:hover {
  background: rgba(180, 50, 50, 0.3);
}

.script-triggers-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(43, 54, 102, 0.3);
}

.script-triggers-section label {
  display: block;
  font-size: 11px;
  color: #9fa6c4;
  margin-bottom: 4px;
}

.trigger-list {
  min-height: 24px;
}

.trigger-empty {
  font-size: 11px;
  color: #5a627e;
  font-style: italic;
  padding: 4px 0;
}

.trigger-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 6px;
  background: rgba(15, 19, 32, 0.4);
  border-radius: 3px;
  margin-bottom: 3px;
  font-size: 11px;
}

.command-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(43, 54, 102, 0.3);
}

.command-editor-header h4 {
  margin: 0;
  font-size: 13px;
}

.command-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.command-empty {
  font-size: 11px;
  color: #5a627e;
  font-style: italic;
  padding: 8px 0;
  text-align: center;
}

.command-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: rgba(15, 19, 32, 0.4);
  border-radius: 3px;
  margin-bottom: 3px;
  font-size: 11px;
}

.command-label {
  font-weight: 600;
  color: #adb5ff;
  flex-shrink: 0;
}

.command-params {
  color: #7a82a8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.command-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.add-command-row {
  display: flex;
  gap: 4px;
}

.add-command-row select {
  flex: 1;
  background: rgba(15, 19, 32, 0.6);
  color: var(--text-primary);
  border: 1px solid rgba(43, 54, 102, 0.5);
  border-radius: 4px;
  padding: 4px;
  font-size: 11px;
}

.add-command-row select optgroup {
  color: #adb5ff;
  font-weight: 600;
}

.add-command-row select option {
  background: #1a2140;
  color: var(--text-primary);
  font-weight: 400;
}

.script-variables-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(43, 54, 102, 0.3);
}

.script-variables-section h4 {
  margin: 0 0 6px 0;
  font-size: 12px;
  color: #9fa6c4;
}

.variables-list,
.switches-list {
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 6px;
}

.var-empty {
  font-size: 11px;
  color: #5a627e;
  font-style: italic;
  padding: 2px 0;
}

.var-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  background: rgba(15, 19, 32, 0.3);
  border-radius: 3px;
  margin-bottom: 2px;
  font-size: 11px;
}

.var-name {
  color: #adb5ff;
  font-weight: 600;
  flex: 1;
}

.var-value {
  color: #7a82a8;
}

.add-variable-row,
.add-switch-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.add-variable-row input,
.add-switch-row input {
  flex: 1;
  background: rgba(15, 19, 32, 0.6);
  color: var(--text-primary);
  border: 1px solid rgba(43, 54, 102, 0.5);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
}

/* Choice dialog */
.choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
}

.choice-btn {
  padding: 10px 16px;
  background: rgba(43, 54, 102, 0.6);
  color: var(--text-primary);
  border: 1px solid rgba(63, 74, 132, 0.5);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.choice-btn:hover,
.choice-btn.choice-highlight {
  background: rgba(63, 74, 132, 0.8);
  border-color: rgba(100, 140, 255, 0.7);
}

/* ============================================
   Consolidated layout breakpoints
   ============================================ */

@media (max-width: 1200px) {
  :root {
    --nav-width: 180px;
    --panel-width: 280px;
  }
}

@media (max-width: 900px) {
  :root {
    --nav-width: 0px;
  }

  .nav-sidebar {
    display: none;
  }

  .panel {
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
  }

  .inventory-catalogue,
  .bestiary-overlay,
  .graphs-overlay,
  .asset-explorer-overlay {
    left: 8px;
    right: 8px;
  }
}

@media (max-width: 600px) {
  :root {
    --topbar-height: 40px;
  }

  .topbar {
    padding: 4px 8px;
  }

  .panel {
    border-radius: var(--radius-lg);
  }
}

/* ── Creature System ─────────────────────────────────────────────────── */

.creature-hint {
  font-size: 0.85em;
  color: #999;
  margin-bottom: 8px;
}

.creature-preview {
  border: 1px solid #2b3566;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(26, 32, 64, 0.5);
}

.creature-preview.hidden { display: none; }

.creature-preview-inner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.creature-preview-sprite {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
}

.creature-preview-info {
  flex: 1;
  min-width: 0;
}

.creature-preview-name {
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 4px;
}

.creature-preview-meta {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.creature-preview-type {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
  text-transform: capitalize;
}

.creature-preview-rarity {
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: capitalize;
}

.creature-preview-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.creature-stat-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.creature-stat-label {
  font-size: 0.7rem;
  color: var(--text-faint);
  width: 26px;
  text-align: right;
}

.creature-stat-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.creature-stat-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.2s;
}

.creature-stat-val {
  font-size: 0.7rem;
  color: var(--text-secondary);
  width: 22px;
  text-align: right;
}

.creature-palette {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}

.creature-palette .tile-swatch {
  flex-direction: row;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #2b3566;
  padding: 4px 8px;
  gap: 8px;
  background: transparent;
}

.creature-palette .tile-swatch:hover {
  background: rgba(124, 140, 255, 0.1);
}

.creature-palette .tile-swatch.selected {
  background: rgba(124, 140, 255, 0.18);
  border-color: #2b3566;
  box-shadow: none;
}

.creature-palette .tile-preview {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  flex-shrink: 0;
}

.creature-palette .tile-label {
  font-size: 0.8rem;
  text-align: left;
}

/* Mine editor */
.mine-hint {
  font-size: 0.85em;
  color: #999;
  margin-bottom: 8px;
}

.mine-ore-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.mine-ore-palette .tile-swatch {
  padding: 4px;
  gap: 4px;
}

.mine-settings h4 {
  font-size: 0.9em;
  color: #b0b8d0;
  margin: 8px 0 4px;
}

/* Battle overlay */
.battle-card {
  width: min(560px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.battle-enemy,
.battle-player {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}

.battle-creature-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.battle-name {
  font-weight: bold;
  font-size: 1.1em;
}

.battle-level {
  font-size: 0.85em;
  color: #aaa;
}

.battle-type-badge {
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.battle-hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.battle-hp-bar {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 5px;
  overflow: hidden;
}

.battle-hp-fill {
  height: 100%;
  background: #2ecc40;
  border-radius: 5px;
  transition: width 0.3s ease;
}

.battle-hp-text {
  font-size: 0.8em;
  color: #ccc;
  min-width: 60px;
  text-align: right;
}

.battle-sprite {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}

.battle-sprite svg,
.battle-sprite canvas {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.battle-log {
  max-height: 100px;
  overflow-y: auto;
  padding: 6px 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  font-size: 0.85em;
  color: #ddd;
}

.battle-log-line {
  margin-bottom: 2px;
}

.battle-moves {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.battle-move-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  border: 2px solid #555;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: #fff;
  cursor: pointer;
  font-size: 0.9em;
  transition: background 0.15s;
}

.battle-move-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
}

.battle-move-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.move-name {
  font-weight: bold;
}

.move-pp {
  font-size: 0.75em;
  color: #aaa;
}

.battle-actions {
  display: flex;
  gap: 8px;
}

.battle-action-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid #555;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  font-size: 0.9em;
}

.battle-action-btn:hover {
  background: rgba(255,255,255,0.12);
}

.capture-btn { border-color: #c0a040; }
.flee-btn { border-color: #60a0c0; }

.battle-close-btn {
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #2080d0;
  color: #fff;
  cursor: pointer;
  font-size: 1em;
  font-weight: bold;
}

.battle-close-btn:hover {
  background: #1a6ab0;
}

/* Team overlay */
.team-card {
  width: min(560px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
}

.team-section {
  margin-bottom: 16px;
}

.team-section h4 {
  margin-bottom: 8px;
  color: #aaa;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.team-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.team-slot {
  padding: 10px;
  border: 1px solid #333;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  min-height: 60px;
}

.team-slot.filled {
  border-color: #555;
}

.team-slot.empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-slot-label,
.empty-storage-label {
  color: #666;
  font-style: italic;
  font-size: 0.85em;
}

.creature-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.creature-card-name {
  font-weight: bold;
  font-size: 0.95em;
}

.creature-card-level {
  font-size: 0.8em;
  color: #aaa;
}

.creature-card-hp {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.creature-card-hp-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.creature-card-hp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.creature-card-hp-text {
  font-size: 0.75em;
  color: #aaa;
}

.creature-lead-badge {
  font-size: 0.65rem;
  background: rgba(124, 140, 255, 0.25);
  color: var(--accent-light);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

.creature-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.creature-card-actions button {
  padding: 2px 6px;
  border: 1px solid #444;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: #ccc;
  cursor: pointer;
  font-size: 0.8em;
}

.creature-card-actions button:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
}

.creature-card-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.storage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.storage-creature-card {
  padding: 8px;
  border: 1px solid #333;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}

.team-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ── Player Panel ──────────────────────────────────────────────────── */

.player-gold-display {
  font-weight: bold;
  font-size: 13px;
  color: #FFD700;
  min-width: 70px;
  text-align: center;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.player-inventory-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.player-inv-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: rgba(15, 19, 32, 0.6);
  border-radius: 4px;
  font-size: 12px;
}

.player-inv-label {
  flex: 1;
  color: #c5ccff;
}

.player-inv-remove {
  padding: 2px 6px !important;
  font-size: 10px !important;
}

.player-inv-empty {
  color: #6a6f90;
  font-size: 12px;
  font-style: italic;
  padding: 8px 0;
}

/* ── Casino ────────────────────────────────────────────────────────────── */

.casino-card {
  width: min(480px, 95vw);
  background: linear-gradient(145deg, #0f1f14, #0a150a);
  border: 2px solid #c8a832;
}

.casino-card .overlay-header {
  border-bottom: 1px solid rgba(200, 168, 50, 0.3);
  padding-bottom: 10px;
}

.casino-card .overlay-header h3 {
  color: #ffd700;
}

.casino-balance {
  color: #ffd700;
  font-weight: bold;
  font-size: 0.9em;
}

.casino-game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
}

/* Slot machine */

.slots-reels {
  display: flex;
  gap: 10px;
}

.slot-reel {
  width: 80px;
  height: 80px;
  background: #1a1a2e;
  border: 2px solid #c8a832;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  transition: transform 0.2s;
}

.slot-reel.spinning {
  filter: blur(2px);
  animation: slotPulse 0.15s infinite alternate;
}

.slot-reel.slot-land {
  animation: slotLand 0.3s;
}

@keyframes slotPulse {
  from { transform: scale(0.95); }
  to { transform: scale(1.05); }
}

@keyframes slotLand {
  0% { transform: scale(1.2); }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.slots-paytable {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: center;
  font-size: 0.75em;
  color: #aaa;
}

.pay-row {
  white-space: nowrap;
}

/* Bet controls */

.casino-bet-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cas-bet-btn {
  padding: 4px 10px;
  border: 1px solid #c8a832;
  border-radius: 4px;
  background: rgba(200, 168, 50, 0.08);
  color: #ffd700;
  cursor: pointer;
  font-size: 0.85em;
}

.cas-bet-btn:hover {
  background: rgba(200, 168, 50, 0.2);
}

.cas-bet-display {
  color: #ffd700;
  font-weight: bold;
  min-width: 80px;
  text-align: center;
}

/* Play button */

.cas-play-btn {
  padding: 10px 28px;
  border: 2px solid #c8a832;
  border-radius: 8px;
  background: linear-gradient(to bottom, #2a4a20, #1a3a10);
  color: #ffd700;
  font-weight: bold;
  font-size: 1.05em;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s;
}

.cas-play-btn:hover:not(:disabled) {
  background: linear-gradient(to bottom, #3a5a30, #2a4a20);
}

.cas-play-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Result message */

.cas-result {
  font-weight: bold;
  font-size: 1.05em;
  min-height: 1.5em;
  text-align: center;
}

.cas-win { color: #2ecc40; }
.cas-lose { color: #ff4444; }

/* Blackjack */

.bj-table {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bj-hand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
}

.bj-label {
  font-size: 0.85em;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.bj-cards {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.bj-card {
  width: 48px;
  height: 68px;
  border-radius: 6px;
  border: 1px solid #888;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  gap: 2px;
  background: #f8f6f0;
}

.bj-card.red { color: #cc0000; }
.bj-card.black { color: #1a1a1a; }

.bj-card.face-down {
  background: linear-gradient(135deg, #1a4a8a, #0a2a5a);
  color: #ffffff;
  border-color: #3a6aaa;
}

.card-rank { font-size: 1.1em; }
.card-suit { font-size: 0.9em; }

.bj-score {
  color: #ccc;
  font-size: 0.9em;
}

.bj-divider {
  height: 1px;
  background: rgba(200, 168, 50, 0.2);
  margin: 4px 0;
}

.bj-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Coin flip */

.coinflip-display {
  text-align: center;
}

.coinflip-coin {
  font-size: 64px;
  transition: transform 0.3s;
}

.coinflip-coin.flipping {
  animation: coinSpin 0.2s infinite linear;
}

@keyframes coinSpin {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

.coinflip-choices {
  display: flex;
  gap: 12px;
}

/* ═══ Projects Screen ═══ */
.projects-screen { position: fixed; inset: 0; z-index: 200; background: var(--bg-deep); display: flex; flex-direction: column; }
.projects-screen.hidden { display: none; }
.projects-header { display: flex; justify-content: space-between; align-items: center; padding: 24px 40px; border-bottom: 1px solid var(--border-subtle); }
.projects-brand { font-size: 1.4rem; margin: 0; color: var(--text-primary); }
.projects-user { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.9rem; }
.projects-body { flex: 1; overflow-y: auto; padding: 32px 40px; max-width: 1000px; margin: 0 auto; width: 100%; }
.projects-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.projects-toolbar h2 { margin: 0; font-size: 1.1rem; color: var(--text-secondary); }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.project-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 12px; padding: 20px; cursor: pointer; transition: border-color 0.2s, transform 0.15s; }
.project-card:hover { border-color: var(--border-accent); transform: translateY(-2px); }
.project-card-name { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.project-card-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }
.projects-empty { text-align: center; color: var(--text-muted); padding: 60px 0; }
.create-project-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 210; }
.create-project-overlay.hidden { display: none; }
.create-project-card { background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 12px; padding: 32px; width: 400px; }
.create-project-card h3 { margin: 0 0 16px; color: var(--text-primary); }
.create-project-card input { width: 100%; padding: 10px 12px; background: var(--bg-recessed); border: 1px solid var(--border-default); border-radius: 6px; color: var(--text-primary); font-size: 14px; outline: none; box-sizing: border-box; }
.create-project-card input:focus { border-color: var(--border-accent); }
.create-hint { font-size: 0.75rem; color: var(--text-muted); margin: 8px 0 16px; }
.create-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Building configurator panel */
#buildingConfigPanel .form-row { margin-bottom: 8px; }
#buildingConfigPanel select,
#buildingConfigPanel input[type="number"] {
  background: var(--bg-recessed);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 4px 6px;
}
#buildingConfigPanel select:focus,
#buildingConfigPanel input[type="number"]:focus {
  border-color: var(--border-accent);
  outline: none;
}
.building-preview {
  width: 128px;
  height: 96px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-recessed);
  image-rendering: pixelated;
}

