/* ══════════════════════════════════════════════════════════════════════
   Base
   ══════════════════════════════════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --fondo: #070b16;
  --panel: #141c33;
  --panel-borde: #26314f;
  --texto: #e7ecf7;
  --texto-tenue: #8d9bbb;
  --acento: #4ade80;
  --acento-osc: #16a34a;
  --sol: #fbbf24;
  --rojo: #f87171;
}

html, body { height: 100%; }

body {
  background: radial-gradient(circle at 50% -10%, #1a2440 0%, var(--fondo) 62%);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* pantallas */
.pantalla {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.pantalla.activa { display: flex; }

/* ══════════════════════════════════════════════════════════════════════
   MENÚ PRINCIPAL
   ══════════════════════════════════════════════════════════════════════ */
.menu-fondo { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.estrella {
  position: absolute;
  width: 3px; height: 3px;
  background: #fff;
  border-radius: 50%;
  opacity: .55;
  animation: titilar 4s ease-in-out infinite;
}
.estrella:nth-child(2n) { animation-delay: 1.2s; width: 2px; height: 2px; }
.estrella:nth-child(3n) { animation-delay: 2.4s; }
@keyframes titilar { 0%,100% { opacity: .18; } 50% { opacity: .8; } }

.astro { position: absolute; border-radius: 50%; filter: blur(.3px); }

.astro.sol {
  width: 340px; height: 340px;
  right: -90px; top: -110px;
  background: radial-gradient(circle at 38% 34%, #fde047, #f97316 55%, #9a3412 100%);
  box-shadow: 0 0 120px 30px rgba(249,115,22,.28), 0 0 40px 10px rgba(253,224,71,.22);
  opacity: .85;
  animation: flotar 11s ease-in-out infinite;
}

.astro.tierra {
  width: 120px; height: 120px;
  left: -40px; bottom: 12%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), transparent 45%),
    radial-gradient(circle at 65% 60%, #15803d 0%, transparent 42%),
    radial-gradient(circle at 40% 75%, #16a34a 0%, transparent 38%),
    radial-gradient(circle at 35% 32%, #60a5fa, #1d4ed8 70%, #1e3a8a);
  box-shadow: inset -14px -14px 32px rgba(0,0,0,.65), 0 0 40px rgba(59,130,246,.25);
  opacity: .9;
  animation: flotar 9s ease-in-out infinite reverse;
}

.astro.saturno {
  width: 90px; height: 90px;
  right: 8%; bottom: 10%;
  background: radial-gradient(circle at 35% 30%, #f7edd0, #e5cf9a 60%, #a8863f);
  box-shadow: inset -10px -10px 22px rgba(0,0,0,.55);
  opacity: .8;
  animation: flotar 13s ease-in-out infinite;
}
.astro.saturno i {
  position: absolute;
  left: 50%; top: 50%;
  width: 190px; height: 52px;
  transform: translate(-50%, -50%) rotate(-18deg);
  border: 6px solid rgba(229,207,154,.55);
  border-radius: 50%;
}

@keyframes flotar {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-14px); }
}

.menu-contenido {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.titulo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: .92;
  letter-spacing: -.02em;
}
.titulo-linea1 {
  font-size: clamp(38px, 7vw, 74px);
  font-weight: 800;
  color: #86efac;
  text-shadow: 0 0 40px rgba(74,222,128,.45), 0 6px 24px rgba(0,0,0,.7);
}
.titulo-vs {
  font-size: clamp(16px, 2.4vw, 26px);
  font-weight: 700;
  color: var(--texto-tenue);
  letter-spacing: .3em;
  margin: 6px 0 2px;
  text-transform: uppercase;
}
.titulo-linea2 {
  font-size: clamp(30px, 5.6vw, 60px);
  font-weight: 800;
  color: #fbbf24;
  text-shadow: 0 0 44px rgba(251,191,36,.40), 0 6px 24px rgba(0,0,0,.7);
}

.lema {
  font-size: clamp(12px, 1.4vw, 15px);
  color: var(--texto-tenue);
  margin-top: 14px;
  letter-spacing: .02em;
}

.menu-botones {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 30px;
}

.btn-principal {
  min-width: 300px;
  padding: 17px 46px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #06210f;
  background: linear-gradient(180deg, #6ee7a0, #22c55e 55%, #16a34a);
  border: none;
  border-radius: 15px;
  cursor: pointer;
  box-shadow: 0 7px 0 #166534, 0 14px 36px rgba(34,197,94,.38);
  transition: transform .09s, box-shadow .09s, filter .15s;
}
.btn-principal:hover { filter: brightness(1.07); }
.btn-principal:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #166534, 0 6px 18px rgba(34,197,94,.30);
}

.menu-progreso {
  font-size: 13px;
  color: var(--sol);
  font-weight: 600;
}
.menu-progreso.nuevo { color: var(--texto-tenue); }
.menu-progreso.completo { color: var(--acento); }

.menu-secundarios {
  display: flex;
  gap: 9px;
  margin-top: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-secundario {
  position: relative;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: rgba(20,28,51,.8);
  border: 1px solid var(--panel-borde);
  border-radius: 11px;
  cursor: not-allowed;
}
.btn-secundario span {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #475569;
  margin-top: 2px;
}

.pie {
  margin-top: 34px;
  font-size: 11px;
  color: #475569;
  letter-spacing: .04em;
}

/* ══════════════════════════════════════════════════════════════════════
   MAPA DE MISIONES
   ══════════════════════════════════════════════════════════════════════ */
#pantalla-mapa { justify-content: flex-start; gap: 0; }

.mapa-cabecera {
  flex: 0 0 auto;
  width: min(1000px, 100%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px 6px;
}
.mapa-cabecera h2 { font-size: 20px; font-weight: 800; letter-spacing: .01em; }
.mapa-ayuda { margin-left: auto; font-size: 11px; color: var(--texto-tenue); }

.btn-volver {
  background: #1b2744;
  color: var(--texto);
  border: 1px solid var(--panel-borde);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-volver:hover { background: #243358; }

.mapa-envoltorio {
  flex: 1 1 auto;
  min-height: 0;
  width: min(1000px, 100%);
  padding: 0 20px;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mapa {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--panel-borde);
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  cursor: pointer;
}

.mapa-pie {
  flex: 0 0 auto;
  width: min(1000px, 100%);
  padding: 10px 20px 14px;
  display: flex;
  justify-content: flex-end;
}
.btn-jugar {
  padding: 13px 38px;
  font-size: 15px;
  font-weight: 800;
  color: #06210f;
  background: linear-gradient(180deg, #6ee7a0, #22c55e 55%, #16a34a);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 5px 0 #166534;
  transition: transform .09s, box-shadow .09s;
}
.btn-jugar:active { transform: translateY(4px); box-shadow: 0 1px 0 #166534; }

/* ══════════════════════════════════════════════════════════════════════
   JUEGO
   ══════════════════════════════════════════════════════════════════════ */
#pantalla-juego { gap: 8px; padding: 8px; justify-content: flex-start; }

.hud {
  flex: 0 0 auto;
  width: min(1000px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-borde);
  border-radius: 14px;
  padding: 9px 14px;
}
.hud-item {
  display: flex; flex-direction: column; min-width: 96px;
  padding-right: 12px; border-right: 1px solid var(--panel-borde);
}
.hud-item:last-of-type { border-right: none; }
.hud-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--texto-tenue);
}
.hud-valor { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
#energia { color: var(--sol); }
#nivel { color: var(--acento); }

.hud-btn {
  margin-left: auto;
  background: #1e2947; color: var(--texto);
  border: 1px solid var(--panel-borde); border-radius: 10px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.hud-btn:hover { background: #27345a; }

.tablero-envoltorio {
  position: relative;
  flex: 1 1 auto;
  min-height: 320px;
  width: min(1000px, 100%);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--panel-borde);
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1526;
}
#juego {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  cursor: pointer;
  background: #0d1526;
}

.cartel {
  position: absolute; inset: 0;
  background: rgba(6,10,22,.90);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; line-height: 1.5; padding: 24px;
}
.cartel.oculto { display: none; }
.cartel h2 { font-size: 38px; }
.cartel p { color: var(--texto-tenue); font-size: 16px; max-width: 480px; }

/* victoria / derrota */
.cartel.gano h2 { color: #4ade80; text-shadow: 0 0 26px rgba(74,222,128,.45); }
.cartel.gano #cartel-btn { background: #22c55e; color: #04240f; }
.cartel.perdio h2 { color: #f87171; text-shadow: 0 0 26px rgba(248,113,113,.45); }
.cartel.perdio #cartel-btn { background: #ef4444; color: #2b0505; }
.cartel.gano::before,
.cartel.perdio::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, rgba(74,222,128,.16), transparent 62%);
}
.cartel.perdio::before {
  background: radial-gradient(ellipse at 50% 42%, rgba(248,113,113,.16), transparent 62%);
}
.cartel > * { position: relative; z-index: 1; }
#cartel-btn {
  margin-top: 8px; background: var(--acento); color: #06210f;
  border: none; border-radius: 12px; padding: 14px 32px;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
#cartel-btn:hover { filter: brightness(1.1); }

.inventario {
  flex: 0 0 auto;
  width: min(556px, 100%);       /* 7 semillas + mano + pala en una fila */
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap; overflow: visible;
  background: var(--panel);
  border: 1px solid var(--panel-borde);
  border-radius: 14px;
  padding: 9px 14px;
}
.semilla {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 2px 6px 3px; border-radius: 9px; flex: 0 0 auto;
  border: 2px solid transparent; background: #1a2440;
  cursor: pointer;
  transition: border-color .15s, transform .1s, background .15s;
}
.semilla:hover { background: #223050; }
.semilla:active { transform: scale(.96); }
.semilla.activa { border-color: var(--acento); background: #16301f; }
.semilla.sin-energia { opacity: .38; cursor: not-allowed; }
.semilla-nombre { display: none; }   /* el ícono basta; el nombre va en el tooltip */
.semilla-coste { font-size: 9.5px; font-weight: 700; color: var(--sol); }

/* velo de recarga sobre el icono: baja del 100 % al 0 % */
.semilla-ico { position: relative; width: 34px; height: 34px; }
.semilla-icono { width: 100%; height: 100%; display: block; }
.semilla-velo {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  border-radius: 9px;
  background: rgba(6, 10, 20, .78);
  pointer-events: none;
  z-index: 2;
}
.semilla-velo::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0; height: 2px;
  background: rgba(255, 255, 255, .32);
}

/* ── velocidad del juego ── */
.hud-velocidad {
  display: inline-flex; align-items: center; gap: 4px;
  background: #131d33; border: 1px solid var(--panel-borde);
  border-radius: 9px; padding: 2px 4px;
}
.hud-velocidad .hud-btn { padding: 4px 7px; border: none; background: transparent; }
.hud-velocidad .hud-btn:hover { background: #223050; }
#velocidad {
  min-width: 46px; text-align: center;
  font-size: 12px; font-weight: 700; color: var(--sol);
  font-variant-numeric: tabular-nums;
}
#velocidad.normal { color: var(--texto-tenue); }

/* ── pala para mover plantas ── */
.pala-btn #pala-icono { width: 34px; height: 34px; display: block; }
.pala-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 8px 6px; border-radius: 11px;
  border: 2px solid transparent; background: #1a2440;
  cursor: pointer; margin-left: 6px;
  transition: border-color .15s, transform .1s, background .15s;
}
.pala-btn:hover { background: #223050; }
.pala-btn:active { transform: scale(.96); }
.pala-btn.activa { border-color: #f59e0b; background: #3b2a10; box-shadow: 0 0 12px rgba(245,158,11,.35); }

.ayuda { display: none; }   /* los atajos viven en los tooltips y el README */
kbd {
  background: #1e2947; border: 1px solid var(--panel-borde);
  border-radius: 5px; padding: 1px 6px; font-size: 11px; font-family: inherit;
}

@media (max-width: 760px) {
  .hud-item { min-width: 68px; }
  .hud-valor { font-size: 17px; }
  .ayuda { display: none; }
  .mapa-ayuda { display: none; }
  .btn-principal { min-width: 240px; }
}

/* ══════════════════════════════════════════════════════════════════════
   Selector de semillas (antes de cada nivel)
   ══════════════════════════════════════════════════════════════════════ */
#pantalla-seleccion {
  gap: 12px;
  padding: 12px;
}

.sel-panel {
  width: min(940px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-borde);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  overflow: hidden;
}

.sel-panel h2 {
  font-size: 20px;
  letter-spacing: .5px;
}

.sel-sub {
  font-size: 13px;
  color: var(--texto-tenue);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sel-contador {
  margin-left: auto;
  font-weight: 700;
  font-size: 14px;
  color: var(--texto-tenue);
  border: 1px solid var(--panel-borde);
  border-radius: 8px;
  padding: 2px 10px;
  background: #0f1729;
}
.sel-contador.completo { color: var(--sol); border-color: var(--sol); }
.sel-contador.lleno { animation: sacudir 0.32s ease; }
@keyframes sacudir {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.sel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  overflow-y: auto;
  padding: 2px;
  flex: 1 1 auto;
  min-height: 0;
}

.sel-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px 6px;
  border-radius: 12px;
  border: 2px solid var(--panel-borde);
  background: #0f1729;
  color: var(--texto);
  cursor: pointer;
  font: inherit;
  transition: transform .08s, border-color .12s, background .12s;
}
.sel-item:hover { background: #16203a; transform: translateY(-2px); }
.sel-item.elegida {
  border-color: var(--acento);
  background: #12291c;
  box-shadow: 0 0 0 2px rgba(74,222,128,.20), 0 6px 18px rgba(0,0,0,.4);
}
.sel-item .sel-ico { width: 64px; height: 64px; display: block; }
.sel-item .sel-nombre { font-size: 10px; font-weight: 600; text-align: center; line-height: 1.1; }
.sel-item .sel-coste { font-size: 11px; font-weight: 700; color: var(--sol); }

.sel-check {
  position: absolute;
  top: 4px; right: 6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--acento);
  color: #052e16;
  font-size: 12px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .12s, transform .12s;
}
.sel-item.elegida .sel-check { opacity: 1; transform: scale(1); }

.sel-acciones {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.btn-principal {
  font: inherit;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 10px;
  border: 1px solid #15803d;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  color: #052e16;
  cursor: pointer;
}
.btn-principal:hover { filter: brightness(1.08); }
.btn-principal:disabled {
  background: #1a2338;
  color: var(--texto-tenue);
  border-color: var(--panel-borde);
  cursor: not-allowed;
}
