* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: Arial, sans-serif;
  user-select: none;
  touch-action: none;
}

#gameShell {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #111;
  overflow: hidden;
}

#topBar { display: none !important; }

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #687a4b;
}

/* 4 BOTTONI HUD */
#warMenuBtn, #warRankingHudBtn, #warMusicBtn,
#warAutoFireBtn, #warInfoBtn, #warFullscreenBtn {
  position: fixed !important;
  z-index: 999999999 !important;
  width: 50px !important;
  height: 50px !important;
  border-radius: 14px !important;
  border: 2px solid rgba(255,255,255,.25) !important;
  background: rgba(10,15,22,.88) !important;
  color: #ffe033 !important;
  font-size: 22px !important;
  font-weight: 900 !important;
  box-shadow: 0 0 12px rgba(0,0,0,.6) !important;
  backdrop-filter: blur(8px) !important;
  touch-action: manipulation !important;
  cursor: pointer !important;
  bottom: auto !important; left: auto !important; right: auto !important; top: auto !important;
}
#warMenuBtn        { top: 8px !important; left: 8px !important; }
#warRankingHudBtn  { top: 8px !important; left: 66px !important; border-color: rgba(255,224,51,.6) !important; }
#warFullscreenBtn  { top: 8px !important; left: 124px !important; }
#warAutoFireBtn    { top: 8px !important; right: 8px !important; }
#warMusicBtn       { top: 8px !important; right: 66px !important; }
#warInfoBtn        { display: none !important; }

#warAutoFireBtn.fireON {
  border: 2px solid #ff2b2b !important;
  background: rgba(80,0,0,.92) !important;
  box-shadow: 0 0 16px #ff2b2b, 0 0 34px rgba(255,43,43,.75) !important;
}
#warMusicBtn.musicOFF {
  color: rgba(255,255,255,.3) !important;
  border-color: rgba(255,255,255,.15) !important;
  box-shadow: none !important;
}

/* POPUP CENTRATI */
#warInfoModal, #warTeamOverlay, #warRankingModal,
#prestigeRankingModal, #warHubOverlay {
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}
#warInfoModal > div, #warTeamOverlay > div,
#warRankingModal > div, #prestigeRankingModal > div, #warHubOverlay > div {
  max-height: 80vh;
  overflow-y: auto;
  margin: auto;
}

/* CLASSIFICA COMPATTA (mobile) */
#warRankingModal, #prestigeRankingModal {
  z-index: 9999999 !important;
}
#warRankingModal > div, #prestigeRankingModal > div {
  width: min(480px, 96vw) !important;
  max-height: 75vh !important;
  overflow-y: auto !important;
  padding: 14px !important;
  font-size: 13px !important;
}
#warRankingModal h1, #warRankingModal h2,
#prestigeRankingModal h1, #prestigeRankingModal h2 {
  font-size: 18px !important;
  margin-bottom: 8px !important;
}
#warRankingModal table, #prestigeRankingModal table {
  font-size: 12px !important;
}
#warRankingModal td, #warRankingModal th,
#prestigeRankingModal td, #prestigeRankingModal th {
  padding: 4px 6px !important;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.86);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hidden { display: none !important; }

.panel, .endPanel {
  width: min(480px, 94vw);
  background: rgba(18,24,32,.97);
  border: 2px solid #ffe033;
  border-radius: 0;
  padding: 18px;
  color: white;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
  max-height: 88vh;
  overflow-y: auto;
}
.panel h1, .endPanel h1 {
  color: #ffe033;
  font-size: 24px;
  margin-bottom: 10px;
  font-weight: 900;
}
.panel p, .endPanel p {
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 14px;
  color: #dbe3ec;
}
.teamGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.teamBtn, .secondaryBtn, #replayBtn, #mainMenuBtn {
  background: #7b1020;
  color: white;
  border: 2px solid #ffe033;
  padding: 11px 14px;
  border-radius: 0;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 0.5px;
  font-size: 14px;
}
.teamBtn:hover, .secondaryBtn:hover, #replayBtn:hover, #mainMenuBtn:hover { background: #9d172b; }
.secondaryBtn { background: #1d2630; }

.rankingPanel { max-height: 70vh; overflow-y: auto; }
#rankingContent { margin: 12px 0; text-align: left; }
.rankingRow {
  display: grid;
  grid-template-columns: 1fr 60px 80px;
  gap: 6px;
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,.14);
  font-weight: 800;
  font-size: 13px;
}
.rankingRow span:first-child { color: #ffe033; }

#endOverlay { gap: 12px; }
.endPanel { width: min(400px, 94vw); min-height: auto; }
.endButtons { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.adColumn { display: flex; flex-direction: column; gap: 14px; }
.adBox {
  width: 160px; height: 110px;
  border-radius: 0;
  border: 2px dashed rgba(255,255,255,.35);
  background: rgba(255,255,255,.08);
  color: #ffe033; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

#landscapeNotice {
  position: fixed; inset: 0; background: #111; color: #ffe033;
  z-index: 999999; display: none; align-items: center; justify-content: center;
  text-align: center; font: 900 25px Arial; padding: 30px;
}
@media (orientation: portrait) { #landscapeNotice { display: flex; } }

@media (max-width: 900px) {
  #endOverlay { gap: 6px; }
  .adBox { width: 90px; height: 80px; font-size: 12px; }
  .endPanel { width: min(340px, 94vw); }
  .panel h1, .endPanel h1 { font-size: 20px; }
}

/* ===== DESIGN MINIMAL / SENZA CURVE =====
   Forza gli angoli vivi sui popup creati via JS (selezione team, classifica,
   fine partita). Le regole inline non usano !important, quindi vengono sovrascritte. */
#warTeamOverlay div, #warTeamOverlay button,
#warEndOverlay div, #warEndOverlay button,
#warRankingModal div, #warRankingModal button,
#prestigeRankingModal div, #prestigeRankingModal button {
  border-radius: 0 !important;
}
