/* Reset e base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -ms-touch-action: none;
  touch-action: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Container principale - si adatta all'iframe */
#game-container {
  width: 100vw;
  height: 100vh;
  max-width: 800px;
  max-height: 450px;
  position: relative;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Schermate */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

.overlay {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
}

/* Menu Iniziale */
#start-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
  color: white;
  padding: 20px;
}

#start-screen h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  margin-bottom: 15px;
  text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
}

#start-screen p {
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  margin-bottom: 20px;
  opacity: 0.9;
}

.best-score {
  font-size: clamp(1rem, 2.8vw, 1.4rem);
  margin-bottom: 30px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

/* Header di gioco */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.1);
}

.stats {
  display: flex;
  gap: 15px;
}

.stat {
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 12px;
  border-radius: 15px;
  color: white;
  font-size: clamp(0.8rem, 2vw, 1rem);
  font-weight: 600;
  backdrop-filter: blur(10px);
}

#streak-container.frozen {
  background: rgba(100, 200, 255, 0.3);
  border: 2px solid rgba(100, 200, 255, 0.5);
  animation: frozenPulse 2s ease-in-out infinite;
}

@keyframes frozenPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(100, 200, 255, 0.5); }
  50% { box-shadow: 0 0 20px rgba(100, 200, 255, 0.8); }
}

/* Active Boosters Indicator */
.active-boosters {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.1);
  flex-wrap: wrap;
}

.booster-badge {
  background: linear-gradient(135deg, #ffd700, #ffed4a);
  color: #2c3e50;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: clamp(0.7rem, 1.8vw, 0.9rem);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Area domanda */
.question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  text-align: center;
}

.question {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: bold;
  color: white;
  margin-bottom: 30px;
  text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.5s ease;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  width: 100%;
  max-width: 400px;
}

/* Bottoni */
.btn {
  border: none;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
  padding: 12px 20px;
}

.btn.primary {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(255, 107, 107, 0.6);
}

.btn.primary:active {
  transform: translateY(0);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn.secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn.small {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.2rem;
}

.btn.large-btn {
  padding: 14px 30px;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 700;
  min-width: 200px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.btn.large-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.option-btn {
  background: linear-gradient(135deg, #ffffff, #f1f2f6);
  color: #2c3e50;
  border: none;
  border-radius: 15px;
  padding: 15px;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.option-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.option-btn.correct {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: white;
  animation: correctPulse 0.5s ease;
}

.option-btn.wrong {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  animation: wrongShake 0.5s ease;
}

/* Booster Screen */
.booster-info {
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  font-size: clamp(0.75rem, 1.8vw, 0.9rem);
  line-height: 1.2;
  font-weight: 500;
}

.booster-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 10px 0;
  width: 100%;
}

.booster-card {
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.booster-card:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}

.booster-card.active {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.25);
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.6);
  animation: boosterActivePulse 2s ease-in-out infinite;
}

@keyframes boosterActivePulse {
  0%, 100% { box-shadow: 0 0 20px rgba(46, 204, 113, 0.6); }
  50% { box-shadow: 0 0 30px rgba(46, 204, 113, 0.8); }
}

.booster-icon {
  font-size: clamp(1.8rem, 4vw, 2.3rem);
  line-height: 1;
  margin-bottom: 2px;
}

.booster-card h3 {
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
  margin: 0;
  color: white;
  line-height: 1.1;
  font-weight: 700;
}

.booster-desc {
  font-size: clamp(0.7rem, 1.7vw, 0.85rem);
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  line-height: 1.2;
  font-weight: 500;
}

.booster-btn {
  width: 100%;
  padding: 8px 6px;
  font-size: clamp(0.75rem, 1.8vw, 0.9rem);
  margin-top: auto;
}

.booster-status {
  font-size: clamp(0.65rem, 1.6vw, 0.8rem);
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
  line-height: 1;
}

.booster-status.active {
  color: #2ecc71;
  font-size: clamp(0.7rem, 1.7vw, 0.85rem);
  font-weight: 700;
}

.booster-summary {
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: clamp(0.8rem, 1.9vw, 0.95rem);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  transition: all 0.3s ease;
  line-height: 1;
}

.booster-summary.has-boosters {
  background: rgba(46, 204, 113, 0.25);
  border-color: #2ecc71;
  color: #2ecc71;
  box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
}

.booster-summary #boosters-count {
  font-size: clamp(1rem, 2.3vw, 1.2rem);
  font-weight: 800;
  color: #ffd700;
}

.start-btn {
  width: 100%;
  max-width: 280px;
  padding: 12px 20px;
  font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  font-weight: 700;
  margin: 8px auto 0;
}

.booster-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Continue Screen */
.continue-offer {
  margin: 10px 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 15px;
}

.continue-icon {
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  margin-bottom: 8px;
  line-height: 1;
}

.continue-offer h3 {
  font-size: clamp(1.1rem, 2.8vw, 1.4rem);
  margin-bottom: 8px;
  color: white;
  line-height: 1.2;
}

.continue-offer p {
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: rgba(255, 255, 255, 0.9);
  margin: 4px 0;
  line-height: 1.3;
}

.continue-highlight {
  color: #ffd700 !important;
  font-weight: 700;
}

/* Menu overlay */
.menu {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 25px 20px;
  margin: auto;
  text-align: center;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 90%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.menu.compact {
  max-width: 550px;
  padding: 22px 18px;
  gap: 12px;
}

.menu.compact-booster {
  max-width: 500px;
  max-height: 95%;
  padding: 15px;
  gap: 8px;
  overflow: visible;
}

.menu.compact-gameover {
  max-width: 480px;
  max-height: 95%;
  padding: 15px;
  gap: 8px;
  overflow: visible;
}

.menu.compact-continue {
  max-width: 450px;
  max-height: 95%;
  padding: 15px;
  gap: 10px;
  overflow: visible;
}

.menu h2 {
  font-size: clamp(1.3rem, 3.5vw, 1.7rem);
  margin-bottom: 8px;
  line-height: 1;
}

.final-score-display {
  margin: 8px 0;
}

.continue-score-display {
  margin: 8px 0 10px;
}

.big-score {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: bold;
  color: #ffd700;
  text-shadow: 2px 2px 10px rgba(255, 215, 0, 0.5);
  line-height: 1;
}

.new-record {
  background: linear-gradient(135deg, #ffd700, #ffed4a);
  color: #2c3e50;
  padding: 6px 12px;
  border-radius: 10px;
  margin: 8px auto;
  font-weight: bold;
  font-size: clamp(0.8rem, 1.9vw, 0.95rem);
  animation: recordPulse 1s ease infinite alternate;
  display: inline-block;
}

.new-record.hidden {
  display: none;
}

.stats-summary {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: clamp(0.85rem, 2vw, 0.95rem);
}

.stats-summary.compact {
  padding: 8px 10px;
  margin: 8px 0;
  font-size: clamp(0.8rem, 1.9vw, 0.9rem);
}

.stats-summary div {
  margin: 3px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.stats-summary span {
  opacity: 0.85;
  min-width: 20px;
}

.stats-summary strong {
  font-weight: 700;
}

.boosters-used {
  color: #ffd700;
  font-weight: 600;
  margin: 8px 0;
  padding: 8px;
  background: rgba(255, 215, 0, 0.15);
  border-radius: 8px;
  font-size: clamp(0.75rem, 1.8vw, 0.85rem);
  line-height: 1.3;
}

.pause-boosters-info {
  background: rgba(255, 215, 0, 0.2);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 18px;
  font-size: clamp(0.9rem, 2.1vw, 1rem);
  color: #ffd700;
}

.buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.buttons .btn {
  flex: 1;
  min-width: 120px;
  max-width: 180px;
}

/* Animazioni */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes recordPulse {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}

/* Responsive per schermi molto piccoli */
@media (max-width: 400px) or (max-height: 300px) {
  .options {
    grid-template-columns: 1fr;
    max-width: 250px;
  }
  
  .stats {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .stat {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .booster-options {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .menu {
    padding: 15px 12px;
  }
  
  .menu.compact {
    padding: 15px 12px;
  }
  
  .menu.compact-booster {
    padding: 12px 10px;
    gap: 6px;
  }
  
  .booster-card {
    padding: 8px 6px;
  }
  
  .booster-icon {
    font-size: 1.6rem;
  }
}

/* Landscape mobile optimization */
@media (max-height: 450px) and (orientation: landscape) {
  .menu.compact {
    max-height: 95vh;
    padding: 15px;
  }
  
  .menu.compact-booster {
    max-height: 95vh;
    padding: 10px 12px;
    gap: 5px;
  }
  
  .menu.compact-gameover {
    max-height: 95vh;
    padding: 12px;
    gap: 6px;
  }
  
  .menu.compact-continue {
    max-height: 95vh;
    padding: 12px;
    gap: 8px;
  }
  
  .menu h2 {
    font-size: 1.1rem;
    margin-bottom: 5px;
  }
  
  .booster-options {
    gap: 8px;
    margin: 6px 0;
  }
  
  .booster-card {
    padding: 8px 6px;
    gap: 4px;
  }
  
  .booster-icon {
    font-size: 1.5rem;
    margin-bottom: 0;
  }
  
  .booster-card h3 {
    font-size: 0.85rem;
  }
  
  .booster-btn {
    padding: 6px 4px;
    font-size: 0.75rem;
  }
  
  .booster-status {
    font-size: 0.65rem;
  }
  
  .booster-summary {
    padding: 6px 10px;
    margin: 5px 0;
    font-size: 0.8rem;
  }
  
  .booster-info {
    font-size: 0.7rem;
    margin: 0;
  }
  
  .start-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
    margin-top: 5px;
  }
  
  .big-score {
    font-size: 1.8rem;
  }
  
  .new-record {
    padding: 5px 10px;
    margin: 5px auto;
    font-size: 0.75rem;
  }
  
  .stats-summary {
    padding: 6px 8px;
    margin: 6px 0;
    font-size: 0.75rem;
  }
  
  .stats-summary div {
    margin: 2px 0;
  }
  
  .boosters-used {
    padding: 5px;
    margin: 5px 0;
    font-size: 0.7rem;
  }
  
  .continue-offer {
    margin: 8px 0;
    padding: 10px;
  }
  
  .continue-icon {
    font-size: 1.8rem;
    margin-bottom: 5px;
  }
  
  .continue-offer h3 {
    font-size: 1rem;
    margin-bottom: 5px;
  }
  
  .continue-offer p {
    font-size: 0.8rem;
    margin: 3px 0;
  }
  
  .buttons {
    margin-top: 8px;
    gap: 8px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
}

/* Nasconde il gioco durante le ads */
body.ad-active #game-container {
  opacity: 0;
  pointer-events: none;
}