:root {
  color-scheme: dark;
  --bg: #090b11;
  --ink: #fff7fb;
  --muted: rgba(255, 247, 251, 0.58);
  --line: rgba(255, 255, 255, 0.16);
  --p1: #ff9fc7;
  --p2: #7bdff2;
  --gold: #ffe08a;
  --danger: #ff4d6d;
}

* {
  box-sizing: border-box;
}

html,
body,
#stage {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background:
    linear-gradient(180deg, #05070c 0%, #12131f 60%, #090b11 100%);
  color: var(--ink);
  font-family:
    Inter, "Microsoft JhengHei", "PingFang TC", "Noto Sans TC",
    "Helvetica Neue", Arial, sans-serif;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: relative;
  isolation: isolate;
}

#stage::before {
  position: fixed;
  inset: 0;
  z-index: 1;
  content: "";
  background:
    linear-gradient(90deg, rgba(255, 159, 199, 0.09), transparent 24%, transparent 76%, rgba(123, 223, 242, 0.09)),
    linear-gradient(180deg, rgba(5, 7, 12, 0.18), transparent 42%, rgba(5, 7, 12, 0.24));
  pointer-events: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #080a0e;
}

.hud {
  position: fixed;
  z-index: 3;
  pointer-events: none;
}

.topbar {
  top: max(16px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.fighter {
  min-width: 0;
  padding: 10px 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
    rgba(7, 9, 15, 0.52);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.fighter-right {
  text-align: right;
}

.fighter p,
.round p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 720;
  letter-spacing: 0;
}

.fighter h1 {
  margin: 5px 0 10px;
  font-size: clamp(20px, 3.4vw, 34px);
  line-height: 1;
  text-shadow: 0 0 22px rgba(255, 255, 255, 0.18);
}

.fighter strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1;
}

.life {
  height: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.24);
}

.life i {
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 42%),
    linear-gradient(90deg, var(--gold), var(--p1));
  transition: width 0.12s ease;
}

.fighter-right .life i {
  margin-left: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 42%),
    linear-gradient(90deg, var(--p2), var(--gold));
}

.round {
  padding: 8px 8px 10px;
  border: 1px solid rgba(255, 224, 138, 0.22);
  border-radius: 8px;
  background: rgba(7, 9, 15, 0.58);
  text-align: center;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(12px);
}

.round strong {
  display: block;
  margin-top: 4px;
  font-size: 44px;
  line-height: 0.95;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 224, 138, 0.3);
}

.stage-label {
  position: fixed;
  z-index: 3;
  left: 50%;
  top: calc(max(118px, env(safe-area-inset-top)) + 10px);
  width: min(360px, 46vw);
  transform: translateX(-50%);
  color: rgba(255, 247, 251, 0.74);
  text-align: center;
  pointer-events: none;
}

.stage-label span,
.stage-label b {
  display: block;
  line-height: 1;
}

.stage-label span {
  font-size: 10px;
  font-weight: 760;
  color: rgba(255, 224, 138, 0.72);
}

.stage-label b {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 900;
  text-shadow:
    0 0 18px rgba(123, 223, 242, 0.42),
    0 0 28px rgba(255, 159, 199, 0.25);
}

.commandbar {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(6, minmax(58px, 88px));
  gap: 8px;
  transform: translateX(-50%);
}

.commandbar div {
  min-height: 48px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
    rgba(8, 10, 14, 0.66);
  text-align: center;
  backdrop-filter: blur(10px);
}

.commandbar span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.commandbar b {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 16px;
}

.feed {
  position: fixed;
  z-index: 3;
  left: max(18px, env(safe-area-inset-left));
  bottom: calc(max(82px, env(safe-area-inset-bottom)) + 12px);
  max-width: min(560px, calc(100vw - 36px));
  padding: 8px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: rgba(7, 9, 15, 0.5);
  color: rgba(255, 247, 251, 0.84);
  font-size: 14px;
  line-height: 1.45;
  text-shadow: 0 0 20px rgba(255, 159, 199, 0.28);
  pointer-events: none;
}

.restart {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: 58%;
  width: 160px;
  height: 50px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  color: #120b11;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  cursor: pointer;
  font-size: 15px;
  font-weight: 820;
}

.restart.is-hidden {
  display: none;
}

.touch-controls {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  height: 228px;
  padding:
    0 max(16px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  pointer-events: none;
}

.stick-zone,
.touch-buttons {
  pointer-events: auto;
}

.stick-zone {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 4px);
  width: 156px;
  height: 156px;
  display: grid;
  place-items: center;
  touch-action: none;
}

.stick-base {
  position: relative;
  width: 124px;
  height: 124px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 224, 138, 0.2), transparent 34%),
    conic-gradient(from 90deg, rgba(255, 159, 199, 0.18), rgba(123, 223, 242, 0.18), rgba(255, 224, 138, 0.16), rgba(255, 159, 199, 0.18)),
    rgba(8, 10, 14, 0.56);
  box-shadow:
    inset 0 0 0 12px rgba(255, 255, 255, 0.035),
    0 18px 50px rgba(0, 0, 0, 0.36),
    0 0 34px rgba(123, 223, 242, 0.14);
  backdrop-filter: blur(12px);
}

.stick-base::before,
.stick-base::after {
  position: absolute;
  content: "";
  background: rgba(255, 255, 255, 0.18);
}

.stick-base::before {
  left: 18px;
  right: 18px;
  top: 50%;
  height: 1px;
}

.stick-base::after {
  top: 18px;
  bottom: 18px;
  left: 50%;
  width: 1px;
}

.stick-base i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 159, 199, 0.9), rgba(123, 223, 242, 0.82));
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
  transform: translate(-50%, -50%);
  transition: transform 0.08s ease;
}

.stick-zone.is-active .stick-base i {
  transition: none;
}

.touch-buttons {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 2px);
  width: 224px;
  height: 184px;
}

.touch-button {
  position: absolute;
  width: 62px;
  height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)),
    rgba(8, 10, 14, 0.58);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(12px);
  font-size: 20px;
  font-weight: 860;
  line-height: 1;
  touch-action: none;
}

.touch-button::after {
  position: absolute;
  inset: 8px;
  content: "";
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.touch-button.is-pressed {
  transform: scale(0.94);
  filter: brightness(1.25);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.3),
    0 0 26px rgba(255, 224, 138, 0.18),
    inset 0 2px 8px rgba(0, 0, 0, 0.28);
}

.touch-jab {
  right: 70px;
  bottom: 48px;
  background: linear-gradient(135deg, rgba(255, 224, 138, 0.7), rgba(255, 159, 199, 0.64));
}

.touch-heavy {
  right: 8px;
  bottom: 84px;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, rgba(255, 77, 109, 0.78), rgba(255, 159, 199, 0.72));
}

.touch-special {
  right: 82px;
  bottom: 110px;
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, rgba(123, 223, 242, 0.76), rgba(255, 224, 138, 0.68));
}

.touch-guard {
  right: 154px;
  bottom: 42px;
}

.touch-jump {
  right: 12px;
  bottom: 12px;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) 68px minmax(0, 1fr);
    gap: 8px;
  }

  .fighter {
    padding: 8px;
  }

  .fighter h1 {
    font-size: 18px;
  }

  .life {
    height: 14px;
  }

  .round strong {
    font-size: 32px;
  }

  .stage-label {
    display: none;
  }

  .commandbar {
    display: none;
  }

  .feed {
    bottom: calc(max(206px, env(safe-area-inset-bottom)) + 10px);
    font-size: 13px;
  }

  .touch-controls {
    display: block;
  }
}

@media (max-width: 430px) {
  .stick-zone {
    left: max(8px, env(safe-area-inset-left));
    width: 136px;
    height: 136px;
  }

  .stick-base {
    width: 108px;
    height: 108px;
  }

  .stick-base i {
    width: 52px;
    height: 52px;
  }

  .touch-buttons {
    right: max(8px, env(safe-area-inset-right));
    width: 206px;
  }

  .touch-button {
    width: 58px;
    height: 58px;
    font-size: 18px;
  }

  .touch-heavy {
    width: 68px;
    height: 68px;
  }

  .touch-special {
    width: 70px;
    height: 70px;
  }
}
