@import url("https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Sans+SC:wght@400;500;600;700;900&family=Oswald:wght@500;600;700&display=swap");

:root {
  color-scheme: dark;
  --night: #070c12;
  --ink: #0b1118;
  --paper: #e9dfca;
  --muted: #8f98a0;
  --vermilion: #ec4f35;
  --gold: #f5bd67;
  --cyan: #99dcdf;
  --line: rgba(233, 223, 202, .16);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #030609; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 50% -20%, #263746 0, transparent 48rem),
    linear-gradient(180deg, #0a1017, #030609);
  overflow-x: hidden;
}

button { color: inherit; font: inherit; }
button, canvas { -webkit-tap-highlight-color: transparent; }
button:focus-visible, canvas:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.arena-shell {
  width: min(1540px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 24px 18px;
}

.topline {
  height: 76px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.game-mark { display: flex; align-items: center; gap: 12px; }
.crest {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(245, 189, 103, .52);
  color: var(--gold);
  font-family: "Ma Shan Zheng", cursive;
  font-size: 26px;
  transform: rotate(-5deg);
  box-shadow: inset 0 0 18px rgba(236, 79, 53, .16);
}
.game-mark strong, .game-mark small { display: block; }
.game-mark strong { font-size: 18px; letter-spacing: .22em; }
.game-mark small { margin-top: 2px; color: #77828b; font: 500 9px/1 "Oswald", sans-serif; letter-spacing: .16em; }
.round-rule { color: #6f7982; font-size: 10px; letter-spacing: .25em; }

.sound-button {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  color: #aab1b5;
  font-size: 11px;
  cursor: pointer;
}
.sound-button:hover { color: var(--paper); }
.sound-button kbd { opacity: .5; }
.sound-bars { height: 18px; display: flex; align-items: flex-end; gap: 2px; }
.sound-bars i { width: 2px; height: 7px; background: var(--gold); animation: soundbar .75s ease-in-out infinite alternate; }
.sound-bars i:nth-child(2) { height: 14px; animation-delay: -.28s; }
.sound-bars i:nth-child(3) { height: 10px; animation-delay: -.48s; }
.sound-button.muted .sound-bars i { height: 2px; animation: none; background: #667079; }

.game-frame {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 168px);
  aspect-ratio: 16 / 9;
  margin: auto;
  overflow: hidden;
  isolation: isolate;
  background: #111923;
  box-shadow: 0 24px 65px rgba(0, 0, 0, .48), 0 0 0 1px rgba(255,255,255,.06);
}

#game-canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }

.hud {
  position: absolute;
  inset: 22px 30px auto;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 120px 1fr;
  gap: 26px;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.75));
}

.fighter-hud { position: relative; min-width: 0; }
.identity { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 0 9px; margin-bottom: 6px; }
.identity strong { font-size: 13px; letter-spacing: .13em; }
.identity small { grid-column: 2; color: rgba(233,223,202,.52); font-size: 8px; letter-spacing: .12em; }
.player-tag { grid-row: 1 / 3; align-self: stretch; display: grid; place-items: center; padding: 0 8px; background: var(--paper); color: #121920; font: 700 10px "Oswald", sans-serif; }
.ai-tag { background: var(--vermilion); color: white; }
.fighter-hud--right .identity { grid-template-columns: 1fr auto; text-align: right; }
.fighter-hud--right .identity .player-tag { grid-column: 2; }
.fighter-hud--right .identity strong, .fighter-hud--right .identity small { grid-column: 1; }
.fighter-hud--right .identity small { grid-row: 2; }

.life { position: relative; height: 18px; overflow: hidden; background: rgba(4,8,12,.76); border: 1px solid rgba(233,223,202,.34); transform: skewX(-9deg); }
.life i { position: absolute; inset: 0; transform-origin: left; }
.life-lag { background: #e6a34c; transition: transform 1s cubic-bezier(.15,.7,.2,1) .35s; }
.life-now { background: linear-gradient(90deg, #d7eee4 0%, #9fd6bd 62%, #6ab18e 100%); transition: transform .12s linear; box-shadow: inset 0 -4px rgba(0,0,0,.15); }
.fighter-hud--right .life i { transform-origin: right; }
.fighter-hud--right .life-now { background: linear-gradient(90deg, #8f201f, #e65338 62%, #f29b59); }

.meter { position: relative; width: 74%; height: 7px; margin-top: 7px; background: rgba(4,8,12,.78); overflow: hidden; }
.meter i { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, #b83927, #ffbc58, #fff2c9); transition: transform .2s ease; }
.meter span { position: absolute; left: calc(100% + 8px); top: -5px; color: rgba(233,223,202,.58); font-size: 8px; letter-spacing: .15em; }
.fighter-hud--right .meter { margin-left: auto; }
.fighter-hud--right .meter i { transform-origin: right; }
.fighter-hud--right .meter span { left: auto; right: calc(100% + 8px); }
.meter.full { box-shadow: 0 0 13px rgba(255,190,85,.8); animation: meterPulse .55s ease-in-out infinite alternate; }

.wins { position: absolute; top: 24px; display: flex; gap: 5px; }
.fighter-hud--left .wins { right: 8px; }
.fighter-hud--right .wins { left: 8px; }
.wins i { width: 8px; height: 8px; border: 1px solid rgba(233,223,202,.46); transform: rotate(45deg); }
.wins i.won { border-color: #ffd87e; background: var(--gold); box-shadow: 0 0 9px var(--gold); }

.round-clock { text-align: center; margin-top: -5px; }
.round-clock span, .round-clock small { display: block; font: 600 9px/1 "Oswald", sans-serif; letter-spacing: .22em; }
.round-clock strong { display: block; margin: -1px 0; font: 700 42px/1 "Oswald", sans-serif; letter-spacing: -.04em; }
.round-clock small { color: var(--gold); font-size: 8px; }

.start-panel {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  background:
    linear-gradient(90deg, rgba(5,9,13,.94), rgba(5,9,13,.5) 40%, rgba(5,9,13,.94)),
    radial-gradient(circle at 50% 50%, rgba(128,36,29,.18), transparent 42%);
  transition: opacity .65s ease, visibility .65s ease;
}
.start-panel.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.start-sigil { position: absolute; width: min(40vw, 350px); aspect-ratio: 1; display: grid; place-items: center; border: 1px solid rgba(220,72,49,.16); border-radius: 50%; color: rgba(236,79,53,.12); font: 300 min(26vw, 230px)/1 "Ma Shan Zheng", cursive; animation: sigil 18s linear infinite; }
.start-panel > *:not(.start-sigil) { position: relative; }
.eyebrow { margin: 0 0 13px; color: var(--gold); font: 600 9px/1 "Oswald", sans-serif; letter-spacing: .34em; }
.start-panel h1 { margin: 0; font: 400 clamp(39px, 5.6vw, 82px)/.98 "Ma Shan Zheng", cursive; letter-spacing: .06em; text-shadow: 0 8px 30px black; }
.start-panel h1 em { color: #e65a3c; font-style: normal; }
.lead { width: min(520px, 88%); margin: 23px auto 26px; color: rgba(233,223,202,.68); font-size: 12px; line-height: 1.8; }
.start-panel button { min-width: 212px; padding: 13px 28px 12px; border: 1px solid rgba(255,220,158,.68); background: linear-gradient(110deg, #b72d24, #e55b36); box-shadow: 0 10px 35px rgba(195,49,31,.34); cursor: pointer; clip-path: polygon(7px 0,100% 0,calc(100% - 7px) 100%,0 100%); transition: transform .18s ease, filter .18s ease; }
.start-panel button:hover { transform: translateY(-3px); filter: brightness(1.13); }
.start-panel button span, .start-panel button small { display: block; }
.start-panel button span { font-weight: 800; letter-spacing: .45em; text-indent: .45em; }
.start-panel button small { margin-top: 4px; color: rgba(255,255,255,.6); font: 500 8px "Oswald", sans-serif; letter-spacing: .14em; }
.start-meta { display: flex; gap: 24px; margin-top: 28px; color: #5f6971; font-size: 8px; letter-spacing: .12em; }

kbd { min-width: 22px; display: inline-grid; place-items: center; padding: 2px 5px; border: 1px solid rgba(233,223,202,.35); border-bottom-color: rgba(233,223,202,.65); border-radius: 3px; background: rgba(0,0,0,.3); color: var(--paper); font: 600 10px/1.4 "Oswald", sans-serif; box-shadow: inset 0 -2px rgba(0,0,0,.28); }

.controls { min-height: 74px; display: flex; align-items: center; justify-content: center; gap: clamp(14px, 2.4vw, 38px); border-bottom: 1px solid var(--line); }
.controls > div { display: grid; grid-template-columns: repeat(2, auto); align-items: center; justify-items: start; gap: 4px; }
.control-title { grid-column: 1 / -1; color: #6f7982; font-size: 8px; letter-spacing: .15em; }
.controls small { color: #555f67; font-size: 7px; }
.ultimate-control kbd { border-color: rgba(245,189,103,.65); color: var(--gold); }
.help-button { margin-left: auto; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: #727d84; font-size: 9px; letter-spacing: .1em; cursor: pointer; }
.help-button:hover { color: var(--paper); }
.help-button span { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; }

.combo { position: absolute; z-index: 7; top: 34%; display: none; align-items: baseline; gap: 7px; text-shadow: 0 3px 8px black; pointer-events: none; }
.combo.show { display: flex; animation: comboIn .18s ease-out both; }
.combo--left { left: 6%; }
.combo--right { right: 6%; flex-direction: row-reverse; }
.combo strong { font: 700 clamp(50px, 6vw, 84px)/.8 "Oswald", sans-serif; color: white; font-style: italic; }
.combo span { color: var(--gold); font: 700 16px "Oswald", sans-serif; letter-spacing: .12em; }
.combo small { position: absolute; top: 100%; color: rgba(255,255,255,.58); font-size: 8px; letter-spacing: .18em; white-space: nowrap; }
.combo--right small { right: 0; }

.announcement { position: absolute; z-index: 10; left: 50%; top: 48%; transform: translate(-50%,-50%) skewX(-8deg); color: white; font: 700 clamp(48px, 9vw, 132px)/.82 "Oswald", sans-serif; font-style: italic; letter-spacing: .04em; text-align: center; text-shadow: 0 8px 0 rgba(111,22,19,.9), 0 14px 30px black; pointer-events: none; white-space: nowrap; }
.announcement.show { animation: announce .85s cubic-bezier(.1,.8,.2,1) both; }
.announcement small { display: block; margin-top: 18px; color: var(--gold); font-size: .15em; letter-spacing: .35em; text-shadow: 0 3px 8px black; }

.pause-panel { position: absolute; z-index: 20; inset: 0; display: grid; place-content: center; gap: 8px; text-align: center; background: rgba(3,6,9,.78); backdrop-filter: blur(5px); }
.pause-panel[hidden] { display: none; }
.pause-panel strong { font: 400 50px "Ma Shan Zheng", cursive; }
.pause-panel span { color: #89939a; font-size: 11px; letter-spacing: .12em; }

dialog { width: min(750px, calc(100% - 30px)); padding: 36px; border: 1px solid rgba(245,189,103,.28); background: #0d141b; color: var(--paper); box-shadow: 0 30px 100px black; }
dialog::backdrop { background: rgba(1,3,5,.78); backdrop-filter: blur(7px); }
dialog h2 { margin: 0 0 28px; font: 400 38px "Ma Shan Zheng", cursive; }
.dialog-close { position: absolute; right: 15px; top: 12px; border: 0; background: transparent; color: #748089; font-size: 24px; cursor: pointer; }
.manual-grid { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); }
.manual-grid > div { padding: 20px; }
.manual-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
.manual-grid > div:nth-child(n+3) { border-top: 1px solid var(--line); }
.manual-grid strong { color: var(--gold); font-size: 11px; letter-spacing: .18em; }
.manual-grid p { margin: 9px 0 0; color: #929ca2; font-size: 11px; line-height: 1.8; }
.credit-line { margin: 20px 0 0; color: #59636b; font-size: 8px; letter-spacing: .08em; }

@keyframes soundbar { to { height: 3px; opacity: .45; } }
@keyframes sigil { to { transform: rotate(360deg); } }
@keyframes comboIn { from { opacity: 0; transform: translateY(14px) scale(1.4); } }
@keyframes announce { 0% { opacity: 0; transform: translate(-50%,-50%) scale(2.2) skewX(-8deg); filter: blur(8px); } 16%, 72% { opacity: 1; transform: translate(-50%,-50%) scale(1) skewX(-8deg); filter: none; } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.9) skewX(-8deg); } }
@keyframes meterPulse { to { filter: brightness(1.5); } }

@media (max-width: 900px) {
  .arena-shell { padding: 0; }
  .topline { height: 58px; padding: 0 14px; grid-template-columns: 1fr auto; }
  .round-rule { display: none; }
  .game-mark .crest { width: 34px; height: 34px; font-size: 21px; }
  .game-mark strong { font-size: 14px; }
  .game-frame { max-height: none; }
  .hud { inset: 10px 12px auto; grid-template-columns: 1fr 65px 1fr; gap: 8px; }
  .identity small, .player-tag, .meter span { display: none; }
  .identity { display: block; }
  .identity strong { font-size: 9px; }
  .fighter-hud--right .identity { text-align: right; }
  .life { height: 12px; }
  .meter { margin-top: 4px; height: 5px; }
  .round-clock strong { font-size: 28px; }
  .wins { top: 17px; }
  .controls { min-height: 60px; padding: 8px 12px; gap: 10px; overflow-x: auto; justify-content: flex-start; }
  .controls > div { flex: 0 0 auto; }
  .controls small, .help-button { display: none; }
}

@media (max-width: 600px) {
  .topline { display: none; }
  .start-panel { padding: 20px; }
  .start-panel h1 { font-size: 42px; }
  .lead { margin: 16px auto 20px; font-size: 10px; }
  .start-meta { display: none; }
  .controls { min-height: 55px; }
  .control-title { font-size: 7px; }
  dialog { padding: 25px 18px; }
  .manual-grid { display: block; }
  .manual-grid > div { border: 0 !important; border-top: 1px solid var(--line) !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
