:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: #070611;
  color: #ecf0ff;
  touch-action: none;
}

#game-root {
  width: 100%;
  height: 100%;
  touch-action: none;
}

#game-root canvas {
  display: block;
}

.hud {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 12;
}

.hud-row {
  width: fit-content;
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(124, 58, 237, 0.45);
  background: rgba(8, 8, 20, 0.72);
  box-shadow: 0 8px 26px rgba(5, 3, 15, 0.5);
  backdrop-filter: blur(5px);
}

.hud-row--small {
  gap: 24px;
  font-size: 13px;
  color: rgba(236, 240, 255, 0.82);
}

.hud b {
  color: #22d3ee;
  font-variant-numeric: tabular-nums;
}

.crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  margin-left: -9px;
  border-radius: 999px;
  border: 2px solid rgba(34, 211, 238, 0.95);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.6);
  z-index: 11;
  pointer-events: none;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(34, 211, 238, 0.95);
}

.crosshair::before {
  width: 2px;
  height: 26px;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
}

.crosshair::after {
  height: 2px;
  width: 26px;
  top: 50%;
  left: -6px;
  transform: translateY(-50%);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(5, 4, 16, 0.64), rgba(3, 2, 9, 0.88));
  z-index: 20;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(520px, 92vw);
  padding: 24px 24px 20px;
  border-radius: 18px;
  border: 1px solid rgba(124, 58, 237, 0.45);
  background: rgba(14, 12, 33, 0.92);
  box-shadow: 0 20px 40px rgba(5, 3, 12, 0.45);
}

.panel h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 38px);
}

.panel p {
  margin: 0 0 16px;
  color: rgba(236, 240, 255, 0.82);
  line-height: 1.45;
}

.panel button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #22d3ee);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 12px 18px;
}

.panel button:hover {
  filter: brightness(1.08);
}

.touch-controls {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  z-index: 16;
  pointer-events: none;
}

.touch-controls.hidden {
  display: none;
}

.touch-controls__left,
.touch-controls__right {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.touch-controls__left {
  align-items: flex-start;
}

.touch-controls__right {
  width: min(46vw, 190px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.joystick-base {
  width: 118px;
  height: 118px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  background: radial-gradient(circle at 35% 35%, rgba(45, 65, 112, 0.58), rgba(9, 12, 28, 0.82));
  box-shadow: inset 0 0 24px rgba(34, 211, 238, 0.12), 0 8px 24px rgba(3, 5, 16, 0.45);
  position: relative;
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.7);
  background: radial-gradient(circle at 32% 32%, rgba(167, 238, 255, 0.9), rgba(34, 211, 238, 0.38));
  box-shadow: 0 4px 14px rgba(8, 44, 56, 0.5);
  pointer-events: none;
}

.touch-controls button {
  appearance: none;
  border: 1px solid rgba(34, 211, 238, 0.42);
  border-radius: 12px;
  background: rgba(8, 12, 28, 0.8);
  color: #eaf6ff;
  font-weight: 700;
  font-size: 14px;
  min-height: 42px;
  min-width: 0;
  width: 100%;
  padding: 9px 8px;
  touch-action: none;
  user-select: none;
}

.touch-controls button:active {
  transform: scale(0.98);
  background: rgba(34, 211, 238, 0.32);
}

#btn-shoot {
  min-height: 52px;
  border-color: rgba(236, 72, 153, 0.55);
}

#btn-fullscreen {
  grid-column: 1 / -1;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#btn-fullscreen svg {
  width: 16px;
  height: 16px;
}

.fs-exit-btn {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  z-index: 26;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.55);
  background: rgba(8, 12, 28, 0.82);
  color: #eaf6ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: none;
  box-shadow: 0 8px 18px rgba(3, 6, 20, 0.42);
}

.fs-exit-btn svg {
  width: 18px;
  height: 18px;
}

.fs-exit-btn.hidden {
  display: none;
}

.fs-exit-btn:active {
  transform: scale(0.96);
}

body.is-mobile .crosshair {
  width: 16px;
  height: 16px;
  margin-top: -8px;
  margin-left: -8px;
}

@media (max-width: 880px) {
  .hud-row {
    width: auto;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 12px;
  }

  .hud-row--small {
    font-size: 12px;
    gap: 14px;
  }
}

@media (max-width: 520px) {
  .touch-controls {
    left: 6px;
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  .joystick-base {
    width: 102px;
    height: 102px;
  }

  .joystick-knob {
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
  }

  .touch-controls__right {
    width: min(50vw, 168px);
  }

  .touch-controls button {
    font-size: 12px;
    min-height: 40px;
    padding: 8px 6px;
  }

  #btn-shoot {
    min-height: 48px;
  }

  .fs-exit-btn {
    width: 34px;
    height: 34px;
    top: calc(6px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
  }
}
