:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #111927;
  --panel-2: #182235;
  --text: #d6e2ff;
  --muted: #8fa3c8;
  --accent: #62a4ff;
  --danger: #ff7f7f;
}
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.devtools-header { position: sticky; top: 0; z-index: 20; display:flex; gap:14px; align-items:center; justify-content:space-between; padding:14px 20px; background:#0f1726; border-bottom:1px solid #2b3b56; }
.devtools-header-main { display:flex; gap:14px; align-items:center; flex-wrap:wrap; }
.devtools-header-title { font-size: 16px; font-weight: 700; color: #c8d9fa; letter-spacing: 0.02em; }
.devtools-header-tabs { display:flex; gap:14px; align-items:center; flex-wrap:wrap; }
.devtools-header-actions { display:flex; gap:10px; align-items:center; flex-wrap:nowrap; }
.header-action-stack { display:flex; flex-direction:column; gap:6px; align-items:flex-start; justify-content:center; align-self:center; }
.header-action-stack .actions { display:flex; align-items:center; justify-content:flex-start; min-height:40px; }
.header-action-stack.has-error {
  justify-content:flex-start;
}
.devtools-tab { color: var(--text); text-decoration:none; padding:10px 14px; border-radius:10px; border:1px solid #2b3b56; font-size: 16px; }
.devtools-tab.is-active { background: var(--accent); color: #081327; border-color: var(--accent); font-weight:700; }


@media (max-width: 900px) {
  .devtools-header {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .devtools-header-main {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    min-width: 0;
  }

  .devtools-header-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .devtools-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .devtools-header-actions {
    justify-content: flex-start;
    align-items: stretch;
    flex-wrap: wrap;
  }

  .header-action-stack {
    align-items: stretch;
  }
}

.page { padding: 20px; }
.page-title-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-title-copy h1 {
  margin: 0;
  font-size: 34px;
}
.panel-toggle-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.panel { background: var(--panel); border:1px solid #2b3b56; border-radius: 14px; padding: 16px; margin-bottom: 20px; }
.panel h2 { margin-top: 0; margin-bottom: 14px; font-size: 34px; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-heading h2 {
  margin-bottom: 0;
}
.panel-heading--collapsible {
  margin-bottom: 0;
}
.panel-toggle {
  min-width: 112px;
}
.panel-toggle--toolbar {
  min-width: 0;
}
.collapsible-panel.is-collapsed {
  display: none;
}
.grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); gap:14px; }

#towerEditorFields.grid { grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); }
.field { display:flex; flex-direction:column; gap:6px; font-size:14px; }
.field-head { display:flex; align-items:center; gap:8px; }
.field input { background: var(--panel-2); color: var(--text); border:1px solid #3a4d71; border-radius:10px; padding:8px 10px; font-size: 16px; }
.field input.is-invalid { border-color: var(--danger); }
.field input:disabled { opacity:.6; }
.help-btn {
  width: 24px;
  height: 24px;
  border-radius: 0;
  border: 0;
  color: #c5d7fb;
  background: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  padding: 0;
}
.help-btn--icon {
  position: relative;
  font-size: 0;
}
.help-btn--icon::before {
  content: 'ⓘ';
  display: block;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}
.tooltip { position:fixed; max-width:620px; background:#08101f; border:1px solid #36517f; padding:16px; border-radius:10px; font-size:18px; line-height:1.5; white-space:pre-line; z-index:60; }
.tooltip p { margin: 0 0 8px; }
.tooltip p:last-child { margin-bottom: 0; }
.tooltip-title { font-weight: 700; color: #dce8ff; font-size: 20px; }
.muted { color: var(--muted); font-size:12px; }
.debug-export-hint { max-width: 920px; line-height: 1.5; }
.actions { display:flex; gap:12px; flex-wrap:wrap; }
button { background:#213658; color:var(--text); border:1px solid #3f5c8f; padding:9px 13px; border-radius:10px; cursor:pointer; font-size: 15px; }
.button-feedback {
  min-height: 16px;
  margin: 0;
  font-size: 12px;
}
.header-action-stack .button-feedback {
  min-height: 0;
}
.header-action-stack:not(.has-error) .button-feedback:empty {
  display: none;
}
.button-status--pending {
  opacity: 0.9;
}
.button-status--success {
  color: #d8ffe7;
  border-color: #2f8f5b;
  background: #173624;
}
.devtools-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:#213658;
  color:var(--text);
  border:1px solid #3f5c8f;
  padding:9px 13px;
  border-radius:10px;
  cursor:pointer;
  font-size: 15px;
  text-decoration: none;
}
.devtools-mode-toggle[data-storage-mode="local"] {
  border-color: #2f8f5b;
  color: #d8ffe7;
  background: #173624;
}

.error { color: var(--danger); }
.devtools-toast {
  position: fixed;
  top: 82px;
  right: 20px;
  z-index: 70;
  max-width: min(420px, calc(100vw - 40px));
}
.devtools-toast[hidden] {
  display: none;
}
.devtools-toast__body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #8a4040;
  background: rgba(44, 16, 20, 0.96);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.devtools-toast__message {
  flex: 1 1 auto;
  color: #ffd0d0;
  font-size: 14px;
  line-height: 1.45;
}
.devtools-toast__close {
  flex: 0 0 auto;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #8a4040;
  background: rgba(255, 255, 255, 0.04);
  color: #ffd0d0;
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 900px) {
  .page-title-bar {
    align-items: stretch;
  }

  .panel-toggle-toolbar {
    width: 100%;
  }

  .devtools-toast {
    top: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; min-width:980px; }
th,td { border-bottom:1px solid #2b3b56; text-align:left; padding:10px 8px; font-size:14px; }
th { position:sticky; top:0; z-index:2; background:#0f1726; }
.sim-frame { width:100%; height: calc(100vh - 70px); border:0; background:white; }

.search-input { width:100%; margin-bottom:14px; background: var(--panel-2); color: var(--text); border:1px solid #3a4d71; border-radius:10px; padding:10px; font-size: 15px; }
.inputs-section { margin-bottom: 12px; }
.inputs-section h3 { margin: 0 0 8px; font-size: 15px; color: var(--text); text-transform: capitalize; }
.field input.is-readonly { opacity:.8; cursor:not-allowed; }
.field input.is-clamped { border-color: #f0c674; }

.field select,
.field textarea {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #3a4d71;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 16px;
}

.madness-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}

.madness-toolbar .field {
  min-width: 220px;
}

.madness-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.5fr) minmax(280px, 1fr);
  gap: 16px;
}

.madness-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.madness-preview-table {
  min-width: 1200px;
}

.madness-preview-table td,
.madness-preview-table th {
  white-space: nowrap;
}

.madness-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.madness-chart-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.madness-chart-svg {
  width: 100%;
  height: 220px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border: 1px solid #2b3b56;
}

.madness-chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.madness-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.madness-chart-legend i {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.madness-config-table {
  min-width: 100%;
}

.madness-help-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
  border-radius: 999px;
  font-weight: 700;
}

.madness-help-button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: min(320px, 60vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: #081327;
  border: 1px solid #3a4d71;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
  z-index: 20;
}

.madness-help-button[data-tooltip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #081327;
  border-right: 1px solid #3a4d71;
  border-bottom: 1px solid #3a4d71;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
  z-index: 19;
}

.madness-help-button[data-tooltip]:hover::after,
.madness-help-button[data-tooltip]:hover::before,
.madness-help-button[data-tooltip]:focus-visible::after,
.madness-help-button[data-tooltip]:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

.madness-help-button--inline {
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  margin-left: 6px;
  font-size: 12px;
  line-height: 1;
}

.madness-field-label {
  display: inline-flex;
  align-items: center;
}

.madness-config-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

@media (max-width: 1100px) {
  .madness-grid {
    grid-template-columns: 1fr;
  }
}


.view-toggle { display:flex; gap:8px; margin-bottom:10px; }
.view-toggle .is-active { background: var(--accent); color: #081327; border-color: var(--accent); }
.level-toggle {
  margin-bottom: 14px;
}
.chart-metric-toggle {
  margin-bottom: 0;
}
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.field-actions { display:flex; align-items:center; gap:6px; margin-left:auto; }
.badge-modified { font-size:11px; color:#081327; background:#f0c674; border-radius:999px; padding:2px 6px; }
.field-reset { padding:2px 7px; font-size:12px; }
tr.is-selected { background: rgba(98, 164, 255, 0.16); }
.tower-roles-block {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  padding: 14px;
  border: 1px solid #2b3b56;
  border-radius: 12px;
  background: rgba(12, 20, 34, 0.85);
}
.tower-roles-block__title {
  grid-column: 1 / -1;
  font-size: 15px;
  font-weight: 700;
  color: #dce8ff;
}
.tower-role-flag {
  min-width: 0;
}
.tower-role-flag__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #3a4d71;
  border-radius: 10px;
  background: var(--panel-2);
}
.tower-role-flag__toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: #7aa2f7;
}
.tower-role-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 220px;
}
.tower-role-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(80, 133, 224, 0.18);
  border: 1px solid rgba(122, 162, 247, 0.35);
  color: #dce8ff;
  font-size: 12px;
  line-height: 1.3;
}


.editor-row { display:flex; gap:12px; margin-bottom:12px; flex-wrap:wrap; }
.compact-field { min-width: 180px; }
.field select { background: var(--panel-2); color: var(--text); border:1px solid #3a4d71; border-radius:10px; padding:8px 10px; font-size: 16px; }
summary { cursor: pointer; margin-bottom: 12px; font-size: 16px; }
.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 2px;
}
.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #7aa2f7;
}
.validation-actions {
  align-items: center;
  margin-top: 12px;
}
.validation-results {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.validation-summary-card {
  border: 1px solid #2b3b56;
  border-radius: 12px;
  padding: 14px;
  background: rgba(12, 20, 34, 0.9);
}
.validation-summary-card h3,
.validation-summary-card h4 {
  margin: 0 0 10px;
}
.validation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}
.validation-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.validation-metric {
  padding: 10px;
  border: 1px solid #324669;
  border-radius: 10px;
  background: #121d2f;
}
.validation-metric-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.validation-metric-value {
  font-size: 15px;
  line-height: 1.4;
  word-break: break-word;
}
.validation-breakdown {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.validation-breakdown-card {
  padding: 12px;
  border: 1px solid #324669;
  border-radius: 10px;
  background: #121d2f;
}


.curve-canvas-wrap {
  height: 450px;
}

.balance-cost-chart-wrap {
  height: 360px;
}

#curveCanvas {
  width: 100% !important;
  height: 100% !important;
}

#costEfficiencyChart {
  width: 100% !important;
  height: 100% !important;
}

.wave-editor-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wave-editor-wave {
  border: 1px solid #2b3b56;
  border-radius: 10px;
  padding: 10px;
  background: #0f1726;
}

.wave-editor-wave > summary {
  margin: 0;
  font-weight: 600;
}

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

.wave-editor-wave-header button {
  margin-left: auto;
}

.wave-spawns-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 10px 0;
}

.wave-spawn-lane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wave-spawn-groups {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.wave-spawn-card {
  border: 1px solid #324669;
  border-radius: 10px;
  padding: 10px;
  background: #121d2f;
}

.wave-spawn-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.wave-slider-row {
  display: grid;
  grid-template-columns: 60px 1fr 48px;
  align-items: center;
  gap: 8px;
}

.wave-slider-row input[type="range"] {
  width: 100%;
}

.wave-slider-value {
  text-align: right;
  color: #d6e2ff;
}

.wave-spawn-empty {
  border: 1px dashed #324669;
  border-radius: 10px;
  padding: 12px;
  background: #0f1726;
}

.wave-add-enemy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wave-add-enemy-btn {
  align-self: flex-start;
}

#runSimulationBtn {
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 700;
  border-color: #6ea8ff;
  box-shadow: 0 0 0 1px rgba(110, 168, 255, 0.18), 0 8px 24px rgba(37, 99, 235, 0.18);
}

.wave-add-enemy-menu {
  display: none;
  border: 1px solid #324669;
  border-radius: 10px;
  padding: 10px;
  background: #121d2f;
}

.wave-add-enemy-menu.is-open {
  display: block;
}

.wave-add-enemy-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wave-add-enemy-group + .wave-add-enemy-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #2b3b56;
}

.wave-add-enemy-group-title {
  font-size: 12px;
  color: #9fb4da;
}

.levels-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.levels-table th,
.levels-table td {
  vertical-align: middle;
}

.levels-table td[data-level-select-zone] {
  cursor: pointer;
}

.levels-actions-col {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
}

.levels-server-row-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #3a4d71;
  background: #121d2f;
  color: #c7dbff;
  font-size: 12px;
  white-space: nowrap;
}

.levels-server-row-chip.is-active {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
  color: #d8ffe7;
}

.levels-server-row-chip.is-failed {
  border-color: rgba(255, 127, 127, 0.48);
  background: rgba(255, 127, 127, 0.12);
  color: #ffd0d0;
}

.levels-run-control {
  min-width: 188px;
  min-height: 34px;
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.levels-run-control.is-running {
  gap: 8px;
}

.levels-run-btn {
  min-width: 188px;
  white-space: nowrap;
}

.levels-run-btn-compact {
  min-width: 96px;
  padding-left: 10px;
  padding-right: 10px;
}

.levels-open-link {
  border: 0;
  background: transparent;
  color: #8fc1ff;
  padding: 0;
  text-decoration: underline;
}

.levels-icon-badge,
.levels-enemy-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid #3a4d71;
  background: #121d2f;
  margin-right: 6px;
}

.levels-enemy-badge {
  gap: 4px;
  padding: 0 8px;
}

.levels-enemy-count {
  font-size: 11px;
  color: #c7dbff;
}

.levels-empty {
  color: #8fa3c8;
  font-style: italic;
}

.levels-charge {
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
}

.levels-charge-stick {
  width: 12px;
  height: 16px;
  border-radius: 999px;
}

.levels-charge-stick--1 {
  background: #ef4444;
}

.levels-charge-stick--2 {
  background: #f97316;
}

.levels-charge-stick--3 {
  background: #facc15;
}

.levels-charge-stick--4 {
  background: #a3e635;
}

.levels-charge-stick--5 {
  background: #22c55e;
}

.levels-expand-row > td {
  background: #0d1626;
}

.levels-expand-card {
  border: 1px solid #2b3b56;
  border-radius: 14px;
  background: #121d2f;
  padding: 12px;
}

.levels-expand-controls {
  display: grid;
  gap: 10px;
}

.levels-expand-controls-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.levels-expand-controls-row--actions {
  align-items: center;
}

.levels-expand-controls-row--actions button {
  min-height: 36px;
}

.levels-autotune-flag-field {
  min-width: 170px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.levels-autotune-flag-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.levels-autotune-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: #9fb4da;
}

.levels-autotune-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #64748b;
}

.levels-autotune-indicator.is-running .levels-autotune-indicator-dot {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.8);
  animation: levels-autotune-pulse 1.2s ease-out infinite;
}

.levels-server-jobs {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(96, 165, 250, 0.18);
}

.levels-server-jobs-title {
  font-size: 13px;
  font-weight: 700;
  color: #dce8ff;
}

.levels-server-jobs-table {
  min-width: 760px;
}

.levels-server-jobs-table th,
.levels-server-jobs-table td {
  padding: 6px 8px;
  font-size: 12px;
}

.levels-server-jobs-table tr.is-current-level td {
  background: rgba(98, 164, 255, 0.08);
}

.levels-server-job-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #3a4d71;
  background: #121d2f;
  color: #c7dbff;
  white-space: nowrap;
}

.levels-server-job-pill.is-active {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
  color: #d8ffe7;
}

.levels-server-job-pill.is-failed {
  border-color: rgba(255, 127, 127, 0.48);
  background: rgba(255, 127, 127, 0.12);
  color: #ffd0d0;
}

@keyframes levels-autotune-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.levels-expand-summary {
  margin-top: 10px;
  display: grid;
  gap: 4px;
}

.levels-autotune-diagnostics {
  margin-top: 10px;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(96, 165, 250, 0.18);
  font-size: 13px;
}

.levels-autotune-history-wrap {
  margin-top: 12px;
}

.levels-autotune-history {
  min-width: 620px;
}

.autotune-diagnostics {
  margin-top: 12px;
}

.autotune-diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.autotune-diagnostics-grid > div {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(96, 165, 250, 0.18);
}

.autotune-diagnostics-note {
  margin-top: 8px;
  font-size: 13px;
  color: #c7dbff;
}

.autotune-diagnostics-note--warning {
  color: #fbbf24;
}

.autotune-wave-diagnostics-wrap {
  margin-top: 12px;
}

.levels-run-progress {
  width: 132px;
  height: 16px;
  border-radius: 999px;
  background: #1f2a3d;
  overflow: hidden;
}

.levels-run-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width 120ms linear;
}

.levels-run-progress-text {
  min-width: 42px;
  font-size: 12px;
  color: #c7dbff;
  text-align: right;
}

.wave-add-enemy-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.wave-add-enemy-option {
  font-size: 12px;
  padding: 6px 8px;
}

.wave-add-enemy-empty {
  font-size: 12px;
}


.wave-crystal-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.wave-crystal-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
}


.wave-editor-actions {
  margin-top: 14px;
}

.wave-level-meta {
  margin-bottom: 10px;
}

.wave-editor-preset-actions {
  align-items: end;
}

.wave-add-enemy-flags {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

.wave-add-enemy-flag {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.wave-add-enemy-flag input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.wave-add-enemy-rules-note {
  margin: 0 0 10px;
}

.wave-editor-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wave-editor-tab {
  min-width: 64px;
}

.wave-editor-tab.is-active {
  background: var(--accent);
  color: #081327;
  border-color: var(--accent);
}

.wave-editor-tab-run-sim {
  min-width: 160px;
}

.wave-editor-tab-run-sim.is-hidden {
  display: none;
}

.wave-editor-sim-progress {
  display: none;
  align-self: center;
  width: 100px;
}

.wave-editor-sim-progress.is-visible {
  display: block;
}

.wave-editor-sim-progress__bar {
  height: 10px;
  border-radius: 999px;
  border: 1px solid #3a4d71;
  background: rgba(15, 23, 42, 0.95);
  overflow: hidden;
}

.wave-editor-sim-progress__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #60a5fa, #22c55e);
}

.wave-manual-timeline {
  margin: 14px 0 18px;
  padding: 14px;
  border: 1px solid #334155;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
}

.wave-manual-timeline-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.wave-manual-timeline-title {
  font-weight: 700;
}

.wave-manual-timeline-actions,
.wave-timeline-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.wave-manual-timeline-badge {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
}

.wave-timeline-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.wave-timeline-track {
  position: relative;
  min-height: 96px;
  border: 1px solid #334155;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(2, 6, 23, 0.9)),
    repeating-linear-gradient(
      90deg,
      rgba(148, 163, 184, 0.1) 0,
      rgba(148, 163, 184, 0.1) 1px,
      transparent 1px,
      transparent 24px
    );
}

.wave-timeline-grid {
  position: absolute;
  inset: 0;
}

.wave-timeline-tick {
  position: absolute;
  inset-block: 0;
  width: 1px;
  background: rgba(148, 163, 184, 0.2);
}

.wave-timeline-tick span {
  position: absolute;
  top: 6px;
  left: 4px;
  color: #94a3b8;
  font-size: 11px;
}

.wave-timeline-bar {
  position: absolute;
  top: 38px;
  height: 34px;
  border: 1px solid rgba(34, 197, 94, 0.55);
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.28), rgba(59, 130, 246, 0.32));
  color: #e2e8f0;
  padding: 0 24px 0 10px;
  text-align: left;
  cursor: grab;
  overflow: hidden;
  white-space: nowrap;
}

.wave-timeline-bar.is-selected {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.22);
}

.wave-timeline-bar:active {
  cursor: grabbing;
}

.wave-timeline-bar-label {
  display: block;
  line-height: 32px;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wave-timeline-bar-handle {
  position: absolute;
  right: 0;
  width: 12px;
  cursor: ew-resize;
  background: rgba(248, 250, 252, 0.18);
}

.wave-timeline-bar-handle--count {
  top: 0;
  height: 50%;
  background: rgba(239, 68, 68, 0.45);
  border-top-right-radius: 10px;
}

.wave-timeline-bar-handle--interval {
  bottom: 0;
  height: 50%;
  background: rgba(248, 250, 252, 0.18);
  border-bottom-right-radius: 10px;
}

.wave-timeline-shield-field {
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.wave-groups-override-note {
  margin-bottom: 12px;
}

.wave-pattern-library {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wave-pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.wave-pattern-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
}

.wave-pattern-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.wave-pattern-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.wave-pattern-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
}

.wave-pattern-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #cbd5e1;
  font-size: 12px;
}

.wave-pattern-timeline {
  position: relative;
  min-height: 118px;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.85), rgba(15, 23, 42, 0.92)),
    repeating-linear-gradient(
      90deg,
      rgba(148, 163, 184, 0.14) 0,
      rgba(148, 163, 184, 0.14) 1px,
      transparent 1px,
      transparent 20%
    );
}

.wave-pattern-bar {
  position: absolute;
  min-width: 56px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(226, 232, 240, 0.28);
  border-radius: 999px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  line-height: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wave-pattern-bar--tank {
  top: 18px;
  background: rgba(245, 158, 11, 0.42);
}

.wave-pattern-bar--normal {
  top: 48px;
  background: rgba(34, 197, 94, 0.38);
}

.wave-pattern-bar--fast {
  top: 78px;
  background: rgba(56, 189, 248, 0.38);
}

.wave-pattern-bar--healer {
  top: 78px;
  background: rgba(168, 85, 247, 0.42);
}

@media (max-width: 1200px) {
  .wave-spawn-groups,
  .wave-add-enemy-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wave-pattern-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .wave-spawn-groups,
  .wave-add-enemy-options {
    grid-template-columns: 1fr;
  }

  .wave-pattern-grid {
    grid-template-columns: 1fr;
  }
}

.sim-progress {
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sim-progress-bar {
  width: 100%;
  height: 10px;
  border: 1px solid #334155;
  border-radius: 999px;
  background: #0f172a;
  overflow: hidden;
}

.sim-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308 65%, #ef4444);
  transition: width 120ms linear;
}


.auto-tune-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auto-tune-flag-field {
  justify-content: space-between;
}

.auto-tune-flag-field input[type="checkbox"] {
  width: auto;
  align-self: flex-start;
  margin-top: 4px;
}

.auto-tune-result-message {
  min-height: 20px;
  margin: 8px 0 4px;
}

.auto-tune-result-message.is-warning {
  color: #fbbf24;
}

.auto-tune-running-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.auto-tune-running-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #64748b;
}

.auto-tune-running-indicator.is-running {
  border-color: #0ea5e9;
  background: rgba(14, 165, 233, 0.12);
  color: #7dd3fc;
}

.auto-tune-running-indicator.is-running::before {
  background: #22d3ee;
  box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.18);
  animation: auto-tune-pulse 1s ease-in-out infinite;
}

@keyframes auto-tune-pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}
