:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111827;
  color: #f8fafc;
  touch-action: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  position: fixed;
  inset: 0;
}

button {
  border: 0;
  border-radius: 8px;
  min-width: 132px;
  min-height: 46px;
  padding: 0 22px;
  background: #22c55e;
  color: #052e16;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(34, 197, 94, 0.25);
  transition: transform 140ms ease, box-shadow 180ms ease, background 180ms ease;
}

input {
  width: min(240px, 100%);
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 0 13px;
  background: rgba(2, 6, 23, 0.7);
  color: #f8fafc;
  font: inherit;
  font-weight: 800;
  outline: none;
  text-align: center;
}

input:focus {
  border-color: rgba(34, 197, 94, 0.8);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

button:active {
  transform: translateY(1px);
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #111827;
}

.minimap {
  pointer-events: none;
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: none;
  width: 152px;
  height: 152px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.66);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.coords {
  pointer-events: none;
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 160px);
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 9px;
  background: rgba(2, 6, 23, 0.66);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(10px);
}

.hud {
  pointer-events: none;
  position: fixed;
  inset: 0;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
}

body:not(.playing) .topbar,
body:not(.playing) .leaderboard {
  display: none;
}

.brand,
.stat,
.dash-meter,
.ping-stat,
.leaderboard,
.center-panel,
.skin-panel,
.server-panel,
.info-panel,
.upgrade-panel,
.ad-slot {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.brand {
  border-radius: 8px;
  padding: 11px 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.stat {
  display: grid;
  min-width: 72px;
  border-radius: 8px;
  padding: 7px 10px;
}

.stat span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  font-size: 18px;
  line-height: 1.05;
}

.dash-meter {
  display: grid;
  gap: 5px;
  width: 118px;
  border-radius: 8px;
  padding: 7px 10px;
}

.dash-meter span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.ping-stat {
  display: grid;
  min-width: 74px;
  border-radius: 8px;
  padding: 7px 10px;
}

.ping-stat span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.ping-stat strong {
  color: #86efac;
  font-size: 16px;
  line-height: 1.2;
}

.dash-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
}

.dash-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #f97316;
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 80ms linear;
}

.leaderboard {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: min(210px, calc(100vw - 28px));
  border-radius: 8px;
  padding: 12px;
}

.leaderboard h2 {
  margin: 0 0 8px;
  color: #cbd5e1;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.leaderboard ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 22px;
}

.leaderboard li {
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
}

.split-button {
  pointer-events: auto;
  position: absolute;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: none;
  min-width: 88px;
  min-height: 54px;
  background: #f97316;
  color: #431407;
  box-shadow: 0 12px 30px rgba(249, 115, 22, 0.25);
}

.ad-slot {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 160px;
  height: 600px;
  border-radius: 8px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  transform: translateY(-50%);
}

.ad-left {
  left: max(18px, env(safe-area-inset-left));
}

.ad-right {
  right: max(18px, env(safe-area-inset-right));
}

.ad-slot span {
  display: grid;
  place-items: center;
  width: calc(100% - 18px);
  height: calc(100% - 18px);
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 6px;
}

.playing .menu-ad,
.gameover-ad.hidden {
  display: none;
}

.center-panel {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  width: min(410px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 30px 24px 26px;
  text-align: center;
  transform: translate(-50%, -50%);
  opacity: 1;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

#startPanel {
  top: 56%;
}

.menu-logo-banner {
  pointer-events: none;
  position: absolute;
  top: clamp(16px, 4.2vh, 48px);
  left: 50%;
  z-index: 2;
  display: grid;
  justify-items: center;
  width: min(520px, calc(100vw - 44px));
  transform: translateX(-50%);
}

.menu-logo {
  display: block;
  width: min(470px, 82vw);
  max-height: clamp(150px, 29vh, 285px);
  object-fit: contain;
  margin: 0;
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.42));
}

.menu-logo.is-missing {
  display: none;
}

.menu-logo.is-loaded + .logo-fallback {
  display: none;
}

.center-panel h1 {
  margin: 0;
  max-width: 100%;
  font-size: clamp(42px, 12vw, 68px);
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.logo-fallback {
  display: block;
  max-width: 100%;
  color: #f8fafc;
  font-size: clamp(42px, 10vw, 72px);
  font-weight: 950;
  line-height: 0.95;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.center-panel p {
  max-width: 270px;
  margin: 12px 0 22px;
  color: #cbd5e1;
  font-size: 15px;
  line-height: 1.45;
}

#gameOverPanel {
  overflow: hidden;
}

#gameOverPanel h1 {
  max-width: 100%;
  font-size: clamp(34px, 6vw, 64px);
  overflow-wrap: normal;
  white-space: nowrap;
  word-break: keep-all;
}

#gameOverPanel::before {
  position: absolute;
  inset: -40%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 63, 94, 0.34), transparent 58%);
  content: "";
  opacity: 0;
  transform: scale(0.45);
}

#gameOverPanel.death-reveal {
  animation: death-panel-in 420ms cubic-bezier(0.18, 0.88, 0.25, 1.2);
}

#gameOverPanel.death-reveal::before {
  animation: death-pulse 900ms ease-out;
}

.death-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(320px, 100%);
}

.death-actions button {
  min-width: 0;
  padding: 0 14px;
}

.menu-button {
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #0f172a;
  color: #e2e8f0;
  box-shadow: none;
}

@keyframes death-panel-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.72) rotate(-2deg);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes death-pulse {
  0% {
    opacity: 0.9;
    transform: scale(0.25);
  }

  100% {
    opacity: 0;
    transform: scale(1.15);
  }
}

.language-switch {
  display: inline-flex;
  gap: 6px;
  margin: 4px 0 2px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.58);
}

.menu-language {
  pointer-events: auto;
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 3;
}

.language-button {
  min-width: 48px;
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  color: #cbd5e1;
  box-shadow: none;
}

.language-button[aria-pressed="true"] {
  background: #38bdf8;
  color: #082f49;
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.22);
}

.player-form {
  display: grid;
  justify-items: center;
  gap: 11px;
  width: 100%;
}

.menu-tools {
  pointer-events: auto;
  position: absolute;
  top: calc(56% + 182px);
  left: 50%;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 240px));
  gap: 12px;
  width: min(492px, calc(100vw - 36px));
  transform: translateX(-50%);
}

.player-form label {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.skin-open-button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(56, 189, 248, 0.42);
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.26);
}

.skin-open-button span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  text-transform: uppercase;
}

.skin-open-button strong {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-open-button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  width: min(240px, 100%);
  min-height: 48px;
  border: 1px solid rgba(45, 212, 191, 0.42);
  background: #0f766e;
  color: #f0fdfa;
  box-shadow: 0 12px 28px rgba(20, 184, 166, 0.22);
}

.server-open-button span {
  color: rgba(240, 253, 250, 0.76);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
}

.server-open-button strong {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skin-panel {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: grid;
  justify-items: center;
  width: min(390px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 24px 22px 22px;
  transform: translate(-50%, -50%);
  opacity: 1;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.server-panel {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: min(430px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 24px 22px 22px;
  text-align: center;
  transform: translate(-50%, -50%);
  opacity: 1;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.server-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1;
}

.server-panel p {
  margin: 0 0 14px;
  color: #cbd5e1;
  font-size: 14px;
}

.server-grid {
  display: grid;
  gap: 9px;
  width: 100%;
  margin-bottom: 16px;
}

.server-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(45, 212, 191, 0.2);
  background: #0f172a;
  color: #f8fafc;
  box-shadow: none;
}

.server-signal {
  display: inline-flex;
  align-items: end;
  gap: 3px;
  width: 34px;
  height: 23px;
}

.server-signal i {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: #22c55e;
  box-shadow: 0 0 9px rgba(34, 197, 94, 0.45);
}

.server-signal i:nth-child(1) {
  height: 7px;
}

.server-signal i:nth-child(2) {
  height: 10px;
}

.server-signal i:nth-child(3) {
  height: 14px;
}

.server-signal i:nth-child(4) {
  height: 18px;
}

.server-signal i:nth-child(5) {
  height: 22px;
}

.server-option[aria-pressed="true"] {
  border-color: rgba(45, 212, 191, 0.78);
  background: #115e59;
}

.info-open-button {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(250, 204, 21, 0.48);
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #431407;
  box-shadow: 0 12px 28px rgba(249, 115, 22, 0.24);
}

.info-panel,
.upgrade-panel {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: min(430px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 24px 22px 22px;
  text-align: center;
  transform: translateX(-50%);
  opacity: 1;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.info-panel {
  top: 50%;
  max-height: min(720px, calc(100vh - 36px));
  overflow-y: auto;
  transform: translate(-50%, -50%);
}

.info-panel h2,
.upgrade-panel h2 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1;
}

.info-list {
  display: grid;
  gap: 9px;
  margin: 4px 0 18px;
  text-align: left;
}

.info-list p,
.upgrade-panel p {
  margin: 0;
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.4;
}

.info-list strong {
  color: #f8fafc;
}

.upgrade-panel {
  top: max(86px, env(safe-area-inset-top));
}

.upgrade-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 14px;
}

.upgrade-option {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  min-height: 126px;
  padding: 14px 12px;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: none;
}

.upgrade-option strong {
  font-size: 15px;
}

.upgrade-option span {
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.25;
}

.skin-preview {
  width: 180px;
  height: 150px;
  margin-bottom: 6px;
}

.skin-panel strong {
  margin-bottom: 14px;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(5, 34px);
  gap: 8px;
  justify-content: center;
  width: 100%;
  margin-bottom: 4px;
}

.skin-option {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  padding: 0;
  background: var(--skin-bg);
  box-shadow: none;
}

.skin-option[aria-pressed="true"] {
  border-color: #f8fafc;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.28);
}

.hidden {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.96);
  visibility: hidden;
}

.upgrade-panel.hidden {
  transform: translateX(-50%) translateY(-12px) scale(0.96);
}

.joystick {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  display: none;
  width: 108px;
  height: 108px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.48);
}

.stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(248, 250, 252, 0.82);
  transform: translate(-50%, -50%);
}

.playing .center-panel {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.96);
  visibility: hidden;
}

.playing .skin-panel {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.96);
  visibility: hidden;
}

.playing .server-panel {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.96);
  visibility: hidden;
}

.playing .info-panel {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.96);
  visibility: hidden;
}

.playing .menu-logo-banner {
  display: none;
}

.playing .menu-tools,
.playing .menu-language {
  display: none;
}

#startPanel.hidden + .menu-tools {
  display: none;
}

.playing .minimap {
  display: block;
}

.playing .coords {
  display: block;
}

@media (hover: none) and (pointer: coarse) {
  .joystick {
    display: block;
  }

  .playing .split-button {
    display: block;
  }

  .minimap {
    bottom: calc(max(24px, env(safe-area-inset-bottom)) + 66px);
    width: 126px;
    height: 126px;
  }

  .coords {
    bottom: calc(max(24px, env(safe-area-inset-bottom)) + 198px);
  }

  .leaderboard {
    top: calc(max(14px, env(safe-area-inset-top)) + 58px);
    right: max(14px, env(safe-area-inset-right));
    bottom: auto;
    width: 164px;
  }

  .leaderboard li {
    font-size: 12px;
  }

  .ad-slot {
    display: none;
  }
}

@media (max-width: 880px), (max-height: 720px) {
  .ad-slot {
    display: none;
  }

  .menu-logo-banner {
    top: 12px;
  }

  .menu-logo {
    width: min(300px, 70vw);
    max-height: 150px;
  }

  .menu-tools {
    top: calc(56% + 168px);
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 7px;
  }

  .brand {
    padding: 10px;
  }

  .stat {
    min-width: 64px;
    padding: 7px 8px;
  }

  .dash-meter {
    width: 92px;
    padding: 7px 8px;
  }

  .ping-stat {
    min-width: 64px;
    padding: 7px 8px;
  }

  .stat strong {
    font-size: 16px;
  }

  .menu-logo {
    width: min(330px, 78vw);
    max-height: 180px;
  }

  .menu-tools {
    top: calc(56% + 168px);
    grid-template-columns: 1fr;
    width: min(240px, calc(100vw - 36px));
  }

  .menu-language {
    top: auto;
    right: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(50%);
  }

  .upgrade-options {
    grid-template-columns: 1fr;
  }

  .upgrade-option {
    min-height: 88px;
  }
}
