:root {
  --accent: #ff5a36;
  --accent2: #36d3ff;
  --panel: rgba(14, 18, 26, 0.82);
  --ink: #eaf1f8;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #0a0d12; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  user-select: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.ingame canvas#game { cursor: none; }
.hidden { display: none !important; }

/* Aim reticle (follows the mouse in-game) */
#reticle {
  position: fixed; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  z-index: 24; pointer-events: none;
  border: 2px solid rgba(255, 90, 54, 0.85); border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 90, 54, 0.5);
}
#reticle::before, #reticle::after { content: ''; position: absolute; background: rgba(255, 90, 54, 0.9); }
#reticle::before { left: 12px; top: -7px; width: 2px; height: 10px; }
#reticle::after { left: 12px; bottom: -7px; width: 2px; height: 10px; }

/* ---- Login ---- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 30%, #1a2433, #070a0f 70%);
}
/* No solid plate — the content floats directly over the gameplay film. */
.panel {
  position: relative; z-index: 2;
  width: min(940px, 94vw);
  max-height: 96vh;
  overflow-y: auto;
  padding: 8px 20px 16px;
  text-align: center;
}

/* Dimmed gameplay video behind the start screen */
#bgvideo {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0.5; filter: saturate(1.05) contrast(1.02);
  pointer-events: none;
}
/* Darken + vignette the video so the panel always reads clearly */
.overlay::after {
  content: ''; position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(circle at 50% 36%, rgba(10, 14, 20, 0.40), rgba(6, 9, 14, 0.88) 76%);
}

/* Live "currently playing" counter (only shown when it's a crowd) */
#playercount {
  margin: 4px 0 16px; font-size: 14px; font-weight: 700; letter-spacing: 0.4px;
  color: #7CFF9B; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
}
#playercount::before {
  content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 7px;
  border-radius: 50%; background: #34e06a; box-shadow: 0 0 8px #34e06a;
  vertical-align: middle; animation: pcpulse 1.6s ease-in-out infinite;
}
@keyframes pcpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Tankageddon emblem */
.logo {
  display: block; height: auto;
  width: min(440px, 72%);
  margin: 2px auto 4px;
  border-radius: 14px;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.55));
}

/* Feature cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 22px 0;
  text-align: left;
}
.card {
  background: rgba(8, 11, 16, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  backdrop-filter: blur(7px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.card-h {
  font-size: 12px; letter-spacing: 1.5px; font-weight: 700;
  color: var(--accent2); margin-bottom: 12px;
}
.feat { display: flex; align-items: center; gap: 11px; margin: 9px 0; }
.feat .ic { font-size: 22px; width: 28px; text-align: center; }
.feat b { display: block; font-size: 14px; color: var(--ink); }
.feat small { color: #8ea0b3; font-size: 12px; }
.card.alt .blurb { color: #b3c1cf; font-size: 13px; line-height: 1.5; margin: 0; }

/* Join bar — one tidy, centered row: alias · room code · JOIN GAME · Watch. */
.joinbar { display: flex; gap: 9px; align-items: stretch; max-width: 660px; margin: 10px auto 0; }
.aliaswrap { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
.joinbar #alias { flex: 1 1 auto; width: 100%; height: 100%; min-width: 0; margin: 0; padding: 14px 40px; }
/* ↻ re-roll button inside the alias field — picks a fresh funny name. */
#reroll {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; padding: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 17px; line-height: 1;
  color: #cfe3ff; background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 7px;
  transition: background .15s, transform .3s;
}
#reroll:hover { background: rgba(255, 255, 255, 0.16); }
#reroll:active { transform: translateY(-50%) rotate(180deg); }
.codewrap { position: relative; flex: 0 0 148px; width: 148px; display: flex; }
/* JOIN + Watch joined into one segmented pill (shared rounded shell, divider seam). */
.btngroup { display: flex; flex: 0 0 auto; border-radius: 11px; overflow: hidden; }
.joinbar #play {
  flex: 0 0 auto; width: auto; margin: 0; padding: 0 26px; font-size: 15px; border-radius: 0;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.joinbar #watch {
  flex: 0 0 auto; margin: 0; padding: 0 16px; border-radius: 0;
  border: none; border-left: 1px solid rgba(255, 255, 255, 0.18);
  display: inline-flex; align-items: center; white-space: nowrap;
}
.joinbar #roomcode {
  width: 100%; height: 100%; margin: 0; text-align: center; padding-right: 32px;
  letter-spacing: 3px; font-variant-numeric: tabular-nums; font-size: 15px;
  background: rgba(0, 0, 0, 0.5); border-color: rgba(255, 255, 255, 0.06);
  color: #aebccb;
}
#roomcode::placeholder { color: #66737f; letter-spacing: 1px; }
/* Small copy-invite-link icon inside the room-code field (appears when valid) */
#copylink {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; padding: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 14px; line-height: 1;
  background: rgba(57, 192, 255, 0.16); color: #cfe3ff;
  border: 1px solid rgba(57, 192, 255, 0.4); border-radius: 7px;
  transition: background .15s, border-color .15s;
}
#copylink:hover { background: rgba(57, 192, 255, 0.32); border-color: rgba(57, 192, 255, 0.7); }
#copylink.copied { background: rgba(124, 255, 155, 0.22); border-color: rgba(124, 255, 155, 0.6); color: #7CFF9B; }
.joinhint { margin-top: 10px; font-size: 12px; color: #9fb0c2; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9); }
#joinerror {
  margin-top: 12px; font-size: 13px; font-weight: 700; color: #ff8a7a;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}
.panel h1 {
  font-size: 44px; letter-spacing: 3px; font-weight: 800;
  background: linear-gradient(90deg, var(--accent), #ffb13b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.panel h1 span { color: var(--accent2); -webkit-text-fill-color: var(--accent2); }
.tag { color: #c4d3e2; margin: 8px 0 24px; font-size: 14px; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95); }
#alias, #roomcode {
  width: 100%; padding: 14px 16px; font-size: 17px;
  border-radius: 11px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35); color: var(--ink); text-align: center;
  outline: none; transition: border .2s;
}
#alias:focus, #roomcode:focus { border-color: var(--accent2); }
#play {
  width: 100%; margin-top: 14px; padding: 14px; font-size: 17px; font-weight: 700;
  letter-spacing: 1.5px; border: none; border-radius: 11px; cursor: pointer;
  color: #0a0d12; background: linear-gradient(90deg, var(--accent), #ff8a3b);
  transition: transform .1s, filter .2s;
}
#play:hover { filter: brightness(1.08); }
#play:active { transform: scale(.98); }
#play:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.5); }

/* Loading bar */
.loadbar {
  position: relative; height: 24px; margin: 4px 0 12px;
  border-radius: 8px; overflow: hidden;
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1);
}
#loadfill {
  position: absolute; inset: 0; width: 0%;
  background: linear-gradient(90deg, var(--accent), #ff8a3b);
  transition: width .2s ease;
}
.loadbar span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
.controls {
  display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center;
  margin-top: 20px; font-size: 12.5px; color: #b6c6d6;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
}
.controls b { color: var(--accent2); }

/* Dissolve Media credit footer */
.credit {
  margin-top: 36px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.credit-logo img { height: 22px; width: auto; display: block; opacity: 0.8; transition: opacity .15s; }
.credit-logo:hover img { opacity: 1; }
.credit-text {
  font-size: 11px; letter-spacing: 0.3px; color: #7e8c9b;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}
.credit-text a { color: #9fb0c2; text-decoration: none; }
.credit-text a:hover { color: var(--accent2); text-decoration: underline; }
.version {
  margin-top: 10px; font-size: 11px; font-style: italic; letter-spacing: 0.3px;
  color: #5d6976; opacity: 0.75; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }

#matchtimer {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px; padding: 7px 20px;
  font-size: 26px; font-weight: 800; letter-spacing: 2px;
  font-variant-numeric: tabular-nums; color: #eaf1f8;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
}
#matchtimer.urgent { color: #ff5a3c; animation: timerpulse 1s ease-in-out infinite; }
#arenaname {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: #ffb14a; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); white-space: nowrap;
}
@keyframes timerpulse { 50% { transform: translateX(-50%) scale(1.12); } }

#winnerbanner {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; padding: 28px 56px;
  background: rgba(10, 14, 20, 0.85); border: 2px solid var(--accent);
  border-radius: 18px; box-shadow: 0 20px 70px rgba(0, 0, 0, 0.7);
  z-index: 26;
}
#winnerbanner .wb-top { font-size: 16px; letter-spacing: 3px; color: #8ea0b3; }
#winnerbanner .wb-name {
  font-size: 46px; font-weight: 800; margin: 8px 0 4px;
  background: linear-gradient(90deg, var(--accent), #ffb13b);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#winnerbanner .wb-sub { font-size: 18px; color: #c7d3df; }

#minimap-wrap {
  position: absolute; top: 16px; right: 16px;
  border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  background: rgba(8, 12, 18, 0.7);
}
#minimap { display: block; }

#scoreboard {
  position: absolute; top: 16px; left: 16px;
  background: var(--panel); border-radius: 12px; padding: 10px 14px;
  min-width: 190px; font-size: 13px; backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
#scoreboard .row, #standings .row { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; }
#scoreboard .row.me, #standings .row.me { color: #7CFF9B; font-weight: 700; }
#scoreboard .sus { color: #ff6a4d; margin-right: 4px; cursor: help; }
#scoreboard .title, #standings .title { font-size: 11px; letter-spacing: 1.5px; color: #8ea0b3; margin-bottom: 6px; }

#standings {
  position: absolute; top: 188px; left: 16px;
  background: var(--panel); border-radius: 12px; padding: 10px 14px;
  min-width: 190px; font-size: 13px; backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
#standings .row span:last-child { color: #ffd27a; font-weight: 700; }
#standings .row.me span:last-child { color: #7CFF9B; }
#standings .row.dim { color: #6a7782; }
#standings .row.dim span:last-child { color: #6a7782; }

#killfeed {
  position: absolute; top: 250px; right: 16px; width: 240px;
  display: flex; flex-direction: column; gap: 5px; align-items: flex-end;
  font-size: 12.5px;
}
#killfeed .line {
  background: rgba(10, 14, 20, 0.78); padding: 5px 10px; border-radius: 7px;
  border-left: 3px solid var(--accent2);
}
#killfeed .line.bad { border-left-color: var(--accent); color: #ffb1a1; }

#status {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 18px;
}
#healthbar {
  position: relative; width: 260px; height: 22px; border-radius: 11px;
  background: rgba(0, 0, 0, 0.5); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#healthfill {
  position: absolute; inset: 0; width: 100%;
  background: linear-gradient(90deg, #ff4d4d, #7CFF9B);
  transition: width .12s;
}
#healthbar span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000;
}
#scoretext {
  font-size: 30px; font-weight: 800; min-width: 70px; text-align: center;
  color: #ffd27a; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
/* Floating score popups */
/* Fullscreen toggle — bottom-right in lobby AND in-game (that corner is free in
   both). Hidden by default; JS reveals it (.show) ONLY where the Fullscreen API
   actually works and it's not a touch device — so it never appears where it can't
   do anything (e.g. iOS) or where it'd fight the touch controls. */
.fsbtn {
  display: none; position: fixed; bottom: 22px; right: 22px; z-index: 30; pointer-events: auto;
  background: rgba(20, 24, 30, 0.7); color: #cfe3ff; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px;
  padding: 7px 13px; font-size: 13px; font-weight: 600; line-height: 1; backdrop-filter: blur(6px);
  transition: background .15s;
}
.fsbtn.show { display: inline-flex; }
.fsbtn:hover { background: rgba(40, 48, 60, 0.9); }

#popups { position: fixed; inset: 0; z-index: 25; pointer-events: none; overflow: hidden; }

/* Directional damage flash — an arc near the screen edge pointing at the hit,
   colored by armor zone (green = front/absorbed, amber = flank, red = rear/weak). */
#hitdir { position: fixed; left: 50%; top: 50%; width: 0; height: 0; z-index: 24; pointer-events: none; opacity: 0; }
#hitdir.on { animation: hitflash 0.6s ease-out; }
@keyframes hitflash { 0% { opacity: 0.95; } 100% { opacity: 0; } }
#hitdir > i {
  position: absolute; left: -100px; top: -226px; width: 200px; height: 22px;
  border-radius: 0 0 120px 120px / 0 0 40px 40px; filter: blur(0.5px);
}
#hitdir.f > i { background: linear-gradient(#9bffc4, #34d878); box-shadow: 0 0 24px 6px rgba(80, 255, 150, 0.7); }
#hitdir.s > i { background: linear-gradient(#ffe08a, #ffb13b); box-shadow: 0 0 24px 6px rgba(255, 190, 60, 0.7); }
#hitdir.r > i { background: linear-gradient(#ff9a7a, #ff4a2c); box-shadow: 0 0 30px 8px rgba(255, 70, 50, 0.8); }
.scorepop {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 26px; font-weight: 800; letter-spacing: 0.5px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  animation: scorepop 1.1s ease-out forwards;
}
.scorepop.plus { color: #7CFF9B; }
.scorepop.minus { color: #ff6a5a; }
@keyframes scorepop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -120%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -260%) scale(1); }
}

#shieldbadge {
  position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; display: flex; flex-direction: column; gap: 4px; min-width: 124px;
  background: rgba(57, 192, 255, 0.18); color: #9fe4ff;
  border: 1px solid rgba(57, 192, 255, 0.5); border-radius: 9px;
  padding: 4px 12px; font-size: 12px; font-weight: 700; letter-spacing: 1px;
}
#stealthbadge {
  position: absolute; bottom: 62px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; display: flex; flex-direction: column; gap: 4px; min-width: 124px;
  background: rgba(192, 124, 255, 0.2); color: #d7b6ff;
  border: 1px solid rgba(192, 124, 255, 0.55); border-radius: 9px;
  padding: 4px 12px; font-size: 12px; font-weight: 700; letter-spacing: 1px;
}
/* Power-up countdown bar — depletes as the effect runs out. */
.pwrbar {
  height: 3px; border-radius: 2px; overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
}
.pwrbar > i { display: block; height: 100%; width: 100%; border-radius: 2px; transition: width .2s linear; }
#shieldbadge .pwrbar > i { background: #9fe4ff; }
#stealthbadge .pwrbar > i { background: #d7b6ff; }
#missileammo {
  position: absolute; bottom: 22px; left: 22px;
  background: var(--panel); border: 1px solid rgba(57, 192, 255, 0.4);
  border-radius: 11px; padding: 8px 16px;
  font-size: 20px; font-weight: 800; color: #9fe4ff;
  backdrop-filter: blur(8px);
}
#missileammo.empty { color: #6a7782; border-color: rgba(255, 255, 255, 0.08); }

#respawn {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; max-width: min(90vw, 560px);
  padding: 22px 34px; border-radius: 16px;
  background: rgba(10, 13, 18, 0.8); border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  color: var(--accent); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
#respawn .dead-head { font-size: 30px; font-weight: 800; letter-spacing: 1px; line-height: 1.15; }
#respawn .dead-sub { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; color: #ffd27a; margin-top: 10px; }
#respawn small { display: block; font-size: 14px; color: #9fb0c2; letter-spacing: 1px; margin-top: 12px; }

/* ---- Spectator (watch live) ---- */
.watch-btn {
  margin-top: 12px; padding: 9px 18px; font-size: 13px; font-weight: 700; letter-spacing: 0.5px;
  border-radius: 10px; cursor: pointer; color: #cfe0f0;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.18);
  transition: filter .15s, background .15s;
}
.watch-btn:hover { background: rgba(255, 255, 255, 0.12); filter: brightness(1.1); }
.watch-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* In watch mode the player-only HUD is meaningless — hide it. */
body.spectating #status, body.spectating #missileammo, body.spectating #reticle,
body.spectating #respawn, body.spectating #adreward, body.spectating #touchui { display: none !important; }

/* Big tap targets on the screen edges (mouse click on desktop, tap on mobile). */
.specnav {
  display: none; position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 22; pointer-events: auto; cursor: pointer;
  width: 56px; height: 84px; place-items: center; font-size: 30px; line-height: 1;
  color: #eaf2fb; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 12px;
  background: rgba(8, 12, 18, 0.5); backdrop-filter: blur(4px);
  transition: background .15s, transform .05s;
}
.specnav:hover { background: rgba(20, 28, 40, 0.72); }
.specnav:active { transform: translateY(-50%) scale(0.94); }
#specprev { left: 16px; left: max(16px, env(safe-area-inset-left)); }
#specnext { right: 16px; right: max(16px, env(safe-area-inset-right)); }
body.spectating .specnav { display: grid; }

#spectatorbar {
  display: none; position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 22; pointer-events: auto; align-items: center; gap: 10px; max-width: 94vw;
  padding: 9px 9px 9px 16px; border-radius: 999px; white-space: nowrap;
  background: rgba(8, 12, 18, 0.74); border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  color: #eaf2fb; font-size: 14px; font-weight: 700;
}
body.spectating #spectatorbar { display: flex; }
#spectatorbar .spec-watching { color: #9fb0c2; letter-spacing: 1px; font-size: 12px; }
#spectatorbar #specname { color: var(--accent); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
#spectatorbar .spec-hint { color: #7d8ea0; font-size: 12px; font-weight: 600; }
#spectatorbar #specjoin {
  margin-left: 4px; padding: 8px 16px; font-size: 13px; font-weight: 800; letter-spacing: 0.5px;
  border: none; border-radius: 999px; cursor: pointer; color: #0a0d12;
  background: linear-gradient(90deg, var(--accent), #ff8a3b);
}
#spectatorbar #specjoin:hover { filter: brightness(1.08); }
#spectatorbar #specleave {
  padding: 8px 13px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); color: #cfe0f0;
}
#spectatorbar #specleave:hover { background: rgba(255, 255, 255, 0.15); }
@media (max-width: 560px) {
  #spectatorbar { gap: 7px; padding: 7px 7px 7px 13px; font-size: 13px; bottom: 14px; }
  #spectatorbar .spec-hint { display: none; }
  .specnav { width: 48px; height: 72px; font-size: 26px; }
}

/* ---- Ads: rewarded button + demo overlay ---- */
#adreward {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, calc(-50% + 132px));
  z-index: 21; pointer-events: auto; cursor: pointer; white-space: nowrap;
  padding: 11px 22px; font-size: 14px; font-weight: 700; letter-spacing: 0.5px;
  border: none; border-radius: 11px; color: #0a0d12;
  background: linear-gradient(90deg, var(--accent), #ff8a3b);
}
#adreward:hover { filter: brightness(1.06); }
#adreward:disabled { filter: grayscale(0.5) brightness(0.8); cursor: default; }

.ad-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(5, 7, 10, 0.92); pointer-events: auto;
}
.ad-panel {
  text-align: center; padding: 28px 40px; border-radius: 16px; max-width: min(92vw, 460px);
  background: rgba(14, 18, 26, 0.9); border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.ad-label { font-size: 11px; letter-spacing: 2px; color: #8ea0b3; font-weight: 700; }
.ad-box { font-size: 56px; margin: 16px 0; background: rgba(0, 0, 0, 0.3); border-radius: 12px; padding: 26px 0; }
.ad-count { font-size: 15px; font-weight: 700; color: #eaf1f8; margin-bottom: 14px; }
.ad-btns { display: flex; gap: 10px; justify-content: center; }
.ad-btn {
  cursor: pointer; padding: 10px 18px; font-size: 14px; font-weight: 700;
  border: none; border-radius: 10px; color: #0a0d12;
  background: linear-gradient(90deg, var(--accent), #ff8a3b);
}
.ad-btn.ad-skip { background: rgba(255, 255, 255, 0.12); color: #cfe3ff; }

/* =========================================================================
   Touch / mobile
   ========================================================================= */

/* Control-hint toggling (lobby) */
.touch-hint { display: none; }
body.touch .kbd-hint { display: none; }
body.touch .touch-hint { display: inline; }

/* No fake cursor / reticle on touch */
body.touch.ingame canvas#game { cursor: auto; }
body.touch #reticle { display: none !important; }

/* Touch controls layer — only on touch devices; .hidden toggles in/out of game */
#touchui { display: none; }
body.touch #touchui {
  display: block; position: fixed; inset: 0; z-index: 22;
  pointer-events: none; touch-action: none;
}
#touchui .stick, #touchui .tbtn { pointer-events: auto; touch-action: none; }

/* Stick zones (bottom corners) + floating knob */
#stick-move { position: absolute; left: 0; bottom: 0; width: 40%; height: 50%;
  padding-left: env(safe-area-inset-left); }
#stick-aim  { position: absolute; right: 0; bottom: 0; width: 40%; height: 50%;
  padding-right: env(safe-area-inset-right); }
.stick .knob {
  position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.5); pointer-events: none;
  opacity: 0; transition: opacity .12s; will-change: transform;
}
.stick .knob::before {
  content: ''; position: absolute; inset: -22px; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.22);
}
.stick.active .knob { opacity: 1; }

/* Rocket / missile buttons (just above the aim stick) */
.tbtns { position: absolute; right: 16px; bottom: 52%; display: flex; flex-direction: column; gap: 14px;
  padding-right: env(safe-area-inset-right); pointer-events: none; }
.tbtn {
  pointer-events: auto; width: 60px; height: 60px; border-radius: 50%; position: relative;
  font-size: 24px; line-height: 1; color: #fff;
  background: rgba(20, 24, 30, 0.6); border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(4px);
}
.tbtn.on, .tbtn:active { transform: scale(0.92); background: rgba(255, 90, 54, 0.45); }
#tmissct {
  position: absolute; right: -3px; bottom: -3px; font-size: 12px; font-weight: 800;
  background: #0b0e13; border-radius: 8px; padding: 0 5px; color: #9fe4ff;
}

/* Rotate-to-landscape nudge */
#rotate { display: none; }
body.touch #rotate:not(.hidden) {
  display: grid; position: fixed; inset: 0; z-index: 40; place-items: center; text-align: center;
  background: radial-gradient(circle at 50% 40%, #1a2433, #06090e 75%); color: #eaf1f8;
}
#rotate .rotate-icon { font-size: 72px; animation: rotnudge 1.8s ease-in-out infinite; transform-origin: 50% 50%; }
#rotate .rotate-inner div { font-size: 20px; font-weight: 800; letter-spacing: 1px; margin-top: 8px; }
#rotate small { color: #9fb0c2; font-weight: 600; }
@keyframes rotnudge { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-25deg); } }

/* ---- Responsive HUD (touch only — desktop never affected) ---- */
@media (max-width: 1024px) {
  body.touch #matchtimer { font-size: 18px; padding: 5px 12px; top: 8px; }
  body.touch #arenaname { top: 44px; font-size: 10px; }
  body.touch #minimap-wrap { top: 10px; right: 10px; }
  body.touch #minimap { width: 132px; height: 132px; display: block; }
  body.touch #scoreboard { top: 10px; left: 10px; min-width: 0; max-width: 40vw; font-size: 11px; padding: 6px 9px; }
  body.touch #standings { display: none; }
  body.touch #killfeed { display: none; } /* hide the right-side info boxes on mobile */
  body.touch #missileammo { display: none; }            /* count lives on the 🎯 button */
  body.touch #healthbar { width: 150px; height: 16px; }
  body.touch #status { gap: 0; }
}
@media (orientation: landscape) and (max-height: 480px) {
  body.touch .tbtn { width: 52px; height: 52px; font-size: 20px; }
  /* Compact lobby so it fits a short landscape phone without scrolling */
  .logo { width: min(210px, 30%); margin: 0 auto 2px; }
  .cards { margin: 8px 0; gap: 8px; }
  .card { padding: 8px 11px; }
  .card-h { margin-bottom: 6px; }
  .feat { margin: 5px 0; }
  .controls { margin-top: 10px; }
  .panel { padding: 10px 16px; }
}

/* ---- Responsive lobby ---- */
@media (max-width: 720px) {
  .logo { width: min(300px, 64%); }
  .cards { grid-template-columns: 1fr; gap: 8px; margin: 12px 0; }
  .card { padding: 10px 12px; }
  .joinbar { flex-wrap: wrap; max-width: 100%; }
  .joinbar .aliaswrap { flex: 1 1 100%; }
  .codewrap { flex: 1 1 100%; width: auto; }
  .joinbar .btngroup { flex: 1 1 100%; }
  .joinbar #play { flex: 1 1 auto; padding: 12px 16px; }
  .joinbar #watch { flex: 1 1 auto; padding: 12px 16px; justify-content: center; }
  .panel { padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
  #alias, #roomcode, #play { font-size: 15px; }
  .joinhint { font-size: 11px; }
}
