:root {
  /* Color Palette */
  --primary-color: #002855; /* Azul West */
  --secondary-color: #97d700; /* Verde */
  --accent-color: #fe5000; /* Naranja */

  /* Feedback Colors */
  --success-color: #97d700;
  --error-color: #f9423a;
  --warning-color: #fe5000;
  --info-color: #0085ca;

  /* Typography */
  --font-family: "Roboto", sans-serif; /* Fallback */

  /* UI Colors */
  --text-color: #333;
  --bg-color: #f4f4f4;
  --white: #ffffff;
  --black: #000000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Bloquear scroll solo en PC */
@media (min-width: 769px) {
  body {
    max-height: 100vh;
    overflow: hidden;
  }
}

/* Utilities */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

main.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Bloquear scroll solo en PC */
@media (min-width: 769px) {
  main.container {
    overflow: hidden;
    max-height: calc(100vh - 140px);
  }
}

/* Ajustar contenedor en index */
#welcome-screen .container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0.5rem 20px;
}

/* Bloquear scroll solo en PC */
@media (min-width: 769px) {
  #welcome-screen .container {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  text-decoration: none;
  transition: background-color 0.3s ease;
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--white);
}

.btn-primary:hover {
  background-color: #001a3a;
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: var(--primary-color);
}

.btn-accent {
  background-color: var(--accent-color);
  color: var(--white);
}

/* Header */
header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #001a3a 100%);
  color: var(--white);
  padding: 1rem 0;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-bottom: 3px solid var(--secondary-color);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}

.header-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: transform 0.3s ease;
}

.header-logo-link:hover {
  transform: scale(1.05);
}

.header-logo {
  height: 45px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.header-title-wrapper {
  display: flex;
  align-items: center;
  padding-left: 16px;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.header-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-title-link {
  color: var(--white);
  text-decoration: none;
  transition: color 0.3s ease;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-title-link:hover {
  color: var(--secondary-color);
}

.header-nav {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 0 0 auto;
}

.btn-exit {
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.25);
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-exit:hover {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-exit:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-leaderboard-link {
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.25);
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-leaderboard-link:hover {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-back-home {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 40, 85, 0.3);
}

.btn-back-home:hover {
  background-color: #003d80;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 40, 85, 0.4);
}

/* Footer */
footer {
  background-color: var(--primary-color);
  color: var(--white);
  text-align: center;
  padding: 0.6rem 0;
  margin-top: auto;
  flex-shrink: 0;
}

/* Screen Management */
.screen {
  display: none;
  min-height: calc(100vh - 200px);
  padding: 2rem 0;
}

.screen.active {
  display: block;
}

/* Pantalla de inicio sin scroll */
#welcome-screen {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
  min-height: calc(100vh - 140px);
}

#welcome-screen.active {
  display: flex;
}

/* Bloquear scroll solo en PC */
@media (min-width: 769px) {
  #welcome-screen {
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
    overflow: hidden;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

.slide-in {
  animation: slideIn 0.5s ease-out;
}

.scale-in {
  animation: scaleIn 0.4s ease-out;
}

/* Game Specific Styles */
.game-container {
  background: var(--white);
  padding: 1.25rem;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-top: 0.5rem;
  text-align: center;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.question-box {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  color: var(--primary-color);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-image {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  margin: 0 auto;
  display: block;
  max-height: 400px;
  object-fit: contain;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.option-btn {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 15px;
  border-radius: 8px;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}

.option-btn:hover {
  transform: translateY(-3px) scale(1.02);
  background-color: #003d80;
  box-shadow: 0 4px 12px rgba(0, 40, 85, 0.3);
}

.option-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Feedback States */
.feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none; /* Hidden by default */
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 1000;
  padding: 1rem;
  box-sizing: border-box;
  overflow-y: auto;
}

.feedback-success {
  background-color: rgba(151, 215, 0, 0.95); /* Green */
  color: var(--primary-color);
}

.feedback-error {
  background-color: rgba(249, 66, 58, 0.95); /* Red */
  color: var(--white);
}

.feedback-content {
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.95);
  padding: 2.5rem;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 100%;
  color: var(--text-color);
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.feedback-content h2 {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  line-height: 1.2;
}

.feedback-content p {
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--text-color);
  margin: 0.5rem 0;
}

#feedback-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
  line-height: 1;
}

.feedback-content .btn {
  margin-top: 1.5rem;
  padding: 12px 24px;
  font-size: 1rem;
}

.game-result-summary {
  text-align: center;
  color: var(--text-color);
}

.result-score {
  font-size: 1.8rem;
  margin-bottom: 1.25rem;
  font-weight: bold;
  color: var(--primary-color);
}

.result-details {
  font-size: 1.3rem;
  margin-top: 1.25rem;
  line-height: 1.8;
}

.result-details p {
  margin: 0.625rem 0;
}

.result-percentage {
  margin-top: 0.9375rem !important;
  font-weight: bold;
  font-size: 1.4rem;
  color: var(--accent-color);
}

.result-message {
  margin-top: 1.5625rem;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--primary-color);
}

/* Form Styles */
.player-form {
  max-width: 500px;
  margin: 0 auto;
  text-align: left;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.form-group {
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.form-group:last-of-type {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--primary-color);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
  font-family: var(--font-family);
  background-color: #fafafa;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 40, 85, 0.1);
  background-color: var(--white);
}

.form-input::placeholder {
  color: #999;
  opacity: 0.7;
}

/* Theme Selection Styles */
.theme-selection-title {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  font-size: 1.75rem;
  text-align: center;
}

.theme-selection-subtitle {
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: #666;
  text-align: center;
}

.themes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-top: 0;
  min-height: auto;
}

.theme-card {
  background: var(--white);
  border: 3px solid var(--primary-color);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
  flex-direction: row;
  align-items: flex-start;
  gap: 1rem;
  min-height: 120px;
}

.theme-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: var(--secondary-color);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.theme-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 40, 85, 0.2);
  border-color: var(--secondary-color);
}

.theme-card:hover::before {
  transform: scaleX(1);
}

.theme-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  flex-direction: row;
}

.theme-card-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
}

.theme-card h3 {
  color: var(--primary-color);
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
  flex: 1;
}

.theme-card p {
  color: #666;
  line-height: 1.4;
  margin: 0;
  font-size: 0.85rem;
  display: -webkit-box;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.theme-card .theme-icon {
  font-size: 2.5rem;
  margin: 0;
  flex-shrink: 0;
  line-height: 1;
  align-self: flex-start;
  padding-top: 0.25rem;
}

.theme-card .start-btn {
  background: var(--primary-color);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s ease;
  flex-shrink: 0;
  font-size: 0.9rem;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 0.25rem;
}

.theme-card .start-btn:hover {
  background: var(--secondary-color);
  color: var(--primary-color);
}

/* Welcome Screen Styles */
.welcome-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  width: 100%;
  align-items: stretch; /* Hace que ambos modales tengan la misma altura */
  overflow: hidden;
}

.welcome-main {
  background: var(--white);
  padding: 2.5rem;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0, 40, 85, 0.15);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 85vh;
  overflow: hidden;
  justify-content: space-between;
}

.leaderboard-preview {
  background: linear-gradient(135deg, var(--primary-color) 0%, #003d80 100%);
  color: var(--white);
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0, 40, 85, 0.2);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 85vh;
  overflow: hidden;
}

.leaderboard-preview #leaderboard-preview {
  flex: 1;
  min-height: 0;
}

.game-logo {
  text-align: center;
  margin-bottom: 2rem;
  flex-shrink: 0;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #f0f0f0;
}

.game-title {
  font-size: 2rem;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  line-height: 1.2;
}

.game-subtitle {
  font-size: 1rem;
  color: #666;
  font-weight: normal;
  line-height: 1.4;
  margin: 0;
}

.btn-start {
  width: 100%;
  font-size: 1.1rem;
  padding: 16px 30px;
  margin-top: 2rem;
  border-radius: 10px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(254, 80, 0, 0.3);
  flex-shrink: 0;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.btn-start:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(254, 80, 0, 0.4);
}

.leaderboard-preview h3 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.leaderboard-preview #leaderboard-preview {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
}

.preview-list {
  margin-bottom: 1.5rem;
}

.preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.preview-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(5px);
}

.preview-position {
  font-size: 1.2rem;
  margin-right: 10px;
}

.preview-name {
  flex: 1;
  font-weight: bold;
}

.preview-score {
  color: var(--secondary-color);
  font-weight: bold;
}

.btn-view-leaderboard {
  display: block;
  text-align: center;
  color: var(--white);
  background: rgba(255, 255, 255, 0.2);
  padding: 12px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.3);
  margin-top: auto; /* Empuja el botón hacia abajo */
}

.btn-view-leaderboard:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

/* Leaderboard Styles */
.leaderboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 0;
}

.leaderboard-header {
  text-align: center;
  margin-bottom: 2rem;
}

.leaderboard-header-content {
  width: 100%;
}

.leaderboard-title {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.leaderboard-subtitle {
  font-size: 1.2rem;
  color: #666;
  margin: 0;
}

.leaderboard-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  padding: 1.5rem;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.leaderboard-filters {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 20px;
  flex: 1;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.filter-label {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-icon {
  font-size: 1.1rem;
}

.filter-select {
  padding: 12px 20px;
  border: 2px solid var(--primary-color);
  background: var(--white);
  color: var(--primary-color);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 200px;
  transition: all 0.3s ease;
  font-family: var(--font-family);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23002855' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 45px;
}

.filter-select:hover {
  border-color: #003d80;
  box-shadow: 0 2px 8px rgba(0, 40, 85, 0.2);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 40, 85, 0.1);
}

.leaderboard-table-container {
  background: var(--white);
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow-x: visible;
  padding: 1.5rem;
  width: 100%;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 100%;
}

.leaderboard-table thead {
  background: var(--primary-color);
  color: var(--white);
}

.leaderboard-table th {
  padding: 12px 10px;
  text-align: left;
  font-weight: bold;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Anchos optimizados para las columnas */
.leaderboard-table th:nth-child(1),
.leaderboard-table td:nth-child(1) {
  width: 7%;
  min-width: 60px;
  max-width: 80px;
}

.leaderboard-table th:nth-child(2),
.leaderboard-table td:nth-child(2) {
  width: 18%;
  min-width: 120px;
}

.leaderboard-table th:nth-child(3),
.leaderboard-table td:nth-child(3) {
  width: 15%;
  min-width: 100px;
}

.leaderboard-table th:nth-child(4),
.leaderboard-table td:nth-child(4) {
  width: 11%;
  min-width: 80px;
}

.leaderboard-table th:nth-child(5),
.leaderboard-table td:nth-child(5) {
  width: 11%;
  min-width: 80px;
}

.leaderboard-table th:nth-child(6),
.leaderboard-table td:nth-child(6) {
  width: 16%;
  min-width: 110px;
}

.leaderboard-table th:nth-child(7),
.leaderboard-table td:nth-child(7) {
  width: 16%;
  min-width: 140px;
}

.leaderboard-table tbody tr {
  border-bottom: 1px solid #eee;
  transition: all 0.2s ease;
}

.leaderboard-table tbody tr:hover {
  background: #f8f9fa;
  transform: scale(1.01);
}

.leaderboard-table tbody tr:last-child {
  border-bottom: none;
}

.leaderboard-table td {
  padding: 12px 10px;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.position {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--primary-color);
}

.player-name {
  font-weight: bold;
  color: #333;
}

.theme {
  color: #666;
  font-size: 0.9rem;
}

.score {
  color: var(--accent-color);
  font-weight: bold;
  font-size: 1.1rem;
}

.time {
  color: var(--primary-color);
  font-weight: bold;
}

.accuracy {
  color: #666;
  font-size: 0.9rem;
}

.date {
  color: #999;
  font-size: 0.85rem;
}

.loading-spinner {
  text-align: center;
  padding: 3rem;
  color: #666;
}

.no-results {
  text-align: center;
  padding: 3rem;
  color: #666;
  font-size: 1.1rem;
}

.error-message {
  text-align: center;
  padding: 3rem;
  color: var(--error-color);
  font-size: 1.1rem;
}

/* Responsive - Mobile First Approach */
@media (max-width: 1024px) {
  .welcome-content {
    gap: 30px;
  }

  .game-title {
    font-size: 2rem;
  }
}

@media (max-width: 768px) {
  /* Container adjustments */
  .container {
    width: 95%;
    padding: 15px;
  }

  /* Header responsive */
  header {
    padding: 0.6rem 0;
    border-bottom-width: 2px;
  }

  .header-container {
    flex-direction: row;
    gap: 8px;
    padding: 0 10px;
    align-items: center;
  }

  .header-brand {
    gap: 8px;
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .header-logo {
    height: 32px;
    flex-shrink: 0;
  }

  .header-title-wrapper {
    padding-left: 8px;
    border-left-width: 1px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .header-title {
    font-size: 0.95rem;
    line-height: 1.2;
    margin: 0;
  }

  .header-title-link {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
  }

  .header-nav {
    gap: 6px;
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .btn-exit,
  .btn-leaderboard-link {
    font-size: 0.75rem;
    padding: 6px 12px;
    border-width: 1.5px;
    white-space: nowrap;
  }

  /* Welcome Screen */
  .welcome-content {
    grid-template-columns: 1fr;
    gap: 25px;
    padding: 0.5rem 0;
    align-items: center;
  }

  .welcome-main {
    padding: 2rem 1.5rem;
    height: auto;
  }

  .leaderboard-preview {
    height: auto;
  }

  .game-title {
    font-size: 1.8rem;
    margin-bottom: 8px;
  }

  .game-subtitle {
    font-size: 1rem;
  }

  .game-logo {
    margin-bottom: 1.5rem;
  }

  .form-group {
    margin-bottom: 20px;
  }

  .form-input {
    padding: 10px 12px;
    font-size: 0.95rem;
  }

  .btn-start {
    font-size: 1.1rem;
    padding: 15px 30px;
    margin-top: 20px;
  }

  /* Leaderboard Preview */
  .leaderboard-preview {
    padding: 2rem 1.5rem;
  }

  .leaderboard-preview h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .preview-item {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .btn-view-leaderboard {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  /* Game Screen */
  .game-container {
    padding: 1.5rem;
    margin-top: 1rem;
  }

  .question-box {
    font-size: 1.2rem;
    min-height: 60px;
    padding: 0 10px;
  }

  .options-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .option-btn {
    padding: 12px;
    font-size: 1rem;
  }

  #hud {
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
  }

  #question-counter,
  #score,
  #timer-display {
    font-size: 0.9rem;
  }

  /* Theme Selection */
  .theme-selection-title {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
  }

  .theme-selection-subtitle {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }

  .game-container {
    padding: 1rem;
    margin-top: 0.5rem;
  }

  .themes-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 0;
  }

  .theme-card {
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
    gap: 0.75rem;
  }

  .theme-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .theme-card h3 {
    font-size: 1rem;
    margin-bottom: 0;
    flex: 1;
  }

  .theme-card p {
    font-size: 0.85rem;
    -webkit-line-clamp: 6;
    line-clamp: 6;
  }

  .theme-card .theme-icon {
    font-size: 2rem;
    align-self: flex-start;
    padding-top: 0;
  }

  .theme-card .start-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    align-self: stretch;
    margin-top: 0;
    width: 100%;
  }

  /* Leaderboard */
  .leaderboard-header {
    margin-bottom: 1.5rem;
  }

  .leaderboard-title {
    font-size: 2rem;
  }

  .leaderboard-subtitle {
    font-size: 1rem;
  }

  .leaderboard-controls {
    flex-direction: column;
    gap: 15px;
    padding: 1.25rem;
  }

  .leaderboard-filters {
    width: 100%;
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
    min-width: auto;
  }

  .filter-select {
    width: 100%;
    min-width: auto;
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .btn-back-home {
    width: 100%;
    text-align: center;
  }

  .filter-label {
    font-size: 0.85rem;
  }

  .leaderboard-table-container {
    padding: 1rem;
    overflow-x: auto;
  }

  .leaderboard-table {
    font-size: 0.8rem;
    min-width: 600px;
    table-layout: auto;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 10px 8px;
  }

  .leaderboard-table th {
    font-size: 0.85rem;
  }

  .btn-back-home {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  /* Feedback Overlay */
  .feedback-overlay {
    padding: 0.75rem;
    align-items: flex-start;
    padding-top: 1rem;
  }

  .feedback-content {
    font-size: 1.2rem;
    padding: 1.5rem 1.25rem;
    max-height: 85vh;
    margin: auto;
    width: calc(100% - 1.5rem);
  }

  .feedback-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .feedback-content p {
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0.4rem 0;
  }

  #feedback-icon {
    font-size: 3.5rem !important;
    margin-bottom: 0.75rem;
  }

  .feedback-content .btn {
    margin-top: 1rem;
    padding: 10px 20px;
    font-size: 0.9rem;
    width: 100%;
  }

  .result-score {
    font-size: 1.4rem;
    margin-bottom: 1rem;
  }

  .result-details {
    font-size: 1rem;
    margin-top: 1rem;
    line-height: 1.6;
  }

  .result-details p {
    margin: 0.5rem 0;
  }

  .result-percentage {
    font-size: 1.1rem;
    margin-top: 0.75rem !important;
  }

  .result-message {
    margin-top: 1.25rem;
    font-size: 1.1rem;
  }

  /* Question Image */
  .question-image {
    max-height: 250px;
  }
}

@media (max-width: 480px) {
  /* Extra small devices */
  .container {
    width: 100%;
    padding: 10px;
  }

  header {
    padding: 0.5rem 0;
    border-bottom-width: 2px;
  }

  .header-container {
    flex-direction: row;
    gap: 6px;
    padding: 0 8px;
    align-items: center;
  }

  .header-brand {
    gap: 6px;
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .header-logo {
    height: 28px;
    flex-shrink: 0;
  }

  .header-title-wrapper {
    padding-left: 6px;
    border-left-width: 1px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .header-title {
    font-size: 0.85rem;
    line-height: 1.2;
    margin: 0;
  }

  .header-title-link {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
  }

  .header-nav {
    gap: 4px;
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .btn-exit,
  .btn-leaderboard-link {
    font-size: 0.7rem;
    padding: 5px 10px;
    border-width: 1px;
    white-space: nowrap;
  }

  .btn-exit span,
  .btn-leaderboard-link span {
    margin-right: 3px;
  }

  .welcome-main {
    padding: 1.5rem 1rem;
  }

  .game-title {
    font-size: 1.5rem;
  }

  .game-subtitle {
    font-size: 0.9rem;
  }

  .form-input {
    font-size: 16px; /* Evita zoom en iOS */
  }

  .btn-start {
    font-size: 1rem;
    padding: 12px 25px;
  }

  .leaderboard-preview {
    padding: 1.5rem 1rem;
  }

  .leaderboard-preview h3 {
    font-size: 1.3rem;
  }

  .game-container {
    padding: 1rem;
    border-radius: 8px;
  }

  .question-box {
    font-size: 1.1rem;
    min-height: 50px;
  }

  .option-btn {
    padding: 10px;
    font-size: 0.95rem;
  }

  .leaderboard-title {
    font-size: 1.5rem;
  }

  .leaderboard-subtitle {
    font-size: 0.9rem;
  }

  .leaderboard-table {
    font-size: 0.75rem;
    min-width: 500px;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 8px 5px;
  }

  .theme-selection-title {
    font-size: 1.4rem;
  }

  .theme-selection-subtitle {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
  }

  .themes-grid {
    gap: 10px;
  }

  .theme-card {
    padding: 0.875rem;
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
    gap: 0.625rem;
  }

  .theme-card-header {
    margin-bottom: 0.25rem;
  }

  .theme-card h3 {
    font-size: 0.95rem;
  }

  .theme-card p {
    font-size: 0.8rem;
    -webkit-line-clamp: 10;
    line-clamp: 10;
  }

  .theme-card .theme-icon {
    font-size: 1.75rem;
  }

  .theme-card .start-btn {
    padding: 10px 18px;
    font-size: 0.85rem;
    width: 100%;
    margin-top: auto;
  }

  .feedback-overlay {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 0.75rem;
  }

  .feedback-content {
    font-size: 1rem;
    padding: 1.25rem 1rem;
    max-height: 90vh;
    margin: auto;
    width: calc(100% - 1rem);
    border-radius: 12px;
  }

  .feedback-content h2 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    line-height: 1.2;
  }

  .feedback-content p {
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0.3rem 0;
  }

  #feedback-icon {
    font-size: 3rem !important;
    margin-bottom: 0.5rem;
  }

  .feedback-content .btn {
    margin-top: 0.75rem;
    padding: 10px 18px;
    font-size: 0.85rem;
    width: 100%;
  }

  .result-score {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
  }

  .result-details {
    font-size: 0.9rem;
    margin-top: 0.75rem;
    line-height: 1.5;
  }

  .result-details p {
    margin: 0.4rem 0;
  }

  .result-percentage {
    font-size: 1rem;
    margin-top: 0.625rem !important;
  }

  .result-message {
    margin-top: 1rem;
    font-size: 1rem;
  }

  .question-image {
    max-height: 200px;
  }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .welcome-content {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .game-title {
    font-size: 1.5rem;
  }

  .game-subtitle {
    font-size: 0.9rem;
  }

  .welcome-main {
    padding: 1.5rem;
  }

  .leaderboard-preview {
    padding: 1.5rem;
  }

  #welcome-screen {
    min-height: auto;
    padding: 1rem 0;
  }
}
