:root {
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #20232c;
  --ink: #fff7dd;
  --muted: #b9b6c7;
  --line: rgba(255, 255, 255, 0.16);
  --p1: #ff4d6d;
  --p2: #4dd2ff;
  --gold: #f6c453;
  --grass: #5dbb63;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 77, 109, 0.2), transparent 24rem),
    radial-gradient(circle at 82% 12%, rgba(77, 210, 255, 0.2), transparent 26rem),
    linear-gradient(135deg, #0d1118 0%, #1e2030 48%, #101116 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button {
  min-width: 96px;
  min-height: 44px;
  border: 1px solid rgba(255, 231, 151, 0.8);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe082, #f6b73f);
  color: #211b0a;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(246, 196, 83, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.music-button {
  min-width: 96px;
  min-height: 36px;
  border-color: rgba(77, 210, 255, 0.48);
  background: linear-gradient(180deg, rgba(77, 210, 255, 0.22), rgba(77, 210, 255, 0.08));
  color: var(--ink);
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.music-button[aria-pressed="false"] {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.game-shell {
  width: min(1120px, calc(100vw - 24px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 0 20px;
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  gap: 14px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
}

.player-card,
.round-panel,
.controls {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(45, 48, 60, 0.92), rgba(23, 25, 32, 0.94)),
    rgba(36, 38, 45, 0.9);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.player-card {
  position: relative;
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 10px;
  overflow: hidden;
}

.player-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
}

.player-one::before {
  background: linear-gradient(90deg, rgba(255, 77, 109, 0.32), transparent 58%);
}

.player-two::before {
  background: linear-gradient(270deg, rgba(77, 210, 255, 0.32), transparent 58%);
}

.player-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}

.player-row span {
  color: var(--gold);
  font-weight: 700;
}

.health-track {
  position: relative;
  height: 22px;
  overflow: hidden;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), rgba(20, 18, 20, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.68);
}

.health-track::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 45%);
  pointer-events: none;
}

.health-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 180ms ease-out;
  box-shadow: 0 0 16px currentColor;
}

.player-one .health-fill {
  color: var(--p1);
  background: linear-gradient(90deg, #ff345c, #ff8ba0);
}

.player-two .health-fill {
  color: var(--p2);
  background: linear-gradient(90deg, #35c7ff, #9cedff);
}

.round-panel {
  width: 196px;
  padding: 12px;
  display: grid;
  place-items: center;
  gap: 8px;
  background:
    linear-gradient(180deg, rgba(246, 196, 83, 0.18), rgba(36, 38, 45, 0.92)),
    rgba(36, 38, 45, 0.92);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.arena-wrap {
  position: relative;
  min-height: 0;
  border: 1px solid rgba(246, 196, 83, 0.3);
  border-radius: 8px;
  background: #11131a;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 44px rgba(77, 210, 255, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.42);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.message {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  min-width: 128px;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(36, 39, 50, 0.84), rgba(14, 15, 20, 0.76));
  color: var(--ink);
  text-align: center;
  font-weight: 700;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

.controls {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.controls div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.controls span {
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 14px;
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 30%, rgba(246, 196, 83, 0.18), transparent 22rem),
    rgba(10, 11, 14, 0.76);
  backdrop-filter: blur(8px);
}

.result-overlay[hidden] {
  display: none;
}

.result-panel {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid rgba(246, 196, 83, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 77, 109, 0.1), transparent 34%),
    linear-gradient(225deg, rgba(77, 210, 255, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(42, 45, 58, 0.98), rgba(18, 20, 27, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56), 0 0 36px rgba(246, 196, 83, 0.12);
  display: grid;
  gap: 16px;
}

.result-kicker,
.result-subtitle {
  margin: 0;
  color: var(--muted);
}

.result-kicker {
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
}

.result-panel h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  display: grid;
  align-content: center;
  gap: 8px;
}

.result-card.is-winner {
  border-color: rgba(246, 196, 83, 0.8);
  background: rgba(246, 196, 83, 0.14);
}

.result-card span {
  font-weight: 700;
}

.result-card strong {
  font-size: 24px;
}

.result-card small {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 760px) {
  .game-shell {
    width: min(100vw - 16px, 680px);
    padding-top: 8px;
    grid-template-rows: auto auto auto;
  }

  .hud,
  .controls {
    grid-template-columns: 1fr;
  }

  .round-panel {
    width: 100%;
    grid-template-columns: 1fr auto;
    justify-items: start;
  }

  canvas {
    min-height: 300px;
  }

  .result-panel {
    padding: 18px;
  }

  .result-panel h2 {
    font-size: 28px;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }
}
