* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #99f6e4;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --lat-color: #e11d48;
  --lon-color: #2563eb;
  --success: #10b981;
  --error: #dc2626;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

html, body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: 'Fredoka', sans-serif; }

.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active, .screen:not(.hidden) { display: flex; }
.hidden { display: none !important; }

/* MENU */
#mainMenu { align-items: center; justify-content: center; padding: 2rem; }
.hub-card {
  background: var(--card); padding: 3rem; border-radius: 24px; 
  box-shadow: var(--shadow); text-align: center; max-width: 600px; width: 100%;
}
.hub-card h1 { font-size: 2.5rem; color: var(--primary-dark); margin-bottom: 0.5rem; }
.subtitle { color: var(--text-light); margin-bottom: 2rem; }
.menu-buttons { display: flex; flex-direction: column; gap: 1rem; }
.author-credit { margin-top: 2rem; font-size: 0.85rem; color: var(--text-light); border-top: 1px solid var(--border); padding-top: 1rem;}

/* BOTTONI */
button { font-family: 'Outfit', sans-serif; font-weight: 600; border: none; cursor: pointer; transition: all 0.2s; border-radius: 12px; }
.btn-primary { background: var(--primary); color: white; padding: 0.875rem 1.5rem; font-size: 1.1rem; box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); }
.btn-accent { background: var(--accent); color: white; padding: 0.875rem 1.5rem; font-size: 1.1rem; box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3); }
.btn-accent:hover { background: var(--accent-dark); transform: translateY(-2px); }
.btn-secondary { background: var(--primary-light); color: var(--primary-dark); padding: 0.625rem 1.2rem; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 0.5rem 1rem; }
.btn-ghost:hover { background: var(--border); }

/* LAYOUT COMUNE */
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--border); }
.top-bar h2 { color: var(--primary-dark); }
.content-box { padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%; }
.center-content { text-align: center; }
.content-box h3 { color: var(--text); margin-bottom: 1.5rem; font-size: 1.5rem; }

/* LEZIONI */
.lesson-text { background: var(--card); padding: 1.5rem 2rem; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 1.5rem; font-size: 1.1rem; line-height: 1.6; min-height: 120px; }
.lesson-text h3 { color: var(--primary-dark); margin-bottom: 0.5rem; }
.lesson-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.dots { display: flex; gap: 0.5rem; }
.dot { width: 10px; height: 10px; background: var(--border); border-radius: 50%; }
.dot.active { background: var(--primary); width: 25px; border-radius: 5px; }

/* HUB GIOCHI */
.map-selector { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
.map-card { background: var(--card); padding: 2rem; border-radius: 20px; box-shadow: var(--shadow); width: 220px; cursor: pointer; transition: transform 0.2s; border: 2px solid transparent; }
.map-card:hover { transform: translateY(-5px); border-color: var(--primary); }
.map-icon { font-size: 3rem; margin-bottom: 1rem; }
.map-card h4 { color: var(--text); margin-bottom: 0.25rem; }
.map-card p { color: var(--text-light); font-size: 0.9rem; }

/* GIOCO */
.game-layout { display: flex; gap: 1.5rem; padding: 1.5rem; max-width: 1400px; margin: 0 auto; width: 100%; }
.game-sidebar { width: 250px; background: var(--card); border-radius: 16px; padding: 1.5rem; box-shadow: var(--shadow); height: fit-content; }
.game-sidebar h3 { font-size: 1.1rem; margin-bottom: 1rem; color: var(--primary-dark); }
.game-type-list { display: flex; flex-direction: column; gap: 0.5rem; }
.game-type-btn { text-align: left; background: var(--bg); border: 1px solid var(--border); padding: 0.75rem 1rem; border-radius: 10px; font-weight: 500; }
.game-type-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.game-type-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.game-main { flex: 1; display: flex; flex-direction: column; gap: 1rem; }
.game-stats span { font-weight: 600; color: var(--text-light); font-size: 0.9rem; }
.game-stats strong { color: var(--primary-dark); font-family: 'Fredoka'; font-size: 1.2rem; margin-left: 0.5rem; }

.instructions { background: var(--card); padding: 1rem 1.5rem; border-radius: 12px; border-left: 4px solid var(--accent); box-shadow: var(--shadow); }
.instructions h3 { font-size: 1.2rem; margin-bottom: 0.25rem; }
.instructions p { color: var(--text-light); }

.map-wrapper { background: var(--card); border-radius: 16px; padding: 0.5rem; box-shadow: var(--shadow); }
canvas { width: 100%; height: auto; aspect-ratio: 2 / 1; display: block; border-radius: 12px; cursor: crosshair; touch-action: manipulation; }

.map-legend { display: flex; gap: 1rem; justify-content: center; font-size: 0.8rem; color: var(--text-light); }
.legend-item { display: flex; align-items: center; gap: 0.25rem; }
.legend-line { width: 20px; height: 3px; border-radius: 2px; }

.answers-section { background: var(--card); padding: 1rem; border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-wrap: wrap; gap: 0.5rem; }
.answer-btn { background: var(--bg); border: 1px solid var(--border); padding: 0.5rem 1rem; border-radius: 8px; font-weight: 500; }
.answer-btn:hover { border-color: var(--primary); }
.answer-btn.correct { background: var(--success); color: white; }
.answer-btn.wrong { background: var(--error); color: white; }

.feedback-box { padding: 0.75rem 1rem; border-radius: 8px; font-weight: 500; display: none; }
.feedback-box.show { display: block; animation: slideIn 0.3s; }
.feedback-box.correct { background: #d1fae5; color: #065f46; }
.feedback-box.error { background: #fee2e2; color: #991b1b; }
@keyframes slideIn { from {opacity: 0; transform: translateY(-10px);} to {opacity: 1; transform: translateY(0);} }

.controls { display: flex; gap: 0.5rem; }
.ctrl-btn { background: var(--card); border: 1px solid var(--border); padding: 0.5rem 1rem; border-radius: 8px; }
.ctrl-btn.help { border-color: var(--accent); color: var(--accent-dark); }