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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #0a0a0a;
  font-family: 'Bangers', 'Permanent Marker', cursive;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#game-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ===================== MENU ===================== */
#menu-screen {
  background: radial-gradient(ellipse at center, rgba(20,0,30,0.35) 0%, rgba(0,0,0,0.75) 75%);
}

.menu-inner {
  text-align: center;
  padding: 20px;
}

#game-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(48px, 11vw, 110px);
  line-height: 0.95;
  letter-spacing: 4px;
  transform: rotate(-3deg);
  -webkit-text-stroke: 3px #000;
  text-shadow:
    4px 4px 0 #ff00c8,
    8px 8px 0 #00e5ff,
    12px 12px 0 #000,
    0 0 30px rgba(255, 0, 200, 0.6);
  animation: titlePulse 2.2s ease-in-out infinite;
}

#game-title .line1 {
  display: block;
  color: #ffe600;
}

#game-title .line2 {
  display: block;
  color: #ff2fb0;
  font-size: 1.1em;
  transform: rotate(2deg) translateX(10px);
}

@keyframes titlePulse {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  50% { transform: rotate(-3deg) scale(1.04); }
}

#play-btn {
  margin-top: 40px;
  font-family: 'Bangers', cursive;
  font-size: 42px;
  letter-spacing: 3px;
  padding: 18px 70px;
  background: linear-gradient(180deg, #ff5ec4 0%, #b3006b 100%);
  color: #fff;
  border: 4px solid #000;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 0 #6b0040, 0 8px 20px rgba(0,0,0,0.6);
  -webkit-text-stroke: 1px #000;
  transition: transform 0.08s ease;
}

#play-btn:hover {
  filter: brightness(1.15);
}

#play-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #6b0040, 0 2px 10px rgba(0,0,0,0.6);
}

/* ===================== TUTORIAL (pop-up centrale) ===================== */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 2, 8, 0.78);
  backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity 0.25s ease;
}

.tutorial-overlay.hidden {
  /* Vince sulla regola generica ".hidden{display:none!important}": qui
     serve restare "display:flex" durante la dissolvenza, altrimenti
     l'elemento sparisce dal rendering all'istante e la transition di
     opacity non fa in tempo ad animarsi. Opacity 0 + pointer-events none
     bastano da soli a nasconderlo davvero e a lasciar passare i click. */
  display: flex !important;
  opacity: 0;
  pointer-events: none;
}

.tutorial-card {
  position: relative;
  width: min(440px, 92vw);
  padding: 40px 34px 32px;
  background: linear-gradient(160deg, #1c1522 0%, #0d0812 100%);
  border: 3px solid #000;
  border-radius: 20px;
  box-shadow:
    0 22px 55px rgba(0, 0, 0, 0.6),
    0 0 0 2px rgba(255, 255, 255, 0.06) inset;
  text-align: center;
}

.tutorial-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  line-height: 28px;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.tutorial-close:hover { background: rgba(255, 255, 255, 0.16); }

.tutorial-icon {
  font-size: 58px;
  letter-spacing: 4px;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.6));
}

.tutorial-title {
  margin-top: 16px;
  font-family: 'Bangers', cursive;
  font-size: clamp(26px, 6vw, 34px);
  letter-spacing: 2px;
  color: #ffe600;
  text-shadow: 3px 3px 0 #ff00c8, 6px 6px 0 #00e5ff;
}

.tutorial-text {
  margin-top: 14px;
  min-height: 64px;
  font-family: 'Permanent Marker', cursive;
  font-size: 15px;
  line-height: 1.6;
  color: #ddd;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.tutorial-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

.tutorial-dot.active {
  background: #00e5ff;
  box-shadow: 0 0 8px #00e5ff;
}

.tutorial-next-btn {
  display: block;
  margin: 22px auto 0;
  font-family: 'Bangers', cursive;
  font-size: 24px;
  letter-spacing: 2px;
  padding: 12px 48px;
  background: linear-gradient(180deg, #00e5ff 0%, #0089a8 100%);
  color: #04121a;
  border: 3px solid #000;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 0 #00505f, 0 6px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.tutorial-next-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #00505f, 0 2px 8px rgba(0, 0, 0, 0.5);
}

.audio-hint {
  margin-top: 8px;
  font-family: 'Permanent Marker', cursive;
  font-size: 13px;
  color: #888;
}

/* ===================== LINK HUB ===================== */
.back-to-hub {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  font-family: 'Permanent Marker', cursive;
  font-size: 13px;
  color: #cbb8d6;
  text-decoration: none;
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 9px 16px;
  z-index: 11;
  touch-action: manipulation;
}

.back-to-hub:hover, .back-to-hub:active {
  color: #fff;
  border-color: #fff;
}

/* ===================== HUD ===================== */
#game-ui {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  padding: 16px 20px;
  z-index: 5;
  pointer-events: none;
}

#score-box {
  display: inline-block;
  font-family: 'Bangers', cursive;
  font-size: 30px;
  letter-spacing: 2px;
  color: #ffe600;
  background: rgba(0,0,0,0.55);
  border: 3px solid #000;
  border-radius: 10px;
  padding: 6px 22px;
  -webkit-text-stroke: 1px #000;
}

/* ===================== GAME OVER ===================== */
#gameover-screen {
  background: #000;
  overflow: hidden;
}

.police-flash {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  animation: policeLights 0.5s steps(1) infinite;
  z-index: 1;
}

@keyframes policeLights {
  0%   { background: rgba(255,0,0,0.35); }
  50%  { background: rgba(0,60,255,0.35); }
  100% { background: rgba(255,0,0,0.35); }
}

.prison-bars {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    90deg,
    #0a0a0a 0px,
    #1c1c1c 18px,
    #3a3a3a 30px,
    #1c1c1c 42px,
    #0a0a0a 60px,
    transparent 60px,
    transparent 130px
  );
  box-shadow: inset 0 0 120px rgba(0,0,0,0.9);
  z-index: 2;
}

.gameover-inner {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 30px 50px;
  background: rgba(0,0,0,0.55);
  border-radius: 12px;
}

#gameover-title {
  font-size: clamp(46px, 10vw, 90px);
  color: #ff1c1c;
  -webkit-text-stroke: 3px #000;
  text-shadow: 4px 4px 0 #000, 0 0 24px rgba(255,0,0,0.8);
  letter-spacing: 3px;
  transform: rotate(-2deg);
}

#final-score {
  margin-top: 14px;
  font-family: 'Permanent Marker', cursive;
  font-size: 26px;
  color: #ffe600;
}

#restart-btn {
  margin-top: 30px;
  font-family: 'Bangers', cursive;
  font-size: 30px;
  letter-spacing: 2px;
  padding: 14px 46px;
  background: linear-gradient(180deg, #4fc3ff 0%, #0057a8 100%);
  color: #fff;
  border: 4px solid #000;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 0 #003463, 0 6px 16px rgba(0,0,0,0.6);
}

#restart-btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #003463, 0 1px 8px rgba(0,0,0,0.6);
}

.back-to-hub--gameover {
  position: static;
  display: inline-block;
  margin-top: 18px;
  padding: 8px 16px;
  font-size: 12px;
}

/* ===================== RESPONSIVE / MOBILE ===================== */
@media (max-width: 420px) {
  #play-btn {
    font-size: 32px;
    padding: 15px 48px;
  }
  #restart-btn {
    font-size: 24px;
    padding: 12px 34px;
  }
  #score-box { font-size: 22px; padding: 5px 16px; }
  .gameover-inner { padding: 24px 26px; }
  .tutorial-card { padding: 32px 22px 26px; }
  .tutorial-icon { font-size: 46px; }
  .tutorial-text { font-size: 13.5px; min-height: 54px; }
  .tutorial-next-btn { font-size: 20px; padding: 11px 38px; }
}

@media (max-height: 480px) {
  #game-title { font-size: clamp(32px, 9vw, 60px); }
  #play-btn { margin-top: 20px; padding: 10px 40px; font-size: 28px; }
  .audio-hint { margin-top: 8px; }
  .tutorial-card { padding: 26px 20px 20px; }
  .tutorial-icon { font-size: 36px; }
  .tutorial-title { font-size: 20px; margin-top: 10px; }
  .tutorial-text { font-size: 12px; line-height: 1.4; min-height: 0; margin-top: 8px; }
  .tutorial-dots { margin-top: 12px; }
  .tutorial-next-btn { margin-top: 12px; font-size: 18px; padding: 8px 32px; }
}
