* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  background: #0b0f1a;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 800px at 50% -10%, #1c2a4a 0%, #0b0f1a 60%);
}
#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #000;
  touch-action: none;
}

/* --- Bouton plein écran --- */
#fs {
  position: fixed; z-index: 30;
  top: calc(8px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  width: 40px; height: 40px; font-size: 20px; line-height: 1;
  color: #cfe0ff; background: rgba(30,40,70,.5);
  border: 2px solid rgba(255,255,255,.2); border-radius: 10px;
  backdrop-filter: blur(2px);
}
#fs:active { background: rgba(120,160,255,.6); }

/* --- Manette tactile --- */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.pad, .btn {
  position: absolute; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.92); font-weight: 800;
  background: rgba(20,28,50,.30);
  border: 2px solid rgba(255,255,255,.30);
  border-radius: 14px; backdrop-filter: blur(1.5px);
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  user-select: none; touch-action: none; font-size: 20px;
  transition: transform .05s, background .1s;
}
.pad:active, .btn:active { background: rgba(120,160,255,.55); transform: scale(.94); }
#dpad {
  left: calc(18px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom));
  width: 168px; height: 168px; pointer-events: none;
}
#dpad .pad { width: 54px; height: 54px; }
#du { left: 57px; top: 0; }
#dd { left: 57px; top: 114px; }
#dl { left: 0; top: 57px; }
#dr { left: 114px; top: 57px; }
#dc { left: 57px; top: 57px; width:54px;height:54px;background:rgba(20,26,44,.35);border-color:rgba(255,255,255,.12);border-radius:12px; }
#btns {
  right: calc(18px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom));
  width: 190px; height: 168px; pointer-events:none;
}
#btns .btn { width: 66px; height: 66px; border-radius: 50%; font-size: 15px; }
#bA { right: 0; bottom: 8px; background: rgba(220,70,90,.36); }
#bB { right: 82px; bottom: 40px; background: rgba(70,120,220,.36); }
#bE { right: 40px; bottom: 108px; width:64px;height:44px;border-radius:12px; background: rgba(90,180,120,.4); font-size:13px; }

.hide { display: none !important; }
#hint {
  position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%);
  font-size: 11px; color: #7f8db0; z-index: 5; text-align:center; width:100%;
  pointer-events: none;
}

/* --- Overlay "tourne ton téléphone" (mobile en portrait) --- */
#rotate {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: linear-gradient(160deg, #131a2e, #0b0f1a);
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
}
.rot-icon { font-size: 64px; animation: rot 1.8s ease-in-out infinite; }
.rot-txt { font-size: 22px; font-weight: 800; margin-top: 18px; line-height: 1.35; }
.rot-sub { font-size: 15px; color: #9fb4d6; margin-top: 8px; }
@keyframes rot { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(78deg); } }

/* montre l'overlay uniquement sur écran tactile en portrait */
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; }
  #touch, #fs, #hint { display: none; }
}
/* sur mobile, on masque la légende clavier */
@media (pointer: coarse) { #hint { display: none; } }

/* --- Astuce installation iOS --- */
#ios-tip {
  display: none;
  position: fixed; z-index: 60; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(92vw, 420px); padding: 14px 16px;
  background: rgba(16,22,40,.96); border: 2px solid #5fd0ff; border-radius: 14px;
  font-size: 14px; line-height: 1.5; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
#ios-tip.show { display: block; }
#ios-close {
  display: block; margin: 12px auto 0; padding: 8px 22px;
  background: #5fd0ff; color: #0b0f1a; font-weight: 800; border: 0; border-radius: 10px; font-size: 14px;
}
