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

:root {
  --bg: #111827;
  --surface: #1f2937;
  --surface-2: #374151;
  --surface-3: #111827;
  --border: #4b5563;
  --text: #f9fafb;
  --text-muted: #a7b0bf;
  --orange: #f97316;
  --orange-light: #fb923c;
  --red: #ef4444;
  --yellow: #facc15;
  --cyan: #22d3ee;
  --green: #22c55e;
  --violet: #8b5cf6;
}

html,
body {
  height: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.back-bar {
  height: 42px;
  padding: 0.6rem 1.5rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--text);
}

.simulator {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: calc(100vh - 42px);
}

.control-panel {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  padding: 1.1rem;
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  border-right: 1px solid var(--border);
  box-shadow: 12px 0 30px rgba(0, 0, 0, 0.28);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--orange-light);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1.15;
}

.reset-button {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
}

.reset-button:hover {
  color: var(--text);
  border-color: var(--orange-light);
}

.control-group,
.target-box,
.summary-panel {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgba(31, 41, 55, 0.78);
  padding: 1rem;
}

.summary-panel[hidden],
.legend[hidden] {
  display: none;
}

.group-label {
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.material-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.material-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--surface-3);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.material-card:hover,
.material-card.is-active {
  border-color: var(--orange-light);
  color: var(--text);
  background: rgba(249, 115, 22, 0.12);
}

.material-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
}

.material-dot--iron {
  background: #cbd5e1;
}

.material-dot--stone {
  background: #a16207;
}

.material-dot--ice {
  background: #67e8f9;
}

.slider-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.slider-label strong {
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 0.85rem 0 0.45rem;
  accent-color: var(--orange);
}

.scale-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.target-box {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.08);
}

.target-label {
  margin-bottom: 0.35rem;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.target-value {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.launch-button {
  min-height: 52px;
  border: none;
  border-radius: 0.7rem;
  background: linear-gradient(135deg, var(--orange), var(--red));
  color: white;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 28px rgba(239, 68, 68, 0.28);
}

.launch-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.launch-button:not(:disabled):hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.summary-title {
  margin-bottom: 0.8rem;
  color: var(--orange-light);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-hero {
  margin-bottom: 0.85rem;
  border: 1px solid rgba(249, 115, 22, 0.38);
  border-radius: 0.65rem;
  padding: 0.85rem;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.16), rgba(239, 68, 68, 0.08));
}

.result-kicker {
  margin-bottom: 0.35rem;
  color: var(--orange-light);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-headline {
  color: var(--text);
  font-size: 1.28rem;
  font-weight: 900;
  line-height: 1.12;
}

.result-subline {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.summary-stat {
  min-height: 70px;
  border: 1px solid rgba(75, 85, 99, 0.75);
  border-radius: 0.6rem;
  padding: 0.75rem;
  background: rgba(17, 24, 39, 0.78);
}

.summary-stat span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.summary-stat strong {
  display: block;
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.effect-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.85rem;
}

.effect-card {
  border: 1px solid rgba(75, 85, 99, 0.78);
  border-radius: 0.7rem;
  overflow: hidden;
  background: rgba(17, 24, 39, 0.78);
}

.effect-card__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.78rem 0.85rem;
  border-bottom: 1px solid rgba(75, 85, 99, 0.62);
}

.effect-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: 0 0 34px;
  background: rgba(249, 115, 22, 0.15);
  color: var(--orange-light);
  font-size: 1.05rem;
}

.effect-title {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 900;
}

.effect-radius {
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.effect-body {
  padding: 0.82rem 0.85rem 0.9rem;
}

.effect-main {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
}

.effect-desc {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.48;
}

.effect-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.effect-metric {
  border: 1px solid rgba(75, 85, 99, 0.62);
  border-radius: 0.5rem;
  padding: 0.55rem;
  background: rgba(31, 41, 55, 0.52);
}

.effect-metric span {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--text-muted);
  font-size: 0.61rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.effect-metric strong {
  color: var(--text);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.map-shell {
  position: relative;
  min-width: 0;
  background: #0b1220;
}

#map {
  width: 100%;
  height: 100%;
  background: #111827;
  z-index: 1;
}

.leaflet-container {
  background: #111827 !important;
  font-family: inherit;
}

.leaflet-tile-pane {
  filter: brightness(0.68) saturate(0.55) hue-rotate(170deg);
}

.map-prompt,
.legend {
  position: absolute;
  z-index: 500;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: rgba(17, 24, 39, 0.9);
  color: var(--text);
  backdrop-filter: blur(8px);
}

.map-prompt {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65rem 1rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.legend {
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem 0.9rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: 0 0 11px;
}

.legend-swatch.crater {
  background: var(--red);
}

.legend-swatch.fireball {
  background: var(--orange);
}

.legend-swatch.blast {
  background: var(--yellow);
}

.legend-swatch.thermal {
  background: var(--cyan);
}

.impact-marker {
  width: 22px;
  height: 22px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.25), 0 0 24px rgba(239, 68, 68, 0.95);
}

.impact-flash {
  position: absolute;
  width: 160px;
  height: 160px;
  margin: -80px 0 0 -80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(251, 146, 60, 0.65) 28%, rgba(239, 68, 68, 0) 72%);
  pointer-events: none;
  animation: impact-flash 0.8s ease-out forwards;
}

@keyframes impact-flash {
  from {
    opacity: 1;
    transform: scale(0.2);
  }
  to {
    opacity: 0;
    transform: scale(2.8);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .simulator {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 42px);
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
  }

  .map-shell {
    height: 62vh;
    min-height: 460px;
  }
}

@media (max-width: 560px) {
  .back-bar {
    padding-inline: 1rem;
  }

  .control-panel {
    padding: 0.85rem;
  }

  .material-options,
  .summary-grid,
  .effect-metrics {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.35rem;
  }

  .map-prompt {
    width: calc(100% - 32px);
    text-align: center;
  }

  .legend {
    left: 16px;
    right: 16px;
  }
}
