/* ============================================================
   1. CSS Variables (Custom Properties)
   ============================================================*/
   :root {
    --background-color: #fdf6e3;
    --text-color: #2d2a26;
    --primary-color: #556B2F;
    --secondary-color: #eee8d5;
    --hover-color: #d6ccc4;
    --correct-color: #22c55e;
    --incorrect-color: #ef4444;
    --progress-color: #b08d57;
    --score-color: #e07c00;
    --hover-btn-color: #475823;
    --disabled-color: #c4b7a3;

    /* Font sizes*/
    --font-size-base: 1rem;
    --font-size-base-modifiable: 1rem;
    --font-size-small: 0.875rem;
    --font-size-extra-small: 0.575rem;
    --font-size-medium: 1.125rem;
    --font-size-medium-modifiable: 1.12rem;
    --font-size-large: 1.5rem;
    --font-size-large-modifiable: 1.2rem;
    --font-size-extra-large: 2rem;
  }

  body.dark-mode {
    --background-color: #121212;
    --text-color: #EDE6D6;
    --primary-color: #789948;
    --secondary-color: #2A2A2A;
    --hover-color: #3E3E3E;
    --correct-color: #4A9D48;
    --incorrect-color: #C45656;
    --progress-color: #84A98C;
    --score-color: #e6b143;
    --hover-btn-color: #556B2F;
    --disabled-color: #454545;
  }

  /* ============================================================
     2. Base Styles
     ============================================================*/
  body, body * {
    font-family: 'Playwrite DE Grund', serif;
  }

  body {
    max-width: 800px;
    margin: 30px auto;
    padding: 10px;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.6s, color 0.6s;
  }

  .Titulo-Sobre {
    text-align: center;
    font-size: var(--font-size-extra-large);
  }

  /* ============================================================
     3. Button System
     ============================================================*/
  /* Common Button Styles*/
  .btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: var(--font-size-base)
  }

  .btn:hover:not(:disabled) {
    background: var(--hover-btn-color);
    transform: scale(1.05);
  }

  .btn:disabled {
    background: var(--disabled-color);
    cursor: not-allowed;
  }

  /* Button Variants*/
  .btn-large {
    width: 375px;
    margin: 10px auto;
    padding: 15px;
    font-size: var(--font-size-medium);
    border-radius: 8px;
    display: block;
  }

  .btn-medium {
    width: 150px;
    margin: 10px 0;
    padding: 10px 20px;
    font-size: var(--font-size-extra-small);
  }

  .btn-small {
    padding: 2px 10px;
    width: 70px;
    height: 30px;
    font-size: var(--font-size-extra-small);
  }

  /* ============================================================
     4. Form Elements
     ============================================================*/
  .select-input {
    display: block;
    margin: 10px auto;
    padding: 10px;
    font-size: var(--font-size-medium);
    background: var(--secondary-color);
    border: 2px solid var(--hover-color);
    border-radius: 7px;
    text-align: center;
    color: var(--text-color);
    transition: all 0.3s;
  }

  .select-input:hover {
    background: var(--hover-color);
  }

  .select-input:focus {
    border-color: var(--primary-color);
  }

  /* Caja de seleccion de num y cat de preguntas y boton de iniciar. Misma caja y tamaño*/
  #input-preguntas .select-input,
  #input-preguntas .btn {
    box-sizing: border-box;
    width: 275px;
  }

  /* ============================================================
     5. Quiz Components
     ============================================================*/

  /* Category/year display styles*/
  #quiz {
    position: relative;
    padding-top: 0; /* Removed padding-top completely for more compact layout */
  }

  .quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3px auto; /* Reduced from 5px to make layout more compact */
    padding: 5px 10px;
    background-color: var(--secondary-color);
    border-radius: 6px;
    max-width: 95%;
  }

  #categoria, #timer {
    position: static; /* Remove absolute positioning */
    max-width: 45%;
    font-size: var(--font-size-small);
    margin: 0;
    padding: 5px;
    color: var(--primary-color);
  }

  #timer {
    font-weight: bold;
    text-align: right;
  }

  .dark-mode #categoria {
    color: var(--text-color);
  }

  #question-container {
    margin-top: 0; /* Removed top margin as requested */
  }

  .opcion {
    display: block;
    width: 95%;
    margin: 5px auto;
    padding: 10px;
    text-align: left;
    background: var(--secondary-color);
    border: 1px solid var(--hover-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: var(--font-size-medium-modifiable);
    line-height: 1.4;
  }

  body.dark-mode .opcion {
    color: var(--text-color);
  }



  .correcto {
    background: var(--correct-color) !important;
    color: white;
  }

  .incorrecto {
    background: var(--incorrect-color) !important;
    color: white;
  }

  #pregunta {
    background-color: var(--secondary-color);
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    padding: 10px;
    margin: 5px auto; /* Reduced from 10px to match the navigation grid spacing */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;

    font-size: var(--font-size-medium-modifiable);
  }

  /* ============================================================
     6. Utility Classes
     ============================================================*/
  .hidden {
    display: none;
  }

  /* had to add this because quiz-container was not showing, and now it does*/
  #quiz-container {
    display: block;
    margin-top: 60px; /* Leave this as is */
    position: relative;
  }

  /* ============================================================
     7. Settings Buttons Location
     ============================================================*/
  .settings {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: absolute;
    top: 20px;
    right: 20px;
    margin-bottom: 25px; /* Add space below settings */
  }

  /* Hide text size buttons in main menu*/
  .menu-principal #increase-text-size,
  .menu-principal #decrease-text-size {
    display: none;
  }

  /* Show text size buttons in quiz sections*/
  .quiz-container #increase-text-size,
  .quiz-container #decrease-text-size,
  .test-finalizado #increase-text-size,
  .test-finalizado #decrease-text-size {
    display: inline-block;
  }

  /* ============================================================
     8. Title Container
     ============================================================*/
  .title-container {
    background-color: var(--background-color);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    margin: 3rem auto;
    max-width: 600px;
    text-align: center;
    position: relative;
  }

  body.dark-mode .title-container {
    background-color: #333333;
  }

  .title-container h1 {
    font-family: 'Playwrite DE Grund', serif;
    font-size: 3.5rem;
    color: var(--primary-color);
    margin: 0;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.15em;
  }

  body.dark-mode .title-container h1 {
    color: #FFFFFF;
    text-shadow: none;
  }

  .title-owl-image {
    width: 50px;
    height: auto;
    vertical-align: middle;
    margin-left: 10px;
    position: absolute;
    top: 5px;
    right: 10px;
    padding: 0.5rem;
  }

  /* ============================================================
     9. Timer
     ============================================================*/

.dark-mode #timer {
  color: var(--text-color);
}


  /* ============================================================
     10. Responsive Design
     ============================================================*/
  @media (max-width: 480px) {
    .estadisticas {
      display: grid;
      grid-template-areas:
        "prog prog no-con no-con no-con"
        "punt punt corr incorr .";
      gap: 4px;
    }

    #progreso { grid-area: prog; }
    #no-contestadas { grid-area: no-con; }
    #puntuacion { grid-area: punt; }
    #correctas { grid-area: corr; }
    #incorrectas { grid-area: incorr; }

    .title-container {
      padding: 1rem;
      margin: 2rem auto;
    }

    .title-container h1 {
      font-size: 2.2rem;
      padding-right: 2rem;
    }

    .btn-large {
      width: 100%;
    }

    #input-preguntas .select-input,
    #input-preguntas .btn {
      width: 90%;
    }

    #settings {
      flex-direction: row;
      gap: 4px;
      top: 15px; /* Move settings up slightly on mobile */
    }

    #settings .btn-small {
      flex: 1;
      padding: 2px 8px;
      font-size: var(--font-size-extra-small);
    }
/*
    #menu-principal,
    .botones-navegacion {
      flex-direction: column;
      align-items: center;
      padding-top: 5px;
    }*/

    .botones-navegacion {
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      font-size: var(--font-size-extra-small)
    }

    #cabecera {
      margin-top: 5px; /* Reduced space in mobile view */
      margin-bottom: 5px; /* Reduced space in mobile view */
    }

    .navigation-grid-container {
      margin: 4px auto; /* Further reduced margin on mobile */
      padding: 4px;
    }

    .quiz-header {
      margin: 4px auto; /* Reduced margin on mobile */
    }

    #pregunta {
      margin: 4px auto; /* Reduced margin on mobile */
    }
  }

  @media (max-width: 400px) {
    #btn-volver {
      font-size: var(--font-size-large);
      font-weight: 500;
      text-align: center;
      margin: 150px auto;
      display: block;
    }
  }

  @media (hover: none) {
    .btn:focus {
      outline: none;
    }
  }

/* ============================================================
   11. Navigation Buttons
   ============================================================*/
  .botones-navegacion {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    font-size: var(--font-size-extra-small);
    align-items: stretch;
    flex-wrap: nowrap;
  }

  

/* Add these new styles */
.navigation-grid-container {
  overflow-x: auto;
  padding: 5px 10px; /* Reduced padding */
  margin: 3px auto; /* Equal margin top and bottom - reduced from 10px */
  background-color: var(--secondary-color);
  border-radius: 6px;
  max-width: 100%;
  width: 100%; /* Force full width */
  box-sizing: border-box; /* Ensure padding is included in width calculation */
  display: block; /* Force block display */

}

/* Add this to ensure the quiz-header and navigation-grid-container have identical styling */
.quiz-header, .navigation-grid-container {
  box-sizing: border-box; /* Ensure consistent box model */
  width: 100%; /* Force both to be exact same width */
  max-width: 100%; /* Force both to be exact same max-width */
}

.navigation-grid {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 6px;
  padding: 3px; /* Reduced padding from 5px to 3px */
  min-width: max-content;
}

.grid-item {
  min-width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--secondary-color);
  border: 1px solid var(--hover-color);
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.grid-item:hover {
  background-color: var(--hover-color);
}

.grid-item.current {
  background-color: var(--primary-color);
  color: white;
  border-color: white;
  transform: scale(1.1);
  box-shadow: 0 0 3px rgba(0,0,0,0.2);
}

.grid-item.answered {
  background-color: var(--correct-color);
  color: white;
}

.grid-item.incorrect {
  background-color: var(--incorrect-color);
  color: white;
}

@media (max-width: 480px) {
  .grid-item {
    min-width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }
}

/* Compact statistics panel pendiente*/ 
  .statistics-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 6px;
    margin-bottom: 10px;
  }

  .stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: var(--secondary-color);
    border-radius: 4px;
    white-space: nowrap;
  }

  .stat-label {
    color: var(--text-color);
    font-weight: 500;
  }

  .stat-value {
    font-weight: 600;
  }

  .progress-container {
    flex-basis: 100%;
    height: 6px;
    background: var(--secondary-color);
    border-radius: 3px;
    margin: 0 auto;
    max-width: 95%;
  }

  .progress-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.3s;
  }

/* ============================================================
   12. Test Completion Elements
   ============================================================*/
.completion-title {
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary-color);
  margin: 1.5rem 0;
  padding: 1rem;
  background-color: var(--secondary-color);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.dark-mode .completion-title {
  color: var(--text-color);
}

.completion-title .emoji {
  font-size: 2.2rem;
}

.estadisticas-finales {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 1.5rem 0;
  text-align: center;
}

.estadisticas-finales .estadistica-final {
  background: var(--secondary-color);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.estadisticas-finales .estadistica-final:first-child {
  grid-column: 1 / -1;
}

.estadisticas-finales .estadistica-final p:first-child {
  font-weight: 500;
  margin: 0 0 5px 0;
  color: var(--text-color);
  font-size: 0.95rem;
}

.estadisticas-finales .estadistica-final p:last-child {
  margin: 0;
  font-weight: bold;
  color: var(--primary-color);
  font-size: 1.2rem;
}

.dark-mode .estadisticas-finales .estadistica-final p:last-child {
  color: var(--text-color);
}

@media (max-width: 480px) {
  .completion-title {
    font-size: 1.5rem;
    padding: 0.75rem;
  }
  
  .completion-title .emoji {
    font-size: 1.7rem;
  }
  
  .estadisticas-finales {
    grid-template-columns: 1fr;
  }
  
  .estadisticas-finales .estadistica-final {
    padding: 0.75rem;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .estadisticas-finales .estadistica-final p:first-child {
    font-size: 0.9rem;
    margin: 0;
  }
  
  .estadisticas-finales .estadistica-final p:last-child {
    font-size: 1.1rem;
  }
}

/* Center "Volver" button in About section */
.btn-volver-centered {
  display: block;
  margin: 30px auto;
  text-align: center;
}

/* Updated Statistics and Header Styles */
#cabecera {
  margin-top: 10px; /* Reduced from 60px since it's now inside quiz-container */
  margin-bottom: 8px; /* Reduced from 15px to decrease space between cabecera and quiz */
  padding: 5px;
  background-color: var(--secondary-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#cabecera h1 {
  margin: 0;
  padding: 0;
  font-size: var(--font-size-medium);
  text-align: center;
}

.estadisticas {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px 0;
  margin: 0;
}

.estadisticas {
  background: var(--secondary-color);
  padding: 3px 10px;
  border-radius: 4px;
  text-align: center;
  box-shadow: none;
  margin: 2px;
  min-width: auto;
  font-size: var(--font-size-small);
  border: 1px solid var(--hover-color);
  justify-content: space-evenly
}

.estadistica p {
  margin: 0;
  line-height: 1.2;
}

.estadistica .numero {
  font-weight: bold;
  color: var(--primary-color);
}

/* Improved responsiveness */
@media (max-width: 480px) {
  .estadisticas {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
  }
  
  .estadistica {
    flex: 0 0 auto;
    padding: 2px 8px;
  }
  
  .estadistica p {
    font-size: var(--font-size-extra-small);
  }
}


