:root {
  color-scheme: dark;
  --bg: #101012;
  --panel: #17171a;
  --line: #333035;
  --text: #f2eee7;
  --muted: #b4a9aa;
  --red: #dc5354;
  --gold: #d2ac77;
  font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: var(--bg); color: var(--text); }
button, a { color: inherit; font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid #efc377; outline-offset: 4px; }
[hidden] { display: none !important; }
.header { border-bottom: 1px solid #2b272b; }
.header-wrap, .shell { width: min(1320px, calc(100% - 88px)); margin: 0 auto; }
.header-wrap { height: 74px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.brand { display: inline-flex; align-items: center; justify-self: start; gap: 11px; white-space: nowrap; text-decoration: none; font-size: 18px; font-weight: 900; letter-spacing: .02em; line-height: 1.13; }
.brand small { display: block; font: 700 8px/1.7 "Consolas", monospace; letter-spacing: .14em; color: var(--muted); }
.seal { width: 37px; height: 37px; display: grid; place-items: center; background: #a8323b; color: #fff1e6; font: 900 24px/1 serif; border: 1px solid #df6060; }
.modes { display: flex; height: 100%; gap: 8px; }
.modes button { color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; font-size: 14px; padding: 0 20px; }
.modes button[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--red); font-weight: 800; }
.modes button:hover { color: var(--text); }
.tools { display: flex; gap: 7px; justify-self: end; }
.tools button { background: #17171a; border: 1px solid var(--line); width: 36px; height: 36px; display: grid; place-items: center; }
.tools button:hover, .secondary:hover { background: #282529; }
.tools svg { width: 18px; height: 18px; stroke: #d1c5c1; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.shell { padding-top: 26px; }
.arena { position: relative; overflow: hidden; isolation: isolate; margin: 0; aspect-ratio: 1280 / 620; border: 1px solid #4c3c3d; background: #211c21 url("assets/moonlit-courtyard.png") center / cover; }
#stage { display: block; width: 100%; height: 100%; }
.arena:fullscreen { width: 100%; height: auto; max-height: 100%; margin: auto; }
.arena:fullscreen::backdrop { background: #080808; }
.intro, .hud, .overlay { position: absolute; inset: 0; }
.intro { background: linear-gradient(90deg, #09080c25, transparent 27%, #0b080c48 43%, #0b080c48 57%, transparent 73%, #09080c25), linear-gradient(0deg, #09080ceb, transparent 28%); }
.arena-caption { position: absolute; top: 25px; left: 27px; color: #ecded2; font-size: 12px; letter-spacing: .11em; }
.arena-caption::before { content: "◇"; color: #f2b273; margin-right: 9px; }
.hero-copy { position: absolute; left: 50%; top: 48%; width: max-content; max-width: 98%; text-align: center; transform: translate(-50%, -50%); }
.eyebrow, .section-kicker { font: 700 12px/1.2 "Consolas", monospace; letter-spacing: .23em; color: var(--gold); }
.eyebrow { color: #f4c992; display: flex; gap: 13px; align-items: center; justify-content: center; }
.eyebrow span { width: 24px; border-top: 1px solid #e4ac75; }
h1 { font-family: "Batang", "Noto Serif KR", serif; font-size: clamp(46px, 8vw, 122px); font-weight: 900; margin: 2px 0 5px; line-height: 1.15; letter-spacing: -.09em; text-shadow: 0 3px 0 #19141b, 0 9px 26px #09080a; }
h1 span { color: #f07573; }
.hero-copy p { font-size: clamp(11px, 1.4vw, 16px); margin: 0 0 23px; text-shadow: 0 2px 8px #000, 0 2px 4px #000; }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 22px; font-weight: 800; white-space: nowrap; }
.primary { min-height: 47px; padding: 0 22px; background: #bd3c46; border: 1px solid #ee7273; color: #fff6ed; }
.primary:hover { background: #d04b52; }
.secondary { min-height: 39px; background: var(--panel); border: 1px solid #54474a; padding: 0 14px; font-size: 13px; }
.match-label { position: absolute; bottom: 25px; display: flex; align-items: center; gap: 11px; }
.match-label.p1 { left: 27px; }
.match-label.p2 { right: 27px; text-align: right; }
.match-label > span, .side-name > span { color: #f9e0bf; font: 700 11px/1 "Consolas", monospace; border: 1px solid #705451; padding: 6px 7px; background: #21181b; }
.match-label strong { display: block; font-size: clamp(13px, 1.7vw, 21px); }
.match-label small { display: block; color: #c2b2ae; margin-top: 3px; font-size: 11px; }
.selection { margin-top: 27px; }
.section-header { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 16px; }
h2 { font-size: 25px; margin: 5px 0 0; line-height: 1.25; }
.select-side { display: flex; }
.select-side button { border: 1px solid var(--line); background: #17171b; padding: 8px 14px; font: 700 14px "Consolas", monospace; }
.select-side button[aria-pressed="true"] { border-color: #e86a68; color: #ffe2d2; background: #3d2228; }
.roster { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 9px; }
.fighter { position: relative; display: grid; text-align: left; padding: 0; min-width: 0; background: #1e1d21; border: 1px solid #3d353a; transition: background .15s, border-color .15s; }
.fighter:hover { background: #30272b; border-color: #77565b; }
.fighter[aria-pressed="true"] { border-color: #e67971; background: #382529; }
.fighter canvas { display: block; width: 100%; height: auto; aspect-ratio: 150 / 102; }
.fighter-marker { position: absolute; z-index: 1; top: 7px; right: 7px; font: 700 10px "Consolas", monospace; padding: 3px 5px; color: #ffe8d1; background: #3f2529; }
.fighter-name { padding: 6px 7px 9px; white-space: nowrap; overflow: hidden; font-size: clamp(10px, 1.1vw, 14px); text-overflow: ellipsis; font-weight: 800; border-top: 1px solid #ffffff11; }
.fighter-name small { display: block; color: #c8afaf; font-size: 10px; margin-top: 2px; font-weight: 400; }
.details { display: grid; grid-template-columns: 1fr 1fr; gap: 38px; margin-top: 30px; }
.details > div { border-top: 1px solid var(--line); padding-top: 19px; }
.details h2 { font-size: 21px; }
.bio, .controls p { font-size: 13px; color: var(--muted); margin: 8px 0 12px; line-height: 1.7; }
dl { margin: 0; }
dl > div { display: grid; grid-template-columns: 28px 1fr; align-items: start; gap: 9px; padding: 6px 0; border-bottom: 1px solid #2b282c; font-size: 13px; }
dt, dd { margin: 0; }
dd small { display: block; color: var(--muted); margin-top: 3px; }
kbd { display: inline-grid; place-items: center; min-width: 24px; min-height: 22px; background: #1e1b21; border: 1px solid #514348; color: #f2d9cf; padding: 2px 4px; font: 700 11px/1 "Consolas", monospace; }
.key-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 13px; margin-top: 14px; font-size: 12px; }
.key-list span { white-space: nowrap; }
.key-list b { color: var(--gold); font: 700 12px "Consolas", monospace; }
footer { display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: #a79899; padding: 15px 0; margin: 30px 0 10px; font-size: 11px; }
.hud { pointer-events: none; display: grid; grid-template-columns: 1fr clamp(56px, 10%, 112px) 1fr; align-items: start; padding: 3% 4%; background: linear-gradient(#08070b99, transparent 30%); }
.side-name { display: flex; gap: 7px; align-items: center; font-size: clamp(11px, 1.65vw, 22px); text-shadow: 0 2px 4px #000; }
.side-name > span { padding: 4px 6px; }
.side-right .side-name { flex-direction: row-reverse; }
.life { margin-top: 6px; height: clamp(9px, 1.65vw, 20px); display: flex; justify-content: end; border: 1px solid #7f625b; background: #311f25; padding: 2px; }
.life i { display: block; width: 100%; background: #e9b56e; transition: width 115ms linear; }
.life i.low { background: #ef6269; }
.side-right .life { justify-content: start; }
.wins { display: flex; gap: 5px; margin-top: 8px; }
.side-right .wins { justify-content: end; }
.wins i { width: 10px; height: 10px; border: 1px solid #d4a474; transform: rotate(45deg); background: #140e13; }
.wins i.on { background: #f5bf78; }
.timer { text-align: center; font: 900 clamp(24px, 4vw, 56px)/.95 "Consolas", monospace; color: #fff0db; text-shadow: 0 2px 8px #10090b; }
.timer span { display: block; font-size: clamp(8px, .9vw, 12px); line-height: 1.3; margin-top: 5px; color: #e5c1a5; white-space: nowrap; }
.meter { position: absolute; bottom: 4%; width: 27%; font-size: clamp(9px, 1vw, 12px); font-weight: 800; text-shadow: 0 2px 5px #000; }
.meter-left { left: 4%; }
.meter-right { right: 4%; text-align: right; }
.meter > div { height: clamp(6px, .9vw, 11px); border: 1px solid #a28470; padding: 1px; background: #221920; display: flex; margin-top: 4px; }
.meter-right > div { justify-content: end; }
.meter i { width: 0; display: block; background: #cd7778; transition: width 115ms linear; }
.meter i.full { background: #f8c871; }
.combat-message { position: absolute; left: 50%; top: 43%; transform: translate(-50%,-50%); min-width: max-content; color: #faddb4; text-align: center; font: italic 900 clamp(25px, 6vw, 82px)/1 "Consolas", "Malgun Gothic", monospace; text-shadow: 0 3px 0 #6c2728, 0 4px 18px #160b10; }
.overlay { display: grid; place-items: center; text-align: center; background: #0c090dcc; padding: 10px; }
.dialog { width: min(410px, 100%); background: #1a171c; border: 1px solid #685153; padding: 25px 20px; }
.dialog > span { font: 700 11px "Consolas", monospace; color: var(--gold); letter-spacing: .17em; }
.dialog h2 { margin-top: 10px; font-size: clamp(23px, 3vw, 40px); }
.dialog p { color: #d3c1bf; font-size: 14px; }
.dialog-actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.match-tools { display: flex; justify-content: end; align-items: center; gap: 7px; margin: 12px 0; }
.match-tools div { display: flex; align-items: baseline; gap: 11px; margin-right: auto; font-size: 14px; }
.match-tools div span { color: var(--muted); font-size: 12px; }
@media (max-width: 800px) {
  .header-wrap, .shell { width: calc(100% - 32px); }
  .roster { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fighter-name { font-size: 13px; }
  .header-wrap { height: 60px; }
  .modes button { padding: 0 11px; }
  .arena-caption { left: 13px; top: 13px; }
  .match-label { bottom: 12px; }
  .match-label.p1 { left: 13px; }
  .match-label.p2 { right: 13px; }
}
@media (max-width: 490px) {
  .shell { padding-top: 13px; }
  .header-wrap, .shell { width: calc(100% - 20px); }
  .header-wrap { grid-template-columns: 1fr auto auto; gap: 5px; }
  .brand { font-size: 13px; gap: 4px; }
  .brand small { display: none; }
  .seal { width: 23px; height: 25px; font-size: 16px; }
  .tools { gap: 3px; }
  .tools button { width: 27px; height: 30px; }
  .tools svg { width: 14px; }
  .modes { gap: 0; }
  .modes button { padding: 0 5px; font-size: 11px; }
  .eyebrow { font-size: 8px; gap: 6px; }
  .eyebrow span { width: 10px; }
  h1 { font-size: clamp(33px, 8vw, 48px); }
  .hero-copy { top: 48%; }
  .hero-copy p { margin-bottom: 9px; font-size: 9px; }
  .primary { min-height: 30px; padding: 0 10px; font-size: 11px; gap: 8px; }
  .arena-caption, .match-label small { display: none; }
  .match-label { gap: 4px; bottom: 5px; }
  .match-label > span { font-size: 8px; padding: 3px; }
  .match-label strong { font-size: 10px; }
  .wins i { width: 7px; height: 7px; }
  .details { grid-template-columns: 1fr; gap: 18px; }
  .dialog { padding: 8px; }
  .dialog h2 { margin-top: 2px; }
  .dialog p { font-size: 11px; margin: 5px 0; }
  .dialog .secondary, .match-tools .secondary { min-height: 30px; padding: 0 8px; font-size: 11px; }
}

.hud.survival { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16%; }
.hud.survival .side-right, .hud.survival .timer, .hud.survival .wins, .hud.survival .meter-right { display: none; }
.survival-status { text-align: right; text-shadow: 0 2px 5px #08060a; }
.survival-status > strong, .survival-status > span { display: block; }
.survival-status > strong { font-size: clamp(12px, 2vw, 25px); color: #f7e5ca; line-height: 1.12; }
.survival-status > span { font-size: clamp(8px, 1.15vw, 14px); margin-top: 4px; color: #e7c6a5; }
.xp, .boss-health { margin: 5px 0 0 auto; height: clamp(4px, .7vw, 8px); width: min(260px, 86%); display: flex; background: #201722; border: 1px solid #ab877c; }
.xp i, .boss-health i { width: 100%; background: #91c9e2; transition: width .13s linear; }
.boss-health i { background: #e56972; }
.xp i { width: 0; }
.dialog:has(.upgrades:not([hidden])) { width: min(630px, 100%); }
.upgrades { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.upgrades button { background: #282129; border: 1px solid #684b52; padding: 14px 7px; }
.upgrades button:hover, .upgrades button:focus-visible { background: #42252e; border-color: #d07173; }
.upgrades b, .upgrades small { display: block; }
.upgrades small { color: #d8c3c0; font-size: 11px; line-height: 1.5; margin-top: 6px; }
@media (max-width: 490px) {
  .modes button { padding: 0 4px; font-size: 10px; }
  .brand { font-size: 12px; }
  .upgrades { margin-top: 6px; }
  .upgrades button { padding: 5px 3px; }
  .upgrades b { font-size: 10px; }
  .upgrades small { font-size: 8px; margin-top: 3px; }
}


@media (max-width: 340px) {
  .header-wrap { gap: 3px; }
  .header-wrap, .shell { width: calc(100% - 14px); }
  .brand { font-size: 11px; }
  .seal { width: 19px; }
  .modes button { padding-inline: 3px; font-size: 9px; }
  .tools button { width: 23px; }
  .match-tools div { align-items: start; gap: 4px; }
  .match-tools div strong { white-space: nowrap; }
}

.arena-surface { position: relative; width: 100%; height: 100%; }
.touch, .touch-tools, .rotate-screen, .touch-guide { display: none; }
.touch-device .touch-guide { display: block; }
.touch-device .key-list { display: none; }

@media (orientation: landscape) {
  .touch-device:not(.in-match) .header-wrap {
    height: 48px;
    width: auto;
    margin-left: max(12px, env(safe-area-inset-left, 0px));
    margin-right: max(12px, env(safe-area-inset-right, 0px));
  }
  .touch-device:not(.in-match) .modes button { padding-inline: clamp(7px, 2vw, 18px); }
  .touch-device:not(.in-match) .shell {
    width: auto;
    padding-top: 9px;
    margin-left: max(12px, env(safe-area-inset-left, 0px));
    margin-right: max(12px, env(safe-area-inset-right, 0px));
  }
  .touch-device:not(.in-match) .arena { aspect-ratio: auto; height: min(54dvh, 380px); }
  .touch-device:not(.in-match) #stage { object-fit: cover; object-position: center 65%; }
  .touch-device:not(.in-match) h1 { font-size: clamp(36px, 12dvh, 83px); }
  .touch-device:not(.in-match) .hero-copy p { margin-bottom: 10px; font-size: 12px; }
  .touch-device:not(.in-match) .hero-copy .primary { min-height: 42px; font-size: 13px; }
  .touch-device:not(.in-match) .arena-caption { top: 10px; left: 12px; }
  .touch-device:not(.in-match) .match-label { bottom: 8px; }
  .touch-device:not(.in-match) .selection { margin-top: 11px; }
  .touch-device:not(.in-match) .section-header { margin-bottom: 8px; }
  .touch-device:not(.in-match) .section-header h2 { font-size: 20px; }
  .touch-device:not(.in-match) .roster { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
  .touch-device:not(.in-match) .fighter-name { font-size: clamp(9px, 1.45vw, 13px); padding: 4px 4px 6px; }
}

.touch-device.in-match { height: 100%; overflow: hidden; overscroll-behavior: none; }
.touch-device.in-match .header,
.touch-device.in-match .match-tools,
.touch-device.in-match .details,
.touch-device.in-match footer { display: none; }
.touch-device.in-match .shell { width: 100%; padding-top: 0; }

.touch-device.in-match .arena {
  --safe-left: max(10px, env(safe-area-inset-left, 0px));
  --safe-right: max(10px, env(safe-area-inset-right, 0px));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  border: 0;
  aspect-ratio: auto;
  background: #0a090c;
  display: grid;
  place-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
.touch-device.in-match .arena-surface {
  width: min(calc(100vw - var(--safe-left) - var(--safe-right)), 206vh);
  width: min(calc(100vw - var(--safe-left) - var(--safe-right)), calc((100dvh - var(--safe-top)) * 2.0645));
  height: auto;
  aspect-ratio: 1280 / 620;
  overflow: hidden;
}
.touch-device.in-match .hud { padding-top: max(30px, 4%); }
.touch-device.in-match .hud .meter { bottom: max(6px, var(--safe-bottom)); width: 19%; }
.touch-device.in-match .meter-left { left: 29%; }
.touch-device.in-match .meter-right { right: 29%; }
.touch-device.in-match .hud.survival .meter-left { left: 40.5%; }
.touch-device.in-match .side-name { font-size: clamp(12px, 2vw, 19px); }
.touch-device.in-match .survival-status > span { font-size: clamp(10px, 1.4vw, 15px); }
.touch-device.in-match .dialog { padding: clamp(12px, 4dvh, 26px) 16px; }
.touch-device.in-match .dialog button { min-height: 42px; }
.touch-device.in-match .overlay { touch-action: manipulation; }

.touch-device .touch:not([hidden]) {
  --pad-size: clamp(106px, 36dvh, 158px);
  --key-size: clamp(44px, 14dvh, 57px);
  --key-gap: clamp(4px, 1.8dvh, 8px);
  display: block;
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
}
.touch-player { display: contents; }
.touch-pad, .touch-actions { position: absolute; bottom: var(--safe-bottom); }
.touch-pad {
  box-sizing: border-box;
  left: var(--safe-left);
  width: var(--pad-size);
  height: var(--pad-size);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #bd9f91a8;
  background: #141218b0;
  color: #fbecd8;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-pad.is-held { background: #271c23da; }
.touch-knob {
  display: block;
  width: 39%;
  height: 39%;
  border-radius: 50%;
  border: 1px solid #e4b7a3;
  background: #a15355;
  pointer-events: none;
}
.touch-arrow { position: absolute; font: 700 16px/1 "Consolas", monospace; opacity: .76; pointer-events: none; }
.touch-arrow:nth-child(1) { top: 8%; }
.touch-arrow:nth-child(2) { right: 8%; }
.touch-arrow:nth-child(3) { bottom: 8%; }
.touch-arrow:nth-child(4) { left: 8%; }
.touch-actions {
  right: var(--safe-right);
  display: grid;
  grid-template-columns: repeat(3, var(--key-size));
  gap: var(--key-gap);
}
.touch-actions button, .touch-tools button {
  display: grid;
  place-items: center;
  background: #20191ede;
  border: 1px solid #c6a093a2;
  color: #fff1dd;
  font-weight: 800;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch-actions button {
  width: var(--key-size);
  height: var(--key-size);
  padding: 0;
  border-radius: 50%;
  font-size: clamp(11px, 3.35dvh, 14px);
}
.touch-actions [data-command="light"], .touch-actions [data-command="heavy"] { background: #5d292edc; }
.touch-actions [data-command="super"] { grid-row: 1; grid-column: 3; }
.touch-actions [data-command="guard"] { grid-row: 2; grid-column: 1; }
.touch-actions [data-command="jump"] { grid-row: 2; grid-column: 2; }
.touch-actions [data-command="dash"] { grid-row: 2; grid-column: 3; }
.touch-actions [data-command="light"] { grid-row: 3; grid-column: 1; }
.touch-actions [data-command="heavy"] { grid-row: 3; grid-column: 2; }
.touch-actions [data-command="special"] { grid-row: 3; grid-column: 3; }
.touch-actions [data-command="super"].is-ready { background: #8b5b2c; border-color: #ffe09b; }
.touch-actions button.is-held { background: #a13f49; border-color: #ffe5c7; }

.touch.is-versus { --pad-size: clamp(93px, 33dvh, 142px); --key-size: clamp(40px, 12.5dvh, 52px); }
.touch.is-versus .touch-player {
  position: absolute;
  bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--key-gap);
}
.touch.is-versus .touch-player:first-child { left: var(--safe-left); }
.touch.is-versus .touch-player:last-child { right: var(--safe-right); }
.touch.is-versus .touch-pad, .touch.is-versus .touch-actions { position: static; }
.touch.is-versus .touch-actions { grid-template-columns: repeat(4, var(--key-size)); }
.touch.is-versus .touch-actions button { grid-column: auto; grid-row: auto; }

.touch-device .touch-tools:not([hidden]) {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-top) + 3px);
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}
.touch-tools button {
  min-width: 42px;
  height: 34px;
  border-radius: 5px;
  touch-action: manipulation;
  font-size: 14px;
}
.touch-tools button[aria-pressed="true"] { background: #77404b; }
.touch-tools svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.touch-tools span { font-size: 18px; }

.touch-device .rotate-screen:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #101012;
  text-align: center;
}
.rotate-screen svg { width: 54px; height: 54px; fill: none; stroke: var(--gold); stroke-width: 2; }
.rotate-screen strong { display: block; margin-top: 14px; font-size: 20px; }
.rotate-screen p { color: var(--muted); margin: 9px 0 21px; font-size: 14px; }
.rotate-screen button { min-height: 44px; }

