/* ── Design tokens ── */
:root {
  --bg: #0f172a;
  --bg-deep: #070b16;
  --bg-card: rgba(255, 255, 255, .05);
  --bg-hover: rgba(255, 255, 255, .09);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #ffffff;
  --text-muted: #a9b3c9;
  --primary: #dc2626;
  --primary-dark: #991b1b;
  --secondary: #2563eb;
  --accent: #22c55e;
  --flame: #ff7a18;
  --gold: #fbbf24;
  --danger: #dc2626;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, .6);
  --font-display: 'Press Start 2P', ui-monospace, monospace;
  --font-body: 'VT323', ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(220, 38, 38, .28), transparent 55%),
    radial-gradient(ellipse at 80% 110%, rgba(37, 99, 235, .25), transparent 55%),
    var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
#app { max-width: 1320px; margin: 0 auto; padding: 14px; }
#stage-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-lg), 0 0 0 6px rgba(0, 0, 0, .35);
  background: #05070d;
}
#game { display: block; width: 100%; height: 100%; image-rendering: auto; }
#overlays { position: absolute; inset: 0; }
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; padding: 3% 4%;
  background: linear-gradient(160deg, rgba(7, 11, 22, .93), rgba(15, 23, 42, .96));
  backdrop-filter: blur(6px);
  text-align: center;
  overflow: auto;
}
.screen.active { display: flex; animation: fadeUp .28s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.5; }
h2 { font-size: clamp(16px, 2vw, 26px); letter-spacing: 1px; }
.hint, .tagline { color: var(--text-muted); font-size: 1.05rem; }
.label { font-family: var(--font-display); font-size: 10px; color: var(--text-muted); letter-spacing: 1px; }

/* ── Title screen ── */
.logo-wrap { position: relative; }
.logo-kanji {
  font-family: var(--font-display); font-size: 64px; color: rgba(220, 38, 38, .18);
  position: absolute; inset: -42px 0 auto; text-align: center; z-index: 0; letter-spacing: 8px;
}
.logo {
  position: relative; font-size: clamp(22px, 4.4vw, 48px); letter-spacing: 2px;
  color: #fff; text-shadow: 4px 4px 0 var(--primary-dark), 8px 8px 0 rgba(0, 0, 0, .6);
  animation: logoPulse 3.2s ease-in-out infinite;
}
.logo span { color: var(--primary); display: block; }
@keyframes logoPulse { 50% { text-shadow: 4px 4px 0 var(--secondary), 8px 8px 0 rgba(0, 0, 0, .6) } }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: center; z-index: 1; }
.menu.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 22px; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-display); font-size: 11px; letter-spacing: .5px;
  text-transform: uppercase; border: 2px solid transparent;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s;
  min-width: 240px;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary {
  background: linear-gradient(140deg, var(--primary), var(--flame));
  color: #fff; box-shadow: 0 6px 24px rgba(220, 38, 38, .4);
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 12px 34px rgba(220, 38, 38, .55); }
.btn-ghost { background: rgba(255, 255, 255, .04); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--bg-hover); transform: translateY(-3px); border-color: var(--secondary); color: #cfe0ff; }
.btn:focus-visible, .tab:focus-visible, .card:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn.small { min-width: 0; padding: 8px 14px; font-size: 9px; }

/* ── Tabs / difficulty ── */
.diff-row { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, .04); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.tab {
  padding: 8px 16px; border-radius: 999px; cursor: pointer; color: var(--text-muted);
  font-family: var(--font-display); font-size: 9px; transition: all .2s; user-select: none;
}
.tab:hover { color: #fff; background: var(--bg-hover); }
.tab.active { background: linear-gradient(140deg, var(--secondary), #60a5fa); color: #fff; box-shadow: 0 4px 18px rgba(37, 99, 235, .45); }

/* ── Character select ── */
.sc-head { text-align: center; }
.sc-head h2 { color: var(--gold); text-shadow: 2px 2px 0 rgba(0, 0, 0, .6); }
.sc-body { display: grid; grid-template-columns: 1fr 288px; gap: 16px; width: 100%; max-width: 1120px; align-items: stretch; }
.sc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.card {
  position: relative; cursor: pointer; border-radius: var(--radius);
  border: 2px solid var(--border-strong); background: var(--bg-card);
  backdrop-filter: blur(10px); overflow: hidden; padding: 6px;
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--secondary); }
.card canvas { display: block; width: 100%; height: auto; border-radius: 10px; background: linear-gradient(180deg, #101a2e, #0a1120); }
.card .cname {
  font-family: var(--font-display); font-size: 8px; padding: 6px 2px 2px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .cname b { display: block; color: #fff; font-size: 9px; }
.card.sel-p1 { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(220, 38, 38, .35), var(--shadow-lg); }
.card.sel-p2 { border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .35), var(--shadow-lg); }
.cursor { position: absolute; top: 4px; font-family: var(--font-display); font-size: 8px; padding: 3px 6px; border-radius: 4px; }
.cursor.p1 { left: 4px; background: var(--primary); }
.cursor.p2 { right: 4px; background: var(--secondary); }
.cursor.p1.p2 { left: auto; }
.sc-info {
  border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--bg-card);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; text-align: left;
}
.portrait-box { border-radius: 10px; overflow: hidden; background: linear-gradient(180deg, #131f36, #090f1c); }
.portrait-box canvas { display: block; width: 100%; height: auto; }
.sc-info h3 { font-size: 12px; color: var(--flame); }
.sc-title { font-family: var(--font-display); font-size: 8px; color: var(--secondary); letter-spacing: .5px; }
.quote { color: var(--text-muted); font-size: .95rem; font-style: italic; }
.stat-list { list-style: none; display: grid; gap: 6px; }
.stat-list li { display: grid; grid-template-columns: 76px 1fr 30px; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-muted); }
.bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.sc-foot { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.stage-pick { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.stage-chip {
  font-family: var(--font-display); font-size: 8px; padding: 7px 11px; cursor: pointer;
  border: 2px solid var(--border-strong); border-radius: 999px; color: var(--text-muted); transition: all .2s;
}
.stage-chip:hover { color: #fff; background: var(--bg-hover); }
.stage-chip.on { border-color: var(--accent); color: #fff; background: rgba(34, 197, 94, .18); }
.sc-keys { font-size: .9rem; color: var(--text-muted); }
.sc-keys b { color: var(--gold); }

/* ── VS splash ── */
#screen-vs { background: #05070d; }
.vs-wrap { display: flex; align-items: center; justify-content: center; gap: 24px; width: 100%; }
.vs-side { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: slideIn .5s ease both; }
.vs-side.right { animation-direction: reverse; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-60px) scale(.94) } to { opacity: 1; transform: none } }
.vs-side canvas { max-width: 260px; width: 100%; filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .6)); }
.vs-name { font-family: var(--font-display); font-size: 13px; }
.vs-side.left .vs-name { color: var(--flame); }
.vs-side.right .vs-name { color: #7dd3fc; }
.vs-mid { font-family: var(--font-display); font-size: clamp(28px, 5vw, 58px); color: var(--primary); text-shadow: 3px 3px 0 #000; animation: vsPop .45s ease both; }
@keyframes vsPop { from { transform: scale(.3); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.vs-tag { font-family: var(--font-display); font-size: 9px; color: var(--text-muted); }

/* ── Result / pause cards ── */
.result-card {
  background: var(--bg-card); border: 2px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 26px 30px; display: flex; flex-direction: column; gap: 14px; align-items: center;
  box-shadow: var(--shadow-lg); backdrop-filter: blur(12px); max-width: 620px;
}
#res-title { color: var(--gold); font-size: clamp(20px, 3vw, 34px); text-shadow: 3px 3px 0 rgba(0, 0, 0, .6); }
#res-sub { font-size: 1.15rem; }

/* ── Move list ── */
.ml-body { display: grid; grid-template-columns: 210px 1fr; gap: 14px; width: 100%; max-width: 1120px; flex: 1; min-height: 0; }
.ml-tabs { display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.ml-tab {
  font-family: var(--font-display); font-size: 9px; text-align: left; padding: 10px 11px; cursor: pointer;
  border-radius: var(--radius-sm); border: 2px solid var(--border); color: var(--text-muted); background: rgba(255, 255, 255, .03);
  transition: all .18s;
}
.ml-tab:hover { color: #fff; transform: translateX(3px); }
.ml-tab.on { border-color: var(--primary); color: #fff; background: rgba(220, 38, 38, .16); }
.ml-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; overflow: auto; text-align: left; padding-right: 6px; }
.mv {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px;
  background: rgba(255, 255, 255, .035); transition: all .18s;
}
.mv:hover { background: var(--bg-hover); transform: translateY(-2px); border-color: var(--border-strong); }
.mv .mv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mv .mv-name { font-family: var(--font-display); font-size: 9px; color: #fff; }
.mv .mv-in { font-family: var(--font-display); font-size: 8px; color: var(--gold); white-space: nowrap; }
.mv .mv-desc { font-size: .88rem; color: var(--text-muted); margin-top: 4px; }
.mv .mv-lv { font-family: var(--font-display); font-size: 7px; color: var(--accent); }
.mv.ult { border-color: rgba(251, 191, 36, .4); background: linear-gradient(120deg, rgba(251, 191, 36, .1), transparent); }

/* ── Controls screen ── */
.ctrl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 900px; text-align: left; }
.ctrl-card { border: 2px solid var(--border-strong); border-radius: var(--radius); padding: 14px; background: var(--bg-card); }
.ctrl-card h3 { font-size: 10px; margin-bottom: 10px; }
.ctrl-card.p1 h3 { color: var(--flame); }
.ctrl-card.p2 h3 { color: #7dd3fc; }
.ctrl-row { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; color: var(--text-muted); padding: 3px 0; border-bottom: 1px dashed rgba(255, 255, 255, .07); }
.keys { display: flex; gap: 4px; }
kbd {
  font-family: var(--font-display); font-size: 8px; padding: 5px 7px; border-radius: 5px;
  background: rgba(255, 255, 255, .1); border: 1px solid var(--border-strong); border-bottom-width: 3px; color: #fff;
}
.legend { max-width: 900px; text-align: left; border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 14px; }
.legend h3 { font-size: 10px; color: var(--gold); margin-bottom: 8px; }
.legend p { color: var(--text-muted); font-size: .95rem; }
.legend b { color: #fff; }

/* ── Quick bar / toast / footer ── */
#quick-bar { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; z-index: 5; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer;
  border-radius: 10px; border: 1px solid var(--border-strong); background: rgba(7, 11, 22, .72);
  color: var(--text); backdrop-filter: blur(8px); transition: all .18s;
}
.icon-btn:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }
.icon-btn.off { color: var(--text-muted); opacity: .6; }
.toast-wrap { position: absolute; bottom: 60px; left: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 6; }
.toast {
  font-family: var(--font-display); font-size: 8px; padding: 9px 12px; border-radius: 6px;
  background: rgba(7, 11, 22, .9); border: 1px solid var(--border-strong); color: #fff;
  animation: fadeUp .25s ease both;
}
.toast.win { border-color: var(--accent); color: #86efac; }
.site-foot { color: var(--text-muted); font-size: .82rem; text-align: center; padding: 12px 6px 4px; opacity: .75; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .sc-body { grid-template-columns: 1fr; }
  .sc-info { display: none; }
  .ml-body { grid-template-columns: 150px 1fr; }
}
@media (max-width: 760px) {
  #app { padding: 6px; }
  body { font-size: 17px; }
  .sc-grid { grid-template-columns: repeat(2, 1fr); }
  .ml-list, .ctrl-grid { grid-template-columns: 1fr; }
  .ml-body { grid-template-columns: 118px 1fr; }
  .btn { min-width: 200px; font-size: 9px; padding: 10px 16px; }
  .logo-kanji { display: none; }
  #quick-bar { right: 8px; bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
