* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a2e;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', Arial, sans-serif;
}

/* La taille de #game-container est définie par JS pour correspondre au canvas */
#game-container {
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(200, 30, 30, 0.5);
  border-radius: 12px;
  touch-action: none;
}

/* Plein écran sur mobile : pas de bords arrondis ni d'ombre */
@media (max-width: 700px) {
  #game-container {
    border-radius: 0;
    box-shadow: none;
  }
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #87CEEB;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  pointer-events: none;
  padding-top: calc(15px + env(safe-area-inset-top, 0px));
}

#score {
  font-size: 48px;
  font-weight: 900;
  color: #fff;
  text-shadow: 3px 3px 0 #c1121f, 0 0 15px rgba(0,0,0,0.6);
}

#mute-controls {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

#mute-controls button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 18px;
  background: rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  cursor: pointer;
  margin: 0;
  transition: background 0.15s;
  touch-action: manipulation;
}

#mute-controls button:hover {
  background: rgba(230, 57, 70, 0.8);
  transform: none;
}

/* Bouton d'attaque toile (visible uniquement sur tactile) */
#attack-btn {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(230, 57, 70, 0.85);
  border: 3px solid #fff;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  padding: 0;
  margin: 0;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.55), inset 0 0 12px rgba(255,255,255,0.15);
  z-index: 6;
  touch-action: none;
  transition: transform 0.08s, background 0.08s;
}

#attack-btn:active {
  background: rgba(255, 89, 100, 1);
  transform: scale(0.9);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 0 20px rgba(255,255,255,0.3);
}

@media (hover: none) and (pointer: coarse) {
  #attack-btn { display: flex; }
  #attack-btn.hidden { display: none !important; }
  .hint-desktop { display: none !important; }
  .hint-mobile  { display: block !important; }
}

@media (hover: hover) and (pointer: fine) {
  .hint-mobile { display: none !important; }
}

.hint-mobile { display: none; }

#effects {
  position: absolute;
  top: calc(70px + env(safe-area-inset-top, 0px));
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.effect-badge {
  background: rgba(0,0,0,0.6);
  border: 2px solid #fff;
  border-radius: 20px;
  padding: 4px 10px;
  color: #fff;
  font-weight: bold;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  animation: pop 0.2s ease-out;
}

@keyframes pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.screen {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  text-align: center;
  gap: 12px;
  padding: 20px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 4;
  overflow-y: auto;
}

.screen h1 {
  font-size: 36px;
  color: #e63946;
  text-shadow: 3px 3px 0 #000, 0 0 25px rgba(230, 57, 70, 0.8);
  letter-spacing: 2px;
  transform-origin: top center;
  animation: swing 2.6s ease-in-out infinite, glow 2.6s ease-in-out infinite;
}

@keyframes swing {
  0%, 100% { transform: rotate(-4deg); }
  50%      { transform: rotate(4deg); }
}

@keyframes glow {
  0%, 100% { text-shadow: 3px 3px 0 #000, 0 0 20px rgba(230, 57, 70, 0.6); }
  50%      { text-shadow: 3px 3px 0 #000, 0 0 45px rgba(230, 57, 70, 1); }
}

.screen p { font-size: 14px; opacity: 0.9; }

.screen .best {
  font-size: 14px;
  color: #ffd166;
  letter-spacing: 1px;
  font-weight: bold;
  margin-top: 2px;
}

.skin-picker {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 8px 10px;
  width: 100%;
  max-width: 340px;
}

.skin-picker .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
  opacity: 0.75;
}

#skin-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.skin-btn {
  padding: 0;
  margin: 0;
  width: 100%;
  aspect-ratio: 62 / 78;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.25);
  background: linear-gradient(160deg, #2a1a5e 0%, #0a0a2e 100%);
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.skin-btn:hover {
  transform: translateY(-2px);
  border-color: #ffd166;
}

.skin-btn.selected {
  border-color: #ffd166;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.8), inset 0 0 8px rgba(255, 209, 102, 0.3);
  transform: translateY(-2px);
}

.skin-btn canvas { display: block; width: 100%; height: 100%; }

button {
  padding: 13px 38px;
  font-size: 19px;
  font-weight: bold;
  background: #e63946;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  letter-spacing: 1px;
  margin-top: 4px;
  touch-action: manipulation;
}

button:hover { transform: scale(1.08); background: #ff5964; }
button:active { transform: scale(0.96); }

.hidden { display: none !important; }