/* --- CONFIGURACIÓN GENERAL --- */
:root {
  --font-size-h1: 3.5em;
  --font-size-pregunta: 3.5em;
  --font-size-resultado: 2.5em;
  --font-size-feedback: 10em;
}
body {
  margin: 0;
  font-family: 'Arial Black', sans-serif;
  overflow: hidden;
  background-image: url('fondo.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: white;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.7);
}
.oculto { display: none !important; }

/* --- LOGO --- */
#logo-img {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 120px;
    z-index: 200;
    opacity: 0.9;
}

/* --- PANTALLA DE MENÚ PRINCIPAL --- */
#menu-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; background-color: rgba(0, 0, 0, 0.4);
  padding: 15px;
  box-sizing: border-box;
}
h1 { font-size: var(--font-size-h1); margin-bottom: 20px; text-align: center; }
#panel-seleccion {
  background: rgba(255, 255, 255, 0.90); border-radius: 20px; padding: 30px 40px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3); backdrop-filter: blur(10px);
  color: #333; text-shadow: none;
  max-width: 600px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}
#panel-seleccion h3 { text-align: center; font-size: 1.6em; margin-top: 0; color: #2c5234; }
.tablas-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 15px; margin-bottom: 25px; }
.tabla-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  background-color: #f0f0f0; border-radius: 50%; border: none;
  border-bottom: 5px solid #bababa; font-size: 1.8em; font-weight: bold; color: #444;
  cursor: pointer; transition: all 0.15s ease-out; display: flex; align-items: center; justify-content: center;
}
.tabla-btn:hover { background-color: #ffffff; transform: translateY(-2px); border-bottom-width: 7px; }
.tabla-btn:active { transform: translateY(1px); border-bottom-width: 4px; }
.tabla-btn.selected { background-color: #4CAF50; color: white; border-bottom: 5px solid #388E3C; transform: translateY(1px); }
.controles-menu { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.modo-btn {
  padding: 12px 24px; margin: 5px; border: none; border-radius: 15px; font-size: 1.1em;
  font-weight: bold; cursor: pointer; transition: all 0.3s; color: white; box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 300px;
}
#btn-aleatorio { background: linear-gradient(45deg, #FF6B6B, #FFC107); }
#btn-iniciar { background: linear-gradient(45deg, #4CAF50, #81C784); font-size: 1.3em; padding: 15px 30px; }
#btn-aleatorio.selected { background: #4CAF50; }
.btn-external {
    display: inline-block;
    margin-top: 15px;
    background: linear-gradient(45deg, #6a1b9a, #ab47bc);
}

/* --- PANTALLA DE JUEGO --- */
#juego-container {
  position: relative; width: 100vw; height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
}
#btn-volver {
  position: absolute; top: 20px; left: 20px; width: 50px; height: 50px; background-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%; border: 2px solid white; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.2s; z-index: 100;
}
#btn-volver:hover { transform: scale(1.1); }
#btn-volver svg { fill: white; width: 60%; height: 60%; }
#pregunta-container {
  margin-top: 20px; padding: 15px 40px; background: rgba(0, 0, 0, 0.6); border-radius: 20px;
  font-size: var(--font-size-pregunta); border: 3px solid rgba(255,255,255,0.5); z-index: 10;
}

#campo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    flex-grow: 1;
}

#porteria-container {
  position: relative;
  width: 90vw;
  max-width: 800px;
  aspect-ratio: 2 / 1;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 15vh; /* <-- VALOR MODIFICADO PARA ORDENADOR */
}
#porteria-img { width: 100%; height: 100%; }
.resultado {
  position: absolute;
  width: 15%;
  height: 22.5%;
  min-width: 80px;
  background: rgba(255, 255, 255, 0.8); color: #111;
  text-shadow: none; font-size: var(--font-size-resultado); font-weight: bold; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 4px solid #2196F3; cursor: pointer; transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 15;
}
.resultado:hover { transform: scale(1.1); box-shadow: 0 8px 25px rgba(0,0,0,0.4); }
.resultado.correcto { background-color: #4CAF50; color: white; border-color: #fff; transform: scale(1.1); }
.resultado.incorrecto { background-color: #f44336; color: white; border-color: #fff; animation: fallo 0.5s ease-in-out; }
@keyframes fallo { 25% { transform: translateX(-15px); } 75% { transform: translateX(15px); } }

/* --- PORTEROS --- */
#portero-reposo-img {
    position: absolute;
    width: 28%;
    max-width: 220px;
    height: auto;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: opacity 0.2s ease-out;
}
.portero {
  position: absolute; top: 50%; left: 50%; opacity: 0; pointer-events: none; z-index: 20;
  transition: all 0.4s cubic-bezier(0.1, 0.9, 0.2, 1); object-fit: contain;
}
.portero.espejo { transform: translate(-50%, -50%) scaleX(-1); }
.portero.normal { transform: translate(-50%, -50%); }

#balon-container { width: 100%; text-align: center; padding-bottom: 20px; }
#balon-img {
  width: 100px;
  height: 100px;
  aspect-ratio: 1 / 1; object-fit: contain; position: relative;
  transition: transform 0.6s cubic-bezier(0.5, 0, 1, 0.5);
}
#info-juego {
  position: absolute; top: 20px; right: 20px; background: rgba(0,0,0,0.6); padding: 10px 15px;
  border-radius: 15px; font-size: 1.1em; text-align: left;
}
#feedback-mensaje {
  position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%) scale(0);
  font-size: var(--font-size-feedback); color: #76ff03; text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #76ff03;
  z-index: 50; pointer-events: none; opacity: 0; transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
#feedback-mensaje.mostrar { transform: translate(-50%, -50%) scale(1); opacity: 1; }
#resultado-final {
  background-color: rgba(0,0,0,0.7); display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; width: 100%; position: fixed; top: 0; left: 0; z-index: 100;
  padding: 15px; box-sizing: border-box; text-align: center;
}
#resultado-final h2 { font-size: 3em; }
#resultado-final p { font-size: 1.8em; }
#btn-reiniciar { background: linear-gradient(45deg, #2196F3, #64B5F6); }

/* --- Media Queries para hacer todo responsivo --- */
@media (max-width: 768px) {
  :root {
    --font-size-h1: 2.5em;
    --font-size-pregunta: 2.8em;
    --font-size-resultado: 1.8em;
    --font-size-feedback: 6em;
  }
  .tablas-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }
  #panel-seleccion { padding: 20px; }
  #pregunta-container { padding: 10px 25px; }
  #info-juego { font-size: 1em; padding: 8px 12px; top: 80px; right: auto; left: 20px; }
  #balon-img { width: 80px; height: 80px; }
  
  /* REGLA AÑADIDA PARA MÓVIL */
  #porteria-container {
      margin-bottom: 8vh;
  }
}

@media (max-width: 480px) {
  :root {
    --font-size-h1: 2em;
    --font-size-pregunta: 2em;
    --font-size-resultado: 1.5em;
    --font-size-feedback: 4.5em;
  }
  .tablas-grid {
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  }
  .tabla-btn { font-size: 1.5em; border-bottom-width: 4px; }
  h1 { margin-bottom: 15px; }
  #panel-seleccion { padding: 20px 15px; }
  .modo-btn { padding: 10px 20px; font-size: 1em; }
  #btn-iniciar { font-size: 1.2em; padding: 12px 25px; }
}

/* --- CORRECCIÓN PARA EL FONDO EN MÓVILES --- */
@media (max-width: 900px) {
  body {
    background-attachment: scroll;
  }
}