@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --bg: #1a0a2e;
  --primary: #ff6b9d;
  --secondary: #f8a5c2;
  --shadow: #c44569;
  --surface: #2d1b69;
  --contrast: #6bc5ff;
  --joystick-size: 142px;
  --joystick-knob-size: 58px;
}

* {
  box-sizing: border-box;
  font-family: "Press Start 2P", monospace;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
}

body {
  background: var(--bg);
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
}

.title-wrap {
  text-align: center;
}

h1 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(28px, 4.8vw, 48px);
  letter-spacing: 10px;
  text-shadow: 4px 4px 0 var(--shadow), -2px -2px 0 var(--secondary);
}

.subtitle {
  margin: 14px 0 0;
  font-size: 12px;
  letter-spacing: 6px;
  color: var(--secondary);
  opacity: 0.9;
}

.hud {
  width: min(1260px, 96vw);
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.hud-item {
  min-width: 210px;
  padding: 14px 18px;
  background: var(--surface);
  border: 4px solid var(--primary);
  box-shadow: 4px 4px 0 var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  letter-spacing: 2px;
}

.hud-action-item {
  justify-content: center;
}

.hud-btn {
  width: 100%;
  max-width: 210px;
  padding: 12px 10px;
  font-size: 10px;
  letter-spacing: 1px;
}

.label {
  color: var(--secondary);
  opacity: 0.8;
  font-size: 11px;
}

.game-shell {
  width: min(1260px, 96vw);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
}

#gameCanvas {
  width: min(960px, 72vw);
  height: auto;
  max-height: 72vh;
  border: 4px solid var(--primary);
  box-shadow: 4px 4px 0 var(--shadow);
  background: var(--bg);
  display: block;
}

.panel {
  width: 270px;
  background: var(--surface);
  border: 4px solid var(--primary);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel h2,
.panel h3 {
  margin: 0;
  color: var(--primary);
  letter-spacing: 3px;
  font-size: 14px;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 170px;
}

.player-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--secondary);
}

.player-row.dead {
  opacity: 0.45;
}

.swatch {
  width: 14px;
  height: 14px;
  border: 2px solid var(--secondary);
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.player-meta .name {
  color: var(--secondary);
}

.player-meta .level {
  color: var(--contrast);
  opacity: 0.9;
  font-size: 8px;
}

.player-area {
  color: var(--secondary);
  opacity: 0.9;
  font-size: 9px;
}

.controls {
  border-top: 4px solid var(--primary);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls p {
  margin: 0;
  color: var(--secondary);
  font-size: 9px;
  line-height: 1.55;
  letter-spacing: 1px;
  opacity: 0.88;
}

button {
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  padding: 20px 40px;
  background: var(--surface);
  color: var(--secondary);
  border: 4px solid var(--primary);
  cursor: pointer;
  letter-spacing: 2px;
  box-shadow: 4px 4px 0 var(--shadow);
  text-transform: uppercase;
  transition: none;
  user-select: none;
}

button:hover {
  background: var(--primary);
  color: var(--bg);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow);
}

button:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--shadow);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

button:disabled:hover,
button:disabled:active {
  background: var(--surface);
  color: var(--secondary);
  transform: none;
  box-shadow: 4px 4px 0 var(--shadow);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(26, 10, 46, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  text-align: center;
  padding: 28px;
}

.overlay h2 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(22px, 4vw, 36px);
  letter-spacing: 8px;
  text-shadow: 4px 4px 0 var(--shadow), -2px -2px 0 var(--secondary);
}

.overlay p {
  margin: 0;
  max-width: 900px;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 3px;
}

.hidden {
  display: none;
}

.touch-controls {
  display: none;
  width: min(1260px, 96vw);
  justify-content: flex-start;
}

body.touch-device .touch-controls {
  display: flex;
  position: fixed;
  left: 14px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  width: auto;
  z-index: 25;
  pointer-events: none;
}

.virtual-joystick {
  width: var(--joystick-size);
  height: var(--joystick-size);
  touch-action: none;
  opacity: 0.72;
  pointer-events: auto;
}

.virtual-joystick.active {
  opacity: 0.96;
}

.joystick-base {
  width: 100%;
  height: 100%;
  border: 4px solid var(--primary);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #3f267d 0%, #24164f 70%, #1b103b 100%);
  box-shadow: 4px 4px 0 var(--shadow), inset 0 0 0 4px rgba(248, 165, 194, 0.12);
  position: relative;
}

.joystick-base::before,
.joystick-base::after {
  content: "";
  position: absolute;
  background: rgba(248, 165, 194, 0.2);
}

.joystick-base::before {
  width: 6px;
  height: 76%;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
}

.joystick-base::after {
  height: 6px;
  width: 76%;
  top: 50%;
  left: 12%;
  transform: translateY(-50%);
}

.joystick-knob {
  width: var(--joystick-knob-size);
  height: var(--joystick-knob-size);
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: calc(var(--joystick-knob-size) / -2);
  margin-top: calc(var(--joystick-knob-size) / -2);
  border: 4px solid var(--secondary);
  border-radius: 50%;
  background: linear-gradient(165deg, #ff7fac 0%, #d24d78 100%);
  box-shadow: 3px 3px 0 var(--shadow);
  transform: translate(0, 0);
  transition: transform 130ms ease-out;
  pointer-events: none;
}

.virtual-joystick.active .joystick-knob {
  transition: none;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.blink {
  animation: blink 1s steps(1) infinite;
}

@media (max-width: 1180px) {
  .game-shell {
    flex-direction: column;
    align-items: center;
  }

  #gameCanvas {
    width: min(960px, 95vw);
    max-height: 58vh;
  }

  .panel {
    width: min(960px, 95vw);
  }

  .touch-controls {
    width: min(960px, 95vw);
    justify-content: center;
  }
}

@media (max-height: 760px) {
  :root {
    --joystick-size: 120px;
    --joystick-knob-size: 50px;
  }

  .app {
    gap: 14px;
  }

  .subtitle {
    letter-spacing: 4px;
    font-size: 10px;
  }

  .hud-item {
    padding: 10px 14px;
  }
}
