* { box-sizing: border-box; }
/* El atributo hidden debe ganar a cualquier display definido en las clases. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #02030a;
  color: #e8ecf5;
  font-family: Consolas, "Cascadia Mono", Menlo, "Courier New", monospace;
  font-size: 13px;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  cursor: grab;
  touch-action: none;
}
#scene.dragging { cursor: grabbing; }

.glass {
  position: fixed;
  background: rgba(14, 18, 32, 0.62);
  border: 1px solid rgba(140, 160, 210, 0.18);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.muted { color: #94a0bb; }

#hud-top {
  top: 14px;
  left: 14px;
  padding: 12px 16px;
}
#hud-top h1 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
#date { font-size: 15px; font-variant-numeric: tabular-nums; }
#speed-label { margin-top: 2px; }

#panel {
  top: 14px;
  right: 14px;
  width: 262px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slider { display: flex; flex-direction: column; gap: 6px; }
.slider input { width: 100%; accent-color: #ffb547; }

.row { display: flex; gap: 8px; }
.row button { flex: 1; }

.checks { display: flex; flex-direction: column; gap: 6px; }
.checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checks input { accent-color: #ffb547; }

button {
  background: rgba(255, 255, 255, 0.07);
  color: inherit;
  border: 1px solid rgba(160, 180, 230, 0.22);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: rgba(255, 255, 255, 0.14); }
button.active {
  background: rgba(255, 181, 71, 0.22);
  border-color: rgba(255, 181, 71, 0.65);
}
.wide { width: 100%; }

select {
  background: rgba(255, 255, 255, 0.07);
  color: inherit;
  border: 1px solid rgba(160, 180, 230, 0.22);
  border-radius: 8px;
  padding: 7px 8px;
  font: inherit;
  cursor: pointer;
}
select option, select optgroup { background: #141a2c; color: #e8ecf5; }

#planet-bar {
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  bottom: 38px;
  padding: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 28px);
}
#planet-bar button { display: flex; align-items: center; gap: 6px; }
#planet-bar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

#info {
  left: 14px;
  top: 120px;
  width: 310px;
  padding: 14px 16px;
}
#info h2 { margin: 0 0 6px; font-size: 18px; }
#info p { margin: 0 0 10px; line-height: 1.45; color: #c5cde0; }
#info dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
}
#info dt { color: #94a0bb; }
#info dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
#info-close {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0 8px;
  font-size: 18px;
  line-height: 24px;
}

#help {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 10px;
  text-align: center;
  font-size: 12px;
  pointer-events: none;
}

/* ---------- Pestañas y laboratorio de impactos ---------- */
#panel { max-height: calc(100vh - 110px); overflow-y: auto; }
.tab { display: flex; flex-direction: column; gap: 12px; }
.tab[hidden] { display: none; }

.tabs, .seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 9px;
}
.tabs button, .seg button {
  flex: 1;
  padding: 6px 4px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 12px;
}
.tabs button.active, .seg button.active {
  background: rgba(255, 181, 71, 0.22);
  border-color: rgba(255, 181, 71, 0.6);
}
.seg { flex-wrap: wrap; }
.seg button { flex: 1 1 45%; }
.seg button[data-type="sn"], .seg button[data-type="evo"] { flex-basis: 45%; }
.estimate .fates { margin-top: 6px; font-size: 11.5px; color: #c9d1e3; line-height: 1.45; }
.estimate .fates b { color: #ffd28a; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 5px; }
.slider-head { display: flex; justify-content: space-between; gap: 8px; }
.slider-head output { color: #ffd28a; font-variant-numeric: tabular-nums; text-align: right; }

.estimate {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.5;
}
.estimate .row-kv { display: flex; justify-content: space-between; gap: 10px; }
.estimate .row-kv span:first-child { color: #94a0bb; }
.estimate .row-kv span:last-child { text-align: right; }
.estimate .verdict {
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.estimate .verdict small { display: block; font-weight: 400; color: #d6dcea; margin-top: 2px; }

button.primary {
  background: linear-gradient(180deg, rgba(255, 150, 60, 0.55), rgba(220, 80, 40, 0.55));
  border-color: rgba(255, 170, 90, 0.8);
  font-weight: 600;
}
button.primary:hover { background: linear-gradient(180deg, rgba(255, 170, 80, 0.7), rgba(235, 95, 50, 0.7)); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

#log {
  left: 14px;
  bottom: 96px;
  width: 370px;
  max-height: 34vh;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}
#log[hidden] { display: none; }
.log-head { display: flex; justify-content: space-between; align-items: center; }
.log-head h3 { margin: 0; font-size: 14px; }
.log-head button { padding: 0 8px; font-size: 16px; line-height: 22px; }
#log-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#log-list li { line-height: 1.4; font-size: 12px; color: #d3d9e8; }
#log-list li .t {
  display: inline-block;
  min-width: 64px;
  color: #ffd28a;
  font-variant-numeric: tabular-nums;
}
#log-list li.new { animation: flashIn 1.2s ease-out; }
@keyframes flashIn { from { background: rgba(255, 180, 80, 0.25); } to { background: transparent; } }

/* ---------- Sin JavaScript ---------- */
.noscript {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  padding: 40px max(24px, calc(50vw - 340px));
  background: #02030a;
  font-size: 15px;
  line-height: 1.6;
}
.noscript h1 { margin-top: 0; }
.noscript li { margin-bottom: 6px; }

/* ---------- Bienvenida ---------- */
.welcome-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center; /* en pantallas bajas no corta la parte superior */
  gap: 14px;
  padding: 16px;
  overflow-y: auto;
  background: rgba(2, 4, 12, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.4s ease-out;
}
.welcome-card {
  max-width: 560px;
  padding: 26px 28px 20px;
  background: rgba(14, 18, 32, 0.9);
  border: 1px solid rgba(140, 160, 210, 0.25);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  font-size: 14px;
  line-height: 1.6;
  color: #d3d9e8;
}
.welcome-card h2 { margin: 0; font-size: 22px; color: #f2f5fb; }
.welcome-sub { margin: 4px 0 16px; color: #ffd28a; font-size: 15px; }
.welcome-card p { margin: 0 0 12px; }
/* Aviso como texto suelto bajo la tarjeta, sin caja ni fondo. */
.welcome-disclaimer {
  max-width: 560px;
  margin: 0;
  padding: 0 6px;
  font-size: 12px;
  line-height: 1.55;
  color: #aab4ca;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.welcome-disclaimer strong { color: #ffd28a; }
.welcome-end { font-weight: 600; color: #f2f5fb; }
.welcome-card .row { margin-top: 18px; }
.welcome-card .row button { padding: 10px 12px; }
.welcome-hide { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; color: #94a0bb; cursor: pointer; }
.welcome-hide input { accent-color: #ffb547; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 720px) {
  #log { width: calc(100vw - 28px); bottom: 70px; max-height: 24vh; }
  #panel { width: 190px; font-size: 12px; }
  #info { top: auto; bottom: 120px; width: calc(100vw - 28px); }
  #help { display: none; }
  #planet-bar { bottom: 10px; }
}
