:root {
  --bg: #0d131b;
  --panel: #17202b;
  --panel-deep: #0b1017;
  --text: #f5f1e6;
  --muted: #9baaa7;
  --cyan: #91d0d4;
  --pink: #8f2d35;
  --gold: #d7b568;
  --line: rgba(189, 201, 190, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
  background:
    radial-gradient(circle at 50% 0%, rgba(201, 223, 218, 0.18), transparent 40%),
    radial-gradient(circle at 82% 18%, rgba(215, 181, 104, 0.12), transparent 26%),
    linear-gradient(150deg, #0b1017, #16212c 52%, #080b10);
}

.game-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 57px);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-shadow: 3px 3px 0 rgba(9, 13, 19, 0.95), 0 0 22px rgba(215, 181, 104, 0.3);
}

.restart,
#playButton {
  border: 1px solid rgba(215, 181, 104, 0.5);
  border-radius: 6px;
  color: var(--text);
  background: rgba(15, 22, 31, 0.92);
  font-weight: 700;
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease;
}

.restart {
  padding: 14px 24px;
  color: #efe5c9;
  font-size: 16px;
}

.restart:hover,
#playButton:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
}

.arena-card {
  overflow: hidden;
  border: 1px solid rgba(215, 181, 104, 0.24);
  border-radius: 9px;
  background: var(--panel-deep);
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.42), inset 0 0 0 1px rgba(235, 226, 201, 0.05);
}

.hud {
  display: grid;
  grid-template-columns: 1fr 106px 1fr;
  gap: 26px;
  align-items: center;
  padding: 20px 27px 17px;
  border-bottom: 1px solid rgba(215, 181, 104, 0.22);
  background:
    linear-gradient(180deg, rgba(25, 34, 45, 0.98), rgba(8, 13, 19, 0.98)),
    radial-gradient(circle at 50% 0%, rgba(215, 181, 104, 0.16), transparent 50%);
}

.hud-name {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.13em;
}

.hud-name strong {
  color: #fff7df;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.cpu-hud .hud-name {
  flex-direction: row-reverse;
}

.health-track {
  position: relative;
  height: 15px;
  overflow: hidden;
  border: 1px solid rgba(214, 193, 145, 0.35);
  background: #111820;
  transform: skewX(-16deg);
}

.health-fill {
  height: 100%;
  transition: width 190ms ease-out;
}

.player-health {
  width: 100%;
  background: linear-gradient(90deg, #4a7f94, var(--cyan));
  box-shadow: 0 0 13px rgba(145, 208, 212, 0.42);
}

.cpu-health {
  width: 100%;
  margin-left: auto;
  background: linear-gradient(90deg, #b88743, #7c2f36);
  box-shadow: 0 0 13px rgba(215, 181, 104, 0.38);
}

.round-display {
  text-align: center;
  color: #899794;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.26em;
}

.round-display strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.canvas-wrap {
  position: relative;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  background: #dce9e4;
}

.combo-banner {
  position: absolute;
  top: 25px;
  left: 28px;
  display: grid;
  transform: translateY(-8px) scale(0.96);
  color: #213040;
  text-align: left;
  opacity: 0;
  transition: opacity 110ms ease, transform 110ms ease;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45), 0 0 14px rgba(215, 181, 104, 0.35);
}

.combo-banner.visible {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.combo-banner.finisher {
  color: var(--gold);
  text-shadow: 0 0 15px rgba(215, 181, 104, 0.72), 2px 2px 0 rgba(8, 12, 18, 0.85);
}

.combo-banner strong {
  font-size: clamp(30px, 5vw, 45px);
  line-height: 0.95;
  font-style: italic;
}

.combo-banner span {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.message-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 15, 0.42);
  backdrop-filter: blur(2px);
  opacity: 1;
  transition: opacity 180ms ease;
}

.message-screen.hidden {
  pointer-events: none;
  opacity: 0;
}

.message-screen p {
  margin: 0;
  color: #efe5c9;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.message-screen h2 {
  margin: 0 0 12px;
  font-size: clamp(58px, 12vw, 92px);
  line-height: 0.9;
  text-shadow: 4px 4px rgba(8, 12, 18, 0.95), 0 0 24px rgba(215, 181, 104, 0.42);
}

.character-select {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 13px;
  width: min(520px, calc(100% - 44px));
  margin: 0 0 13px;
}

.select-group {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(215, 181, 104, 0.32);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.72);
}

.select-group > span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.select-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.character-option {
  min-height: 42px;
  border: 1px solid rgba(145, 208, 212, 0.28);
  border-radius: 6px;
  color: #dce7df;
  background: rgba(16, 25, 34, 0.94);
  font: 800 14px/1.1 inherit;
  cursor: pointer;
}

.character-option.active {
  border-color: rgba(215, 181, 104, 0.86);
  color: #111820;
  background: linear-gradient(180deg, #ead28e, #b78a42);
  box-shadow: 0 0 18px rgba(215, 181, 104, 0.22);
}

#playButton {
  padding: 14px 32px;
  border-color: rgba(215, 181, 104, 0.75);
  background: linear-gradient(180deg, #ead28e, #b78a42);
  color: #111820;
  font-size: 17px;
}

.controls {
  display: flex;
  gap: 34px;
  align-items: center;
  margin-top: 13px;
  padding: 17px 25px;
  border: 1px solid rgba(215, 181, 104, 0.24);
  border-radius: 8px;
  background: rgba(10, 16, 23, 0.84);
}

.control-heading {
  min-width: 150px;
}

.control-heading h2 {
  margin: 0;
  font-size: 22px;
}

.control-list {
  display: flex;
  flex: 1;
  gap: clamp(15px, 3vw, 38px);
}

.control-list div {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #c0c9bd;
  font-weight: 600;
}

kbd {
  display: inline-grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid rgba(215, 181, 104, 0.34);
  border-radius: 5px;
  color: #fff7df;
  background: #121922;
  font-family: inherit;
  font-weight: 800;
}

.tip {
  max-width: 165px;
  margin: 0;
  color: #94a29d;
  font-size: 13px;
  line-height: 1.45;
}

.touch-controls {
  display: none;
  position: relative;
  justify-content: space-between;
  gap: 16px;
  margin-top: 13px;
  padding: 15px 12px 42px;
  border: 1px solid rgba(215, 181, 104, 0.24);
  border-radius: 8px;
  background: rgba(10, 16, 23, 0.84);
  user-select: none;
  -webkit-user-select: none;
}

.touch-pad {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.movement-pad {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(2, 54px);
  gap: 6px;
}

.attack-pad {
  display: flex;
  align-items: flex-end;
}

.touch-button {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 1px solid rgba(215, 181, 104, 0.34);
  border-radius: 50%;
  color: #f6edcf;
  background: rgba(18, 27, 35, 0.92);
  box-shadow: inset 0 0 15px rgba(143, 116, 62, 0.24);
  font: 800 22px/1 inherit;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-button.jump {
  color: var(--cyan);
}

.movement-pad .touch-button {
  width: 54px;
  height: 54px;
  font-size: 20px;
}

.touch-button.diagonal {
  color: var(--cyan);
  border-color: rgba(145, 208, 212, 0.45);
}

.pad-core {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(215, 181, 104, 0.16), rgba(14, 21, 28, 0.42) 58%);
}

.touch-button.punch {
  color: var(--gold);
  border-color: rgba(215, 181, 104, 0.56);
}

.touch-button.kick {
  width: 70px;
  height: 70px;
  color: var(--cyan);
  border-color: rgba(145, 208, 212, 0.5);
}

.touch-button.active {
  transform: scale(0.94);
  border-color: var(--gold);
  background: rgba(45, 42, 34, 0.98);
  box-shadow: inset 0 0 18px rgba(215, 181, 104, 0.18), 0 0 12px rgba(145, 208, 212, 0.18);
}

.touch-tip {
  position: absolute;
  right: 12px;
  bottom: 10px;
  left: 12px;
  margin: 0;
  color: #96a6a0;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 760px) {
  .game-shell {
    width: calc(100% - 22px);
    padding-top: 17px;
  }

  .hud {
    grid-template-columns: 1fr 63px 1fr;
    gap: 10px;
    padding: 14px 12px;
  }

  .hud-name strong {
    font-size: 15px;
  }

  .round-display strong {
    font-size: 28px;
  }

  .controls {
    display: block;
    padding: 16px;
  }

  .control-list {
    flex-wrap: wrap;
    margin-top: 15px;
  }

  .tip {
    max-width: none;
    margin-top: 14px;
  }

  .touch-controls {
    display: flex;
    gap: 8px;
  }

  .character-select {
    grid-template-columns: 1fr;
    width: min(390px, calc(100% - 24px));
  }
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}
