:root {
  color-scheme: dark;
  --ink: #e9edf7;
  --muted: #a4adc0;
  --paper: #070913;
  --panel: #111522;
  --line: rgba(255,255,255,.14);
  --pink: #ff4053;
  --amber: #ffc16d;
  --cyan: #6af1e9;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { position: fixed; width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--paper); color: var(--ink); overscroll-behavior: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { min-width: 280px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; -webkit-touch-callout: none; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }
button:disabled { opacity: .42; cursor: default; }
[hidden] { display: none !important; }
#app { position: relative; width: 100%; height: 100%; height: 100dvh; overflow: hidden; isolation: isolate; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }
.eyebrow { margin: 0; color: var(--cyan); font-size: clamp(9px, 1.3vw, 12px); font-weight: 800; letter-spacing: .23em; }

/* TITLE */
.title-screen { overflow: hidden; background: #07070d; }
.title-art { position: absolute; inset: 0; background: url("assets/last-round-title.webp") 62% 43% / cover no-repeat, radial-gradient(ellipse at 71% 40%, #51202a 0, #15101a 45%, #07070d 100%); transform: scale(1.035); animation: breathe 20s ease-in-out infinite alternate; }
.title-vignette { position: absolute; inset: 0; background: linear-gradient(90deg,rgba(5,6,12,.96) 0%,rgba(5,6,12,.85) 32%,rgba(5,6,12,.47) 53%,rgba(5,6,12,.09) 76%),linear-gradient(0deg,#08070e 0,transparent 24%,transparent 77%,rgba(6,6,13,.32)); }
.title-orbit { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 69% 45%,rgba(255,43,66,.13),transparent 34%),radial-gradient(ellipse at 83% 81%,rgba(80,129,230,.11),transparent 27%); mix-blend-mode: screen; }
.title-grid { position: absolute; inset: 0; pointer-events: none; opacity: .1; background-image: linear-gradient(rgba(255,255,255,.16) 1px,transparent 1px); background-size: 100% 4px; mask-image: linear-gradient(90deg,#000,transparent 54%); -webkit-mask-image: linear-gradient(90deg,#000,transparent 54%); }
.rain-overlay { position: absolute; inset: -35%; pointer-events: none; opacity: .21; background-image: repeating-linear-gradient(105deg, transparent 0 38px, rgba(196,212,241,.15) 39px, transparent 41px 87px); animation: rain 1.8s linear infinite; }
.title-wrap { position: absolute; left: max(7vw, calc(var(--safe-left) + 24px)); top: 50%; width: min(525px, 77vw); transform: translateY(-50%); }
.title-overline { display: flex; align-items: center; gap: 9px; }
.title-live-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--pink); box-shadow: 0 0 15px rgba(255,64,83,.84); }
.title-overline .eyebrow { color: #fff0e5; font-size: clamp(8px,1.2vw,10px); letter-spacing: .17em; }
.title-round-tag { padding: 4px 6px; border: 1px solid rgba(255,92,100,.4); border-radius: 4px; color: #ff9a98; font-size: 8px; font-weight: 850; letter-spacing: .07em; }
.game-logo { position: relative; margin: 20px 0 0; font-size: clamp(65px,12.1vw,121px); font-style: italic; font-weight: 950; line-height: .78; letter-spacing: -.105em; transform: skew(-4deg); }
.game-logo span { display: block; width: fit-content; color: #fff6eb; text-shadow: 0 2px 0 rgba(255,255,255,.27),0 9px 36px rgba(255,255,255,.13); }
.game-logo strong { display: block; margin-top: 8px; width: fit-content; background: linear-gradient(118deg,#ff2e47 7%,#ff4254 45%,#ffac71 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; font-size: .93em; filter: drop-shadow(0 9px 19px rgba(245,40,62,.2)); }
.title-subline { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.title-divider { width: 30px; height: 1px; background: linear-gradient(90deg,#ff4656,#ffc283); }
.title-divider-end { width: 62px; opacity: .52; }
.title-kana { margin: 0; color: #ffd3bd; font-size: 11px; font-weight: 800; letter-spacing: .3em; }
.title-copy { margin: 16px 0 25px; color: #edf0f8; font-size: clamp(12px,1.55vw,16px); letter-spacing: .1em; }
.title-actions { display: grid; gap: 9px; width: min(300px, 100%); }
.button { width: 100%; min-height: 49px; padding: 0 17px; border: 1px solid transparent; border-radius: 11px; font-size: 12px; font-weight: 850; letter-spacing: .09em; transition: transform .14s, filter .14s, background-color .14s; }
.button:active { transform: scale(.975); }
.button-primary { display: flex; align-items: center; justify-content: space-between; background: linear-gradient(110deg,#ff384e,#ff785f); color: #fff8f1; box-shadow: 0 10px 38px rgba(255,51,73,.29); }
.button-primary span { font-size: 22px; }
.button-glass { border-color: rgba(255,255,255,.17); background: rgba(15,19,31,.62); text-align: left; backdrop-filter: blur(10px); }
.button-glass span { float: right; font-size: 20px; }
.button-quiet { min-height: 37px; padding-left: 2px; background: none; text-align: left; color: var(--muted); font-size: 10px; letter-spacing: .14em; }
.title-stats { display: flex; gap: 17px; margin-top: 15px; color: #aab3c4; font-size: 10px; font-weight: 700; letter-spacing: .07em; }
.title-stats b { color: #fff; }
.icon-button { display: grid; width: 39px; height: 39px; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; background: rgba(11,14,22,.66); backdrop-filter: blur(12px); font-size: 18px; }
.title-settings { position: absolute; right: max(22px,var(--safe-right)); top: max(20px,var(--safe-top)); }
.title-credit { position: absolute; right: max(26px,var(--safe-right)); bottom: max(15px,var(--safe-bottom)); color: rgba(255,255,255,.57); font-size: 8px; letter-spacing: .13em; }

/* SELECT */
.select-screen { overflow-y: auto; background: radial-gradient(ellipse at 50% -10%,rgba(66,57,114,.45),transparent 55%),linear-gradient(180deg,#111323,#070913); padding: max(28px,var(--safe-top)) max(26px,var(--safe-right)) max(20px,var(--safe-bottom)) max(26px,var(--safe-left)); }
.back-button { position: absolute; top: max(20px,var(--safe-top)); left: max(21px,var(--safe-left)); width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 11px; background: rgba(15,19,31,.8); font-size: 27px; line-height: 1; }
.select-head { text-align: center; }
.select-head h2, .overlay-card h2, .modal h2 { margin: 9px 0 5px; font-size: clamp(29px,6vw,48px); font-style: italic; font-weight: 930; letter-spacing: -.045em; }
.select-head > p:last-child { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.fighter-cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; max-width: 760px; margin: 23px auto 16px; }
.fighter-card { position: relative; overflow: hidden; min-height: clamp(177px,36vh,253px); padding: 0; border: 1px solid rgba(255,255,255,.13); border-radius: 14px; background: linear-gradient(165deg,#20253b,#111423 73%); text-align: left; transition: transform .18s,border-color .18s,box-shadow .18s; }
.fighter-card.selected { transform: translateY(-3px); border-color: var(--fighter-color,var(--cyan)); box-shadow: 0 0 31px color-mix(in srgb,var(--fighter-color,var(--cyan)) 30%,transparent); }
.fighter-preview { display: block; width: 100%; height: clamp(110px,24vh,170px); image-rendering: pixelated; }
.fighter-meta { position: absolute; right: 10px; bottom: 12px; left: 10px; }
.fighter-meta b { display: block; font-size: clamp(13px,2vw,19px); font-style: italic; letter-spacing: .05em; }
.fighter-meta small { display: block; margin: 2px 0 5px; color: #afbacd; font-size: 8px; }
.stat-bars { display: flex; gap: 4px; }
.stat-bars i { width: 13px; height: 3px; border-radius: 5px; background: #30384b; }
.stat-bars i.on { background: var(--fighter-color,var(--cyan)); }
.difficulty-picker { display: flex; gap: 6px; justify-content: center; }
.difficulty-picker button { min-width: 83px; height: 32px; border: 1px solid rgba(255,255,255,.11); border-radius: 8px; background: rgba(255,255,255,.035); color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.difficulty-picker button.selected { border-color: rgba(106,241,233,.55); background: rgba(106,241,233,.11); color: var(--cyan); }
.select-fight { max-width: 360px; margin: 16px auto 0; }

/* GAME */
.game-screen { overflow: hidden; background: radial-gradient(ellipse at 52% 33%,rgba(33,40,67,.23),transparent 49%),#070913; touch-action: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.game-ambient { position: absolute; inset: -20px; opacity: .2; background: url("assets/street-art.webp") center/cover no-repeat; filter: blur(28px) saturate(1.15); transform: scale(1.14); transition: background-image .3s ease; }
.game-frame { position: absolute; inset: 0; display: grid; place-items: center; touch-action: none; }
#game-canvas { display: block; width: min(100vw, calc(100dvh * 16 / 9)); height: auto; max-height: 100dvh; aspect-ratio: 16 / 9; background: #0b0d16; box-shadow: 0 18px 62px rgba(0,0,0,.34),0 0 0 1px rgba(191,205,223,.08); image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; -webkit-touch-callout: none; }
.pause-button { position: absolute; top: max(9px,var(--safe-top)); right: max(11px,var(--safe-right)); z-index: 4; width: 37px; height: 37px; border-color: rgba(189,208,223,.22); background: rgba(10,14,24,.72); box-shadow: inset 0 1px 0 rgba(255,255,255,.08),0 8px 22px rgba(0,0,0,.19); font-size: 15px; backdrop-filter: blur(14px); }
.controls { position: absolute; z-index: 3; right: 0; bottom: 0; left: 0; display: flex; height: min(39vh,175px); align-items: center; justify-content: space-between; padding-right: max(23px,var(--safe-right)); padding-bottom: max(8px,var(--safe-bottom)); padding-left: max(24px,var(--safe-left)); pointer-events: none; touch-action: none; }
.controls > * { pointer-events: auto; }
.dpad { position: relative; width: 121px; height: 121px; border-radius: 50%; touch-action: none; }
.dpad::after { position: absolute; right: 0; bottom: -7px; left: 0; color: rgba(186,207,226,.6); font-size: 6px; font-weight: 780; letter-spacing: .19em; text-align: center; content: "MOVE · 360°"; }
.dpad-ring { position: absolute; inset: 7px; border: 1px solid rgba(194,215,233,.35); border-radius: 50%; background: radial-gradient(circle at 42% 32%,rgba(85,109,140,.15),rgba(11,15,26,.6) 73%); box-shadow: 0 12px 30px rgba(0,0,0,.27),inset 0 1px 0 rgba(255,255,255,.11),inset 0 0 22px rgba(125,155,199,.06); backdrop-filter: blur(11px); }
.dpad-knob { position: absolute; z-index: 1; top: 43px; left: 43px; width: 35px; height: 35px; border: 1px solid rgba(204,221,239,.56); border-radius: 50%; background: radial-gradient(circle at 36% 30%,rgba(230,237,248,.38),rgba(124,143,171,.22) 67%); box-shadow: 0 4px 15px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.32); transition: transform 45ms linear; }
.dpad > span { position: absolute; color: rgba(219,234,247,.78); font-size: 10px; text-shadow: 0 1px 7px rgba(148,177,206,.31); }
.dpad-up { top: 14px; left: 56px; }.dpad-down { bottom: 13px; left: 56px; }.dpad-left { top: 54px; left: 14px; }.dpad-right { top: 54px; right: 14px; }
.action-pad { position: relative; width: 161px; height: 124px; }
.touch-button { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; font-weight: 850; touch-action: none; backdrop-filter: blur(11px); transition: transform .08s,filter .08s,box-shadow .08s; }
.touch-button > span { line-height: 1; text-shadow: 0 1px 8px rgba(255,255,255,.18); }
.touch-button > small { color: rgba(245,246,253,.78); font-size: 5px; font-weight: 760; letter-spacing: .08em; line-height: 1; }
.touch-button.pressed { transform: scale(.89); filter: brightness(1.44); }
.touch-attack { right: 2px; bottom: 20px; width: 65px; height: 65px; border-color: rgba(255,136,154,.83); background: radial-gradient(circle at 34% 25%,rgba(255,154,162,.65),rgba(206,39,70,.61) 46%,rgba(106,24,52,.83) 100%); box-shadow: 0 9px 27px rgba(222,52,80,.23),inset 0 1px 0 rgba(255,255,255,.36); font-size: 23px; }
.touch-jump { right: 71px; bottom: 6px; width: 52px; height: 52px; border-color: rgba(128,224,250,.8); background: radial-gradient(circle at 35% 25%,rgba(145,225,246,.49),rgba(39,111,157,.65) 63%,rgba(20,52,87,.82)); box-shadow: 0 8px 20px rgba(65,155,208,.16),inset 0 1px 0 rgba(255,255,255,.27); font-size: 18px; }
.touch-special { top: 4px; right: 67px; width: 45px; height: 45px; border-color: rgba(255,200,117,.77); background: radial-gradient(circle at 35% 25%,rgba(255,206,135,.52),rgba(175,97,35,.64) 67%,rgba(85,42,28,.83)); box-shadow: 0 7px 19px rgba(220,134,51,.16),inset 0 1px 0 rgba(255,255,255,.26); font-size: 15px; }
.touch-dash { top: 13px; left: 0; width: 41px; height: 41px; border-color: rgba(191,160,251,.78); background: radial-gradient(circle at 35% 25%,rgba(201,181,251,.47),rgba(101,72,153,.66) 67%,rgba(46,35,80,.82)); box-shadow: 0 7px 18px rgba(133,93,199,.15),inset 0 1px 0 rgba(255,255,255,.25); font-size: 13px; }
.touch-special > small,.touch-dash > small { font-size: 4px; }
.portrait-hint { display: none; }
body.hide-touch .controls { display: none; }

/* OVERLAYS / DIALOGS */
.overlay-screen.active { z-index: 5; display: grid; place-items: center; background: rgba(4,6,12,.82); backdrop-filter: blur(12px); }
.overlay-card { width: min(360px,calc(100% - 38px)); padding: 30px 26px; border: 1px solid rgba(255,255,255,.14); border-radius: 19px; background: linear-gradient(155deg,rgba(29,34,53,.94),rgba(12,15,24,.98)); box-shadow: 0 32px 90px rgba(0,0,0,.48); }
.overlay-card h2 { margin-bottom: 24px; }
.overlay-card .button + .button { margin-top: 9px; }
.result-message { margin: -12px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 17px; }
.result-stat { padding: 9px 10px; border-radius: 8px; background: rgba(255,255,255,.055); }
.result-stat small { display: block; color: var(--muted); font-size: 8px; letter-spacing: .09em; }
.result-stat b { display: block; margin-top: 4px; color: var(--cyan); font-size: 16px; }
.modal { width: min(470px,calc(100% - 34px)); max-height: min(85dvh,670px); overflow-y: auto; padding: 0; border: 1px solid rgba(255,255,255,.17); border-radius: 18px; background: linear-gradient(145deg,#1d2235,#111522); color: var(--ink); }
.modal::backdrop { background: rgba(4,6,12,.8); backdrop-filter: blur(8px); }
.modal-body { position: relative; padding: 27px 26px 24px; }
.modal h2 { margin-bottom: 16px; font-size: 34px; }
.modal-close { position: absolute; top: 17px; right: 17px; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-size: 19px; }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 10px; }
.guide-grid b { display: block; color: var(--cyan); font-size: 10px; letter-spacing: .08em; }
.guide-grid span { display: block; margin-top: 4px; color: #c5cddd; font-size: 10px; line-height: 1.55; }
.guide-tip { margin: 19px 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.settings-list { display: grid; gap: 4px; margin-bottom: 19px; }
.settings-list label { display: flex; min-height: 53px; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.settings-list small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 400; }
.settings-list input { width: 39px; height: 22px; accent-color: var(--pink); }

@keyframes breathe { from { transform: scale(1.035); } to { transform: scale(1.095); } }
@keyframes rain { from { transform: translate3d(-2%, -8%,0); } to { transform: translate3d(2%, 8%,0); } }

@media (max-width: 600px) and (orientation: portrait) {
  .title-art { background-position: 67% 35%; }
  .title-vignette { background: linear-gradient(0deg,#08070d 0,rgba(8,7,13,.96) 38%,rgba(8,7,13,.59) 57%,rgba(7,9,19,.1) 100%),linear-gradient(90deg,rgba(7,9,19,.31),transparent); }
  .title-wrap { top: auto; bottom: max(67px,calc(var(--safe-bottom) + 50px)); left: 25px; width: calc(100% - 49px); transform: none; }
  .title-round-tag { font-size: 7px; }
  .game-logo { font-size: clamp(68px,20vw,96px); }
  .title-subline { margin-top: 15px; }
  .title-copy { margin: 14px 0 20px; }
  .title-actions { width: min(310px,100%); }
  .title-credit { right: 17px; bottom: max(11px,var(--safe-bottom)); }
  .select-screen { padding: max(74px,var(--safe-top)) 13px max(20px,var(--safe-bottom)); }
  .select-head h2 { font-size: 34px; }
  .fighter-cards { gap: 7px; margin-top: 21px; }
  .fighter-card { min-height: 218px; }
  .fighter-preview { height: 150px; }
  .fighter-meta { right: 7px; left: 7px; }
  .fighter-meta b { font-size: 12px; }
  .fighter-meta small { font-size: 7px; }
  .game-frame { bottom: min(35dvh,248px); }
  #game-canvas { box-shadow: 0 23px 76px rgba(0,0,0,.48),0 0 0 1px rgba(210,222,236,.13); }
  .controls { height: min(36dvh,252px); padding-right: 19px; padding-bottom: max(22px,var(--safe-bottom)); padding-left: 15px; }
  .controls::before { position: absolute; top: 7px; right: 23px; left: 23px; height: 1px; background: linear-gradient(90deg,transparent,rgba(145,179,213,.26) 21%,rgba(211,150,160,.19) 77%,transparent); content: ""; }
  .portrait-hint { position: absolute; right: 0; bottom: max(8px,var(--safe-bottom)); left: 0; display: block; margin: 0; color: rgba(205,221,238,.61); font-size: 9px; letter-spacing: .035em; text-align: center; }
}

@media (max-height: 470px) and (orientation: landscape) {
  .title-wrap { left: max(6vw,calc(var(--safe-left) + 12px)); }
  .title-wrap .eyebrow { font-size: 7px; }
  .title-round-tag { padding: 3px 5px; font-size: 7px; }
  .game-logo { margin-top: 9px; font-size: clamp(53px,16vh,88px); }
  .title-subline { gap: 7px; margin-top: 10px; }
  .title-kana { font-size: 8px; }
  .title-copy { margin: 9px 0 12px; font-size: 12px; }
  .title-actions { gap: 5px; width: 240px; }
  .button { min-height: 38px; }
  .button-quiet { min-height: 27px; }
  .title-stats { margin-top: 8px; font-size: 8px; }
  .title-credit { font-size: 7px; }
  .select-screen { padding-top: max(11px,var(--safe-top)); }
  .select-head h2 { margin: 4px 0 2px; font-size: 30px; }
  .fighter-cards { max-width: 640px; margin: 11px auto 8px; }
  .fighter-card { min-height: clamp(143px,43vh,179px); }
  .fighter-preview { height: clamp(103px,32vh,135px); }
  .fighter-meta { bottom: 7px; }
  .difficulty-picker button { height: 26px; }
  .select-fight { max-width: 310px; margin-top: 8px; }
  .controls { height: 142px; }
  .dpad { transform: scale(.85); transform-origin: left bottom; }
  .action-pad { transform: scale(.85); transform-origin: right bottom; }
  .overlay-card { padding-top: 19px; padding-bottom: 18px; }
  .overlay-card h2 { margin-bottom: 12px; font-size: 33px; }
  .modal-body { padding-top: 18px; padding-bottom: 16px; }
}

@media (hover: hover) and (pointer: fine) {
  .controls { opacity: .28; transition: opacity .2s; }
  .controls:hover { opacity: .82; }
  .fighter-card:hover { transform: translateY(-4px); }
  .button:hover { filter: brightness(1.12); }
}

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