:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07090f;
  color: #f4f7fb;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 12%, rgba(82, 118, 164, 0.24), transparent 24rem),
    linear-gradient(180deg, #080b13 0%, #131722 58%, #283227 100%);
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 8px;
  width: min(410px, calc(100vw - 32px));
  pointer-events: none;
}

.hud div {
  position: relative;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(4, 8, 14, 0.58);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
}

.hud span,
.hud strong {
  display: block;
  white-space: nowrap;
}

.hud span {
  color: rgba(244, 247, 251, 0.66);
  font-size: 11px;
  line-height: 1.1;
}

.hud strong {
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 720;
}

.score-card {
  overflow: visible;
}

.score-deltas {
  position: absolute;
  right: 10px;
  bottom: -20px;
  display: grid;
  gap: 2px;
  min-width: 54px;
  text-align: right;
  pointer-events: none;
}

.score-delta {
  display: block;
  font-size: 14px;
  line-height: 1;
  font-weight: 820;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.62);
  animation: score-delta 1.1s ease-out forwards;
}

.score-delta.positive {
  color: #76f09b;
}

.score-delta.negative {
  color: #ff6c73;
}

@keyframes score-delta {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  16% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-16px);
  }
}

.record-form {
  position: absolute;
  left: 50%;
  top: calc(50% + 72px);
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(4, 8, 14, 0.78);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(12px);
}

.record-form[hidden] {
  display: none;
}

.record-form [hidden] {
  display: none;
}

.record-form label {
  display: block;
  margin-bottom: 8px;
  color: #f8fbff;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 800;
}

.record-form div {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 8px;
}

.record-form .record-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.record-form input,
.record-form button,
.record-form a {
  height: 40px;
  border-radius: 8px;
  font: inherit;
  font-weight: 760;
}

.record-form input {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fbff;
  padding: 0 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.record-form button,
.record-form a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: #f4f7fb;
  color: #10131a;
  cursor: pointer;
  text-decoration: none;
}

.record-form a {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fbff;
}

.record-form p {
  margin: 8px 0 0;
  color: rgba(244, 247, 251, 0.7);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 620;
}

.restart {
  position: absolute;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  width: 132px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #f4f7fb;
  color: #10131a;
  font: inherit;
  font-weight: 760;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.36);
  cursor: pointer;
}

.restart:hover {
  background: #dce8f5;
}

.target-scoreboard {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: min(560px, max(220px, calc(100vw - 800px)));
  pointer-events: none;
}

.target-scoreboard span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(4, 8, 14, 0.58);
  color: rgba(244, 247, 251, 0.78);
  font-size: 12px;
  line-height: 1;
  font-weight: 720;
  backdrop-filter: blur(10px);
}

.target-scoreboard span.destroyed {
  color: rgba(244, 247, 251, 0.38);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(97, 222, 255, 0.86);
}

.controls {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: min(260px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(4, 8, 14, 0.58);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.controls dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

.controls div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: baseline;
}

.controls dt,
.controls dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
}

.controls dt {
  color: #f4f7fb;
  font-weight: 760;
}

.controls dd {
  color: rgba(244, 247, 251, 0.72);
  font-weight: 620;
}

.touch-controls {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.touch-btn {
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  background: rgba(4, 8, 14, 0.58);
  color: #f4f7fb;
  font: inherit;
  font-size: 20px;
  font-weight: 760;
  backdrop-filter: blur(8px);
}

.touch-btn.active {
  background: rgba(97, 222, 255, 0.4);
  border-color: rgba(97, 222, 255, 0.75);
}

.touch-joystick {
  pointer-events: auto;
}

.joystick-base {
  position: relative;
  width: 128px;
  height: 128px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  background: rgba(4, 8, 14, 0.5);
  backdrop-filter: blur(8px);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(97, 222, 255, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.joystick-knob.returning {
  transition: transform 0.15s ease-out;
}

.touch-actions {
  display: grid;
  grid-template-columns: repeat(2, 74px);
  gap: 8px;
}

.action-fire {
  grid-column: 1 / span 2;
  height: 58px;
  font-size: 15px;
  background: rgba(255, 111, 61, 0.3);
  border-color: rgba(255, 149, 88, 0.6);
}

.action-fire.active {
  background: rgba(255, 149, 88, 0.55);
}

.action-shield,
.action-weapon {
  height: 46px;
  font-size: 11px;
}

.action-shield {
  background: rgba(97, 222, 255, 0.22);
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }

  .controls {
    display: none;
  }
}

@media (pointer: coarse) and (max-width: 480px) {
  .joystick-base {
    width: 108px;
    height: 108px;
  }

  .joystick-knob {
    width: 46px;
    height: 46px;
  }

  .touch-actions {
    grid-template-columns: repeat(2, 64px);
  }

  .action-fire {
    height: 50px;
  }

  .action-shield,
  .action-weapon {
    height: 40px;
  }
}

@media (max-width: 520px) {
  .hud {
    grid-template-columns: 1fr;
    width: 150px;
  }

  .hud div {
    padding: 8px 10px;
  }

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

  .target-scoreboard {
    max-width: calc(100vw - 190px);
    gap: 4px;
  }

  .target-scoreboard span {
    min-height: 24px;
    padding: 4px 6px;
    font-size: 10px;
  }

  .controls {
    bottom: 12px;
    left: 12px;
    width: min(226px, calc(100vw - 24px));
    padding: 8px 10px;
  }

  .controls div {
    grid-template-columns: 78px 1fr;
    gap: 8px;
  }

  .controls dt,
  .controls dd {
    font-size: 11px;
  }
}
