*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #07070c;
  --surface: rgba(18, 18, 28, 0.75);
  --border: rgba(80, 120, 180, 0.2);
  --text: #c8d0e0;
  --text-dim: #6a7490;
  --accent: #3eaadd;
  --accent-glow: rgba(62, 170, 221, 0.3);
  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 300;
}

#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  border-radius: 8px;
  cursor: crosshair;
  position: relative;
  z-index: 1;
}

#canvas-glow {
  position: absolute;
  pointer-events: none;
  border-radius: 12px;
  z-index: 0;
  box-shadow: 
    0 0 60px 10px rgba(30, 90, 140, 0.15),
    0 0 120px 30px rgba(20, 60, 110, 0.08),
    inset 0 0 40px rgba(30, 90, 140, 0.05);
}

/* Top Bar */
#top-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.top-left, .top-center, .top-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.ctrl-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.speed-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.fps {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  min-width: 52px;
  text-align: right;
}

/* Sliders */
.slider-accent {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  outline: none;
  cursor: pointer;
}

.slider-accent::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(0,0,0,0.3);
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-glow);
}

.slider-accent::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(0,0,0,0.3);
  cursor: pointer;
}

#slider-dt-top {
  width: 90px;
}

/* Panels */
.panel {
  position: absolute;
  z-index: 20;
  padding: 18px 20px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  width: 300px;
  animation: panelIn 0.2s ease-out;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel.hidden {
  display: none;
}

#param-panel {
  top: 62px;
  right: 12px;
}

#info-panel {
  top: 62px;
  right: 12px;
}

.panel h3 {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.param-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.param-row label {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 110px;
  flex-shrink: 0;
}

.param-row .slider-accent {
  flex: 1;
  min-width: 60px;
}

.param-val {
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 42px;
  text-align: right;
  color: var(--text);
}

.select-box {
  flex: 1;
  padding: 5px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.select-box:focus {
  border-color: var(--accent);
}

.select-box option {
  background: #14141e;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.panel p {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 10px;
  color: var(--text);
}

.info-link a {
  color: var(--accent);
  text-decoration: none;
}

.info-link a:hover {
  text-decoration: underline;
}

.info-controls {
  font-size: 12px !important;
  color: var(--text-dim) !important;
}

/* Tooltip */
#cell-tooltip {
  position: absolute;
  z-index: 30;
  background: rgba(10,10,20,0.9);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  pointer-events: none;
}

#cell-tooltip.hidden {
  display: none;
}

/* Footer */
#footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-dim);
}

#footer a {
  color: var(--accent);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s;
}

#footer a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Mobile */
@media (max-width: 600px) {
  #top-bar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
  }
  .top-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .panel {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
  }
  .ctrl-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}