@font-face {
  font-display: swap;
  font-family: 'Battle Cities UI';
  font-style: normal;
  font-weight: 400;
  src: url('/fonts/BarlowCondensed-Regular.ttf') format('truetype');
}

@font-face {
  font-display: swap;
  font-family: 'Battle Cities UI';
  font-style: normal;
  font-weight: 600;
  src: url('/fonts/BarlowCondensed-SemiBold.ttf') format('truetype');
}

@font-face {
  font-display: swap;
  font-family: 'Battle Cities UI';
  font-style: normal;
  font-weight: 700;
  src: url('/fonts/BarlowCondensed-Bold.ttf') format('truetype');
}

html {
  display: flex;
  height: 100%;
}

[hidden] {
  display: none !important;
}

body {
  align-items: stretch;
  background: radial-gradient(
      circle at 78% 12%,
      rgba(255, 176, 28, 0.18),
      transparent 30%
    ),
    linear-gradient(135deg, #070807 0%, #10130e 48%, #050607 100%);
  color: #f4efe4;
  display: flex;
  flex: 1;
  font-family: 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial, sans-serif;
  letter-spacing: 1px;
  justify-content: center;
  margin: 0;
  min-height: 100vh;
  overflow: auto;
  position: relative;
}

body.game-running {
  background: #000;
  overflow: hidden;
}

body.game-running::before {
  background: radial-gradient(
    circle at center,
    rgba(0, 0, 0, 0) 48%,
    rgba(0, 0, 0, 0.18) 68%,
    rgba(0, 0, 0, 0.45) 84%,
    rgba(0, 0, 0, 0.72) 100%
  );
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
}

body.game-running::after {
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.12) 0,
    rgba(255, 255, 255, 0.12) 1px,
    rgba(0, 0, 0, 0.32) 1px,
    rgba(0, 0, 0, 0.32) 4px
  );
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
}

body.scanlines-disabled::before,
body.scanlines-disabled::after {
  display: none;
}

.webrtc-network-stats {
  background: rgba(5, 10, 12, 0.88);
  border: 1px solid rgba(83, 231, 84, 0.72);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.72),
    0 6px 18px rgba(0, 0, 0, 0.42);
  box-sizing: border-box;
  color: #d8e3dc;
  font-family: 'Battle Cities UI', 'Arial Narrow', sans-serif;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  left: 12px;
  letter-spacing: 1px;
  min-width: 132px;
  padding: 7px 9px 8px;
  pointer-events: none;
  position: fixed;
  top: 12px;
  z-index: 1002;
}

.webrtc-network-stats__title {
  color: #53e754;
  display: block;
  font-size: 12px;
  line-height: 16px;
  margin-bottom: 2px;
}

.webrtc-network-stats__row {
  align-items: baseline;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  line-height: 18px;
}

.webrtc-network-stats__row output {
  color: #ffc928;
  min-width: 54px;
  text-align: right;
}

@media (pointer: coarse) and (max-width: 900px) {
  .webrtc-network-stats {
    font-size: 12px;
    left: max(8px, env(safe-area-inset-left));
    min-width: 116px;
    padding: 5px 7px 6px;
    top: max(8px, env(safe-area-inset-top));
  }

  .webrtc-network-stats__title {
    font-size: 11px;
    line-height: 14px;
  }

  .webrtc-network-stats__row {
    line-height: 16px;
  }
}

.auth-shell {
  align-items: center;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
  position: relative;
  width: 100%;
  z-index: 2;
}

.auth-panel {
  background: rgba(16, 18, 14, 0.92);
  border: 1px solid rgba(255, 176, 28, 0.32);
  box-sizing: border-box;
  max-width: 460px;
  padding: 40px;
  width: 100%;
}

.auth-kicker {
  color: #ffb018;
  font: 700 13px/1.2 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  letter-spacing: 1px;
  margin-bottom: 14px;
  text-transform: uppercase;
}

.auth-panel h1 {
  color: #fff7df;
  font: 800 44px/1.02 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  margin: 0 0 16px;
}

.auth-copy {
  color: #c9c1ad;
  font: 400 16px/1.55 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  margin: 0 0 28px;
}

.auth-actions {
  display: grid;
  gap: 12px;
}

.auth-button {
  align-items: center;
  background: #202219;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f6f1e6;
  cursor: pointer;
  display: flex;
  font: 700 16px/1 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  text-align: left;
}

.auth-button:hover {
  background: #2a2d21;
}

.auth-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.auth-button:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

.auth-button--primary {
  background: #ffb018;
  border-color: #ffcf5c;
  color: #111207;
}

.auth-button--primary:hover {
  background: #ffc247;
}

.auth-button__mark {
  align-items: center;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: flex;
  flex: 0 0 30px;
  font: 800 13px/1 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.auth-store-link {
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-sizing: border-box;
  display: block;
  margin: 20px auto 0;
  max-width: 220px;
  min-height: 40px;
  padding: 8px 12px;
  transition: border-color 100ms ease-out, transform 100ms ease-out;
  width: 100%;
}

.auth-store-link img {
  display: block;
  height: auto;
  width: 100%;
}

@media (hover: hover) {
  .auth-store-link:hover {
    border-color: rgba(255, 176, 24, 0.72);
    transform: translateY(-1px);
  }
}

.auth-store-link:active {
  transform: translateY(1px);
}

.auth-store-link:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

.auth-technology {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #c7c1b4;
  display: flex;
  flex-wrap: wrap;
  font: 600 11px/1.4 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  gap: 10px 16px;
  justify-content: center;
  margin-top: 20px;
  padding: 14px 0;
}

.auth-technology__brand {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.auth-technology__solana {
  display: block;
  height: auto;
  width: 72px;
}

.auth-technology__magicblock {
  display: block;
  height: auto;
  width: 78px;
}

.auth-status {
  color: #9f9785;
  font: 400 14px/1.45 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  margin: 18px 0 0;
  min-height: 20px;
}

.auth-legal {
  color: #817b6c;
  font: 400 12px/1.5 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  margin: 14px 0 0;
}

.auth-legal a {
  color: #d8c98e;
}

.auth-legal a:hover {
  color: #ffb018;
}

.auth-legal a:focus-visible {
  outline: 2px solid #ffd166;
  outline-offset: 2px;
}

@media (max-width: 520px) {
  .auth-shell {
    padding: max(16px, env(safe-area-inset-top)) 16px
      max(16px, env(safe-area-inset-bottom));
  }

  .auth-panel {
    padding: 28px 24px;
  }

  .auth-panel h1 {
    font-size: 38px;
  }

  .auth-technology {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 768px), (pointer: coarse) {
  .auth-store-link {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-store-link {
    transition: none;
  }
}

.loading {
  align-items: center;
  background: #050706;
  box-sizing: border-box;
  display: flex;
  color: #fff;
  font-family: Lucida Console, Courier, monospace;
  inset: 0;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px;
  position: fixed;
  width: 100%;
  z-index: 2;
}

.splash__content {
  align-items: center;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  position: relative;
  width: 100%;
  z-index: 1;
}

.splash__logo {
  display: block;
  height: auto;
  max-width: 460px;
  width: min(76vw, 460px);
}

.splash__status {
  color: #fff7df;
  font: 700 17px/1.2 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  margin: 28px 0 12px;
  letter-spacing: 0;
  min-height: 21px;
  text-align: center;
  text-transform: uppercase;
}

.splash__progress {
  background: rgba(255, 255, 255, 0.16);
  height: 4px;
  overflow: hidden;
  width: min(320px, 72vw);
}

.splash__progress span {
  background: #ffb018;
  display: block;
  height: 100%;
  transform: translateX(-70%);
  width: 56%;
}

.splash__version {
  color: #777d7c;
  font: 600 11px/1 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  letter-spacing: 1px;
  margin: 12px 0 0;
  text-transform: uppercase;
}

.splash__technology {
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  color: #d6d0c2;
  display: flex;
  flex-wrap: wrap;
  font: 600 12px/1.4 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
    sans-serif;
  gap: 14px 24px;
  justify-content: center;
  letter-spacing: 0;
  margin-top: 20px;
  padding-top: 18px;
  width: min(520px, 88vw);
}

.splash__technology-brand {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.splash__technology-brand img {
  display: block;
  height: auto;
  max-height: 24px;
  max-width: 92px;
}

@media (prefers-reduced-motion: no-preference) {
  .splash__progress span {
    animation: splash-progress 1100ms ease-in-out infinite alternate;
  }
}

@keyframes splash-progress {
  from {
    transform: translateX(-70%);
  }
  to {
    transform: translateX(150%);
  }
}

@media (max-width: 520px) {
  .loading {
    padding: 24px 18px;
  }

  .splash__status {
    font-size: 15px;
    margin-top: 22px;
  }

  .splash__technology {
    align-items: flex-start;
    flex-direction: column;
    width: min(300px, 88vw);
  }
}

canvas {
  display: block;
  height: 100vh;
  image-rendering: pixelated;
  width: 100vw;
}

/* Cosmetic particle overlay, composited directly over the game canvas. */
.particle-overlay {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 1;
}

.mobile-touch-controller {
  display: none;
}

.game-stage {
  display: contents;
}

@media (pointer: coarse) and (max-width: 900px) {
  body.game-running {
    display: block;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    width: 100%;
  }

  body.game-running .game-stage {
    background: #000;
    display: block;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
  }

  body.game-running.level-playing .game-stage {
    height: 60dvh;
  }

  body.game-running.main-menu-active .game-stage {
    background-image: url('/assets/main-menu-battlefield-mobile.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
  }

  body.game-running canvas:not(.particle-overlay) {
    height: var(--mobile-game-css-height);
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--mobile-game-css-width);
  }

  body.game-running.main-menu-active canvas:not(.particle-overlay),
  body.game-running.shop-active canvas:not(.particle-overlay),
  body.game-running.ranking-active canvas:not(.particle-overlay),
  body.game-running.settings-active canvas:not(.particle-overlay),
  body.game-running.panel-screen-active canvas:not(.particle-overlay) {
    top: 0;
    transform: translateX(-50%);
  }

  body.game-running .particle-overlay {
    height: var(--mobile-game-css-height);
    inset: auto;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--mobile-game-css-width);
  }

  body.game-running.main-menu-active .particle-overlay,
  body.game-running.shop-active .particle-overlay,
  body.game-running.ranking-active .particle-overlay,
  body.game-running.settings-active .particle-overlay,
  body.game-running.panel-screen-active .particle-overlay {
    top: 0;
    transform: translateX(-50%);
  }

  body.game-running .mobile-gamepad-qr,
  body.game-running .mobile-gamepad-debug {
    display: none;
  }

  body.game-running .mobile-touch-controller {
    --controller-accent: #ffae0a;
    --controller-bg: #11130f;
    --controller-line: #5f5a43;
    --controller-panel: #20231b;
    background-color: var(--controller-bg);
    background-image: linear-gradient(
        rgba(255, 255, 255, 0.015),
        rgba(0, 0, 0, 0.08)
      ),
      url('/assets/mobile-gamepad-panel-background.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    border-top: 0;
    bottom: 0;
    box-sizing: border-box;
    display: none;
    grid-template-rows: 0 1fr;
    height: 40dvh;
    left: 0;
    padding: 8px max(12px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    position: fixed;
    max-width: 100%;
    width: 100%;
    z-index: 30;
  }

  body.game-running.level-playing .mobile-touch-controller {
    display: grid;
  }

  .mobile-touch-controller button {
    -webkit-tap-highlight-color: transparent;
    color: #f5f2e8;
    cursor: pointer;
    font-family: 'Battle Cities UI', 'Arial Narrow', 'Segoe UI', Arial,
      sans-serif;
    touch-action: none;
    user-select: none;
  }

  .mobile-touch-controller button:focus-visible {
    outline: 3px solid #fff2b5;
    outline-offset: 2px;
  }

  .mobile-touch-controller__powers {
    align-items: center;
    align-self: start;
    aspect-ratio: 963 / 311;
    background: url('/assets/mobile-gamepad-loadout-container.png') center /
      contain no-repeat;
    box-sizing: border-box;
    display: grid;
    gap: clamp(6px, 1.7vw, 12px);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-self: stretch;
    margin-top: -18px;
    overflow: hidden;
    padding: clamp(24px, 4.1dvh, 38px) clamp(22px, 5.5vw, 44px)
      clamp(12px, 1.8dvh, 18px);
    visibility: hidden;
    width: 100%;
  }

  .mobile-touch-controller.is-gameplay,
  body.level-playing .mobile-touch-controller {
    grid-template-rows: minmax(clamp(104px, 32vw, 164px), auto) 1fr;
  }

  .mobile-touch-controller.is-gameplay .mobile-touch-controller__powers,
  body.level-playing .mobile-touch-controller__powers {
    visibility: visible;
  }

  .mobile-touch-power {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    box-sizing: border-box;
    display: block;
    height: 100%;
    min-height: 44px;
    min-width: 0;
    padding: 0;
    position: relative;
  }

  .mobile-touch-power.is-equipped {
    box-shadow: inset 0 0 13px rgba(255, 127, 18, 0.22);
  }

  .mobile-touch-power.is-pressed {
    box-shadow: inset 0 0 18px rgba(255, 24, 16, 0.72),
      0 0 14px rgba(255, 24, 16, 0.45);
    transform: scale(0.96);
  }

  .mobile-touch-power__key {
    color: var(--controller-accent);
    display: block;
    font-size: clamp(14px, 3.2vw, 20px);
    font-weight: 900;
    left: clamp(5px, 1.5vw, 10px);
    line-height: 1;
    position: absolute;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.95);
    top: clamp(5px, 1.2dvh, 9px);
  }

  .mobile-touch-power__icon {
    height: clamp(60px, 10dvh, 92px);
    image-rendering: auto;
    left: 50%;
    max-width: clamp(60px, 19vw, 92px);
    object-fit: contain;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
  }

  .mobile-touch-power__count {
    bottom: clamp(4px, 0.9dvh, 8px);
    color: var(--controller-accent);
    font-size: clamp(13px, 2.8vw, 18px);
    font-weight: 900;
    position: absolute;
    right: clamp(6px, 1.5vw, 11px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  }

  .mobile-touch-controller__main {
    align-items: center;
    display: flex;
    justify-content: space-between;
    min-height: 0;
    padding: 4px clamp(4px, 3vw, 28px) 0;
  }

  .mobile-touch-stick {
    background-color: transparent;
    background-image: url('/assets/mobile-gamepad-joystick-base.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    border: 0;
    border-radius: 50%;
    box-shadow: none;
    flex: 0 0 auto;
    height: min(17dvh, 32vw, 150px);
    min-height: 88px;
    min-width: 88px;
    padding: 0;
    position: relative;
    transform: translateY(-10px);
    width: min(17dvh, 32vw, 150px);
  }

  .mobile-touch-stick::before {
    background: url('/assets/mobile-gamepad-joystick-ring.png') center / contain
      no-repeat;
    content: '';
    inset: -8%;
    pointer-events: none;
    position: absolute;
    z-index: 0;
  }

  .mobile-touch-stick__cross {
    background: url('/assets/mobile-gamepad-joystick-directions.png') center /
      contain no-repeat;
    inset: 8%;
    pointer-events: none;
    position: absolute;
    z-index: 1;
  }

  .mobile-touch-stick__knob {
    background: url('/assets/mobile-gamepad-joystick-knob.png') center / contain
      no-repeat;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.42);
    height: 42%;
    left: 50%;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translate(
      calc(-50% + var(--stick-x, 0px)),
      calc(-50% + var(--stick-y, 0px))
    );
    width: 42%;
    z-index: 2;
  }

  .mobile-touch-stick.is-pressed {
    box-shadow: 0 0 20px rgba(255, 24, 16, 0.95);
  }

  .mobile-touch-stick.is-pressed .mobile-touch-stick__knob {
    filter: drop-shadow(0 0 12px rgba(25, 82, 180, 0.98)) brightness(1.08);
  }

  .mobile-touch-fire {
    align-items: center;
    display: flex;
    gap: clamp(12px, 4vw, 28px);
    justify-content: flex-end;
  }

  .mobile-touch-fire__button {
    align-items: center;
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    border: 0;
    border-radius: 50%;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    height: min(14dvh, 24vw, 112px);
    justify-content: center;
    min-height: 64px;
    min-width: 64px;
    padding: 0;
    position: relative;
    width: min(14dvh, 24vw, 112px);
  }

  .mobile-touch-fire__button--normal {
    transform: translateY(-8px);
  }

  .mobile-touch-fire__button--normal .mobile-touch-fire__label {
    background-image: url('/assets/mobile-gamepad-normal-fire-button.png');
  }

  .mobile-touch-fire__button--rapid .mobile-touch-fire__label {
    background-image: url('/assets/mobile-gamepad-rapid-fire-button.png');
  }

  .mobile-touch-fire__button.is-pressed {
    box-shadow: 0 0 20px rgba(255, 24, 16, 0.95);
    transform: scale(0.96);
  }

  .mobile-touch-fire__button.is-pressed .mobile-touch-fire__label {
    filter: hue-rotate(-32deg) saturate(2.4) brightness(1.15);
  }

  .mobile-touch-fire__button--normal.is-pressed {
    transform: translateY(-6px) scale(0.96);
  }

  .mobile-touch-fire__label {
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    font-size: 0;
    inset: 0;
    position: absolute;
  }
}

@media (max-width: 560px) {
  .auth-shell {
    padding: 20px;
  }

  .auth-panel {
    padding: 28px 22px;
  }

  .auth-panel h1 {
    font-size: 34px;
  }
}
