:root {
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --ink: #141414;
  --paper: #f3efe6;
  --paper2: #e7e1d4;
  --red: #b3120b;
  --red2: #e02a1f;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", "Franklin Gothic Heavy", "Arial Black", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0d0d0d; color: var(--ink);
  font-family: var(--body); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: none;
}
#app { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#screens { position: absolute; inset: 0; pointer-events: none; }
.screen {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: auto; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  animation: fadeIn .25s ease-out;
}
.screen.on { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- title ---------- */
#s-title { background: radial-gradient(ellipse at center, rgba(243,239,230,0) 30%, rgba(243,239,230,.55) 100%); justify-content: space-between; }
.logo { margin-top: 3vh; text-align: center; line-height: .82; filter: drop-shadow(0 6px 0 rgba(0,0,0,.08)); }
.logo .l1 {
  font-family: var(--display); font-size: clamp(40px, min(13vw, 21vh), 170px); letter-spacing: .02em; color: var(--ink);
  transform: skewX(-8deg); position: relative;
}
.logo .l1::after {
  content: ""; position: absolute; left: 3%; right: 1%; bottom: -7%; height: 13%;
  background: var(--red); z-index: -1; transform: skewX(-18deg) rotate(-1.5deg); border-radius: 4px 40px 6px 30px;
  animation: brush 1s cubic-bezier(.2,.9,.2,1) both .15s; transform-origin: left;
}
@keyframes brush { from { transform: skewX(-18deg) rotate(-1.5deg) scaleX(0); } }
.logo .l2 { font-family: var(--display); font-size: clamp(20px, min(5.4vw, 8.5vh), 70px); letter-spacing: .12em; color: var(--ink); transform: skewX(-8deg); margin-top: .28em; }
.logo .l2 span { color: var(--red); }
.logo .tag { font-size: clamp(11px, 1.6vw, 16px); letter-spacing: .5em; text-transform: uppercase; margin-top: 1.1em; color: #4a4a4a; }

.menu { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 2vh 0; }
.btn {
  font-family: var(--display); font-size: clamp(18px, 2.6vw, 26px); letter-spacing: .12em;
  color: var(--paper); background: var(--ink); border: 0; padding: .45em 1.6em .4em; min-width: 250px;
  cursor: pointer; transform: skewX(-10deg); box-shadow: 5px 5px 0 var(--red); transition: transform .08s, box-shadow .08s, background .15s;
}
.btn:hover, .btn:focus-visible { background: var(--red); box-shadow: 5px 5px 0 var(--ink); outline: none; }
.btn:active { transform: skewX(-10deg) translate(3px, 3px); box-shadow: 2px 2px 0 var(--red); }
.btn.big { font-size: clamp(24px, 3.6vw, 38px); min-width: 300px; }
.menu .br { display: none; }
.best { font-family: var(--display); letter-spacing: .2em; font-size: clamp(13px, 1.8vw, 18px); color: var(--ink); min-height: 1.2em; }
.foot { font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: #555; margin-bottom: 1vh; }

/* ---------- panels ---------- */
.panel {
  background: var(--paper); border: 4px solid var(--ink); box-shadow: 10px 10px 0 var(--red);
  padding: clamp(14px, 3vw, 30px) clamp(16px, 4vw, 40px); max-width: min(560px, 94vw); max-height: 92vh; overflow: auto;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.panel.wide { max-width: min(1000px, 96vw); }
.panel h2 { font-family: var(--display); font-size: clamp(30px, 5vw, 54px); margin: 0 0 4px; letter-spacing: .08em; transform: skewX(-8deg); }
.panel h3 { font-family: var(--display); letter-spacing: .12em; margin: 10px 0 6px; font-weight: normal; font-size: 20px; }
.cols { display: flex; gap: 28px; text-align: left; flex-wrap: wrap; justify-content: center; }
.col { flex: 1 1 320px; font-size: 14px; line-height: 1.45; }
.col ul { padding-left: 18px; margin: 0; }
.col li { margin-bottom: 6px; }
.col table { border-collapse: collapse; width: 100%; }
.col td { padding: 3px 6px; border-bottom: 1px solid #d6cfbf; }
.col td:first-child { color: #333; }
kbd { font-family: var(--body); font-size: 12px; background: var(--ink); color: var(--paper); padding: 1px 6px; margin: 0 2px; border-radius: 3px; }
.red { color: var(--red); }
.set { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: min(380px, 80vw); font-size: 16px; }
.set label { font-weight: 600; letter-spacing: .03em; }
.tog { font-family: var(--display); letter-spacing: .1em; font-size: 16px; min-width: 120px; padding: 6px 12px; border: 3px solid var(--ink); background: var(--paper); cursor: pointer; }
.tog.on { background: var(--ink); color: var(--paper); }
input[type=range] { accent-color: var(--red); width: 170px; }
.stats { font-size: 16px; line-height: 1.7; min-width: 240px; }
.stats .row { display: flex; justify-content: space-between; gap: 30px; border-bottom: 1px dashed #bdb5a4; }
.stats .row b { font-family: var(--display); letter-spacing: .08em; font-weight: normal; font-size: 19px; }
.stats .new { color: var(--red); font-family: var(--display); letter-spacing: .2em; font-size: 20px; margin-top: 6px; }

/* ---------- cards ---------- */
#s-cards { background: rgba(13,13,13,.72); gap: 2vh; }
.cards-head { text-align: center; color: var(--paper); }
.cards-head .wc { font-family: var(--display); color: var(--red2); letter-spacing: .4em; font-size: clamp(14px, 2vw, 20px); }
.cards-head h2 { font-family: var(--display); font-size: clamp(28px, 5vw, 56px); margin: 0; letter-spacing: .1em; transform: skewX(-8deg); }
#cards { display: flex; gap: clamp(10px, 2vw, 26px); flex-wrap: wrap; justify-content: center; }
.card {
  width: clamp(150px, 24vw, 250px); min-height: clamp(200px, 36vh, 330px); background: var(--paper); border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--red); display: flex; flex-direction: column; align-items: center; padding: 12px 12px 16px; gap: 8px;
  cursor: pointer; transition: transform .12s; animation: deal .45s cubic-bezier(.2,1.4,.4,1) both; text-align: center;
}
.card:nth-child(2) { animation-delay: .08s; } .card:nth-child(3) { animation-delay: .16s; }
@keyframes deal { from { transform: translateY(40px) rotate(-6deg) scale(.8); opacity: 0; } }
.card:hover, .card:focus-visible { transform: translateY(-8px) rotate(-1deg); outline: none; box-shadow: 8px 14px 0 var(--red); }
.card canvas { width: 88px; height: 88px; }
.card .n { font-family: var(--display); font-size: clamp(18px, 2.4vw, 24px); letter-spacing: .06em; }
.card .d { font-size: clamp(12px, 1.5vw, 14px); line-height: 1.35; color: #333; }
.card .k { margin-top: auto; font-family: var(--display); color: #fff; background: var(--ink); padding: 1px 10px; letter-spacing: .1em; }
.card.rare { border-color: var(--red); }
.card.rare .n { color: var(--red); }
.card .lv { font-size: 11px; letter-spacing: .25em; color: #777; }

/* ---------- rotate ---------- */
#s-rotate { background: rgba(13,13,13,.85); }
.phone { width: 44px; height: 76px; border: 4px solid var(--ink); border-radius: 8px; animation: rot 1.6s ease-in-out infinite; margin: 6px auto; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

.touch-only, .touch-block { display: none; }
body.touch .touch-block { display: block; }
body.touch .kb-block { display: none; }
.btn.sticky { position: sticky; bottom: 0; }
body.touch .touch-only { display: inline-block; }
body.touch .kb-only { display: none; }

@media (max-height: 520px) {
  .logo { margin-top: 0; }
  .logo .tag { margin-top: .7em; }
  .menu { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 94vw; gap: 10px 16px; margin: 1vh 0; }
  .menu .br { display: block; flex-basis: 100%; height: 0; }
  .menu .btn.big { min-width: 260px; }
  .menu .btn:not(.big) { min-width: 0; font-size: 15px; padding: .35em 1.1em .3em; }
  .btn { padding: .3em 1.2em .28em; min-width: 200px; }
  .best { font-size: 12px; }
  #s-title .foot { display: none; }
  .panel { gap: 8px; }
  .card { min-height: 170px; padding: 8px; }
  .card canvas { width: 60px; height: 60px; }
  .panel { padding: 10px 22px; max-height: 96vh; }
  .panel h2 { font-size: 30px; margin: 0; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; column-gap: 26px; font-size: 13px; line-height: 1.5; }
  .stats .row b { font-size: 15px; }
  .stats .new { grid-column: 1 / -1; font-size: 16px; margin-top: 2px; }
  .panel .btn { font-size: 16px; }
  .panel .btn.big { font-size: 20px; min-width: 220px; }
  .col { font-size: 12px; }
}

/* ---------- fighter select ---------- */
#s-fighter { background: rgba(13,13,13,.78); overflow: auto; justify-content: flex-start; }
.fighter { display: flex; gap: clamp(12px, 2.5vw, 34px); align-items: stretch; width: min(1180px, 100%); margin: auto; flex-wrap: wrap; justify-content: center; }
.fp-left { flex: 0 1 380px; display: flex; flex-direction: column; align-items: center; background: var(--paper); border: 4px solid var(--ink); box-shadow: 10px 10px 0 var(--red); padding: 10px; }
.fp-left canvas { width: min(360px, 80vw, 52vh); height: min(360px, 80vw, 52vh); display: block; background: #ddd; }
.fp-name { font-family: var(--display); font-size: clamp(22px, 3vw, 34px); letter-spacing: .08em; margin-top: 8px; transform: skewX(-8deg); text-align: center; }
.fp-tag { font-size: 13px; color: #444; text-align: center; min-height: 2.6em; max-width: 340px; }
.fp-right { flex: 1 1 480px; color: var(--paper); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fp-right h3 { font-family: var(--display); font-weight: normal; letter-spacing: .25em; font-size: 15px; margin: 6px 0 2px; color: #d9d2c2; }
.fp-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fp-style { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); padding: 8px 10px; text-align: left; cursor: pointer; font-family: var(--body); transition: transform .1s; }
.fp-style b { font-family: var(--display); font-weight: normal; font-size: 18px; letter-spacing: .06em; display: block; }
.fp-style i { font-style: normal; font-size: 12px; color: #555; display: block; }
.fp-style small { display: block; font-size: 11px; margin-top: 4px; color: var(--red); letter-spacing: .06em; font-weight: 700; }
.fp-style.on { border-color: var(--red); box-shadow: 5px 5px 0 var(--red); transform: translateY(-2px); }
.fp-suits { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; }
.fp-suit { background: var(--paper); border: 3px solid var(--ink); padding: 3px 3px 5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; position: relative; }
.fp-suit canvas { width: 72px; height: 72px; }
.fp-suit span { font-family: var(--display); font-size: 10.5px; letter-spacing: .05em; color: var(--ink); text-align: center; line-height: 1.05; }
.fp-suit.on { border-color: var(--red); box-shadow: 4px 4px 0 var(--red); }
.fp-suit.locked canvas { filter: grayscale(1) brightness(.35); }
.fp-suit.locked::after { content: "LOCKED"; position: absolute; top: 28px; left: 0; right: 0; text-align: center; font-family: var(--display); color: #fff; letter-spacing: .15em; font-size: 12px; }
.fp-row { display: flex; gap: 22px; flex-wrap: wrap; }
.fp-colors, .fp-arts { display: flex; gap: 8px; flex-wrap: wrap; }
.fp-color { width: 34px; height: 34px; border: 3px solid var(--paper); cursor: pointer; transform: skewX(-10deg); }
.fp-color.on { outline: 3px solid var(--red); outline-offset: 2px; }
.fp-art { font-family: var(--display); letter-spacing: .12em; font-size: 15px; padding: 6px 12px; border: 3px solid var(--paper); background: transparent; color: var(--paper); cursor: pointer; }
.fp-art.on { background: var(--paper); color: var(--ink); }
.fp-actions { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; align-items: center; justify-content: center; }
.fp-actions .btn { min-width: 150px; }
.fp-actions .btn.big { min-width: 170px; }

/* ---------- controls ---------- */
.presets { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.presets button { font-family: var(--display); letter-spacing: .08em; font-size: 15px; padding: 6px 12px; border: 3px solid var(--ink); background: var(--paper); cursor: pointer; }
.presets button.on { background: var(--ink); color: var(--paper); }
table.binds { border-collapse: collapse; width: min(620px, 90vw); }
table.binds td { padding: 4px 8px; border-bottom: 1px solid #d6cfbf; font-size: 14px; }
table.binds td:first-child { text-align: left; font-weight: 600; }
.kbtn { font-family: var(--display); letter-spacing: .08em; font-size: 15px; min-width: 96px; padding: 5px 10px; background: var(--ink); color: var(--paper); border: 0; cursor: pointer; }
.kbtn.alt { background: #5a5650; }
.kbtn.wait { background: var(--red); animation: blink .6s infinite; }
@keyframes blink { 50% { opacity: .6; } }
.hint { font-size: 12px; color: #555; margin: 0; }
.stats .unlock { color: var(--red); font-family: var(--display); letter-spacing: .12em; font-size: 16px; }
h3 small { font-family: var(--body); font-size: 11px; letter-spacing: .1em; color: #777; }

/* ---------- art-style tinting of menus ---------- */
body[data-art="neon"] #s-title { background: radial-gradient(ellipse at center, rgba(10,6,30,0) 30%, rgba(10,6,30,.7) 100%); }
body[data-art="neon"] .logo .l1, body[data-art="neon"] .logo .l2 { color: #f4f2ff; text-shadow: 0 0 18px #ff4fd8, 0 0 4px #35e6ff; }
body[data-art="neon"] .logo .tag, body[data-art="neon"] .best, body[data-art="neon"] .foot { color: #c9c3ff; }
body[data-art="manga"] .logo .l1::after { background: #111; }
body[data-art="sketch"] .logo .l1, body[data-art="sketch"] .logo .l2 { color: #2a2a2a; filter: url(#none); text-shadow: 1px 1px 0 rgba(0,0,0,.15), -1px 0 0 rgba(0,0,0,.1); }

@media (max-width: 760px) {
  .fp-styles { grid-template-columns: 1fr; }
  .fp-left { flex-basis: 100%; flex-direction: row; gap: 10px; align-items: center; }
  .fp-left canvas { width: 34vw; height: 34vw; max-width: 170px; max-height: 170px; }
}
@media (max-height: 520px) {
  .fighter { flex-wrap: nowrap; align-items: flex-start; }
  .fp-left { flex: 0 0 auto; padding: 6px; }
  .fp-left canvas { width: 38vh; height: 38vh; }
  .fp-tag { font-size: 11px; max-width: 38vh; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 0; }
  .fp-left { max-width: 44vh; }
  .fp-actions { gap: 6px; margin-top: 4px; } .fp-actions .btn, .fp-actions .btn.big { min-width: 0; font-size: 15px; padding: .3em .9em; }
  .fp-styles { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .fp-style { padding: 4px 6px; } .fp-style b { font-size: 14px; } .fp-style i { display: none; }
  .fp-suits { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; }
  .fp-suit canvas { width: 50px; height: 50px; }
  .fp-suit.locked::after { top: 18px; }
  .fp-right h3 { font-size: 12px; margin: 2px 0 0; }
}

.fp-combos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; font-size: 12px; color: #d9d2c2; }
.fp-combos div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed rgba(255,255,255,.15); padding: 2px 0; }
.fp-combos b { font-family: var(--display); font-weight: normal; letter-spacing: .06em; color: #fff; }
.fp-combos span { color: #ffb3ad; white-space: nowrap; }
.fp-skill { margin-top: 6px; font-size: 12.5px; text-align: left; line-height: 1.35; max-width: 340px; }
.fp-skill b { font-family: var(--display); font-weight: normal; letter-spacing: .08em; color: var(--red); }
.fp-skill i { font-style: normal; }
@media (max-height: 520px) {
  .fp-combos { display: none; } h3:has(+ .fp-combos) { display: none; }
  .fp-tag { display: block; -webkit-line-clamp: unset; overflow: visible; }
  .fp-tag .fp-line, .fp-skill i { display: none; }
  .fp-skill { font-size: 11px; margin-top: 2px; line-height: 1.5; }
  .fp-left canvas { width: 32vh; height: 32vh; }
}
.card.styled .lv { color: var(--red); }

.fp-roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 7px; }
.fp-char span { font-size: 9.5px; }
.fp-char .pips { display: flex; gap: 3px; margin-top: 2px; }
.fp-char .pips b { width: 10px; height: 4px; background: #bbb; }
.fp-char .pips b.ok { background: var(--red); }
.fp-rinfo { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.fp-rinfo .mv { background: rgba(255,255,255,.06); border-left: 4px solid var(--red); padding: 5px 8px; font-size: 12px; color: #d9d2c2; position: relative; }
.fp-rinfo .mv b { display: block; font-family: var(--display); font-weight: normal; letter-spacing: .06em; color: #fff; font-size: 14px; }
.fp-rinfo .mv i { font-style: normal; display: block; line-height: 1.3; }
.fp-rinfo .mv small { position: absolute; top: 5px; right: 8px; font-size: 9.5px; letter-spacing: .12em; color: #8fd18f; }
.fp-rinfo .mv.locked { border-left-color: #666; opacity: .9; }
.fp-rinfo .mv.locked b { color: #aaa; }
.fp-rinfo .mv em { font-style: normal; display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 11px; color: #ffb3ad; flex-wrap: wrap; }
.fp-rinfo .mv em u { flex: 1 1 60px; height: 5px; background: rgba(255,255,255,.15); text-decoration: none; display: block; min-width: 50px; }
.fp-rinfo .mv em s { display: block; height: 100%; background: var(--red); text-decoration: none; }
.missions { margin-top: 8px; font-size: 12.5px; text-align: left; }
.missions div { padding: 3px 0; border-bottom: 1px dashed rgba(0,0,0,.15); }
.missions span { display: inline-block; min-width: 58px; font-weight: 700; color: var(--red); }
.missions .ok span { color: #1d8a2e; }
.missions i { font-style: normal; color: #777; font-size: 11px; }
@media (max-width: 760px) { .fp-rinfo { grid-template-columns: 1fr; } }
@media (max-height: 520px) {
  .fp-roster { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 4px; }
  .fp-char canvas { width: 44px; height: 44px; } .fp-char span { font-size: 8px; }
  .fp-rinfo { gap: 3px 8px; } .fp-rinfo .mv { padding: 2px 6px; font-size: 10px; } .fp-rinfo .mv b { font-size: 11.5px; } .fp-rinfo .mv i { display: none; }
}
