:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: #b7c6d9;
  --panel: rgba(9, 20, 34, 0.82);
  --line: rgba(255, 255, 255, 0.16);
  --teal: #38d8cb;
  --gold: #ffd66b;
  --coral: #ff7468;
  --blue: #172f5b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #08121f;
  color: var(--ink);
  touch-action: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.game-page {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(circle at 18% 16%, rgba(56, 216, 203, 0.24), transparent 26%),
    radial-gradient(circle at 86% 18%, rgba(255, 214, 107, 0.18), transparent 22%),
    linear-gradient(135deg, #08121f 0%, #11233e 48%, #092c35 100%);
}

.orientation-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 32%, rgba(56, 216, 203, 0.12), transparent 34%),
    rgba(8, 18, 31, 0.985);
  text-align: center;
}

.orientation-gate div {
  display: grid;
  gap: 10px;
  max-width: 320px;
}

.orientation-gate strong {
  font-size: 1.3rem;
}

.orientation-gate span {
  color: var(--muted);
  line-height: 1.45;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.screen.is-active {
  display: grid;
}

.intro-screen {
  position: absolute;
  isolation: isolate;
  display: none;
  grid-template-columns: minmax(280px, 0.78fr) minmax(340px, 1.22fr);
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: #06111d;
}

.intro-screen.is-active {
  display: grid;
}

.intro-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(3, 9, 20, 0.94) 0%, rgba(5, 13, 27, 0.72) 42%, rgba(5, 13, 27, 0.1) 72%),
    radial-gradient(circle at 54% 50%, rgba(255, 214, 107, 0.3), transparent 20%),
    url("assets/stage-merlion-park-arcade.webp") center / cover no-repeat;
}

.intro-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 68% 82%, rgba(56, 216, 203, 0.28), transparent 30%),
    radial-gradient(ellipse at 82% 62%, rgba(255, 94, 169, 0.24), transparent 24%),
    linear-gradient(180deg, rgba(2, 6, 14, 0.08), rgba(2, 6, 14, 0.58));
}

.intro-copy-panel {
  z-index: 2;
  display: grid;
  align-content: center;
  gap: 14px;
  max-width: 560px;
  min-height: 100%;
  padding: clamp(24px, 5vw, 64px);
}

.intro-copy-panel h1 {
  max-width: 560px;
  font-size: clamp(2.4rem, 10vh, 5.8rem);
  text-shadow: 0 0 26px rgba(56, 216, 203, 0.28), 0 8px 28px rgba(0, 0, 0, 0.72);
}

.intro-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.intro-badges span {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(5, 14, 28, 0.58);
  color: #e7f8ff;
  font-size: clamp(0.7rem, 2vh, 0.82rem);
  font-weight: 950;
  backdrop-filter: blur(8px);
}

.intro-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.start-duel-button {
  min-width: min(58vw, 220px);
  min-height: clamp(48px, 10vh, 62px);
  font-size: clamp(1rem, 3vh, 1.2rem);
  box-shadow: 0 0 28px rgba(255, 214, 107, 0.34), 0 20px 42px rgba(0, 0, 0, 0.38);
}

.intro-scene {
  position: relative;
  z-index: 1;
  min-height: 100%;
  overflow: hidden;
}

.intro-fighter,
.intro-clash {
  position: absolute;
  display: block;
  pointer-events: none;
}

.intro-fighter {
  bottom: max(6px, 1.4vh);
  width: clamp(310px, 39vw, 480px);
  aspect-ratio: 1.14 / 1;
  background: center bottom / contain no-repeat;
  filter: drop-shadow(0 26px 24px rgba(0, 0, 0, 0.72));
  animation: intro-fighter-breathe 1800ms ease-in-out infinite;
}

.intro-fighter-blue {
  left: clamp(-18px, 11vw, 88px);
  background-image: url("assets/fighter-blue-arcade.webp");
}

.intro-fighter-red {
  right: clamp(-42px, 4vw, 42px);
  background-image: url("assets/fighter-red-arcade.webp");
  animation-delay: -620ms;
}

.intro-clash {
  left: 49%;
  top: 49%;
  width: clamp(120px, 22vw, 250px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 8%, rgba(255, 214, 107, 0.85) 9% 18%, rgba(56, 216, 203, 0.36) 19% 38%, transparent 62%),
    conic-gradient(from 20deg, transparent 0 18deg, rgba(255, 255, 255, 0.8) 18deg 22deg, transparent 22deg 68deg, rgba(255, 116, 104, 0.68) 68deg 72deg, transparent 72deg 100deg);
  filter: blur(0.2px) drop-shadow(0 0 34px rgba(255, 214, 107, 0.72));
  opacity: 0.9;
  transform: translate(-50%, -50%);
  animation: intro-clash-pulse 1100ms ease-in-out infinite;
  mix-blend-mode: screen;
}

.setup-screen {
  grid-template-columns: minmax(260px, 1.15fr) minmax(260px, 0.85fr);
  align-items: center;
  gap: clamp(18px, 4vw, 54px);
  max-width: 1120px;
  margin: 0 auto;
  background:
    linear-gradient(90deg, rgba(5, 12, 24, 0.92), rgba(5, 12, 24, 0.7)),
    url("assets/stage-merlion-park-arcade.webp") center / cover no-repeat;
}

.brand-panel {
  display: grid;
  gap: 14px;
}

.place-line {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 680px;
  font-size: clamp(2rem, 7vh, 5.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.25rem, 4.5vh, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 460px;
  color: var(--muted);
  font-size: clamp(0.95rem, 2.6vh, 1.18rem);
  line-height: 1.45;
}

.setup-card,
.result-card,
.player-slot {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.setup-card {
  display: grid;
  gap: 14px;
  padding: clamp(16px, 3vw, 26px);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  outline: none;
}

input:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(56, 216, 203, 0.2);
}

.setup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 16px;
  color: #06111d;
  font-weight: 900;
}

.primary-button {
  background: linear-gradient(135deg, var(--gold), #ffaf4e);
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.compact {
  min-height: 38px;
}

.status-line,
.slot-state,
.arcade-toast {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.top-bar,
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-actions,
.hud-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-center {
  flex-direction: column;
  gap: 6px;
}

.sound-toggle {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 950;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.sound-toggle[aria-pressed="true"] {
  border-color: rgba(255, 116, 104, 0.48);
  background: rgba(255, 116, 104, 0.18);
  color: #ffd2cc;
}

.lobby-screen {
  position: relative;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(8px, 2.5vh, 16px);
  width: 100%;
  max-width: min(980px, 100vw);
  margin: 0 auto;
  padding-bottom: max(74px, calc(env(safe-area-inset-bottom) + 64px));
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.player-slot {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(7px, 1.8vh, 12px);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: clamp(10px, 2.6vh, 18px);
}

.avatar-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: min(22vh, 132px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(56, 216, 203, 0.24), rgba(255, 214, 107, 0.18));
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-picker {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(100%, 270px);
}

.avatar-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.upload-button {
  appearance: none;
  display: grid;
  place-items: center;
  width: min(100%, 240px);
  min-height: 44px;
  border: 1px solid rgba(56, 216, 203, 0.38);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(56, 216, 203, 0.24), rgba(255, 214, 107, 0.18));
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 950;
  cursor: pointer;
}

.upload-file-name {
  max-width: 100%;
  min-height: 18px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-native-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0.01;
}

.ready-button {
  position: absolute;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 16;
  width: min(360px, calc(100% - 36px));
  transform: translateX(-50%);
  box-shadow: 0 0 26px rgba(255, 214, 107, 0.3), 0 18px 40px rgba(0, 0, 0, 0.36);
}

.fight-screen {
  display: none;
  width: 100%;
  padding: 0;
}

.fight-screen.is-active {
  display: block;
}

.premium-fight-hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 18;
  min-height: 70px;
  pointer-events: none;
}

.hud-player {
  display: grid;
  grid-template-columns: clamp(52px, 12vh, 68px) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: min(42vw, 386px);
  min-width: 0;
  font-size: clamp(0.74rem, 2.2vh, 0.95rem);
  font-weight: 950;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.68);
}

.hud-player.right {
  grid-template-columns: minmax(0, 1fr) clamp(52px, 12vh, 68px);
  text-align: right;
}

.hud-stack {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.player-tag {
  color: var(--gold);
  font-size: 0.7rem;
}

.portrait-ring {
  display: grid;
  place-items: center;
  width: clamp(52px, 12vh, 68px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid #66eaff;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 35%, #f8fbff 0 28%, #54dff2 29% 57%, #071527 58%);
  color: #06111d;
  font-weight: 950;
  box-shadow:
    0 0 0 4px rgba(4, 12, 24, 0.72),
    0 0 24px rgba(56, 216, 203, 0.62);
}

.portrait-ring.red {
  border-color: #ff6d78;
  background: radial-gradient(circle at 45% 35%, #fff4ef 0 28%, #ff6d78 29% 57%, #1b0c16 58%);
  box-shadow:
    0 0 0 4px rgba(4, 12, 24, 0.72),
    0 0 24px rgba(255, 94, 169, 0.58);
}

.portrait-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hp-track {
  position: relative;
  height: clamp(14px, 3.2vh, 22px);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 3px;
  background: rgba(3, 8, 16, 0.74);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.38), 0 4px 14px rgba(0, 0, 0, 0.35);
}

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

.hp-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #25ef9f, #d8ff5d 64%, #ffe36d);
  transform-origin: left center;
  transition: width 180ms ease;
}

.hp-fill.rival {
  background: linear-gradient(90deg, #ffe36d, #ff7c68 48%, #ef3d5d);
}

.hud-center {
  display: grid;
  justify-items: center;
  gap: 3px;
  pointer-events: none;
}

.timer,
.timer-medallion {
  display: grid;
  place-items: center;
  width: clamp(50px, 10vh, 72px);
  height: clamp(38px, 7.2vh, 54px);
  clip-path: polygon(15% 0, 85% 0, 100% 30%, 100% 70%, 85% 100%, 15% 100%, 0 70%, 0 30%);
  background: linear-gradient(180deg, #ffe877, #d28f27 48%, #38200e);
  color: #19110b;
  font-size: clamp(1.2rem, 4.5vh, 1.9rem);
  font-weight: 950;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(6, 13, 26, 0.78), 0 0 24px rgba(255, 214, 107, 0.42);
}

.round-pips {
  display: flex;
  gap: 8px;
}

.round-pips span {
  width: 12px;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: rgba(4, 12, 24, 0.68);
}

.fight-sound-toggle {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.58rem;
  opacity: 0.86;
}

.fight-corner-controls {
  position: absolute;
  top: max(92px, calc(env(safe-area-inset-top) + 86px));
  right: max(12px, env(safe-area-inset-right));
  z-index: 19;
  pointer-events: auto;
}

.merlion-stage {
  position: absolute;
  inset: 0;
  isolation: isolate;
  width: 100vw;
  height: min(100dvh, calc(100dvw * 9 / 16));
  min-height: 100dvh;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 55%, rgba(255, 210, 72, 0.22), transparent 18%),
    linear-gradient(180deg, rgba(2, 8, 20, 0.08) 0%, rgba(2, 8, 20, 0.08) 56%, rgba(1, 3, 9, 0.28) 100%),
    url("assets/stage-merlion-park-arcade.webp") center / cover no-repeat;
  box-shadow: inset 0 -92px 120px rgba(0, 0, 0, 0.3);
}

.merlion-stage.is-impact {
  animation: stage-shake 180ms steps(2, end);
}

.merlion-stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  height: 42%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 33% 58%, rgba(34, 223, 255, 0.22), transparent 28%),
    radial-gradient(ellipse at 67% 58%, rgba(255, 52, 168, 0.22), transparent 28%),
    linear-gradient(180deg, transparent 0%, rgba(2, 6, 13, 0.42) 100%);
  mix-blend-mode: screen;
}

.merlion-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.2)),
    radial-gradient(circle at 50% 46%, transparent 0 18%, rgba(2, 6, 16, 0.18) 60%, rgba(1, 3, 9, 0.54) 100%);
}

.skyline,
.merlion,
.waterfront {
  display: none;
}

.round-banner,
.round-kicker {
  position: absolute;
  left: 50%;
  top: clamp(66px, 15vh, 82px);
  z-index: 12;
  min-width: 96px;
  border: 1px solid rgba(255, 214, 107, 0.62);
  border-radius: 999px;
  padding: 4px 13px;
  background: rgba(4, 12, 24, 0.56);
  color: var(--gold);
  font-size: 0.66rem;
  font-weight: 950;
  text-align: center;
  transform: translateX(-50%);
  text-shadow: 0 0 12px rgba(255, 214, 107, 0.72);
  backdrop-filter: blur(7px);
}

.arena-spotlight {
  position: absolute;
  top: -10%;
  z-index: 3;
  width: 42%;
  height: 122%;
  pointer-events: none;
  opacity: 0.32;
  background: linear-gradient(180deg, rgba(56, 216, 203, 0.24), transparent 76%);
  filter: blur(8px);
  transform: skewX(-16deg);
}

.spotlight-left {
  left: 18%;
}

.spotlight-right {
  right: 17%;
  background: linear-gradient(180deg, rgba(255, 94, 169, 0.22), transparent 76%);
  transform: skewX(16deg);
}

.stage-depth {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: 31%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 31% 18%, rgba(56, 216, 203, 0.28), transparent 29%),
    radial-gradient(ellipse at 69% 18%, rgba(255, 94, 169, 0.26), transparent 29%),
    repeating-linear-gradient(93deg, transparent 0 86px, rgba(255, 255, 255, 0.06) 87px 90px, transparent 91px 172px);
  mix-blend-mode: screen;
}

.fighter {
  position: absolute;
  bottom: clamp(15px, 1.8vh, 24px);
  z-index: 9;
  width: clamp(300px, 38vw, 430px);
  aspect-ratio: 1.14 / 1;
  --fighter-flip: 1;
  --fighter-action-x: 0px;
  --fighter-action-y: 0px;
  transform-origin: center bottom;
  transform: translateX(-50%) translate(var(--fighter-action-x), var(--fighter-action-y)) scaleX(var(--fighter-flip));
  transition: transform 120ms ease, filter 120ms ease;
  animation: fighter-idle 1700ms ease-in-out infinite;
}

.fighter-left {
  left: clamp(250px, 33vw, 370px);
}

.fighter-right {
  left: clamp(590px, 68vw, 720px);
  --fighter-flip: 1;
}

.fighter.is-striking {
  --fighter-action-x: 32px;
  filter: drop-shadow(0 0 22px rgba(56, 216, 203, 0.64));
}

.fighter-right.is-striking {
  --fighter-action-x: -32px;
  filter: drop-shadow(0 0 22px rgba(255, 94, 169, 0.6));
}

.fighter.is-guarding {
  filter: drop-shadow(0 0 22px rgba(119, 241, 255, 0.85));
  animation: guard-brace 240ms ease-out;
}

.fighter.guard-brace {
  animation: guard-brace 240ms ease-out;
}

.fighter.is-dashing {
  --fighter-action-y: -10px;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.58));
}

.fighter.is-windup {
  animation: strike-windup 110ms ease-out forwards;
}

.fighter.is-strike-extend {
  animation: strike-extend 130ms cubic-bezier(0.2, 0.9, 0.25, 1.25) forwards;
}

.fighter.is-recoiling {
  animation: recoil-return 170ms ease-out forwards;
}

.fighter.is-hit-freeze {
  animation: hit-freeze 150ms steps(2, end);
}

.avatar-head {
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  color: #06111d;
  font-size: 0.82rem;
  font-weight: 950;
}

.avatar-head.guest {
  background: linear-gradient(135deg, var(--coral), #8dd8ff);
}

.avatar-head img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fighter-badge {
  position: absolute;
  top: 21%;
  left: 39%;
  z-index: 11;
  width: clamp(38px, 6.6vh, 52px);
  border-width: 3px;
  box-shadow:
    0 0 0 4px rgba(5, 12, 22, 0.72),
    0 0 20px rgba(56, 216, 203, 0.5),
    0 8px 16px rgba(0, 0, 0, 0.38);
}

.fighter-right .fighter-badge {
  top: 18%;
  left: 61%;
  box-shadow:
    0 0 0 4px rgba(5, 12, 22, 0.72),
    0 0 20px rgba(255, 94, 169, 0.48),
    0 8px 16px rgba(0, 0, 0, 0.38);
}

.fighter-body {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 8;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  background: center bottom / contain no-repeat;
  transform: translateX(-50%);
  filter: drop-shadow(0 24px 20px rgba(0, 0, 0, 0.58));
}

.fighter-left .fighter-body {
  background-image: url("assets/fighter-blue-arcade.webp");
}

.fighter-right .fighter-body {
  background-image: url("assets/fighter-red-arcade.webp");
}

.fighter::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 2;
  width: 70%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.58), transparent 68%);
  transform: translateX(-50%);
}

.fighter-weapon {
  position: absolute;
  left: 58%;
  top: 38%;
  z-index: 10;
  width: 45%;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.98), rgba(56, 216, 203, 0.8), transparent);
  box-shadow: 0 0 18px rgba(56, 216, 203, 0.78), 0 0 34px rgba(56, 216, 203, 0.34);
  transform: rotate(-17deg);
  transform-origin: 8% center;
  opacity: 0.5;
}

.fighter-right .fighter-weapon {
  left: 2%;
  top: 34%;
  background: linear-gradient(270deg, rgba(255, 255, 255, 0.98), rgba(255, 94, 169, 0.8), transparent);
  box-shadow: 0 0 18px rgba(255, 94, 169, 0.76), 0 0 34px rgba(255, 94, 169, 0.32);
  transform: rotate(17deg);
}

.fighter::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 12;
  width: 150px;
  max-width: 116%;
  aspect-ratio: 1;
  pointer-events: none;
  opacity: 0;
  background: url("assets/hit-sparks.webp") 33.333% center / 400% 100% no-repeat;
  transform: translate(-50%, -50%);
}

.fighter.is-guarding::after {
  opacity: 0.95;
  background-position: 33.333% center;
  animation: fighter-effect 260ms ease-out;
}

.fighter.is-dashing::after {
  opacity: 0.75;
  background-position: 66.666% center;
  animation: fighter-effect 260ms ease-out;
}

.hit-spark,
.damage-pop,
.clash-flare,
.dash-afterimage,
.weapon-trail,
.freeze-flash {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.hit-spark {
  left: var(--spark-x, 50%);
  top: var(--spark-y, 42%);
  z-index: 15;
  width: clamp(150px, 23vh, 220px);
  height: clamp(150px, 23vh, 220px);
  border-radius: 0;
  background: url("assets/hit-sparks.webp") left center / 400% 100% no-repeat;
  filter: drop-shadow(0 0 16px rgba(255, 214, 107, 0.68));
  transform: translate(-50%, -50%) scale(0.65);
}

.hit-spark.is-visible {
  animation: spark 220ms ease-out;
}

.damage-pop {
  left: var(--spark-x, 54%);
  top: calc(var(--spark-y, 42%) - 34px);
  z-index: 16;
  min-width: 112px;
  color: var(--gold);
  font-size: clamp(1.12rem, 4.2vh, 1.8rem);
  font-weight: 950;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
}

.damage-pop.is-visible {
  animation: pop 520ms ease-out;
}

.impact-ripple {
  position: absolute;
  left: var(--spark-x, 50%);
  top: var(--spark-y, 42%);
  z-index: 14;
  width: clamp(130px, 22vh, 210px);
  height: clamp(130px, 22vh, 210px);
  border: 4px solid rgba(255, 214, 107, 0.82);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.54);
}

.impact-ripple.is-visible {
  animation: impact-ripple 430ms ease-out;
}

.clash-flare {
  left: 50%;
  top: 48%;
  z-index: 13;
  width: clamp(180px, 34vh, 320px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    conic-gradient(from 8deg, transparent 0 7%, rgba(255, 255, 255, 0.95) 8% 10%, transparent 11% 18%, rgba(255, 214, 107, 0.95) 19% 21%, transparent 22% 35%, rgba(56, 216, 203, 0.8) 36% 39%, transparent 40% 52%, rgba(255, 94, 169, 0.8) 53% 56%, transparent 57% 100%),
    radial-gradient(circle, #ffffff 0 8%, #ffe36d 9% 16%, rgba(255, 94, 169, 0.56) 17% 29%, rgba(56, 216, 203, 0.34) 30% 42%, transparent 58%);
  filter: drop-shadow(0 0 26px rgba(255, 214, 107, 0.95));
  transform: translate(-50%, -50%) scale(0.42);
}

.clash-flare.is-visible {
  animation: clash-flare 260ms ease-out;
}

.weapon-trail {
  top: 44%;
  z-index: 13;
  width: clamp(210px, 30vw, 330px);
  height: 34px;
  border-radius: 999px;
  filter: blur(0.5px) drop-shadow(0 0 22px rgba(255, 255, 255, 0.72));
  transform-origin: center;
}

.weapon-trail.left {
  left: 38%;
  background: linear-gradient(90deg, transparent, rgba(44, 235, 255, 0.42), rgba(255, 255, 255, 0.92), rgba(255, 218, 88, 0.2), transparent);
  transform: translate(-50%, -50%) rotate(-14deg) scaleX(0.6);
}

.weapon-trail.right {
  left: 62%;
  background: linear-gradient(90deg, transparent, rgba(255, 73, 170, 0.3), rgba(255, 255, 255, 0.9), rgba(255, 218, 88, 0.24), transparent);
  transform: translate(-50%, -50%) rotate(14deg) scaleX(0.6);
}

.weapon-trail.is-visible {
  animation: weapon-trail 260ms ease-out;
}

.freeze-flash {
  inset: 0;
  z-index: 17;
  background:
    radial-gradient(circle at var(--spark-x, 50%) var(--spark-y, 42%), rgba(255, 255, 255, 0.36), transparent 18%),
    linear-gradient(90deg, rgba(56, 216, 203, 0.08), rgba(255, 94, 169, 0.08));
  mix-blend-mode: screen;
}

.freeze-flash.is-visible {
  animation: freeze-flash 170ms steps(2, end);
}

.dash-afterimage {
  bottom: clamp(15px, 1.8vh, 24px);
  z-index: 7;
  width: clamp(300px, 38vw, 430px);
  aspect-ratio: 1.14 / 1;
  background: center bottom / contain no-repeat;
  mix-blend-mode: screen;
  filter: blur(1px) drop-shadow(0 0 18px rgba(255, 255, 255, 0.58));
}

.dash-afterimage.left {
  left: clamp(250px, 33vw, 370px);
  background-image: url("assets/fighter-blue-arcade.webp");
  transform: translateX(-56%);
}

.dash-afterimage.right {
  left: clamp(590px, 68vw, 720px);
  background-image: url("assets/fighter-red-arcade.webp");
  transform: translateX(-44%);
}

.dash-afterimage.is-visible {
  animation: dash-afterimage 300ms ease-out;
}

.arcade-toast {
  position: absolute;
  left: 50%;
  top: max(104px, calc(env(safe-area-inset-top) + 96px));
  z-index: 18;
  width: max-content;
  max-width: min(68vw, 560px);
  min-height: 26px;
  padding: 5px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(4, 12, 24, 0.66);
  color: #eaf6ff;
  font-weight: 850;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  transform: translateX(-50%) translateY(-6px);
  backdrop-filter: blur(8px);
  opacity: 0;
}

.arcade-toast.is-visible {
  animation: arcade-toast 1250ms ease-out;
}

.touch-controls,
.mobile-arcade-controls {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 128px;
  pointer-events: none;
}

.virtual-stick,
.combat-buttons {
  pointer-events: auto;
}

.virtual-stick {
  position: relative;
  width: clamp(108px, 24vh, 138px);
  height: clamp(108px, 24vh, 138px);
  border: 2px solid rgba(169, 231, 255, 0.2);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(97, 212, 255, 0.28) 0 26%, rgba(6, 21, 35, 0.6) 27% 43%, rgba(255, 255, 255, 0.08) 44% 100%);
  box-shadow: inset 0 0 24px rgba(119, 241, 255, 0.22), 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
}

.virtual-stick button {
  position: absolute;
  width: 38%;
  height: 38%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: transparent;
}

.virtual-stick [data-stick="up"] {
  left: 31%;
  top: 2%;
}

.virtual-stick [data-stick="left"] {
  left: 2%;
  top: 31%;
}

.virtual-stick [data-stick="right"] {
  right: 2%;
  top: 31%;
}

.virtual-stick [data-stick="down"] {
  left: 31%;
  bottom: 2%;
}

.combat-buttons {
  position: relative;
  display: block;
  width: clamp(232px, 43vw, 330px);
  height: 130px;
}

.combat-button {
  position: absolute;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  color: #06111d;
  font-size: clamp(0.75rem, 2.4vh, 0.95rem);
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: inset 0 8px 18px rgba(255, 255, 255, 0.2), 0 10px 24px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
}

.combat-button.strike {
  right: 0;
  bottom: 0;
  width: clamp(82px, 19vh, 108px);
  background: linear-gradient(135deg, #ffd66b, #ff7468);
}

.combat-button.guard {
  right: 88px;
  bottom: 55px;
  width: clamp(66px, 15vh, 84px);
  background: linear-gradient(135deg, #c8f7f2, #38d8cb);
}

.combat-button.dash {
  right: 116px;
  bottom: 0;
  width: clamp(64px, 14vh, 78px);
  background: linear-gradient(135deg, #d7e8ff, #8dd8ff);
}

.result-screen {
  place-items: center;
}

.result-card {
  display: grid;
  position: relative;
  overflow: hidden;
  gap: 14px;
  width: min(440px, 88vw);
  padding: 24px;
  text-align: center;
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(8, 18, 31, 0.72), rgba(8, 18, 31, 0.94)),
    url("assets/stage-merlion-park-arcade.webp") center / cover no-repeat;
  opacity: 0.88;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes spark {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45);
  }

  45% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.35);
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }

  30% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-22px);
  }
}

@keyframes fighter-effect {
  0% {
    transform: translate(-50%, -50%) scale(0.72);
  }

  100% {
    transform: translate(-50%, -50%) scale(1.1);
  }
}

@keyframes fighter-idle {
  0%,
  100% {
    translate: 0 0;
  }

  50% {
    translate: 0 -2px;
  }
}

@keyframes strike-windup {
  0% {
    translate: 0 0;
    rotate: 0deg;
  }

  100% {
    translate: -14px -2px;
    rotate: -2deg;
  }
}

@keyframes strike-extend {
  0% {
    translate: -8px -2px;
    scale: 0.98 1.02;
  }

  65% {
    translate: 34px -4px;
    scale: 1.05 0.98;
  }

  100% {
    translate: 26px -3px;
    scale: 1.02 1;
  }
}

@keyframes recoil-return {
  0% {
    translate: 22px -3px;
  }

  100% {
    translate: 0 0;
  }
}

@keyframes guard-brace {
  0% {
    translate: 0 0;
    scale: 1;
  }

  45% {
    translate: -6px 0;
    scale: 0.97 1.03;
  }

  100% {
    translate: 0 0;
    scale: 1;
  }
}

@keyframes hit-freeze {
  0%,
  100% {
    filter: saturate(1.15) brightness(1.02) drop-shadow(0 0 0 transparent);
  }

  50% {
    filter: saturate(1.7) brightness(1.25) drop-shadow(0 0 30px rgba(255, 236, 145, 0.9));
  }
}

@keyframes impact-ripple {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.42);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.28);
  }
}

@keyframes weapon-trail {
  0% {
    opacity: 0;
    scale: 0.32 0.78;
  }

  28% {
    opacity: 0.95;
    scale: 1 1;
  }

  100% {
    opacity: 0;
    scale: 1.22 0.72;
  }
}

@keyframes freeze-flash {
  0%,
  100% {
    opacity: 0;
  }

  35% {
    opacity: 0.85;
  }
}

@keyframes arcade-toast {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.96);
  }

  18%,
  72% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.98);
  }
}

@keyframes clash-flare {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.36) rotate(-12deg);
  }

  42% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(5deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.42) rotate(14deg);
  }
}

@keyframes dash-afterimage {
  0% {
    opacity: 0.62;
  }

  100% {
    opacity: 0;
    translate: -26px 0;
  }
}

@keyframes stage-shake {
  0%,
  100% {
    translate: 0 0;
  }

  25% {
    translate: 5px -2px;
  }

  50% {
    translate: -4px 2px;
  }

  75% {
    translate: 3px 1px;
  }
}

@keyframes intro-fighter-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-7px) scale(1.012);
  }
}

@keyframes intro-clash-pulse {
  0%,
  100% {
    opacity: 0.74;
    transform: translate(-50%, -50%) scale(0.92) rotate(-6deg);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(8deg);
  }
}

@media (orientation: portrait) {
  .game-page:not([data-active-screen="intro"]) .orientation-gate {
    display: grid;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .orientation-gate {
    display: none;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .screen.is-active {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: 100dvh;
    height: 100dvw;
    min-height: 0;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .screen {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .setup-screen {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .setup-card {
    gap: 9px;
    padding: 14px;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .lobby-screen {
    gap: 8px;
    padding-bottom: max(58px, calc(env(safe-area-inset-bottom) + 52px));
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .top-bar h2 {
    font-size: clamp(1.15rem, 7vw, 2rem);
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .player-slot {
    gap: 6px;
    padding: 9px;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .avatar-preview {
    width: clamp(62px, 18vw, 86px);
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .avatar-picker {
    gap: 5px;
    width: min(100%, 220px);
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .upload-button {
    width: min(100%, 202px);
    min-height: 36px;
    font-size: 0.78rem;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .upload-file-name,
  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .slot-state,
  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .avatar-label {
    font-size: 0.72rem;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .ready-button {
    min-height: 42px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .touch-controls {
    min-height: 118px;
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .virtual-stick {
    width: clamp(90px, 24vw, 118px);
    height: clamp(90px, 24vw, 118px);
  }

  .game-page[data-force-landscape="true"]:not([data-active-screen="intro"]) .combat-buttons {
    width: clamp(220px, 43vw, 320px);
  }

  .game-page[data-active-screen="intro"] .orientation-gate {
    display: none;
  }

  .game-page[data-active-screen="intro"] .intro-screen {
    grid-template-columns: 1fr;
    align-items: end;
    overflow: hidden;
  }

  .game-page[data-active-screen="intro"] .intro-screen::before {
    background:
      linear-gradient(180deg, rgba(3, 9, 20, 0.22) 0%, rgba(3, 9, 20, 0.2) 38%, rgba(3, 9, 20, 0.88) 100%),
      radial-gradient(circle at 50% 58%, rgba(255, 214, 107, 0.28), transparent 26%),
      url("assets/stage-merlion-park-arcade.webp") 56% center / cover no-repeat;
  }

  .game-page[data-active-screen="intro"] .intro-screen::after {
    background:
      radial-gradient(ellipse at 50% 74%, rgba(56, 216, 203, 0.28), transparent 30%),
      radial-gradient(ellipse at 64% 52%, rgba(255, 94, 169, 0.22), transparent 26%),
      linear-gradient(180deg, rgba(2, 6, 14, 0.02), rgba(2, 6, 14, 0.68));
  }

  .game-page[data-active-screen="intro"] .intro-scene {
    position: absolute;
    inset: 0;
    z-index: 0;
    min-height: auto;
  }

  .game-page[data-active-screen="intro"] .intro-copy-panel {
    align-content: end;
    gap: 12px;
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    padding: max(24px, env(safe-area-inset-top)) clamp(18px, 6vw, 28px)
      max(26px, env(safe-area-inset-bottom));
  }

  .game-page[data-active-screen="intro"] .intro-copy-panel h1 {
    max-width: 9ch;
    font-size: clamp(2.45rem, 13vw, 3.7rem);
    line-height: 0.96;
  }

  .game-page[data-active-screen="intro"] .intro-copy {
    max-width: 28ch;
    font-size: clamp(1rem, 4.7vw, 1.2rem);
  }

  .game-page[data-active-screen="intro"] .intro-badges {
    max-width: 320px;
  }

  .game-page[data-active-screen="intro"] .intro-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: min(100%, 320px);
    gap: 10px;
  }

  .game-page[data-active-screen="intro"] .start-duel-button,
  .game-page[data-active-screen="intro"] .sound-toggle.compact {
    width: 100%;
    min-width: 0;
  }

  .game-page[data-active-screen="intro"] .intro-fighter {
    bottom: clamp(150px, 26vh, 220px);
    width: clamp(210px, 67vw, 330px);
    opacity: 0.92;
  }

  .game-page[data-active-screen="intro"] .intro-fighter-blue {
    left: clamp(-28px, 2vw, 10px);
  }

  .game-page[data-active-screen="intro"] .intro-fighter-red {
    right: clamp(-48px, -4vw, -12px);
  }

  .game-page[data-active-screen="intro"] .intro-clash {
    left: 50%;
    top: 42%;
    width: clamp(118px, 40vw, 180px);
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  .screen {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  h1 {
    font-size: clamp(1.75rem, 10vh, 3.5rem);
  }

  .setup-card {
    gap: 9px;
    padding: 14px;
  }

  .lobby-screen {
    gap: 8px;
    padding-top: 8px;
    padding-bottom: max(58px, calc(env(safe-area-inset-bottom) + 52px));
  }

  .top-bar {
    gap: 8px;
  }

  .top-bar h2 {
    font-size: clamp(1.15rem, 7vh, 2rem);
  }

  .top-actions {
    gap: 7px;
  }

  .player-slot {
    gap: 6px;
    padding: 9px;
  }

  .avatar-preview {
    width: clamp(62px, 18vh, 86px);
  }

  .avatar-picker {
    gap: 5px;
    width: min(100%, 220px);
  }

  .upload-button {
    width: min(100%, 202px);
    min-height: 36px;
    font-size: 0.78rem;
  }

  .upload-file-name,
  .slot-state,
  .avatar-label {
    font-size: 0.72rem;
  }

  .ready-button {
    min-height: 42px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .intro-screen {
    grid-template-columns: 0.82fr 1.18fr;
  }

  .intro-copy-panel {
    gap: 10px;
    padding: 18px 16px 18px max(18px, env(safe-area-inset-left));
  }

  .intro-fighter {
    width: clamp(250px, 40vw, 350px);
  }

  .intro-clash {
    left: 51%;
    width: clamp(98px, 20vw, 180px);
  }

  .fight-screen {
    padding: 0;
  }

  .fighter {
    width: clamp(300px, 38vw, 430px);
  }

  .touch-controls {
    min-height: 118px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .intro-screen {
    grid-template-columns: 1fr 1fr;
  }

  .intro-copy-panel {
    padding-right: 8px;
  }

  .setup-screen {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .lobby-grid {
    gap: 10px;
  }

  .player-slot {
    padding: 12px;
  }

  .fighter-left {
    left: clamp(230px, 33vw, 350px);
  }

  .fighter-right {
    left: clamp(570px, 68vw, 700px);
  }

  .combat-buttons {
    width: clamp(220px, 43vw, 320px);
  }
}
