:root {
  --bg-deep: #05010f;
  --neon-cyan: #33fff0;
  --neon-magenta: #ff2fd0;
  --neon-purple: #8b5cf6;
  --neon-green: #39ff8f;
  --panel-bg: rgba(10, 6, 32, 0.86);
  --text-dim: #9fa8d0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Il nickname va comunque selezionabile/modificabile normalmente: il blocco sopra
   serve solo a evitare che i tap ripetuti sul resto dell'interfaccia (specialmente
   su iOS Safari) attivino la selezione di testo nativa. */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: 'Share Tech Mono', monospace;
  color: #eef1ff;
  touch-action: none;
  overscroll-behavior: none;
}

#game-root {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--bg-deep);
}

/* Icon button (es. toggle audio) */
.icon-btn {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(51, 255, 240, 0.4);
  background: rgba(10, 6, 32, 0.7);
  color: #eef1ff;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(2px);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* HUD */
#hud {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 5;
}

#score-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#score-live {
  position: relative;
  z-index: 2;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 2.4rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px var(--neon-cyan), 0 0 22px rgba(51, 255, 240, 0.6);
  letter-spacing: 2px;
}

/* Moltiplicatore trofei: un anello inclinato "alla Saturno" attorno al punteggio,
   sempre visibile durante il gioco. Il badge scorre lungo l'ellisse passando dietro
   (metà superiore, z-index sotto il punteggio) e davanti (metà inferiore, sopra). */
#score-ring-back,
#score-ring-front {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 170px;
  height: 50px;
  margin: -25px 0 0 -85px;
  border-radius: 50%;
  border: 2px solid rgba(51, 255, 240, 0.4);
  box-shadow: 0 0 10px rgba(51, 255, 240, 0.3);
  transform: rotate(-14deg);
  pointer-events: none;
}

#score-ring-back {
  clip-path: inset(0 0 50% 0);
  z-index: 1;
}

#score-ring-front {
  clip-path: inset(50% 0 0 0);
  z-index: 3;
}

#score-mult-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(10, 4, 20, 0.75);
  border: 1px solid rgba(51, 255, 240, 0.6);
  color: var(--neon-cyan);
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 0.72rem;
  text-shadow: 0 0 6px rgba(51, 255, 240, 0.8);
  box-shadow: 0 0 10px rgba(51, 255, 240, 0.5);
  animation: score-ring-orbit 8s linear infinite;
}

#score-mult-badge.is-boosted {
  color: #ffd23f;
  border-color: rgba(255, 210, 63, 0.7);
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.9);
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.6);
}

@keyframes score-ring-orbit {
  0%    { transform: translate(82.5px, -20.6px); z-index: 3; }
  12.5% { transform: translate(62.6px, 2.6px);   z-index: 3; }
  25%   { transform: translate(6.1px, 24.3px);   z-index: 3; }
  37.5% { transform: translate(-54px, 31.7px);   z-index: 3; }
  50%   { transform: translate(-82.5px, 20.6px); z-index: 1; }
  62.5% { transform: translate(-62.6px, -2.6px); z-index: 1; }
  75%   { transform: translate(-6.1px, -24.3px); z-index: 1; }
  87.5% { transform: translate(54px, -31.7px);   z-index: 1; }
  100%  { transform: translate(82.5px, -20.6px); z-index: 3; }
}

.powerup-status {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  min-height: 1.2em;
  color: var(--neon-green);
  text-shadow: 0 0 8px rgba(57, 255, 143, 0.7);
}

.powerup-status.star {
  color: #ffd23f;
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.8);
}

.powerup-status.fire {
  color: #ff7a3d;
  text-shadow: 0 0 10px rgba(255, 122, 61, 0.9);
}

.powerup-status.mult {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(51, 255, 240, 0.9);
}

.powerup-status.mini {
  color: #b98bff;
  text-shadow: 0 0 10px rgba(185, 139, 255, 0.9);
}

/* Toast riusabile per feedback transitorio (combo, quasi salvo, streak) */
.hud-toast {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 1px;
  color: #fff;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}

.hud-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hud-toast.toast-combo { color: var(--neon-magenta); text-shadow: 0 0 8px rgba(255, 47, 208, 0.8); }
.hud-toast.toast-nearmiss { color: var(--neon-cyan); text-shadow: 0 0 8px rgba(51, 255, 240, 0.8); }
.hud-toast.toast-streak { color: #ff9d3d; text-shadow: 0 0 8px rgba(255, 157, 61, 0.8); }
.hud-toast.toast-achievement { color: #ffd23f; text-shadow: 0 0 8px rgba(255, 210, 63, 0.8); }

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 20%, rgba(139, 92, 246, 0.18), transparent 60%), rgba(2, 1, 10, 0.55);
  backdrop-filter: blur(2px);
  z-index: 10;
  transition: opacity 0.2s ease;
}

.screen.hidden {
  display: none;
}

.screen-inner {
  width: 100%;
  max-width: 420px;
  background: var(--panel-bg);
  border: 1px solid rgba(51, 255, 240, 0.35);
  border-radius: 18px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.15), 0 0 40px rgba(139, 92, 246, 0.25), inset 0 0 30px rgba(51, 255, 240, 0.04);
  max-height: 92dvh;
  overflow-y: auto;
}

.title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 2.6rem;
  margin: 0 0 2px;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 10px var(--neon-magenta), 0 0 26px rgba(255, 47, 208, 0.6), 0 0 2px #fff;
}

.title.small {
  font-size: 1.7rem;
  letter-spacing: 2px;
}

.subtitle {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(51, 255, 240, 0.7);
  margin: 0 0 18px;
  font-size: 0.95rem;
}

.lore {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 24px;
}

.lore strong {
  color: var(--neon-green);
}

.btn {
  display: block;
  width: 100%;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 1rem;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 12px;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-magenta));
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 47, 208, 0.45);
}

.btn-ghost {
  background: transparent;
  color: var(--neon-cyan);
  border-color: rgba(51, 255, 240, 0.5);
}

.btn-install {
  background: transparent;
  color: var(--neon-green);
  border-color: rgba(57, 255, 143, 0.5);
}

/* Pulsante "condividi storia" quando si è sul podio: variante dorata in risalto */
.btn-podium {
  background: linear-gradient(135deg, #ffd23f, #ff9d3d);
  color: #1a0f00;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(255, 210, 63, 0.6);
  animation: podium-btn-pulse 1.6s ease-in-out infinite;
}

@keyframes podium-btn-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255, 210, 63, 0.5); }
  50% { box-shadow: 0 0 26px rgba(255, 210, 63, 0.9); }
}

.hint {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin: 10px 0 0;
  opacity: 0.8;
}

.row-buttons {
  display: flex;
  gap: 10px;
}

.row-buttons .btn {
  margin-bottom: 0;
}

.btn-icon {
  font-size: 1.5rem;
  padding: 10px;
  line-height: 1.2;
}

.score-box {
  margin: 6px 0 20px;
}

.score-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 3px;
}

.score-value {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 3.4rem;
  color: var(--neon-green);
  text-shadow: 0 0 12px rgba(57, 255, 143, 0.65);
  line-height: 1.1;
}

.best-score-line {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}

#best-score {
  color: var(--neon-cyan);
}

/* Banner podio (primi 3 posti in classifica dopo l'invio del punteggio) */
.podium-banner {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 10px;
  margin: 0 0 16px;
  border: 1px solid;
}

.podium-banner.rank-1 {
  color: #ffd23f;
  border-color: rgba(255, 210, 63, 0.5);
  background: rgba(255, 210, 63, 0.1);
  text-shadow: 0 0 10px rgba(255, 210, 63, 0.7);
}

.podium-banner.rank-2 {
  color: #d7d7e0;
  border-color: rgba(215, 215, 224, 0.5);
  background: rgba(215, 215, 224, 0.08);
  text-shadow: 0 0 10px rgba(215, 215, 224, 0.6);
}

.podium-banner.rank-3 {
  color: #e08c4f;
  border-color: rgba(224, 140, 79, 0.5);
  background: rgba(224, 140, 79, 0.1);
  text-shadow: 0 0 10px rgba(224, 140, 79, 0.6);
}

#nickname-form {
  margin-bottom: 6px;
}

.nickname-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

#nickname-input {
  width: 100%;
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(51, 255, 240, 0.4);
  color: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  outline: none;
}

#nickname-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(51, 255, 240, 0.4);
}

.nickname-availability {
  min-height: 1.1em;
  font-size: 0.76rem;
  margin: -4px 0 10px;
  color: var(--text-dim);
}

.nickname-availability.available {
  color: var(--neon-green);
}

.nickname-availability.taken {
  color: #ff5c7a;
}

.submit-feedback {
  min-height: 1.2em;
  font-size: 0.82rem;
  margin-bottom: 14px;
  color: var(--neon-green);
}

.submit-feedback.error {
  color: #ff5c7a;
}

.leaderboard-status {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.leaderboard-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  text-align: left;
  max-height: 46dvh;
  overflow-y: auto;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.leaderboard-list li .rank {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--neon-purple);
  width: 28px;
  flex-shrink: 0;
}

.leaderboard-list li:nth-child(1) .rank { color: #ffd23f; text-shadow: 0 0 8px rgba(255, 210, 63, 0.7); }
.leaderboard-list li:nth-child(2) .rank { color: #d7d7e0; text-shadow: 0 0 8px rgba(215, 215, 224, 0.6); }
.leaderboard-list li:nth-child(3) .rank { color: #e08c4f; text-shadow: 0 0 8px rgba(224, 140, 79, 0.6); }

/* Riga del giocatore corrente nella classifica: "illuminata" per ritrovarsi subito */
.leaderboard-list li.is-me {
  background: rgba(51, 255, 240, 0.12);
  border-color: var(--neon-cyan);
  animation: leaderboard-me-pulse 1.8s ease-in-out infinite;
}

.leaderboard-list li.is-me .lb-name {
  color: var(--neon-cyan);
}

@keyframes leaderboard-me-pulse {
  0%, 100% { box-shadow: 0 0 16px rgba(51, 255, 240, 0.5), inset 0 0 12px rgba(51, 255, 240, 0.15); }
  50% { box-shadow: 0 0 26px rgba(51, 255, 240, 0.85), inset 0 0 18px rgba(51, 255, 240, 0.3); }
}

.leaderboard-list li .lb-name {
  flex: 1;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list li .lb-score {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--neon-cyan);
}

/* Social: follow (schermata iniziale) e condivisione (game over) */
.social-follow {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.social-follow-label,
.share-row-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.share-row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.social-icons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.social-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(51, 255, 240, 0.35);
  background: rgba(255, 255, 255, 0.03);
  color: var(--neon-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.social-icon svg {
  width: 18px;
  height: 18px;
}

.social-icon:active {
  transform: scale(0.92);
}

/* Legenda "come giocare" */
.legend-list {
  margin: 8px 0 22px;
  text-align: left;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.legend-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-icon-star {
  color: #ffd23f;
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.8);
  border-color: rgba(255, 210, 63, 0.4);
}

.legend-icon-fire {
  border-color: rgba(255, 122, 61, 0.4);
}

.legend-icon-enemy {
  color: #ff2f2f;
  text-shadow: 0 0 8px rgba(255, 47, 47, 0.8);
  border-color: rgba(255, 47, 47, 0.4);
}

.legend-icon-share,
.legend-icon-home,
.legend-icon-nearmiss {
  color: var(--neon-cyan);
  border-color: rgba(51, 255, 240, 0.4);
}

.legend-icon-combo {
  color: var(--neon-magenta);
  text-shadow: 0 0 8px rgba(255, 47, 208, 0.7);
  border-color: rgba(255, 47, 208, 0.4);
}

.legend-icon-streak {
  color: #ff9d3d;
  text-shadow: 0 0 8px rgba(255, 157, 61, 0.7);
  border-color: rgba(255, 157, 61, 0.4);
}

.legend-icon-podium {
  color: #ffd23f;
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.7);
  border-color: rgba(255, 210, 63, 0.4);
}

.legend-icon-mult {
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(51, 255, 240, 0.7);
  border-color: rgba(51, 255, 240, 0.4);
  font-size: 0.85rem;
  font-weight: 700;
}

.legend-icon-mini {
  color: #b98bff;
  text-shadow: 0 0 8px rgba(185, 139, 255, 0.7);
  border-color: rgba(185, 139, 255, 0.4);
}

.legend-icon-share svg {
  width: 18px;
  height: 18px;
}

.legend-icon-home {
  font-size: 1.4rem;
  font-weight: 700;
}

.legend-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legend-text strong {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.5px;
  color: #fff;
}

.legend-text span {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

/* Coriandoli podio: overlay sopra tutte le schermate (.screen è z-index:10) */
#confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--drift), 110vh) rotate(540deg); opacity: 0.25; }
}

/* Bacheca trofei */
.achievements-multiplier {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(51, 255, 240, 0.6);
  text-align: center;
  margin: 0 0 18px;
}

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  max-height: 60dvh;
  overflow-y: auto;
  text-align: left;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.achievement-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: rgba(255, 210, 63, 0.1);
  border: 1px solid rgba(255, 210, 63, 0.4);
}

.achievement-text strong {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  color: #fff;
}

.achievement-text span {
  font-size: 0.74rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.achievement-item.is-locked {
  opacity: 0.4;
}

.achievement-item.is-locked .achievement-icon {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
  filter: grayscale(1);
}

.achievement-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.achievement-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.achievement-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green));
}

.achievement-progress-text {
  flex-shrink: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Schermata novità */
.changelog-list {
  text-align: left;
  margin: 8px 0 22px;
  max-height: 60dvh;
  overflow-y: auto;
}

.changelog-entry {
  margin-bottom: 20px;
}

.changelog-entry h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  color: #ffd23f;
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.6);
  margin: 0 0 10px;
}

.changelog-entry ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.changelog-entry li {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 8px;
}

@media (max-height: 600px) {
  .title { font-size: 2rem; }
  .lore { margin-bottom: 14px; }
  .btn { padding: 11px; }
}
