:root {
  --orange: #FF8A3D;
  --orange-hi: #FFB45C;
  --orange-deep: #E8631B;
  --cream: #FFF3DF;
  --cream-dim: #E8D3B7;
  --ink: #170F21;
  --ink-2: #241832;
  --violet: #6B4DA0;
  --danger: #FF5A6E;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #08060d;
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(255, 138, 61, .12), transparent 60%),
    radial-gradient(70% 50% at 50% 100%, rgba(107, 77, 160, .18), transparent 65%),
    #08060d;
}

.game-shell {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: #150f21;
  box-shadow: 0 0 80px rgba(0, 0, 0, .7);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(120% 90% at 50% 42%, transparent 45%, rgba(8, 5, 14, .38) 78%, rgba(6, 4, 10, .72) 100%),
    linear-gradient(180deg, rgba(9, 6, 16, .34), transparent 22%, transparent 78%, rgba(9, 6, 16, .3));
}

.stage-vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .16;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .08) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------------- HUD ---------------- */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: calc(10px + var(--safe-top)) 13px 18px;
  pointer-events: none;
}

.hud::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 152%;
  z-index: -1;
  background: linear-gradient(180deg, rgba(8, 5, 14, .82) 0%, rgba(9, 6, 15, .46) 52%, transparent 100%);
}

.fighter {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.fighter-foe { flex-direction: row; }

.portrait-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 41px;
  height: 41px;
  border-radius: 13px;
  padding: 2px;
  background: linear-gradient(150deg, rgba(255, 190, 122, .85), rgba(255, 122, 47, .18) 48%, rgba(37, 25, 50, .9));
  box-shadow: 0 3px 12px rgba(0, 0, 0, .45), 0 0 16px rgba(255, 138, 61, .2);
}

.fighter-foe .portrait-wrap {
  background: linear-gradient(210deg, rgba(142, 112, 255, .8), rgba(74, 52, 110, .2) 50%, rgba(37, 25, 50, .9));
  box-shadow: 0 3px 12px rgba(0, 0, 0, .45), 0 0 16px rgba(116, 87, 255, .18);
}

.portrait {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 11px;
  background: #241833;
}

.ptag {
  position: absolute;
  left: -3px;
  bottom: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--orange-hi), var(--orange-deep));
  color: #2a1204;
  font-size: 9px;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .4);
}

.ptag-foe {
  left: auto;
  right: -3px;
  background: linear-gradient(180deg, #A98BFF, #6B4DC0);
  color: #171024;
}

.fighter-info { flex: 1 1 auto; min-width: 0; }

.fighter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 2px 3px;
}

.fighter-foe .fighter-meta { flex-direction: row; }

.fname {
  display: block;
  overflow: hidden;
  color: var(--cream);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .09em;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .75);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fighter-foe .fname { color: #E4D8FF; }

.hp-label {
  flex: 0 0 auto;
  color: rgba(255, 226, 196, .45);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .12em;
}

.hp-track {
  position: relative;
  height: 13px;
  overflow: hidden;
  border: 1px solid rgba(255, 232, 205, .34);
  border-radius: 3px;
  background: linear-gradient(180deg, #22172e, #120c1c);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 255, 255, .06);
  transform: skewX(-13deg);
}

.fighter-foe .hp-track { transform: skewX(13deg); }

.hp-fill,
.hp-ghost {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: 2px;
}

.hp-fill {
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .38), transparent 45%),
    linear-gradient(90deg, #FFD18C 0%, var(--orange) 38%, #F2661B 100%);
  box-shadow: 0 0 10px rgba(255, 138, 61, .55);
  transition: width .12s ease-out;
}

.hp-ghost {
  z-index: 1;
  background: rgba(255, 238, 217, .5);
  transition: width .55s ease-in .18s;
}

.fighter-foe .hp-fill {
  left: auto;
  right: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .32), transparent 45%),
    linear-gradient(270deg, #FFD0DC 0%, #FF5A6E 35%, #C0377F 100%);
  box-shadow: 0 0 10px rgba(255, 90, 110, .5);
}

.fighter-foe .hp-ghost { left: auto; right: 0; }

.fighter.is-low .hp-track {
  border-color: rgba(255, 132, 112, .72);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, .6),
    0 0 0 1px rgba(255, 92, 74, .16),
    0 0 14px rgba(255, 74, 64, .4);
}

.fighter.is-low .hp-fill {
  animation: lowHpPulse .78s ease-in-out infinite;
}

@keyframes lowHpPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5) saturate(1.25); }
}

.hp-ticks {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: .45;
  background: repeating-linear-gradient(90deg, transparent 0 16px, rgba(20, 10, 24, .6) 16px 18px);
}

.vs-badge {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 40px;
  justify-self: center;
  background: linear-gradient(160deg, #FFD9A8, #FF8A3D 45%, #B84A12);
  clip-path: polygon(22% 0, 78% 0, 100% 50%, 78% 100%, 22% 100%, 0 50%);
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .55)) drop-shadow(0 0 10px rgba(255, 138, 61, .28));
}

.vs-badge::before {
  content: "";
  position: absolute;
  inset: 2px;
  clip-path: polygon(22% 0, 78% 0, 100% 50%, 78% 100%, 22% 100%, 0 50%);
  background: linear-gradient(180deg, #352343, #170f21 68%);
}

.vs-badge span {
  position: relative;
  z-index: 1;
  color: #FFB45C;
  font-size: 13px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.03em;
  text-shadow: 0 0 8px rgba(255, 138, 61, .7);
}

.card-hit {
  animation: cardHit .28s ease-out;
}

@keyframes cardHit {
  0% { transform: translateX(0); filter: brightness(1); }
  22% { transform: translateX(-4px); filter: brightness(1.9); }
  48% { transform: translateX(3px); filter: brightness(1.3); }
  100% { transform: translateX(0); filter: brightness(1); }
}

/* ---------------- Announce / combo ---------------- */

.announce {
  position: absolute;
  left: 50%;
  top: 32%;
  z-index: 9;
  transform: translate(-50%, -50%) scale(.8);
  color: var(--cream);
  font-size: clamp(46px, 15vw, 76px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.03em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  text-shadow:
    0 3px 0 #A3430D,
    0 6px 0 rgba(30, 12, 5, .45),
    0 0 30px rgba(255, 138, 61, .55);
}

.announce.show {
  animation: announcePop .82s cubic-bezier(.17, .9, .25, 1) both;
}

.announce.is-fight {
  color: #FFD7A3;
  text-shadow:
    0 3px 0 #C1480C,
    0 7px 0 rgba(30, 12, 5, .5),
    0 0 38px rgba(255, 138, 61, .85);
}

@keyframes announcePop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.75) rotate(-3deg); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  68% { opacity: 1; transform: translate(-50%, -50%) scale(1.02) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.92) rotate(-2deg); }
}

.combo-pop {
  position: absolute;
  right: 8%;
  top: 41%;
  z-index: 8;
  color: #FFD08A;
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.04em;
  line-height: .95;
  text-align: right;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 0 #A3430D, 0 0 18px rgba(255, 138, 61, .75);
}

.combo-pop span {
  display: block;
  margin-top: 2px;
  color: var(--cream);
  font-size: 11px;
  letter-spacing: .24em;
}

.combo-pop.show { animation: comboPop .62s ease-out both; }

@keyframes comboPop {
  0% { opacity: 0; transform: scale(1.7) translateY(8px) rotate(6deg); }
  18% { opacity: 1; transform: scale(1) translateY(0) rotate(-3deg); }
  70% { opacity: 1; transform: scale(1.02) rotate(-3deg); }
  100% { opacity: 0; transform: scale(.94) translateY(-12px) rotate(-3deg); }
}

/* ---------------- Controls ---------------- */

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 22px 18px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(11, 7, 18, 0) 0%, rgba(11, 7, 18, .44) 28%, rgba(11, 7, 18, .9) 100%);
  transition: opacity .25s ease;
}

.controls::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 13px;
  height: 2px;
  opacity: .5;
  background: repeating-linear-gradient(90deg, rgba(255, 160, 86, .75) 0 16px, transparent 16px 30px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}

.controls.is-locked { opacity: .42; pointer-events: none; }
.controls.is-hidden { opacity: 0; pointer-events: none; }

.move-pad,
.action-pad {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 2px);
  margin: 0;
  padding: 6px 11px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 226, 198, .15);
  border-radius: 999px;
  background: rgba(10, 6, 16, .62);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: rgba(255, 238, 218, .84);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  line-height: 1;
  white-space: nowrap;
  transition: opacity .5s ease;
  text-shadow: 0 1px 4px #000;
}

.controls.is-locked .hint { opacity: 0; }

.ctl {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  border: 1.5px solid rgba(255, 225, 194, .26);
  color: var(--cream);
  font-family: inherit;
  cursor: pointer;
  outline: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .07s ease, box-shadow .07s ease, filter .07s ease;
  -webkit-user-select: none;
  user-select: none;
}

.ctl::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 7px;
  height: 26%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .28), transparent);
  pointer-events: none;
}

.ctl-move {
  width: 58px;
  height: 58px;
  border-radius: 19px;
  border-color: rgba(255, 226, 198, .38);
  background:
    radial-gradient(70% 55% at 50% 18%, rgba(255, 255, 255, .16), transparent 62%),
    linear-gradient(180deg, rgba(95, 73, 120, .97), rgba(45, 32, 64, .98));
  box-shadow:
    0 5px 0 #120b1a,
    0 9px 18px rgba(0, 0, 0, .42),
    inset 0 1px 0 rgba(255, 255, 255, .24),
    0 0 16px rgba(255, 138, 61, .16);
}

.ctl-move .mp-icon {
  width: 32px;
  height: 32px;
  color: #FFE9CF;
  filter: drop-shadow(0 0 6px rgba(255, 180, 110, .35)) drop-shadow(0 2px 2px rgba(0, 0, 0, .45));
}

.ctl-jump {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFF1DC, #E6BC8C);
  border-color: rgba(255, 255, 255, .55);
  color: #2B1A10;
  box-shadow: 0 5px 0 #8C5B31, 0 9px 18px rgba(0, 0, 0, .42), inset 0 2px 0 rgba(255, 255, 255, .7);
}

.ctl-jump .mp-icon {
  width: 26px;
  height: 26px;
  color: #3A2415;
}

.ctl-jump span {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .12em;
  color: #4B2E18;
}

.ctl-punch {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid #FFD3A1;
  color: #341306;
  background:
    radial-gradient(60% 50% at 34% 24%, rgba(255, 255, 255, .58), transparent 60%),
    linear-gradient(180deg, #FFC078, #FF8A3D 46%, #EC6418 100%);
  box-shadow:
    0 6px 0 #8F3A0B,
    0 12px 26px rgba(0, 0, 0, .42),
    0 0 28px rgba(255, 138, 61, .4),
    inset 0 2px 0 rgba(255, 255, 255, .42);
}

.ctl-punch .mp-icon {
  width: 33px;
  height: 33px;
  color: #341306;
}

.ctl-punch span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}

.ctl.is-down,
.ctl:active {
  transform: translateY(4px) scale(.97);
  filter: brightness(1.08);
}

.ctl-move.is-down,
.ctl-move:active {
  box-shadow: 0 1px 0 #0f0a17, inset 0 1px 0 rgba(255, 255, 255, .16);
}

.ctl-jump.is-down,
.ctl-jump:active {
  box-shadow: 0 1px 0 #8C5B31, inset 0 2px 0 rgba(255, 255, 255, .5);
}

.ctl-punch.is-down,
.ctl-punch:active {
  box-shadow: 0 2px 0 #8F3A0B, 0 4px 14px rgba(0, 0, 0, .4), 0 0 34px rgba(255, 138, 61, .5), inset 0 2px 0 rgba(255, 255, 255, .35);
}

/* ---------------- End screen ---------------- */

.end-screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(80% 55% at 50% 46%, rgba(255, 138, 61, .16), transparent 70%),
    rgba(8, 5, 14, .66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: endFade .3s ease-out both;
}

.end-screen[hidden] { display: none; }

@keyframes endFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.end-panel {
  position: relative;
  width: 100%;
  max-width: 330px;
  padding: 28px 22px 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 183, 116, .36);
  border-radius: 24px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 138, 61, .17), transparent 58%),
    linear-gradient(180deg, #291C39, #160F21 72%);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, .6),
    inset 0 1px 0 rgba(255, 255, 255, .12),
    0 0 0 6px rgba(255, 138, 61, .05);
  text-align: center;
  animation: endRise .38s cubic-bezier(.18, .9, .28, 1.15) both;
}

@keyframes endRise {
  from { opacity: 0; transform: translateY(22px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.end-panel::before,
.end-panel::after {
  content: "";
  position: absolute;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 160, 86, .55);
  pointer-events: none;
}

.end-panel::before {
  left: 10px;
  top: 10px;
  border-right: 0;
  border-bottom: 0;
  border-radius: 12px 0 0 0;
}

.end-panel::after {
  right: 10px;
  bottom: 10px;
  border-left: 0;
  border-top: 0;
  border-radius: 0 0 12px 0;
}

.end-kicker {
  margin: 0 0 8px;
  color: #FFB463;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .38em;
  text-indent: .38em;
  text-shadow: 0 0 14px rgba(255, 138, 61, .65);
}

.end-title {
  margin: 0;
  color: var(--cream);
  font-size: 54px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.04em;
  line-height: 1;
  text-shadow: 0 3px 0 #B84A12, 0 8px 24px rgba(255, 138, 61, .35);
}

.end-title.is-defeat { text-shadow: 0 3px 0 #4A2D71, 0 8px 24px rgba(124, 92, 200, .35); }

.end-sub {
  margin: 12px 0 22px;
  color: rgba(255, 235, 214, .62);
  font-size: 12px;
  letter-spacing: .04em;
}

.replay-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 52px;
  border: 1.5px solid #FFD3A1;
  border-radius: 16px;
  color: #341306;
  background:
    radial-gradient(70% 60% at 35% 10%, rgba(255, 255, 255, .5), transparent 60%),
    linear-gradient(180deg, #FFC078, #FF8A3D 52%, #EC6418);
  box-shadow: 0 5px 0 #8F3A0B, 0 12px 22px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .4);
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .08em;
  cursor: pointer;
  touch-action: none;
  transition: transform .07s ease, box-shadow .07s ease;
}

.replay-btn .mp-icon { width: 22px; height: 22px; }
.replay-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #8F3A0B, inset 0 1px 0 rgba(255, 255, 255, .5); }

/* ---------------- Flash ---------------- */

.hit-flash {
  position: absolute;
  inset: 0;
  z-index: 14;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 58%, rgba(255, 244, 224, .75), rgba(255, 138, 61, .22) 42%, transparent 72%);
  mix-blend-mode: screen;
}

.hit-flash.on { animation: hitFlash .2s ease-out both; }

@keyframes hitFlash {
  0% { opacity: .8; }
  100% { opacity: 0; }
}

/* ---------------- Responsive ---------------- */

@media (max-width: 360px) {
  .hud { grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr); padding-left: 10px; padding-right: 10px; gap: 4px; }
  .portrait-wrap { width: 35px; height: 35px; border-radius: 11px; }
  .ptag { min-width: 14px; height: 14px; line-height: 14px; font-size: 8px; }
  .fname { font-size: 9px; }
  .vs-badge { width: 38px; height: 35px; }
  .controls { padding-left: 14px; padding-right: 14px; }
  .ctl-move { width: 54px; height: 54px; }
  .ctl-jump { width: 58px; height: 58px; }
  .ctl-punch { width: 78px; height: 78px; }
}

@media (max-height: 700px) {
  .controls { padding-top: 16px; padding-bottom: calc(10px + var(--safe-bottom)); }
  .ctl-move { width: 52px; height: 52px; }
  .ctl-jump { width: 58px; height: 58px; }
  .ctl-punch { width: 76px; height: 76px; }
  .hint { font-size: 9px; padding: 5px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .announce.show,
  .combo-pop.show,
  .card-hit,
  .hit-flash.on,
  .end-screen,
  .end-panel { animation-duration: .01s !important; }
}
