:root {
  color-scheme: dark;
  --panel: rgba(12, 16, 24, 0.84);
  --line: rgba(255, 255, 255, 0.14);
  --text: #edf3ff;
  --muted: #9aa8bd;
  --accent: #61e8ff;
  --button: rgba(255, 255, 255, 0.09);
  --button-hover: rgba(255, 255, 255, 0.16);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020308;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.world-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  background: radial-gradient(circle at 50% 45%, #0b1020 0%, #03040a 55%, #000 100%);
}

.world-canvas.is-active { display: block; }

.panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  transition: opacity 160ms ease, transform 180ms ease;
}


.panel.is-hidden {
  opacity: 0;
  transform: translateX(calc(100% + 24px));
  pointer-events: none;
}

.top-actions {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 4;
  display: flex;
  gap: 8px;
}

.panel-toggle, .fullscreen-toggle {
  min-width: 96px;
  background: rgba(12, 16, 24, 0.76);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}

.panel-toggle.is-panel-hidden, .fullscreen-toggle.is-fullscreen {
  border-color: rgba(97, 232, 255, 0.5);
  background: rgba(97, 232, 255, 0.18);
}
.panel-header, .matrix-head, .buttons, .modebar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 22px;
  line-height: 1.1;
  font-weight: 760;
}

h2 {
  font-size: 13px;
  line-height: 1.2;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}

#stats {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}

button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--button);
  color: var(--text);
  min-height: 36px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

button:hover { background: var(--button-hover); }
button:active { transform: translateY(1px); }

.modebar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.mode-btn {
  min-width: 0;
  min-height: 32px;
  padding: 0 6px;
  border-color: transparent;
  background: transparent;
  font-size: 12px;
  white-space: nowrap;
}

.mode-btn.is-active {
  border-color: rgba(97, 232, 255, 0.42);
  background: rgba(97, 232, 255, 0.16);
  color: #f6fdff;
}

.control-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 10px;
  font-size: 13px;
  color: var(--muted);
}

output {
  min-width: 56px;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

.buttons {
  flex-wrap: wrap;
  margin: 16px 0;
}

.buttons button { flex: 1 1 130px; }

.nav3d {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-bottom: 14px;
}

.nav3d-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.nav3d label + label { margin-top: 12px; }
.worlds {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-bottom: 14px;
}

.worlds-head, .world-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.worlds-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

#worldName, #worldSelect {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
}

#worldName { margin-bottom: 8px; }
#worldSelect { min-width: 0; flex: 1 1 auto; }
.world-row button { flex: 0 0 auto; }
.matrix {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.matrix-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

#matrixGrid {
  display: grid;
  grid-template-columns: repeat(var(--species), minmax(28px, 1fr));
  gap: 5px;
}

.cell {
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  min-width: 0;
}

@media (max-width: 720px) {
  .panel {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    max-height: 48vh;
    padding: 12px;
  }

  h1 { font-size: 19px; }
  button { min-height: 34px; }
  .top-actions {
    top: 10px;
    left: 10px;
  }

  .panel-toggle, .fullscreen-toggle {
    min-width: 88px;
  }

  .panel.is-hidden {
    transform: translateY(calc(100% + 20px));
  }

  .mode-btn { font-size: 11px; }
}









