:root {
  --bg-1: #0a0c10;
  --bg-2: #151a1f;
  --bg-3: #1f2729;
  --accent: #d9432f;
  --accent-soft: #f2694a;
  --ink: #f2f2f2;
  --ink-dim: #b8c0c7;
  --ok: #5fe06f;
  --warning: #f4cf59;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 25% 20%, #253238 0%, transparent 40%),
    radial-gradient(circle at 80% 15%, #2a1c1d 0%, transparent 35%),
    linear-gradient(165deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
}

.game-shell {
  width: min(1200px, 100vw);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
  background: linear-gradient(180deg, #111920b8, #0f1318d2);
  border: 1px solid #ffffff1f;
  border-radius: 10px;
  backdrop-filter: blur(5px);
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.hud-label {
  color: var(--ink-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-value {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.health-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid #ffffff26;
  overflow: hidden;
  background-color: #1d2329;
}

.health-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ok), var(--warning), var(--accent));
  transition: width 0.15s linear;
}

.arena-wrap {
  position: relative;
  width: 100%;
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #ffffff26;
  border-radius: 12px;
  background: #0a1016;
  box-shadow: 0 18px 36px #00000066;
  touch-action: none;
}

.game-over {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.7rem;
  text-align: center;
  padding: 1rem;
  background: linear-gradient(170deg, #0f141dd9, #180c0fd6);
  border-radius: 12px;
  animation: fade-in 200ms ease-out;
}

.game-over h1 {
  margin: 0;
  color: #ffb5a4;
  letter-spacing: 0.04em;
}

.game-over p {
  margin: 0;
  color: var(--ink-dim);
}

.game-over button {
  justify-self: center;
  border: 0;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: linear-gradient(180deg, #ea6b4f, #cb3d2a);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.game-over button:hover {
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.1);
}

.hidden {
  display: none;
}

.touch-controls {
  display: none;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  padding: 0.25rem 0.2rem;
  user-select: none;
  -webkit-user-select: none;
}

.dpad {
  position: relative;
  width: 170px;
  height: 170px;
}

.ctrl-btn {
  position: absolute;
  border: 1px solid #ffffff2e;
  border-radius: 12px;
  background: linear-gradient(180deg, #232a33db, #12161cde);
  color: var(--ink);
  font-weight: 800;
  touch-action: none;
}

.ctrl-btn:active,
.ctrl-btn.active {
  transform: scale(0.96);
  filter: brightness(1.25);
}

.ctrl-btn.up,
.ctrl-btn.down,
.ctrl-btn.left,
.ctrl-btn.right {
  width: 60px;
  height: 60px;
  font-size: 1.05rem;
}

.ctrl-btn.up {
  left: 55px;
  top: 0;
}

.ctrl-btn.left {
  left: 0;
  top: 55px;
}

.ctrl-btn.right {
  right: 0;
  top: 55px;
}

.ctrl-btn.down {
  left: 55px;
  bottom: 0;
}

.ctrl-btn.fire {
  position: static;
  width: 135px;
  height: 135px;
  border-radius: 50%;
  font-size: 1.1rem;
  background: radial-gradient(circle at 30% 25%, #ef7f66, #b72e20);
  box-shadow: 0 0 0 4px #ffffff11, 0 8px 22px #00000055;
}

@media (max-width: 900px) {
  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (hover: none), (pointer: coarse) {
  body {
    align-items: start;
    padding: 0.3rem;
  }

  .game-shell {
    min-height: 100%;
  }

  .touch-controls {
    display: flex;
  }
}

@media (max-width: 600px) {
  .hud-label {
    font-size: 0.72rem;
  }

  .hud-value {
    font-size: 0.95rem;
  }

  .dpad {
    width: 150px;
    height: 150px;
  }

  .ctrl-btn.up,
  .ctrl-btn.down,
  .ctrl-btn.left,
  .ctrl-btn.right {
    width: 52px;
    height: 52px;
  }

  .ctrl-btn.up {
    left: 49px;
  }

  .ctrl-btn.left {
    top: 49px;
  }

  .ctrl-btn.right {
    top: 49px;
  }

  .ctrl-btn.down {
    left: 49px;
  }

  .ctrl-btn.fire {
    width: 120px;
    height: 120px;
    font-size: 1rem;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
