* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a1a;
  font-family: "Segoe UI", system-ui, sans-serif;
  touch-action: none;
}

#game-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* horizontal 16:9, encajado al viewport */
  width: min(100vw, 177.78vh);
  height: min(100vh, 56.25vw);
  background: #000;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 5;
  pointer-events: none;
}

#lives {
  background: rgba(20,20,20,0.75);
  padding: 8px 16px;
  border-radius: 12px;
  border: 3px solid #7a1730;
  display: flex;
  gap: 6px;
  min-width: 56px;
}

#lives .heart {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

#lives .heart.lost {
  opacity: 0.25;
  filter: grayscale(1) drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

#score-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  height: 40px;
  background: rgba(20,20,20,0.75);
  border: 3px solid #7a1730;
  border-radius: 16px;
  padding: 0 18px;
}

#score-label {
  color: #c98a3f;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
}

#score-value {
  color: #e8c46a;
  font-weight: 800;
  font-size: 24px;
  min-width: 2ch;
  text-align: right;
}

#meteor-warning {
  position: absolute;
  top: 40%;
  left: 6%;
  right: 6%;
  z-index: 8;
  text-align: center;
  font-style: italic;
  font-weight: 900;
  font-size: clamp(22px, 5.4vh, 48px);
  line-height: 1.2;
  color: #fff4e0;
  text-shadow: 0 3px 12px rgba(0,0,0,0.85), 0 0 4px rgba(0,0,0,0.9);
  letter-spacing: 0.5px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-14px) scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#meteor-warning.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#meteor-warning .mw-fire {
  background-image:
    linear-gradient(90deg, #fff3b0, #ffb300 35%, #ff5a00 65%, #ff2a00),
    url('assets/meteorito.png');
  background-blend-mode: screen;
  background-size: 100% 100%, 260% auto;
  background-position: center, 78% 22%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px rgba(90,10,0,0.35);
  filter: drop-shadow(0 0 10px rgba(255,140,0,0.85)) drop-shadow(0 0 22px rgba(255,61,0,0.6));
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(15,10,5,0.92);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

.overlay .logo {
  width: 420px;
  max-width: 62%;
  margin-bottom: 10px;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.6));
}

.overlay .brand-title {
  font-size: clamp(30px, 6.5vh, 54px);
  line-height: 1.15;
  color: #f4e9d8;
  text-shadow: 0 4px 18px rgba(0,0,0,0.75);
  letter-spacing: 0.5px;
  margin: 0 0 10px;
  font-style: italic;
  font-weight: 800;
  text-transform: uppercase;
}

.overlay h1 {
  color: #e8c46a;
  font-size: 28px;
  margin: 8px 0;
}

.overlay p {
  font-size: 15px;
  line-height: 1.5;
  max-width: 380px;
  color: #f0e6d8;
}

/* pantalla de inicio con KV de la fábrica de fondo */
#start-screen {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.30), rgba(0,0,0,0.05) 38%, rgba(0,0,0,0.55)),
    url('assets/inicio_bg.png') center/cover no-repeat;
  justify-content: flex-start;
  padding-top: 3vh;
}

#start-screen .logo {
  width: 38%;
  max-width: 360px;
  margin-bottom: 2vh;
}

#start-screen {
  justify-content: center;
}

#start-screen #start-btn {
  margin-top: 3vh;
  font-size: clamp(24px, 4.6vh, 40px);
  padding: clamp(16px, 2.6vh, 26px) clamp(48px, 9vw, 90px);
  border-radius: 60px;
}

.overlay button {
  margin-top: 20px;
  background: linear-gradient(180deg, #f0d38a, #d4a840);
  border: none;
  color: #3d0a14;
  font-weight: 800;
  font-size: 20px;
  padding: 14px 40px;
  border-radius: 40px;
  cursor: pointer;
  box-shadow: 0 6px 0 #3d0a14, 0 8px 16px rgba(0,0,0,0.4);
  animation: btn-blink 1.3s ease-in-out infinite;
}

@keyframes btn-blink {
  0%, 100% { box-shadow: 0 6px 0 #3d0a14, 0 8px 16px rgba(0,0,0,0.4); filter: brightness(1); }
  50% { box-shadow: 0 6px 0 #3d0a14, 0 8px 30px 6px rgba(255,214,120,0.9); filter: brightness(1.2); }
}

.overlay button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #3d0a14, 0 4px 8px rgba(0,0,0,0.4);
  animation-play-state: paused;
}
