/* ============================================================
   ACCESSIBILITÀ IMPOSSIBLE — CSS completo
   Versione con immagini realistiche
============================================================ */

* {
  box-sizing: border-box;
}

:root {
  --bg-main: #0f172a;
  --bg-soft: #111827;
  --card-bg: #1f2937;
  --card-bg-soft: #243244;
  --border: rgba(255, 255, 255, 0.12);
  --text: #f9fafb;
  --muted: #cbd5e1;
  --muted-2: #94a3b8;
  --accent: #14b8a6;
  --accent-blue: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #facc15;
  --radius: 22px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.16), transparent 34%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.18), transparent 34%),
    linear-gradient(135deg, #0f172a, #020617);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

button {
  cursor: pointer;
}

.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  padding: 48px 24px;
}

.screen.active {
  display: block;
}

.hidden {
  display: none !important;
}

.container,
.menu-container,
.level-container,
.complete-container {
  width: min(1180px, 100%);
  margin: 0 auto;
}

/* ============================================================
   MENU PRINCIPALE
============================================================ */

.menu-header {
  text-align: center;
  margin-bottom: 48px;
}

.menu-header h1,
.main-title {
  margin: 0;
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.06em;
}

.main-title span,
.gradient-text {
  display: block;
  background: linear-gradient(135deg, #60a5fa, #14b8a6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.menu-header p,
.subtitle {
  max-width: 880px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 600;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px;
  align-items: stretch;
}

.level-card {
  min-height: 230px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(31, 41, 55, 0.94), rgba(15, 23, 42, 0.95));
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  outline: none;
}

.level-card:hover,
.level-card:focus-visible {
  transform: translateY(-6px);
  border-color: rgba(20, 184, 166, 0.75);
  box-shadow: 0 22px 70px rgba(20, 184, 166, 0.16);
}

.level-card.completed {
  border-color: rgba(34, 197, 94, 0.65);
  background:
    linear-gradient(145deg, rgba(22, 101, 52, 0.28), rgba(15, 23, 42, 0.95));
}

.level-card-number {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.level-card-icon {
  display: block;
  margin-bottom: 18px;
  font-size: 2rem;
}

.level-card-title {
  margin: 0 0 12px;
  color: #ffffff;
  font-size: 1.45rem;
  line-height: 1.2;
}

.level-card-desc {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 1rem;
}

.level-card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ============================================================
   BARRA LIVELLO
============================================================ */

.level-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  width: min(1180px, 100%);
  margin: 0 auto 34px;
  padding: 18px 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 0 20px 20px;
  background: rgba(2, 6, 23, 0.86);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

#back-to-menu-btn,
#menu-btn,
.back-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

#back-to-menu-btn:hover,
#menu-btn:hover,
.back-btn:hover {
  color: #ffffff;
}

#level-badge,
.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #60a5fa, #14b8a6);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#level-title-small {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

#score-text {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 900;
}

#timer-display {
  display: none !important;
}

/* ============================================================
   INTRO LIVELLO
============================================================ */

.level-intro-card,
#level-intro {
  width: min(900px, 100%);
  margin: 60px auto;
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(31, 41, 55, 0.82);
  box-shadow: var(--shadow);
  text-align: center;
}

#intro-title {
  margin: 0 0 22px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.1;
}

#intro-narrative {
  margin: 0 auto 34px;
  max-width: 760px;
  color: var(--muted);
  font-size: 1.12rem;
}

.primary-btn,
.secondary-btn,
#start-level-btn,
#next-step-btn,
#next-level-btn,
#restart-btn,
#final-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 14px 28px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
  color: white;
  font-size: 1rem;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 12px 30px rgba(20, 184, 166, 0.22);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
#start-level-btn:hover,
#next-step-btn:hover,
#next-level-btn:hover,
#restart-btn:hover,
#final-menu-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

/* ============================================================
   IMMAGINI REALISTICHE LIVELLO
============================================================ */

#scene-container {
  width: min(900px, 100%);
  margin: 0 auto 34px;
}

.realistic-scene {
  position: relative;
  width: 100%;
  border-radius: 26px;
  overflow: hidden;
  background: #0f172a;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.level-real-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.scene-overlay {
  position: absolute;
  left: 24px;
  bottom: 24px;
  right: 24px;
  padding: 18px 22px;
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(10px);
  color: #ffffff;
}

.scene-overlay h2 {
  margin: 8px 0 4px;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  line-height: 1.1;
}

.scene-overlay p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.scene-level-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   DOMANDE E OPZIONI
============================================================ */

#level-game {
  width: min(900px, 100%);
  margin: 0 auto;
}

#step-counter {
  margin: 20px 0 10px;
  color: var(--accent);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#step-question {
  margin: 0 auto 28px;
  max-width: 820px;
  color: #ffffff;
  text-align: center;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.25;
}

#options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.option-card {
  min-height: 108px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(31, 41, 55, 0.92);
  display: flex;
  align-items: center;
  gap: 18px;
  color: #ffffff;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  outline: none;
}

.option-card:hover,
.option-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(20, 184, 166, 0.8);
  background: rgba(36, 50, 68, 0.98);
}

.option-card.disabled {
  pointer-events: none;
  opacity: 0.88;
}

.option-card.correct {
  border-color: rgba(34, 197, 94, 0.85);
  background: rgba(22, 101, 52, 0.38);
}

.option-card.wrong {
  border-color: rgba(239, 68, 68, 0.85);
  background: rgba(127, 29, 29, 0.38);
}

.option-letter {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #93c5fd;
  font-weight: 900;
}

.option-text {
  font-size: 1.06rem;
  font-weight: 800;
}

/* ============================================================
   FEEDBACK
============================================================ */

#step-feedback {
  width: min(760px, 100%);
  margin: 80px auto;
}

.feedback-card {
  padding: clamp(30px, 5vw, 54px);
  border-radius: 28px;
  background: rgba(19, 78, 74, 0.38);
  border: 1px solid rgba(45, 212, 191, 0.18);
  box-shadow: var(--shadow);
  text-align: center;
}

#feedback-icon {
  display: block;
  margin-bottom: 18px;
  font-size: 4rem;
}

#feedback-title {
  margin: 0 0 14px;
  color: #4ade80;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

#feedback-text {
  margin: 0 auto 30px;
  max-width: 680px;
  color: var(--muted);
  font-size: 1.15rem;
}

/* ============================================================
   COMPLETAMENTO LIVELLO
============================================================ */

#level-complete {
  width: min(820px, 100%);
  margin: 70px auto;
}

.complete-card,
.level-complete-card {
  padding: clamp(30px, 5vw, 58px);
  border-radius: 30px;
  background: rgba(31, 41, 55, 0.88);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

#complete-title {
  margin: 0 0 18px;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

#level-score {
  margin: 0 0 24px;
  color: var(--accent);
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 900;
}

#educational-text {
  margin: 0 auto 34px;
  max-width: 700px;
  color: var(--muted);
  font-size: 1.18rem;
  font-weight: 700;
}

.complete-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}

/* ============================================================
   SCHERMATA FINALE
============================================================ */

#complete-screen {
  text-align: center;
}

.final-card {
  width: min(880px, 100%);
  margin: 60px auto;
  padding: clamp(34px, 6vw, 70px);
  border-radius: 34px;
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid rgba(20, 184, 166, 0.28);
  box-shadow: var(--shadow);
}

.final-card h1,
#complete-screen h1 {
  margin: 0 0 20px;
  font-size: clamp(2.4rem, 6vw, 4.5rem);
}

#total-score {
  margin: 22px 0;
  color: var(--accent);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
}

#final-rank {
  margin: 0 0 30px;
  color: var(--warning);
  font-size: 1.6rem;
  font-weight: 900;
}

/* ============================================================
   ANIMAZIONI
============================================================ */

.animate-fade-in {
  animation: fadeIn 0.45s ease both;
}

.animate-bounce {
  animation: bounce 0.45s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {
  0% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.12);
  }

  100% {
    transform: scale(1);
  }
}

/* ============================================================
   RESPONSIVE
============================================================ */

@media (max-width: 980px) {
  .levels-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-topbar {
    flex-wrap: wrap;
  }

  .topbar-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .screen {
    padding: 28px 16px;
  }

  .levels-grid,
  #options-grid {
    grid-template-columns: 1fr;
  }

  .level-card {
    min-height: auto;
  }

  .level-topbar {
    position: static;
    padding: 16px;
    border-radius: 18px;
  }

  #level-title-small {
    font-size: 0.92rem;
  }

  .realistic-scene {
    border-radius: 18px;
  }

  .level-real-image {
    aspect-ratio: 4 / 3;
  }

  .scene-overlay {
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 14px 16px;
  }

  .scene-overlay h2 {
    font-size: 1.25rem;
  }

  .scene-overlay p {
    font-size: 0.9rem;
  }

  .option-card {
    min-height: auto;
    padding: 18px;
  }

  .option-text {
    font-size: 1rem;
  }
}

@media (max-width: 460px) {
  .menu-header h1,
  .main-title {
    font-size: 3rem;
  }

  .topbar-left,
  .topbar-center,
  .topbar-right {
    width: 100%;
    justify-content: center;
  }

  .complete-actions {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  #start-level-btn,
  #next-step-btn,
  #next-level-btn,
  #restart-btn,
  #final-menu-btn {
    width: 100%;
  }
}