/* ============================================================
   BOMB BLITZ — estilo arcade neon-retro
   ============================================================ */

:root{
  --bg0:#0a0a14;
  --bg1:#141426;
  --accent:#ffcc33;
  --accent2:#ff5a3c;
  --cyan:#34e1ff;
  --green:#5fe06a;
  --pink:#ff5fa2;
  --ink:#e8ecff;
  --panel:#12122a;
  --panel-border:#3a3a6a;
}

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

html,body{
  height:100%;
  background:radial-gradient(circle at 50% 20%, #1a1a38 0%, var(--bg0) 70%);
  color:var(--ink);
  font-family:"Trebuchet MS","Segoe UI",system-ui,sans-serif;
  overflow:hidden;
  -webkit-user-select:none; user-select:none;
  -webkit-tap-highlight-color:transparent;
  touch-action:none;
  overscroll-behavior:none;
  position:fixed; inset:0;  /* trava scroll/pull-to-refresh em mobile */
}

#game-shell{
  width:100%; height:100%;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  gap:10px;
  padding:8px;
  padding-top:max(8px, env(safe-area-inset-top));
}

/* Palco: mantém proporção da arena via JS (define width/height) */
#stage{
  position:relative;
  display:flex; align-items:center; justify-content:center;
  border-radius:14px;
  overflow:hidden;
  box-shadow:0 0 0 3px #000, 0 10px 50px rgba(0,0,0,.6),
             0 0 60px rgba(52,225,255,.08);
  background:#05050d;
}

canvas#game{
  display:block;
}

/* ---------------- OVERLAYS ---------------- */
.overlay{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background:rgba(6,6,16,.78);
  backdrop-filter:blur(3px);
  z-index:20;
  animation:fade .25s ease;
}
.overlay.hidden{ display:none; }

@keyframes fade{ from{opacity:0} to{opacity:1} }

.panel{
  background:linear-gradient(180deg,var(--panel),#0c0c1e);
  border:2px solid var(--panel-border);
  border-radius:16px;
  padding:30px 34px;
  text-align:center;
  min-width:min(380px,86vw);
  max-height:calc(100% - 24px);
  overflow:auto;
  box-shadow:0 12px 40px rgba(0,0,0,.6), inset 0 0 30px rgba(52,225,255,.04);
}
.panel.ghost{
  background:rgba(10,10,26,.55);
  border-color:rgba(255,204,51,.4);
  animation:pop .4s ease;
}
@keyframes pop{ from{transform:scale(.8);opacity:0} to{transform:scale(1);opacity:1} }

/* Logótipo */
.logo{
  font-size:clamp(40px,9vw,68px);
  font-weight:900;
  letter-spacing:2px;
  line-height:.95;
  color:var(--accent);
  text-shadow:0 0 18px rgba(255,204,51,.5), 4px 4px 0 #b03a1e;
}
.logo span{ display:block; color:var(--accent2);
  text-shadow:0 0 18px rgba(255,90,60,.6), 4px 4px 0 #7a1f0f; }

.tagline{ margin:10px 0 22px; color:var(--cyan); letter-spacing:3px; font-size:14px; text-transform:uppercase; }

h2{ font-size:30px; margin-bottom:18px; color:var(--accent); letter-spacing:1px; }
h2.danger{ color:var(--accent2); text-shadow:0 0 16px rgba(255,90,60,.6); }
h2.win{ color:var(--green); text-shadow:0 0 16px rgba(95,224,106,.6); }

.menu-buttons{ display:flex; flex-direction:column; gap:12px; margin:6px 0 14px; }

.btn{
  font:inherit; font-weight:700; font-size:17px;
  color:var(--ink);
  background:#1c1c3a;
  border:2px solid var(--panel-border);
  border-radius:10px;
  padding:12px 18px;
  cursor:pointer;
  transition:transform .08s, background .15s, border-color .15s, box-shadow .15s;
  letter-spacing:.5px;
}
.btn:hover{ background:#26264e; border-color:var(--cyan); transform:translateY(-2px); }
.btn:active{ transform:translateY(0); }
.btn[disabled]{ opacity:.55; cursor:wait; transform:none; }
.link-btn{ text-decoration:none; }
.btn.primary{
  background:linear-gradient(180deg,var(--accent),#e0a800);
  color:#241500; border-color:#ffe08a;
  box-shadow:0 4px 0 #9c7400, 0 0 22px rgba(255,204,51,.35);
}
.btn.primary:hover{ box-shadow:0 6px 0 #9c7400, 0 0 30px rgba(255,204,51,.5); }

.hiscore{ margin-top:8px; color:var(--accent); font-weight:700; letter-spacing:1px; }
.credits{ margin-top:14px; font-size:11px; color:#6a6a96; letter-spacing:1px; }
.tagline + .menu-buttons{ margin-top:0; }

.controls-list{ list-style:none; text-align:left; margin:6px 0 16px; }
.controls-list li{
  display:flex; justify-content:space-between; gap:20px;
  padding:9px 4px; border-bottom:1px dashed #2a2a4e;
}
.controls-list b{ color:var(--cyan); }
.controls-list span{ color:#aab; }
.hint{ font-size:12px; color:#7a7aa6; margin-bottom:16px; }

.toggle{ display:flex; align-items:center; gap:10px; justify-content:flex-start;
  padding:12px 4px; font-size:17px; cursor:pointer; border-bottom:1px dashed #2a2a4e; }
.toggle input{ width:20px; height:20px; accent-color:var(--accent); cursor:pointer; }

.stat{ margin:6px 0; color:#cfd3f5; font-size:16px; }
.stat b{ color:var(--accent); font-size:22px; display:inline-block; margin-left:6px; }
.newhi{ color:var(--accent); font-weight:900; letter-spacing:2px; margin:12px 0;
  animation:blink 1s steps(2) infinite; }
.newhi.hidden{ display:none; }
@keyframes blink{ 50%{opacity:.25} }

#li-title{ font-size:42px; text-shadow:0 0 20px rgba(255,204,51,.5); }
#li-sub{ color:var(--cyan); margin-top:8px; }

/* ---------------- RANKINGS ---------------- */
.rank-copy{
  max-width:320px;
  margin:-6px auto 16px;
  color:#aab;
  font-size:13px;
  line-height:1.45;
}
.rank-form{
  margin:14px 0 12px;
  padding:12px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:10px;
  background:rgba(0,0,0,.22);
  text-align:left;
}
.rank-form[hidden]{ display:none; }
.rank-form label{
  display:block;
  margin-bottom:8px;
  color:var(--cyan);
  font-size:12px;
  font-weight:900;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.rank-save-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:8px;
}
.rank-save-row input{
  min-height:44px;
  min-width:0;
  border:2px solid var(--panel-border);
  border-radius:10px;
  background:#09091a;
  color:var(--ink);
  padding:0 12px;
  font:900 15px "Trebuchet MS","Segoe UI",system-ui,sans-serif;
  letter-spacing:.06em;
  text-transform:uppercase;
}
.rank-save-row .btn{
  min-height:44px;
  padding:8px 12px;
  font-size:14px;
}
.rank-status{
  min-height:1.3em;
  margin-top:8px;
  color:#8da4d8;
  font-size:12px;
}
.ranking-panel{ width:min(440px,90vw); }
.rank-tabs{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
  margin:10px 0 12px;
}
.rank-tabs .btn{
  min-height:38px;
  padding:8px;
  font-size:12px;
}
.rank-tabs .is-active{
  border-color:var(--accent);
  background:rgba(255,204,51,.16);
  color:var(--accent);
}
.rank-list{
  display:grid;
  gap:6px;
  max-height:246px;
  margin:0 0 14px;
  overflow:auto;
  list-style:none;
  text-align:left;
}
.rank-list li{
  display:grid;
  grid-template-columns:34px minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
  min-height:36px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:8px;
  background:rgba(255,255,255,.045);
  padding:7px 10px;
}
.rank-list span{
  color:#8a96c8;
  font-size:12px;
  font-weight:900;
}
.rank-list span:last-child{
  color:var(--accent);
  text-align:right;
}
.rank-list strong{
  overflow:hidden;
  color:var(--ink);
  font-size:13px;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* ---------------- COMANDO TÁCTIL ---------------- */
#touch-controls{
  display:flex; justify-content:space-between; align-items:center;
  width:100%; max-width:600px; gap:10px;
  padding:0 max(10px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
}
#touch-controls.hidden{ display:none; }

/* D-pad analógico: a direção sai da posição do dedo (gerido no JS) */
.dpad{
  position:relative; width:148px; height:148px;
  touch-action:none;
}
.dpad-ring{
  position:absolute; inset:0; border-radius:50%;
  background:radial-gradient(circle at 38% 32%, rgba(60,70,130,.7), rgba(20,24,48,.78));
  border:2px solid var(--panel-border);
  box-shadow:inset 0 4px 14px rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.4);
}
.dchev{
  position:absolute; color:#7e8ac0; font-size:18px; line-height:1;
  pointer-events:none;
}
.dchev.up{ top:8px; left:50%; transform:translateX(-50%); }
.dchev.down{ bottom:8px; left:50%; transform:translateX(-50%); }
.dchev.left{ left:8px; top:50%; transform:translateY(-50%); }
.dchev.right{ right:8px; top:50%; transform:translateY(-50%); }
.dnub{
  position:absolute; left:50%; top:50%; width:60px; height:60px; margin:-30px 0 0 -30px;
  border-radius:50%;
  background:radial-gradient(circle at 38% 32%, #4a5aa8, #232a52);
  border:2px solid #6a78c0;
  box-shadow:0 3px 10px rgba(0,0,0,.5);
  transition:transform .04s linear;
  pointer-events:none;
}

.action-buttons{ display:flex; gap:16px; align-items:center; }
.abtn{
  display:flex; align-items:center; justify-content:center;
  width:82px; height:82px; border-radius:50%;
  cursor:pointer; color:#fff;
  background:radial-gradient(circle at 35% 30%, #ff7a5c, var(--accent2));
  border:3px solid #ffb39a;
  box-shadow:0 5px 0 #7a1f0f, 0 6px 16px rgba(0,0,0,.4);
  touch-action:none;
}
.abtn.pause{ width:60px; height:60px;
  background:radial-gradient(circle at 35% 30%, #5b5be0, #2d2da0);
  border-color:#9a9aff; box-shadow:0 5px 0 #1a1a6a, 0 6px 16px rgba(0,0,0,.4); }
.abtn:active{ transform:translateY(4px); box-shadow:0 1px 0 #7a1f0f; }
.abtn.pause:active{ box-shadow:0 1px 0 #1a1a6a; }

/* ---------------- LAYOUT PAISAGEM (mobile) ---------------- */
/* Em paisagem os controlos fixam-se nos cantos inferiores, libertando
   altura para a arena ocupar o ecrã todo. */
body.landscape #game-shell{ padding-bottom:4px; }
body.landscape #touch-controls{
  position:fixed; left:0; right:0; bottom:0;
  max-width:none; pointer-events:none;
  padding:0 max(14px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
  z-index:30;
}
body.landscape #touch-controls .dpad,
body.landscape #touch-controls .action-buttons{ pointer-events:auto; }
body.landscape #touch-controls .dpad{ width:128px; height:128px; }
body.landscape #touch-controls .dnub{ width:52px; height:52px; margin:-26px 0 0 -26px; }

@media (max-width:560px), (max-height:620px){
  .panel{
    min-width:min(340px,86vw);
    padding:18px 20px;
    border-radius:12px;
  }
  .logo{
    font-size:clamp(34px,12vw,48px);
    letter-spacing:1px;
  }
  .tagline{
    margin:8px 0 14px;
    font-size:12px;
    letter-spacing:2px;
  }
  h2{ font-size:25px; margin-bottom:12px; }
  .menu-buttons{ gap:8px; margin:6px 0 10px; }
  #menu .menu-buttons{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #menu .menu-buttons .primary{
    grid-column:1 / -1;
  }
  #menu .menu-buttons .btn{
    width:100%;
    padding-inline:8px;
  }
  .btn{ min-height:42px; padding:9px 14px; font-size:15px; }
  .hiscore{ font-size:13px; }
  .credits{ display:none; }
  .controls-list li{ padding:7px 2px; font-size:14px; }
  .stat{ font-size:14px; }
  .stat b{ font-size:18px; }
  .rank-save-row{ grid-template-columns:1fr; }
  .rank-tabs{ gap:6px; }
  .rank-list{ max-height:190px; }
}
