.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.9fr);
  gap: 1.1rem;
  align-items: start;
}

.stage-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(180deg, rgba(8, 24, 36, 0.9), rgba(6, 18, 28, 0.95));
  box-shadow: var(--shadow);
  overflow: hidden;
}

#bondCanvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  touch-action: manipulation;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pulse-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  animation: pulseOut 0.7s ease-out forwards;
}

@keyframes pulseOut {
  to {
    transform: scale(18);
    opacity: 0;
  }
}

.hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.panel {
  display: grid;
  gap: 1rem;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.meter-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.energy-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.energy-readout .label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.energy-readout strong {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-variant-numeric: tabular-nums;
}

.energy-readout .unit {
  margin-left: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.progress-wrap {
  margin-bottom: 1rem;
}

.progress-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--amber));
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 18px rgba(240, 180, 41, 0.35);
}

.progress-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.55);
  transform: translateX(-1px);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.actions {
  display: grid;
  gap: 0.55rem;
}

.legend-card h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.legend-list li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.legend-list li:hover,
.legend-list li.active {
  border-color: rgba(53, 208, 197, 0.4);
  background: rgba(53, 208, 197, 0.08);
}

.legend-list li.broken {
  opacity: 0.55;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.legend-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.legend-meta strong {
  font-size: 0.9rem;
}

.legend-meta span {
  color: var(--muted);
  font-size: 0.72rem;
}

.legend-energy {
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  font-size: 0.82rem;
  font-weight: 600;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    order: 2;
  }

  .stage {
    order: 1;
  }
}

@media (max-width: 560px) {
  .energy-readout {
    grid-template-columns: 1fr;
  }

  .meter-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
