:root {
  --ink: #150c1f;
  --bg0: #14062b;
  --bg1: #2a0f55;
  --pink: #ff4fa3;
  --cyan: #35e0ff;
  --yellow: #ffe94a;
  --panel: rgba(22, 8, 48, 0.86);
  --font: "Bangers", "Impact", "Arial Black", sans-serif;
  --jp: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg0); color: #fff; font-family: "Noto Sans JP", system-ui, sans-serif; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(120% 90% at 50% 20%, var(--bg1), var(--bg0) 70%); }
#bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hidden { display: none !important; }
.center { text-align: center; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; padding: 18px 20px; overflow: auto; }
.screen.active { display: flex; }
#screen-game { padding: 0; overflow: hidden; background: #000; align-items: center; justify-content: center; }
#stagebox { position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; background: #000; }
#stagebox canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#game3d { background: #000; }

h1, h2, h3 { font-family: var(--font); letter-spacing: 2px; font-weight: 400; margin: 0; }
h2 { font-size: clamp(30px, 4.6vw, 52px); text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink); transform: skewX(-6deg); }
h3 { font-size: 22px; color: var(--cyan); margin: 8px 0; }

/* title */
#screen-title { justify-content: center; gap: 26px; }
.logo { text-align: center; position: relative; transform: rotate(-3deg); }
.logo-jp { font-family: var(--jp); font-weight: 900; font-size: clamp(16px, 2.6vw, 26px); letter-spacing: .6em; color: var(--yellow); text-shadow: 2px 2px 0 var(--ink); }
.logo h1 { display: flex; gap: .25em; justify-content: center; font-size: clamp(64px, 14vw, 170px); line-height: .9; transform: skewX(-8deg); }
.logo h1 span { background: linear-gradient(180deg, #fff 10%, var(--yellow) 45%, #ff7a2a 100%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; filter: drop-shadow(5px 6px 0 var(--ink)) drop-shadow(0 0 22px rgba(255, 90, 160, .65)); }
.logo h1 span:last-child { background: linear-gradient(180deg, #fff 10%, var(--cyan) 50%, #3a7bff 100%); -webkit-background-clip: text; background-clip: text; }
.logo-sub { font-family: var(--font); letter-spacing: .5em; color: #fff; font-size: clamp(14px, 2vw, 22px); text-shadow: 2px 2px 0 var(--ink); margin-top: 6px; }
.menu { display: flex; flex-direction: column; gap: 12px; width: min(420px, 90vw); }
.title-foot { font-family: var(--font); letter-spacing: 2px; opacity: .8; font-size: 16px; text-shadow: 2px 2px 0 var(--ink); text-align: center; }

/* buttons */
.btn { font-family: var(--font); letter-spacing: 2px; font-size: 20px; color: #fff; background: linear-gradient(180deg, #5b2cc9, #3a1a8a); border: 3px solid var(--ink); box-shadow: 0 0 0 2px #fff inset, 4px 5px 0 var(--ink); padding: 10px 22px; cursor: pointer; transform: skewX(-8deg); transition: transform .08s, filter .15s; text-shadow: 2px 2px 0 var(--ink); -webkit-appearance: none; appearance: none; }
.btn:hover:not(:disabled), .btn:focus-visible { filter: brightness(1.25) saturate(1.2); transform: skewX(-8deg) translate(-2px, -2px) scale(1.03); outline: none; }
.btn:active:not(:disabled) { transform: skewX(-8deg) translate(2px, 3px); box-shadow: 0 0 0 2px #fff inset, 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.7); }
.btn.big { font-size: 28px; padding: 14px 26px; background: linear-gradient(180deg, #ff4fa3, #b61e6e); }
.btn.go { background: linear-gradient(180deg, #ffd23a, #ff7a1a); color: #2a0f00; text-shadow: 1px 1px 0 rgba(255,255,255,.4); }
.btn.small { font-size: 15px; padding: 6px 14px; }
.btn.back { position: absolute; top: 14px; left: 16px; z-index: 5; font-size: 16px; padding: 6px 14px; }
.mute { position: fixed; top: 10px; right: 12px; z-index: 40; }
.pause { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); z-index: 6; opacity: .65; }
body.ingame #btn-mute { display: none; }

/* panels */
.panel { background: var(--panel); border: 3px solid var(--ink); box-shadow: 0 0 0 2px #fff inset, 6px 8px 0 rgba(0,0,0,.45); padding: 22px 26px; margin: auto; transform: skewX(-1.5deg); backdrop-filter: blur(6px); }
.panel.narrow { width: min(520px, 94vw); display: flex; flex-direction: column; gap: 14px; }
.panel.wide { width: min(980px, 96vw); margin-top: 40px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-family: var(--font); letter-spacing: 2px; font-size: 18px; }
input, select { font-family: var(--font); letter-spacing: 2px; font-size: 22px; padding: 8px 12px; background: #fff; color: var(--ink); border: 3px solid var(--ink); outline: none; width: 100%; text-transform: none; }
#in-code { text-transform: uppercase; text-align: center; letter-spacing: 6px; }
.join-row { display: flex; gap: 10px; }
.join-row .btn { flex: 0 0 auto; }
.status { min-height: 1.4em; font-family: var(--font); letter-spacing: 1px; color: var(--yellow); margin: 0; text-align: center; }
.keys { width: 100%; border-collapse: collapse; font-size: 15px; }
.keys td { padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,.12); }
.keys td:first-child { color: #cfc6ff; }
kbd { display: inline-block; min-width: 24px; padding: 1px 7px; margin: 0 2px; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 5px; font-family: var(--font); font-size: 14px; text-align: center; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.tips { margin: 14px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.6; color: #e8e2ff; }
@media (max-width: 760px) { .help-grid { grid-template-columns: 1fr; } }

/* select */
#screen-select { padding-top: 10px; overflow: hidden; }
#screen-stage { padding-top: 12px; }
.sel-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 6px; }
.room-bar { font-family: var(--font); letter-spacing: 2px; background: var(--panel); border: 3px solid var(--ink); padding: 4px 14px; font-size: 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.room-bar b { color: var(--yellow); font-size: 26px; letter-spacing: 6px; }
.sel-layout { display: grid; grid-template-columns: 210px minmax(260px, 1fr) minmax(300px, 390px); gap: 16px; width: min(1280px, 100%); margin-top: 6px; flex: 1 1 0; min-height: 0; }
.roster, .info-col { overflow-y: auto; min-height: 0; padding-right: 4px; scrollbar-width: thin; }
.roster { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; align-content: start; }
.rcard { position: relative; border: 3px solid var(--ink); background: linear-gradient(160deg, #3a1a7a, #1b0a3c); box-shadow: 0 0 0 2px rgba(255,255,255,.25) inset, 3px 4px 0 rgba(0,0,0,.5); cursor: pointer; overflow: hidden; aspect-ratio: 1; transform: skewX(-4deg); transition: transform .1s, filter .15s; }
.rcard canvas { width: 100%; height: 100%; display: block; transform: skewX(4deg) scale(1.1); }
.rcard span { position: absolute; left: 0; right: 0; bottom: 0; font-family: var(--font); letter-spacing: 2px; font-size: 16px; text-align: center; padding: 2px 0; background: rgba(15,5,30,.8); }
.rcard:hover { filter: brightness(1.2); transform: skewX(-4deg) translateY(-3px); }
.rcard.sel { box-shadow: 0 0 0 4px var(--yellow), 0 0 22px var(--yellow); }
.rcard.p2 { box-shadow: 0 0 0 4px var(--cyan), 0 0 22px var(--cyan); }
.preview-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.preview-wrap { position: relative; background: radial-gradient(circle at 50% 70%, rgba(255,255,255,.18), rgba(255,255,255,0) 60%), linear-gradient(160deg, #4b1f9e, #1b0a3c); border: 3px solid var(--ink); box-shadow: 0 0 0 2px #fff inset, 5px 6px 0 rgba(0,0,0,.45); overflow: hidden; min-height: 0; flex: 1; display: flex; }
.preview-wrap::before { content: ""; position: absolute; inset: 0; background: repeating-conic-gradient(from 0deg at 50% 78%, rgba(255,255,255,.07) 0 4deg, transparent 4deg 12deg); pointer-events: none; }
#preview { width: 100%; height: 100%; min-height: 0; object-fit: contain; position: relative; }
.preview-name { position: absolute; left: 12px; top: 8px; display: flex; flex-direction: column; text-shadow: 2px 2px 0 var(--ink); pointer-events: none; }
.preview-name span { font-family: var(--jp); font-weight: 900; font-size: 44px; color: rgba(255,255,255,.35); line-height: 1; }
.preview-name b { font-family: var(--font); font-size: 44px; font-weight: 400; letter-spacing: 3px; line-height: 1; }
.preview-name i { font-family: var(--font); font-style: normal; font-size: 18px; letter-spacing: 2px; color: var(--yellow); }
.demo { position: absolute; right: 10px; bottom: 10px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; background: var(--panel); border: 3px solid var(--ink); padding: 10px 14px; font-family: var(--font); letter-spacing: 2px; font-size: 15px; align-items: center; }
.bar { height: 12px; background: rgba(255,255,255,.12); border: 2px solid var(--ink); position: relative; transform: skewX(-20deg); }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
.info-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 3px solid var(--ink); box-shadow: 0 0 0 2px rgba(255,255,255,.2) inset; padding: 10px 14px; font-size: 13px; }
.card h3 { margin-top: 0; }
.mv .k .ar { font-family: sans-serif; font-weight: 900; }
.mv { display: grid; grid-template-columns: 62px 1fr; gap: 2px 10px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.1); }
.mv .k { font-family: var(--font); letter-spacing: 1px; color: var(--yellow); font-size: 14px; }
.mv .n { font-weight: 900; }
.mv .d { grid-column: 2; color: #d8d0f7; font-size: 12px; line-height: 1.35; }
.blurb { font-size: 13px; line-height: 1.5; color: #e8e2ff; margin: 0 0 8px; }
.swrow { display: flex; align-items: center; gap: 6px; margin: 5px 0; }
.swrow label { width: 56px; font-family: var(--font); letter-spacing: 1px; font-size: 14px; color: #cfc6ff; }
.sws { display: flex; flex-wrap: nowrap; gap: 3px; flex: 1; align-items: center; }
.sw { width: 17px; height: 17px; border: 2px solid var(--ink); box-shadow: 0 0 0 1px rgba(255,255,255,.4); cursor: pointer; padding: 0; }
.sw.on { box-shadow: 0 0 0 2px var(--yellow); transform: scale(1.18); }
.sw-custom { width: 26px; height: 20px; margin-left: 3px; padding: 0; border: 2px solid var(--ink); cursor: pointer; background: none; }
.pick { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.pick label { width: 56px; font-family: var(--font); letter-spacing: 1px; font-size: 14px; color: #cfc6ff; }
.pick .val { flex: 1; text-align: center; font-family: var(--font); letter-spacing: 2px; font-size: 17px; text-transform: capitalize; }
.pick button { font-family: var(--font); font-size: 16px; width: 34px; height: 28px; border: 2px solid var(--ink); background: var(--pink); color: #fff; cursor: pointer; }
.custom-actions { display: flex; gap: 8px; margin-top: 8px; }
.sel-foot { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 8px 0 2px; flex-wrap: wrap; flex: 0 0 auto; }
.sel-foot .btn.big { font-size: 24px; padding: 8px 26px; }
.cpu-opts { font-family: var(--font); letter-spacing: 2px; display: flex; gap: 8px; align-items: center; }
.cpu-opts select { font-size: 18px; width: auto; }
.opp-status { font-family: var(--font); letter-spacing: 2px; font-size: 18px; background: var(--panel); border: 3px solid var(--ink); padding: 6px 14px; }
@media (max-width: 1000px) { #screen-select { overflow: auto; } .sel-layout { grid-template-columns: 1fr; flex: none; } .roster { grid-template-columns: repeat(6, 1fr); overflow: visible; } .rcard span { font-size: 11px; } .preview-wrap { min-height: 320px; } .info-col { overflow: visible; } }

/* stage select */
.stage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; width: min(1000px, 96vw); margin-top: 12px; }
.scard { position: relative; border: 3px solid var(--ink); box-shadow: 0 0 0 2px rgba(255,255,255,.25) inset, 4px 5px 0 rgba(0,0,0,.5); cursor: pointer; overflow: hidden; aspect-ratio: 16/9; transform: skewX(-3deg); transition: transform .1s, filter .15s; background: #000; }
.scard canvas { width: 100%; height: 100%; display: block; }
.scard span { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 10px; background: linear-gradient(0deg, rgba(15,5,30,.9), rgba(15,5,30,0)); font-family: var(--font); letter-spacing: 2px; font-size: 20px; display: flex; justify-content: space-between; align-items: baseline; }
.scard span small { font-family: var(--jp); font-weight: 900; font-size: 13px; opacity: .8; }
.scard:hover { filter: brightness(1.15); transform: skewX(-3deg) translateY(-3px); }
.scard.sel { box-shadow: 0 0 0 4px var(--yellow), 0 0 24px var(--yellow); }
.stage-info { min-height: 48px; margin-top: 12px; font-family: var(--font); letter-spacing: 2px; font-size: 20px; text-align: center; text-shadow: 2px 2px 0 var(--ink); }
.stage-info small { display: block; font-family: "Noto Sans JP", sans-serif; letter-spacing: 0; font-size: 14px; opacity: .85; }
@media (max-width: 700px) { .stage-grid { grid-template-columns: repeat(2, 1fr); } }

/* overlay */
.overlay { position: absolute; inset: 0; background: rgba(8, 2, 20, .72); display: flex; align-items: center; justify-content: center; z-index: 20; }
.net-msg { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); font-family: var(--font); letter-spacing: 2px; background: var(--panel); border: 3px solid var(--ink); padding: 8px 18px; font-size: 20px; z-index: 12; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--yellow); color: var(--ink); font-family: var(--font); letter-spacing: 2px; font-size: 20px; padding: 8px 20px; border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); z-index: 99; }

/* result */
#screen-result { justify-content: center; }
.result { display: flex; gap: 26px; align-items: center; justify-content: center; flex-wrap: wrap; margin: auto; }
.result canvas { width: min(440px, 80vw); aspect-ratio: 1; background: radial-gradient(circle at 50% 70%, rgba(255,255,255,.25), transparent 65%), linear-gradient(160deg, #4b1f9e, #1b0a3c); border: 3px solid var(--ink); box-shadow: 0 0 0 2px #fff inset, 6px 8px 0 rgba(0,0,0,.45); }
.res-text { display: flex; flex-direction: column; gap: 12px; min-width: 280px; }
.res-jp { font-family: var(--jp); font-weight: 900; font-size: 64px; color: rgba(255,233,74,.9); text-shadow: 3px 3px 0 var(--ink); line-height: 1; }
.res-text h2 { font-size: clamp(40px, 7vw, 76px); }
.res-text p { margin: 0; font-family: var(--font); letter-spacing: 2px; font-size: 20px; }

/* touch controls */
.touch { position: absolute; inset: auto 0 0 0; display: none; justify-content: space-between; align-items: flex-end; padding: 0 14px calc(14px + env(safe-area-inset-bottom)); pointer-events: none; z-index: 8; }
.touch button { pointer-events: auto; touch-action: none; font-family: var(--font); letter-spacing: 1px; color: #fff; background: rgba(40, 15, 90, .55); border: 3px solid rgba(255,255,255,.7); border-radius: 50%; width: 64px; height: 64px; font-size: 18px; text-shadow: 2px 2px 0 var(--ink); }
.touch button.on { background: rgba(255, 79, 163, .8); }
.dpad { display: grid; grid-template-columns: 64px 64px 64px; grid-template-rows: 64px 64px; gap: 4px; }
.dpad [data-b="U"] { grid-column: 2; grid-row: 1; } .dpad [data-b="L"] { grid-column: 1; grid-row: 2; } .dpad [data-b="D"] { grid-column: 2; grid-row: 2; } .dpad [data-b="R"] { grid-column: 3; grid-row: 2; }
.acts { display: grid; grid-template-columns: 70px 70px 70px; grid-template-rows: 70px 70px; gap: 6px; }
.acts button { width: 70px; height: 70px; font-size: 13px; }
.acts .lgt { grid-column: 3; grid-row: 2; background: rgba(50,160,255,.5); } .acts .hvy { grid-column: 2; grid-row: 1; background: rgba(255,120,40,.5); } .acts .spc { grid-column: 3; grid-row: 1; background: rgba(190,80,255,.55); }
.acts .grd { grid-column: 2; grid-row: 2; background: rgba(60,200,120,.45); } .acts .sup { grid-column: 1; grid-row: 1; background: rgba(255,60,120,.6); }
@media (pointer: coarse) { .touch.show { display: flex; } }
body.touch-dev .touch.show { display: flex; }

/* portrait phones: nudge to landscape */
@media (orientation: portrait) and (pointer: coarse) {
  #screen-game.active::after { content: "↻ Rotate your device for the best view"; position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-family: var(--font); letter-spacing: 2px; background: var(--yellow); color: var(--ink); border: 3px solid var(--ink); padding: 6px 14px; z-index: 30; white-space: nowrap; font-size: 15px; pointer-events: none; }
}

/* no double-tap / pinch zoom, no long-press menus (iOS ignores user-scalable=no) */
* { touch-action: manipulation; -webkit-touch-callout: none; }
#screen-game, #screen-game * { touch-action: none; }


/* ---- batch: training, move list, spectate, leaderboard, settings ---- */
.menu-row { display: flex; gap: 10px; } .menu-row .btn { flex: 1; }
#screen-title .menu { display: grid; grid-template-columns: 1fr 1fr; width: min(640px, 92vw); gap: 10px; }
#screen-title .menu .btn.big { font-size: 22px; padding: 10px 14px; }
#screen-title .menu .menu-row { grid-column: 1 / -1; }
#btn-ranked small { font-size: 14px; opacity: .8; }
h4 { font-family: var(--font); letter-spacing: 2px; font-weight: 400; color: var(--pink); margin: 14px 0 4px; font-size: 20px; }
.hint { font-size: 13px; color: #cfc6ff; margin: 0; line-height: 1.5; }
.fd { color: #9fe8ff; font-size: 12px; }
.panel .btn.small { margin-bottom: 6px; }
.movelist { max-height: 88vh; overflow-y: auto; margin-top: 4vh; }
.movelist .mv { grid-template-columns: 112px 1fr; }
.train { position: absolute; left: 10px; top: 128px; width: 262px; background: rgba(20, 6, 43, .82); border: 3px solid var(--ink); box-shadow: 0 0 0 2px rgba(255,255,255,.25) inset; padding: 8px 10px; font-size: 13px; z-index: 7; transform: skewX(-2deg); }
.train.flash { box-shadow: 0 0 0 3px var(--yellow), 0 0 22px var(--yellow); }
.train .th-head { display: flex; justify-content: space-between; font-family: var(--font); letter-spacing: 2px; font-size: 18px; color: var(--yellow); }
.train .th-text { margin: 6px 0; line-height: 1.45; }
.train .th-bar { height: 8px; background: rgba(255,255,255,.15); border: 2px solid var(--ink); }
.train .th-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .3s; }
.train .th-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 5px 0; align-items: center; }
.train .th-row label { display: flex; gap: 4px; align-items: center; font-size: 12px; }
.train select { font-size: 13px; padding: 2px 4px; width: auto; }
.train input[type=checkbox] { width: auto; }
.train .btn.small { font-size: 12px; padding: 3px 8px; margin: 0; }
.th-inputs { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 6px; min-height: 22px; }
.th-inputs span { background: #fff; color: var(--ink); font-family: var(--font); font-size: 12px; padding: 1px 5px; border: 2px solid var(--ink); }
.th-data div { margin: 2px 0; }
@media (max-width: 800px) { .train { top: auto; bottom: 150px; width: 220px; font-size: 11px; } }
.spec-info { display: flex; flex-direction: column; gap: 8px; }
.spec-room { font-family: var(--font); letter-spacing: 2px; font-size: 18px; } .spec-room b { color: var(--yellow); letter-spacing: 5px; font-size: 24px; }
.spec-card { display: flex; gap: 12px; align-items: baseline; background: rgba(255,255,255,.08); border: 2px solid var(--ink); padding: 8px 12px; font-family: var(--font); letter-spacing: 2px; font-size: 20px; }
.spec-card span { color: var(--cyan); } .spec-card i { margin-left: auto; font-style: normal; color: var(--yellow); font-size: 15px; } .spec-card small { opacity: .7; }
.spec-card.empty { opacity: .5; }
table.lb { font-size: 16px; } table.lb th { text-align: left; color: var(--cyan); font-family: var(--font); letter-spacing: 2px; font-weight: 400; }
table.lb tr.me td { background: rgba(255, 233, 74, .18); }
.kote { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; } .kote input { width: auto; }
.share { margin-top: 8px; } .share input { font-size: 13px; padding: 4px 8px; } .share .btn { flex: 0 0 auto; }
#prof-key, #prof-import { font-size: 13px; letter-spacing: 0; }
@media (max-width: 1000px) { .roster { grid-template-columns: repeat(4, 1fr) !important; } }
