:root {
  --bg: #070b17;
  --bg-2: #0b1330;
  --accent: #42d9ff;
  --accent-2: #9a4dff;
  --danger: #ff4f7c;
  --ok: #52ff9f;
  --text: #e7f2ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #122040 0%, var(--bg) 40%, #03050d 100%);
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.health-panel .name {
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 12px;
  margin-bottom: 6px;
  opacity: 0.9;
}

.health-track {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.health-fill {
  width: 100%;
  height: 100%;
  transition: width 180ms linear, box-shadow 160ms ease;
}

.player-fill {
  background: linear-gradient(90deg, #4de5ff, #2ea0ff);
  box-shadow: 0 0 12px rgba(66, 217, 255, 0.8);
}

.enemy-fill {
  background: linear-gradient(90deg, #ff7db8, #ff3f69);
  box-shadow: 0 0 12px rgba(255, 79, 124, 0.8);
}

.center-info {
  text-align: center;
}

.round-state {
  font-size: 18px;
  font-weight: 700;
}

.combo-text {
  font-size: 12px;
  opacity: 0.85;
}

.arena-wrap {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.arena {
  position: relative;
  min-height: 460px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(8, 18, 45, 0.85), rgba(6, 10, 24, 0.96));
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(66, 217, 255, 0.15), 0 16px 40px rgba(0, 0, 0, 0.35);
}

.arena-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(66, 217, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66, 217, 255, 0.08) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.energy-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms ease;
  background: radial-gradient(circle at center, rgba(154, 77, 255, 0.4), transparent 55%);
}

.energy-flash.active {
  opacity: 1;
}

.fighter {
  --fighter-x: 15%;
  --fighter-y: 58%;
  --arm-angle: -12deg;
  position: absolute;
  left: var(--fighter-x);
  top: var(--fighter-y);
  width: 120px;
  height: 190px;
  transform: translate(-50%, -50%);
  transition: left 80ms linear, top 80ms linear, filter 120ms ease;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.35));
}

.fighter .head,
.fighter .body,
.fighter .arm,
.fighter .leg {
  position: absolute;
  border-radius: 999px;
}

.fighter .head {
  top: 8px;
  left: 44px;
  width: 30px;
  height: 30px;
}

.fighter .body {
  top: 38px;
  left: 36px;
  width: 48px;
  height: 72px;
  border-radius: 18px;
}

.fighter .arm {
  top: 48px;
  width: 44px;
  height: 14px;
  transform-origin: 8px center;
  transition: transform 100ms ease;
}

.fighter .arm-front {
  left: 68px;
  transform: rotate(var(--arm-angle));
}

.fighter .arm-back {
  left: 8px;
  transform: rotate(calc(var(--arm-angle) * -0.55));
  opacity: 0.8;
}

.fighter .leg {
  top: 108px;
  width: 18px;
  height: 62px;
}

.fighter .leg-front {
  left: 64px;
}

.fighter .leg-back {
  left: 36px;
  opacity: 0.86;
}

.player .head,
.player .body,
.player .arm,
.player .leg {
  background: linear-gradient(180deg, #72f7ff, #2b9fff);
  box-shadow: 0 0 10px rgba(66, 217, 255, 0.6);
}

.enemy .head,
.enemy .body,
.enemy .arm,
.enemy .leg {
  background: linear-gradient(180deg, #ffc4e2, #ff4f7c);
  box-shadow: 0 0 10px rgba(255, 79, 124, 0.55);
}

.enemy {
  --fighter-x: 82%;
  --fighter-y: 58%;
  --arm-angle: 192deg;
  transform: translate(-50%, -50%) scaleX(-1);
}

.fighter.idle {
  animation: breathe 1.2s infinite ease-in-out;
}

.fighter.attack .arm-front {
  transform: rotate(8deg) scaleX(1.08);
}

.enemy.attack .arm-front {
  transform: rotate(180deg) scaleX(1.08);
}

.fighter.defend .arm-front {
  transform: rotate(-45deg);
}

.fighter.hit {
  animation: hitShake 160ms 1;
  filter: brightness(1.35) drop-shadow(0 0 16px rgba(255, 255, 255, 0.6));
}

.fighter.strong .arm-front {
  transform: rotate(20deg) scaleX(1.22);
}

.camera-panel {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(9, 16, 38, 0.95), rgba(4, 10, 24, 0.95));
  padding: 12px;
}

.camera-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.camera-header h2 {
  margin: 0;
  font-size: 16px;
}

.gesture-label {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(66, 217, 255, 0.12);
  border: 1px solid rgba(66, 217, 255, 0.4);
}

.camera-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#webcam,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#webcam {
  transform: scaleX(-1);
  opacity: 0.86;
}

.hint {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.5;
  margin-top: 10px;
}

.modal-screen {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(1, 5, 12, 0.86);
  z-index: 99;
}

.modal-screen.visible {
  display: grid;
}

.modal-card {
  width: min(560px, 90%);
  padding: 28px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, rgba(14, 26, 61, 0.94), rgba(8, 15, 34, 0.96));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.modal-card h1,
.modal-card h2 {
  margin-top: 0;
}

.btn-primary {
  border: 0;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #00111c;
  background: linear-gradient(90deg, #5de7ff, #9a5dff);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 140ms ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(90, 176, 255, 0.35);
}

@keyframes breathe {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, -51.8%);
  }
}

@keyframes hitShake {
  0% {
    transform: translate(-50%, -50%);
  }
  25% {
    transform: translate(-48%, -50%);
  }
  50% {
    transform: translate(-52%, -50%);
  }
  100% {
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 980px) {
  .arena-wrap {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .hud {
    grid-template-columns: 1fr;
  }

  .fighter {
    width: 100px;
    height: 160px;
  }

  .fighter .head {
    top: 8px;
    left: 38px;
    width: 24px;
    height: 24px;
  }

  .fighter .body {
    top: 32px;
    left: 31px;
    width: 38px;
    height: 58px;
  }

  .fighter .arm {
    top: 40px;
    width: 34px;
    height: 10px;
  }

  .fighter .leg {
    top: 86px;
    height: 50px;
  }
}
