/* ── Layout Reset ─────────────────────────────────────────────────────────── */

.site-header,
.site-footer {
  display: none !important;
}

main.container {
  position: fixed !important;
  inset: 0 !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

html,
body {
  overflow: hidden;
  background: #0a0a0f;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Canvas ───────────────────────────────────────────────────────────────── */

#canvas {
  position: fixed;
  inset: 0;
  display: block;
  z-index: 0;
  cursor: crosshair;
}

/* ── Top Bar ──────────────────────────────────────────────────────────────── */

#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: 48px;
  background: rgba(8, 8, 20, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(127, 119, 221, 0.18);
}

.top-left {
  flex: 0 0 auto;
  min-width: 150px;
}

.app-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #7F77DD;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
}

/* ── Mode Tabs ────────────────────────────────────────────────────────────── */

.mode-tabs {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.mode-tabs::-webkit-scrollbar {
  display: none;
}

.mode-btn {
  padding: 4px 11px;
  border-radius: 5px;
  font-size: 0.76rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.mode-btn:hover {
  background: rgba(127, 119, 221, 0.12);
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(127, 119, 221, 0.3);
}

.mode-btn.active {
  background: rgba(127, 119, 221, 0.22);
  color: #c0bcf5;
  border-color: rgba(127, 119, 221, 0.55);
  box-shadow: 0 0 12px rgba(127, 119, 221, 0.3);
}

/* ── Top-right info ───────────────────────────────────────────────────────── */

.top-right {
  flex: 0 0 auto;
  min-width: 150px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
}

.mono {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.73rem;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}

#fps-display {
  color: rgba(100, 220, 120, 0.7);
}

#consumed-display {
  color: rgba(190, 170, 255, 0.7);
}

#seed-display {
  opacity: 0.4;
}

/* ── Bottom Panel ─────────────────────────────────────────────────────────── */

#bottom-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(8, 8, 20, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(127, 119, 221, 0.18);
}

#panel-toggle {
  display: block;
  width: 100%;
  padding: 4px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.65rem;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s;
  font-family: inherit;
}

#panel-toggle:hover {
  color: rgba(127, 119, 221, 0.9);
}

#panel-content {
  overflow: hidden;
  max-height: 260px;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease;
  opacity: 1;
}

#panel-content.collapsed {
  max-height: 0;
  opacity: 0;
}

/* ── Control Rows ─────────────────────────────────────────────────────────── */

.ctrl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  align-items: center;
  padding: 0.45rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ctrl-row:last-child {
  border-bottom: none;
}

.ctrl-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  cursor: default;
  font-family: inherit;
}

.ctrl-item > span:first-child {
  min-width: 66px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 0.72rem;
}

.ctrl-val {
  min-width: 36px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.72rem;
  color: rgba(127, 119, 221, 0.9);
}

/* ── Sliders ──────────────────────────────────────────────────────────────── */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 108px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #7F77DD;
  box-shadow: 0 0 7px rgba(127, 119, 221, 0.65);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: #7F77DD;
  box-shadow: 0 0 7px rgba(127, 119, 221, 0.65);
  cursor: pointer;
}

/* ── Selects ──────────────────────────────────────────────────────────────── */

select {
  background: rgba(16, 16, 32, 0.95);
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(127, 119, 221, 0.22);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

select:focus,
select:hover {
  border-color: rgba(127, 119, 221, 0.55);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.ctrl-btn,
.toggle-btn {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.58);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.ctrl-btn:hover,
.toggle-btn:hover {
  background: rgba(127, 119, 221, 0.15);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(127, 119, 221, 0.4);
}

.ctrl-btn.active,
.toggle-btn.active {
  background: rgba(127, 119, 221, 0.22);
  color: #c0bcf5;
  border-color: rgba(127, 119, 221, 0.5);
}

.btn-group {
  display: flex;
}

.btn-group .toggle-btn {
  border-radius: 0;
}

.btn-group .toggle-btn:first-child {
  border-radius: 4px 0 0 4px;
}

.btn-group .toggle-btn:last-child {
  border-radius: 0 4px 4px 0;
  border-left: none;
}

/* ── Help Overlay ─────────────────────────────────────────────────────────── */

#help-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#help-overlay.hidden {
  display: none;
}

#help-content {
  background: rgba(11, 11, 26, 0.97);
  border: 1px solid rgba(127, 119, 221, 0.28);
  border-radius: 10px;
  padding: 1.5rem 2rem;
  max-width: 500px;
  width: 90%;
  max-height: 82vh;
  overflow-y: auto;
  color: rgba(255, 255, 255, 0.78);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 40px rgba(127, 119, 221, 0.08);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.help-header h2 {
  margin: 0;
  font-size: 1rem;
  color: #c0bcf5;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.close-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(127, 119, 221, 0.5);
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
  margin-bottom: 0.8rem;
}

.shortcut-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.65);
}

.shortcut-table .key {
  font-family: 'Courier New', Courier, monospace;
  color: #9B96E8;
  white-space: nowrap;
  width: 72px;
}

.help-section h3 {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.38);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.9rem 0 0.3rem;
}

.help-section p,
.help-section li {
  font-size: 0.81rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 0.2rem 0;
  line-height: 1.5;
}

.help-section ul {
  margin: 0;
  padding-left: 1.1rem;
}

.help-section strong {
  color: #c0bcf5;
}

/* ── Explode Flash Ring ────────────────────────────────────────────────────── */

#flash-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.flash-ring {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform-origin: center;
  animation: flash-expand 0.7s ease-out forwards;
}

@keyframes flash-expand {
  0% {
    transform: scale(0.4);
    opacity: 1;
    border-color: #ffffff;
    box-shadow: 0 0 18px #ffffff;
  }
  35% {
    border-color: #c0bcf5;
    box-shadow: 0 0 28px rgba(127, 119, 221, 0.8);
  }
  100% {
    transform: scale(22);
    opacity: 0;
    border-color: #7F77DD;
  }
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(127, 119, 221, 0.92);
  color: #fff;
  padding: 7px 18px;
  border-radius: 20px;
  font-size: 0.81rem;
  font-family: inherit;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-title {
    display: none;
  }

  .top-left {
    min-width: 0;
  }

  .top-right {
    min-width: 0;
    gap: 0.35rem;
  }

  .mode-btn {
    padding: 3px 7px;
    font-size: 0.68rem;
  }

  input[type="range"] {
    width: 78px;
  }

  .ctrl-row {
    gap: 0.3rem 0.6rem;
    padding: 0.35rem 0.7rem;
  }

  #help-content {
    padding: 1.1rem 1.3rem;
  }
}
