* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif;
  background: #0b1020;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.hidden { display: none !important; }

/* Screen-to-screen crossfade (menu <-> game <-> death), distinct from the
   plain .hidden utility above so these three can animate instead of
   popping instantly. */
#start-screen, #hud, #death-screen {
  transition: opacity 0.45s ease, transform 0.45s ease;
}
#start-screen.screen-off, #hud.screen-off, #death-screen.screen-off {
  opacity: 0;
  pointer-events: none;
}
#start-screen.screen-off { transform: scale(1.06); }
#death-screen.screen-off { transform: scale(0.96); }

/* ===================== START SCREEN ===================== */
#start-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 6vh 0 7vh;
  background: radial-gradient(ellipse at center, #6a6fd8 0%, #4b3fb5 55%, #3a2f9c 100%);
  overflow: hidden;
  z-index: 10;
}

/* A square sized off the larger viewport dimension, centered on the tank
   stage's own box (its parent, .logo-wrap, now centers that box for us -
   see below) so the burst's focal point always sits right behind the tank
   instead of at a fixed viewport percentage that drifts out of place
   whenever the tank's position changes. At any rotation its inscribed
   circle (radius = half the side) still covers every screen corner, so the
   rays never get clipped regardless of aspect ratio. z-index:-1 keeps it
   behind the tank canvas within .logo-wrap's stacking context. */
.rays {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 200vmax;
  height: 200vmax;
  margin: -100vmax 0 0 -100vmax;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255,255,255,0.05) 0deg 6deg,
    rgba(255,255,255,0.0) 6deg 12deg
  );
  animation: spin 90s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fills the whole vertical run above .menu-box (which stays pinned to the
   bottom via margin-top:auto) and centers the tank stage inside that run,
   instead of leaving it stuck to the top with all the leftover space
   falling below it. */
.logo-wrap {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 20px;
}

/* Sized off viewport HEIGHT (clamped) since the hero has to fit the upper
   third of the screen on any device; aspect-ratio derives the width from
   that, with a vw cap as a safety net on narrow-but-tall screens. This
   scales generously on tablets/desktop instead of maxing out at a small
   fixed pixel size like a phone-only layout would. */
.tank-stage {
  height: clamp(170px, 31vh, 480px);
  aspect-ratio: 1.45;
  max-width: 90vw;
  margin: 0 auto -6px;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.4));
  pointer-events: none;
}
.tank-stage canvas {
  width: 100%; height: 100%; display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.tank-stage canvas.ready { opacity: 1; }

/* The "tanks.io" wordmark is now real 3D geometry inside the tank canvas
   (see menu-tank.js / buildGroundText) - #title stays in the DOM only for
   document structure / screen readers. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.menu-box {
  position: relative;
  z-index: 2;
  margin-top: auto; /* pins the menu to the bottom, tank+title stay up top */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(92vw, 340px);
}

#nickname {
  width: min(100%, 280px);
  padding: 10px 16px;
  border-radius: 20px;
  border: none;
  outline: none;
  font-size: 14px;
  text-align: center;
  background: rgba(255,255,255,0.16);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
}
#nickname::placeholder { color: rgba(255,255,255,0.7); }
#nickname:focus { background: rgba(255,255,255,0.24); }

.play-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 5vw, 30px);
  width: 100%;
}

.side-stats {
  flex: 0 1 92px;
  min-width: 0;
  text-align: center;
}
.side-stats-title {
  font-size: 9px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding-bottom: 3px;
  margin-bottom: 3px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-stat {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  line-height: 1.15;
  margin-top: 4px;
  white-space: nowrap;
}
.side-stat-label {
  font-size: 9px;
  font-weight: 700;
  color: #a9d4ff;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.side-stat-value {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}

.play-btn {
  width: 100%;
  border: none;
  cursor: pointer;
  padding: 12px 0;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 700;
  color: #0c3d13;
  background: linear-gradient(180deg, #7bf08c 0%, #3ddc55 55%, #2fb946 100%);
  box-shadow: 0 4px 0 #1c7a2e, 0 8px 14px rgba(0,0,0,0.35);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.06s ease;
}
.play-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #1c7a2e, 0 4px 10px rgba(0,0,0,0.35); }
.play-btn { display: flex; align-items: center; justify-content: center; }
.play-row .play-btn {
  width: auto;
  flex: 1 1 110px;
  max-width: 138px;
  padding: 12px 6px;
  font-size: 15px;
}

.play-btn .btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(12,61,19,0.3);
  border-top-color: #0c3d13;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
.play-btn.loading { cursor: default; opacity: 0.9; }
.play-btn.loading .btn-label { display: none; }
.play-btn.loading .btn-spinner { display: inline-block; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

.conn-status { color: #ffd166; font-size: 13px; min-height: 16px; margin: 0; text-align: center; }

/* ===================== GAME CANVAS ===================== */
#game-canvas {
  position: fixed;
  inset: 0;
  display: block;
  background: #0e1526;
  transition: transform 1.6s ease;
  transform: scale(1);
}
#game-canvas.zoomed-out { transform: scale(0.88); }

/* ===================== HUD ===================== */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  font-family: 'Trebuchet MS', sans-serif;
  color: #fff;
}

#minimap {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(10, 14, 30, 0.55);
  border: 2px solid rgba(255,255,255,0.25);
}

#leaderboard {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(10, 14, 30, 0.55);
  border-radius: 8px;
  padding: 5px 8px;
  min-width: 100px;
  max-width: 140px;
}
.lb-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.6;
  margin-bottom: 3px;
}
#lb-list { list-style: none; margin: 0; padding: 0; font-size: 9px; }
#lb-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#lb-list li .lb-name { overflow: hidden; text-overflow: ellipsis; }
#lb-list li.me { font-weight: 700; }
#lb-list li.me .lb-name { text-shadow: 0 0 6px currentColor; }

#statbar {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  background: rgba(10, 14, 30, 0.5);
  padding: 5px 14px;
  border-radius: 10px;
}
.stat { text-align: center; }
.stat-value { font-size: 15px; font-weight: 700; }
.stat-label { font-size: 8px; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.5px; }

#cooldown-ring {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
}
#cooldown-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: rgba(10,14,30,0.5); stroke: rgba(255,255,255,0.15); stroke-width: 4; }
.ring-fg {
  fill: none;
  stroke: #ffcf4d;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.05s linear;
}

/* ===================== ICON BUTTONS (mute / fullscreen) ===================== */
.icon-btn {
  position: fixed;
  bottom: 12px;
  z-index: 30;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 14, 30, 0.55);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mute-btn { left: 12px; }
.fullscreen-btn { left: 56px; }

/* ===================== DEATH SCREEN ===================== */
#death-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(6, 8, 20, 0.32);
}
