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

body {
  margin: 0;
  overflow: hidden;
  background: #0d1117;
  color: #e6edf3;
  font-family: system-ui, -apple-system, sans-serif;
}

#field-canvas {
  display: block;
  border: 1px solid #30363d;
}

#control-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100vh;
  background: #161b22;
  padding: 16px;
  overflow-y: auto;
  border-left: 1px solid #30363d;
}

#energy-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 280px;
  height: 0;
  padding: 0 20px;
  overflow: hidden;
  background: #161b22;
  border-top: 1px solid #30363d;
  transition: height 0.3s ease, padding 0.3s ease;
}

#energy-drawer.open {
  height: 220px;
  padding: 12px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

#pause-indicator {
  position: fixed;
  top: 8px;
  left: 64px;
  background: #f0883e;
  color: #0d1117;
  padding: 4px 10px;
  border-radius: 4px;
  font: bold 12px 'Courier New', monospace;
  letter-spacing: 0.08em;
  z-index: 50;
}

button {
  background: transparent;
  border: 1px solid #58a6ff;
  color: #58a6ff;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

button:hover {
  background: #58a6ff22;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

input[type="range"] {
  accent-color: #58a6ff;
  width: calc(100% - 64px);
  vertical-align: middle;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0;
}

.step-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 16px;
  font-weight: bold;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#help-overlay {
  position: fixed;
  inset: 0;
  background: #000000cc;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

#help-overlay.visible {
  display: flex;
}

.help-content {
  max-width: 600px;
  width: 90%;
  background: #161b22;
  border-radius: 12px;
  padding: 32px;
  color: #e6edf3;
  max-height: 80vh;
  overflow-y: auto;
}

/* ── Control panel components ─────────────────────────────── */

.section-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b949e;
  padding-bottom: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid #30363d;
}

.slider-value {
  min-width: 52px;
  text-align: right;
  color: #58a6ff;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  flex-shrink: 0;
}

.shortcut-table {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 3px 8px;
  font-size: 11px;
  margin: 4px 0 0;
}

.shortcut-table dt {
  color: #e6edf3;
  font-family: 'Courier New', monospace;
  font-weight: bold;
}

.shortcut-table dd {
  color: #8b949e;
  margin: 0;
}

/* ── Help overlay ─────────────────────────────────────────── */

.help-section {
  color: #58a6ff;
  font-size: 14px;
  margin: 18px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #30363d;
}

.help-content p {
  font-size: 14px;
  line-height: 1.65;
  color: #c9d1d9;
  margin: 6px 0;
}

.help-content dl.shortcut-table {
  grid-template-columns: 120px 1fr;
  margin: 8px 0;
  font-size: 13px;
}

.help-content dl.shortcut-table dt { color: #e6edf3; }
.help-content dl.shortcut-table dd { color: #8b949e; }

/* ── Fullscreen ───────────────────────────────────────────── */

:fullscreen body,
:-webkit-full-screen body {
  background: #0d1117;
  display: flex;
  align-items: center;
  justify-content: center;
}

:fullscreen #control-panel,
:-webkit-full-screen #control-panel,
:fullscreen #energy-drawer,
:-webkit-full-screen #energy-drawer {
  display: none !important;
}

:fullscreen #field-canvas,
:-webkit-full-screen #field-canvas {
  position: absolute;
  inset: 0;
  margin: auto;
  width:  min(100vw, calc(100vh * 1.5));
  height: min(100vh, calc(100vw / 1.5));
  border: none;
}
