html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0a0a12;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e8e8f0;
  user-select: none;
}
#game { display: block; cursor: crosshair; touch-action: none; }
#hud {
  position: fixed;
  top: 12px; left: 12px;
  font-size: 13px;
  line-height: 1.6;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
#hud .stat { display: inline-block; min-width: 130px; }
#hud b { color: #6cf; }
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 12, 0.88);
  text-align: center;
  z-index: 10;
  padding: 0 16px;
  box-sizing: border-box;
}
/* The actual scroll container. Sized by #overlay's horizontal padding so it sits
   between the side rails — its scrollbar stays inboard and never hides behind a
   rail. */
#menuScroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 28px 0;
  box-sizing: border-box;
}
#overlay h1 { font-size: 46px; margin: 0 0 2px; letter-spacing: 1px; color: #6cf; text-shadow: 0 0 24px rgba(102,204,255,0.4); }
#overlaySub { color: #8fa; font-size: 13px; text-transform: uppercase; letter-spacing: 3px; margin: 0 0 6px; }
#overlay p { max-width: 640px; line-height: 1.6; color: #bcc; margin: 4px 0; }
#classGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 1000px;
  box-sizing: border-box;
  margin-top: 16px;
}
.classCard {
  width: 168px;
  background: rgba(20, 24, 40, 0.85);
  border: 2px solid #2a2f4a;
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color .12s, transform .12s;
}
.classCard:hover { border-color: #4a8cff; transform: translateY(-2px); }
.classCard.selected { border-color: #6cf; box-shadow: 0 0 12px rgba(102, 204, 255, 0.35); }
.classCard .cname { font-weight: bold; margin-top: 2px; }
.classCard .crole { color: #8fa; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.classCard .cskill { color: #aab; font-size: 10.5px; line-height: 1.4; margin-top: 6px; text-align: left; }
.classCard .cskill b { color: #6cf; }
#overlay .key { color: #6cf; font-weight: bold; }
#menuForm { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
#menuForm input {
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 8px;
  border: 2px solid #2a2f4a;
  background: rgba(20, 24, 40, 0.85);
  color: #e8e8f0;
  outline: none;
  width: 220px;
}
#menuForm input:focus { border-color: #4a8cff; }
#serverInput { width: 280px !important; font-family: Consolas, monospace; font-size: 12.5px !important; }
#lobbyBox {
  margin-top: 14px;
  background: rgba(20, 24, 40, 0.85);
  border: 2px solid #2a2f4a;
  border-radius: 10px;
  padding: 12px 26px;
  min-width: 280px;
}
#lobbyBox .lobbyTitle { color: #9aa; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#playerList { list-style: none; margin: 8px 0 0; padding: 0; text-align: left; }
#playerList li { padding: 3px 0; color: #cdd6e8; }
#netStatus { margin-top: 12px; color: #ffd166; min-height: 18px; font-size: 13px; }
#overlay button {
  margin-top: 22px;
  padding: 14px 40px;
  font-size: 18px;
  border: none;
  border-radius: 8px;
  background: #2a6cf0;
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
#overlay button:hover { background: #4a8cff; }
.hidden { display: none !important; }
#minimap {
  position: fixed;
  top: 12px; right: 12px;
  border: 1px solid #33334d;
  border-radius: 8px;
  background: rgba(8, 10, 18, 0.85);
  pointer-events: none;
}
#leaderboard {
  position: fixed;
  top: 264px; right: 12px;
  width: 240px;
  box-sizing: border-box;
  background: rgba(8, 10, 18, 0.8);
  border: 1px solid #33334d;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  pointer-events: none;
}
#leaderboard.lbEmpty { display: none; }
#leaderboard .lbTitle { color: #9aa; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.lbRow { display: flex; justify-content: space-between; padding: 1.5px 0; color: #cdd6e8; }
.lbRow.lbMe { color: #ffd166; font-weight: bold; }
.lbKills { color: #6cf; }
.lbMe .lbKills { color: #ffd166; }
#killfeed {
  position: fixed;
  top: 386px; right: 12px;
  width: 280px;
  text-align: right;
  font-size: 12.5px;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
#killfeed .kf {
  padding: 2px 0;
  opacity: 1;
  transition: opacity 0.6s;
}
#killfeed .kf.kfFade { opacity: 0; }
#legend {
  position: fixed;
  bottom: 12px; left: 12px;
  font-size: 12px;
  line-height: 1.7;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
#legend .icon { display:inline-block; width:16px; height:16px; margin-right:7px; vertical-align:middle; }
#legend .row { margin: 2px 0; }
#legend .title { color:#9aa; font-size:11px; text-transform:uppercase; letter-spacing:1px; margin-bottom:3px; }

/* ---- Touch / mobile on-screen controls ---- */
#touchControls {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;   /* only the sticks/buttons are interactive */
  touch-action: none;
}
.stickBase {
  position: fixed;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: rgba(20, 24, 40, 0.32);
  border: 2px solid rgba(120, 150, 220, 0.35);
  pointer-events: auto;
  touch-action: none;
}
#moveStick { left: calc(24px + env(safe-area-inset-left));  bottom: calc(24px + env(safe-area-inset-bottom)); }
#aimStick  { right: calc(24px + env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom)); }
.stickKnob {
  position: absolute;
  left: 50%; top: 50%;
  width: 62px; height: 62px;
  border-radius: 50%;
  background: rgba(120, 160, 240, 0.55);
  border: 2px solid rgba(180, 210, 255, 0.7);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#aimStick .stickKnob { background: rgba(240, 150, 120, 0.55); border-color: rgba(255, 200, 180, 0.7); }
.skillBtn {
  position: fixed;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(42, 108, 240, 0.42);
  border: 2px solid rgba(120, 160, 240, 0.7);
  color: #eef3ff;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 11px; line-height: 1.15; text-align: center;
  pointer-events: auto; touch-action: none;
  transition: transform .06s, background .1s, opacity .1s;
}
.skillBtn .sbName { font-weight: bold; padding: 0 5px; }
.skillBtn .sbCd { font-size: 14px; color: #ffd166; min-height: 15px; }
.skillBtn.pressed { background: rgba(74, 140, 255, 0.78); transform: scale(0.93); }
.skillBtn.cooling { opacity: 0.45; }
#skillBtn0 { right: calc(42px + env(safe-area-inset-right));  bottom: calc(180px + env(safe-area-inset-bottom)); }
#skillBtn1 { right: calc(150px + env(safe-area-inset-right)); bottom: calc(208px + env(safe-area-inset-bottom));
             background: rgba(150, 80, 220, 0.42); border-color: rgba(190, 140, 240, 0.7); }
#skillBtn1.pressed { background: rgba(180, 110, 245, 0.78); }

/* ---- Ad panels (main page only) ---- */
/* Bottom banner: mobile only (touch devices). */
#adFooter {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 11;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  background: rgba(8, 10, 18, 0.85);
  border-top: 1px solid #20243a;
}
body.touch-mode #adFooter { display: flex; }
body.touch-mode #menuScroll { padding-bottom: 80px; }   /* clear the footer ad */

/* Popup vignette: desktop + mobile, closeable after 5s. */
#adVignette {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  padding: 16px;
  box-sizing: border-box;
}
.vignetteBox {
  position: relative;
  width: min(92vw, 360px);
  background: #0d0f18;
  border: 1px solid #2a2f4a;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
#adVignetteClose {
  position: absolute;
  top: -14px; right: -14px;
  min-width: 96px;
  padding: 7px 14px;
  border-radius: 18px;
  border: none;
  background: #2a2f4a;
  color: #cdd6e8;
  font-size: 13px;
  cursor: default;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
#adVignetteClose:disabled { opacity: 0.75; }
#adVignetteClose:not(:disabled) { background: #2a6cf0; color: #fff; cursor: pointer; }
#adVignetteClose:not(:disabled):hover { background: #4a8cff; }

/* hide every ad once a match is running */
body.playing #adFooter,
body.playing #adVignette { display: none !important; }

/* ---- Smaller class cards so all classes fit a phone screen ---- */
@media (max-width: 820px) {
  #menuScroll { padding-top: 14px; }
  #overlay h1 { font-size: 32px; }
  #overlay p { font-size: 13px; }
  #classGrid { gap: 6px; margin-top: 10px; }
  .classCard { width: 94px; padding: 6px 4px; border-radius: 8px; box-sizing: border-box; }
  .classCard canvas { width: 40px; height: 40px; }
  .classCard .cname { font-size: 12.5px; }
  .classCard .crole { font-size: 9px; }
  .classCard .cskill { display: none; }   /* drop the long skill text to fit */
}
@media (max-width: 820px) and (orientation: landscape) {
  #overlay h1 { font-size: 26px; margin-bottom: 0; }
  #overlay p { display: none; }            /* save vertical space in landscape */
  .classCard { width: 92px; }
}

/* ---- Compact in-game HUD for touch devices ---- */
body.touch-mode #minimap {
  width: 120px; height: 120px;
  top: 8px; right: 8px;
}
body.touch-mode #hud {
  top: 8px; left: 8px;
  font-size: 10px; line-height: 1.45;
}
body.touch-mode #hud .stat { min-width: 92px; }
body.touch-mode #leaderboard {
  top: 136px; right: 8px;
  width: 150px;
  font-size: 10px;
  padding: 6px 8px;
}
body.touch-mode #leaderboard .lbTitle { font-size: 9px; }
body.touch-mode #killfeed {
  top: 232px; right: 8px;
  width: 180px;
  font-size: 10.5px;
}
/* the pickup legend sits in the bottom-left corner — exactly where the walk
   stick lives — so hide it on touch to keep the controls clear */
body.touch-mode #legend { display: none; }
