/* ===== TOKEN DI DESIGN =====
   Palette "spazio profondo": blu indaco scurissimo di fondo,
   ambra come colore della navicella (accento caldo, non il solito
   arancio/terracotta), viola tenue per i meteoriti.
*/
:root {
  --bg-deep: #0b0e1a;
  --bg-panel: #12172a;
  --accent-amber: #ffb454;
  --accent-violet: #7c6ff0;
  --text-main: #eef0fb;
  --text-dim: #8891b5;
  --danger: #ff5d6c;
}

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

body {
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Courier New', Courier, monospace;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 480px;
  max-height: 800px;
  background: var(--bg-panel);
  box-shadow: 0 0 60px rgba(124, 111, 240, 0.15);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 0%, #171e35 0%, var(--bg-deep) 70%);
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 14px 18px;
  z-index: 10;
  font-size: 14px;
  letter-spacing: 1px;
  pointer-events: none;
}

.hud-item {
  color: var(--text-dim);
  text-shadow: 0 0 10px rgba(0,0,0,0.6);
}

.hud-item span {
  color: var(--accent-amber);
  font-weight: bold;
  margin-left: 6px;
}

#lives {
  color: var(--danger) !important;
  letter-spacing: 2px;
}

/* ===== SCHERMATE OVERLAY (start / game over) ===== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 14, 26, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 20;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none;
}

.overlay h1 {
  font-size: 28px;
  letter-spacing: 3px;
  color: var(--accent-amber);
  text-shadow: 0 0 20px rgba(255, 180, 84, 0.5);
  margin-bottom: 16px;
  animation: pulse-glow 2s ease-in-out infinite;
}

.overlay p {
  color: var(--text-dim);
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.overlay p b {
  color: var(--accent-violet);
}

#finalScore {
  font-size: 20px;
  color: var(--text-main);
  margin: 12px 0;
}

#newRecord {
  color: var(--accent-amber);
  font-weight: bold;
  margin-bottom: 16px;
  animation: pulse-glow 1s ease-in-out infinite;
}

/* ===== STILI HALL OF FAME ===== */
#hall-of-fame {
  margin: 15px 0;
  padding: 12px 18px;
  background: rgba(18, 23, 42, 0.85);
  border: 1px solid var(--accent-violet);
  border-radius: 6px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 0 15px rgba(124, 111, 240, 0.2);
}

#hall-of-fame h3 {
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--accent-amber);
  margin-bottom: 10px;
  text-align: center;
}

#hall-of-fame ol {
  padding-left: 24px;
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
}

#hall-of-fame li {
  margin-bottom: 4px;
}

#hall-of-fame li strong {
  color: var(--accent-violet);
}

button {
  margin-top: 15px;
  padding: 14px 36px;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 2px;
  font-weight: bold;
  color: var(--bg-deep);
  background: var(--accent-amber);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 180, 84, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 28px rgba(255, 180, 84, 0.6);
}

button:active {
  transform: translateY(0);
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ===== CONTROLLI TOUCH (mobile) ===== */
#touch-controls {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 15;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(124, 111, 240, 0.2);
  border: 2px solid var(--accent-violet);
  color: var(--text-main);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  margin-top: 0;
}

.touch-btn:active {
  background: rgba(124, 111, 240, 0.45);
}

/* Su desktop nascondiamo i controlli touch e mostriamo l'hint tastiera */
.mobile-only { display: none; }
.desktop-only { display: block; }

@media (hover: none) and (pointer: coarse) {
  .mobile-only { display: block; }
  .desktop-only { display: none; }
  #touch-controls { display: flex; }
}

@media (hover: hover) and (pointer: fine) {
  #touch-controls { display: none; }
}





/* SEZIONE QUIZ */
#quiz-container {
  width: 90%;
  max-width: 480px;
  margin: 20px auto;
  padding: 15px;
  background: #1a1f36;
  border-radius: 5px;
}

#quiz-container h2 {
  color: #ffb454;
  margin-bottom: 15px;
}

.domanda {
  background: #0d111e;
  padding: 10px;
  margin-bottom: 10px;
  border-left: 2px solid #7c6ff0;
  text-align: left;
}

.domanda p {
  font-weight: bold;
  margin-bottom: 5px;
}

#quiz-container button {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: #ffb454;
  border: none;
  font-weight: bold;
  cursor: pointer;
}

#esito {
  margin-top: 10px;
  font-size: 16px;
  font-weight: bold;
  color: #5ddcff;
}