* { box-sizing: border-box; }
html, body { margin: 0; }
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10141c;
  --bg-spot: radial-gradient(900px 420px at 50% -8%, #1c2740 0%, transparent 62%);
  --panel: #171d28;
  --raised: #1e2634;
  --hover: #222b3a;
  --line: #2c3648;
  --line-2: #3d4a60;
  --text: #eef2f7;
  --text-2: #c5cedb;
  --muted: #8b97ab;
  --muted-2: #9aa6b8;
  --lede: #a8b3c4;
  --link: #7eb6ff;
  --link-hover: #b9d6ff;
  --accent: #e4c37a;
  --primary: #e4c37a;
  --primary-fg: #16120a;
  --badge: #1e2634;
  --badge-on-bg: #163528;
  --badge-on: #8fd4b8;
  --fmt-hover: #e4c37a;
  --preview: rgba(8, 10, 16, .72);
  --now-bg: #2a2416;
  --now-fg: #f3e2a6;
  --now-line: #5a4a24;
  --log-head: #e4c37a;
  --log-on: #2c281c;
  --log-on-fg: #fff8e8;
  --log-group: #141922;
  --log-text: #c5cedb;
  --log-hover: #1e2634;
  --shadow: 0 1px 0 rgba(255,255,255,.04), 0 10px 28px rgba(0,0,0,.28);
  --hair: rgba(228, 195, 122, .4);
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #efe6d4;
  --bg-spot: radial-gradient(900px 420px at 50% -8%, #f7f0e2 0%, transparent 62%);
  --panel: #f7f1e6;
  --raised: #efe6d4;
  --hover: #ece3d2;
  --line: #d9ccb4;
  --line-2: #c9b896;
  --text: #1c1812;
  --text-2: #3f382e;
  --muted: #6f675b;
  --muted-2: #5c554b;
  --lede: #534c42;
  --link: #185b86;
  --link-hover: #0f3d5c;
  --accent: #9a6b1f;
  --primary: #2a241c;
  --primary-fg: #f7f1e6;
  --badge: #efe6d4;
  --badge-on-bg: #d5eadc;
  --badge-on: #1a5c3c;
  --fmt-hover: #9a6b1f;
  --preview: rgba(28, 24, 18, .48);
  --now-bg: #f4ead0;
  --now-fg: #6b4a12;
  --now-line: #e0c98a;
  --log-head: #9a6b1f;
  --log-on: #f3e6c4;
  --log-on-fg: #1c1812;
  --log-group: #f3ebdc;
  --log-text: #3f382e;
  --log-hover: #ece3d2;
  --shadow: 0 1px 0 rgba(255,255,255,.7), 0 10px 24px rgba(80, 60, 20, .08);
  --hair: rgba(154, 107, 31, .45);
}
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg) var(--bg-spot) no-repeat;
  color-scheme: inherit;
}
::selection { background: var(--accent); color: var(--primary-fg); }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--primary); color: var(--primary-fg); padding: 8px 12px;
}
.skip:focus { left: 8px; }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px; }
.top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -2px 0 var(--hair);
  position: sticky; top: 0; z-index: 8;
}
.bar {
  max-width: 920px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand span { color: var(--accent); font-weight: 600; }
.brand:hover { text-decoration: none; }
.menu {
  display: none; margin-left: auto; appearance: none; font: inherit; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text); padding: 6px 10px; border-radius: 8px;
}
.theme {
  appearance: none; font: inherit; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font-size: 14px;
}
.theme:hover, .menu:hover { background: var(--hover); border-color: var(--accent); }
nav { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-left: auto; }
nav a { color: var(--muted-2); font-size: 14px; }
nav a:hover { color: var(--text); text-decoration: none; }
nav a.on { color: var(--accent); font-weight: 600; }
main.wrap { padding-top: 28px; padding-bottom: 64px; min-height: calc(100vh - 160px); }
h1, h2, h3 { margin: 0 0 8px; letter-spacing: -0.03em; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 700; margin-bottom: 10px; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
.kicker { color: var(--accent); font-size: 12px; margin-bottom: 8px; letter-spacing: 0.06em; }
.page-head { margin-bottom: 28px; }
.lede { color: var(--lede); margin: 0; max-width: 42em; line-height: 1.55; }
.notice {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 16px; color: var(--text-2); font-size: 14px;
}
.block, .card, .copy, .prose {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 22px; box-shadow: var(--shadow);
}
.block-header, .kind {
  padding: 14px 18px; font-size: 13px; font-weight: 650; color: var(--text-2);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 3px 0 0 var(--accent);
}
.card, .copy, .prose { padding: 18px 20px; }
.row, .node, .deck {
  display: flex; justify-content: space-between; gap: 14px; align-items: center;
  padding: 16px 18px; border-top: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.node:first-child, .row:first-of-type, .deck:first-child { border-top: 0; }
.deck {
  appearance: none; width: 100%; background: transparent; border-left: 0; border-right: 0; border-bottom: 0;
  font: inherit; cursor: pointer; text-align: left; color: inherit;
}
.deck:hover, .node:hover, a.row:hover { background: var(--hover); }
.name { font-weight: 650; color: var(--text); }
a.name { color: var(--link); }
.meta { font-size: 13px; color: var(--muted); line-height: 1.45; }
.node .meta, .deck .meta { margin-top: 3px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.stat .k, .stat .h { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin: 2px 0; }
.btn {
  display: inline-flex; align-items: center; appearance: none; font: inherit; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text);
  padding: 6px 11px; border-radius: 8px; text-decoration: none; font-size: 14px;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.copy h3 { font-size: 16px; font-weight: 650; margin: 18px 0 8px; color: var(--text); }
.copy h3:first-child { margin-top: 0; }
.copy p, .prose p, .card p { margin: 0 0 10px; color: var(--text-2); }
.copy p:last-child, .prose p:last-child, .card p:last-child { margin-bottom: 0; }
.prose ul { margin: 0 0 10px 18px; padding: 0; color: var(--text-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 650; }
code {
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--raised); padding: 1px 5px; border-radius: 4px;
}
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; }
.fmt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.fmt-card {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; color: inherit; text-decoration: none; box-shadow: var(--shadow);
}
.fmt-card:hover { border-color: var(--fmt-hover); text-decoration: none; }
.fmt-card h3 { margin-bottom: 4px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 650; color: var(--lede);
  background: var(--badge); border-radius: 999px; padding: 2px 8px; margin-left: 6px;
}
.badge.on { background: var(--badge-on-bg); color: var(--badge-on); }
.rules { display: grid; grid-template-columns: 160px 1fr; gap: 0; font-size: 14px; }
.rules div { padding: 8px 0; border-top: 1px solid var(--line); }
.rules div:nth-child(-n+2) { border-top: 0; }
.rules .k { color: var(--muted); }
.list-card { margin-top: 12px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.list-row img, .deck img { width: 34px; height: 46px; object-fit: cover; object-position: top; border-radius: 4px; background: var(--raised); }
.player { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 12px; }
.board { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.side { padding: 6px 0; }
.side.foe { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.seat { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.who { font-weight: 650; }
.prizes { display: flex; gap: 3px; }
.prize { width: 10px; height: 14px; background: var(--text); border-radius: 2px; }
.prize.off { opacity: 0.15; }
.row-cards { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 70px; }
.pk {
  width: 92px; border: 1px solid var(--line); background: var(--bg); padding: 0; border-radius: 8px;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.pk.active { width: 108px; border-color: var(--text); }
.pk img { width: 100%; height: 80px; object-fit: cover; object-position: top; display: block; background: var(--raised); }
.pk.active img { height: 96px; }
.pk .info { padding: 6px; }
.pk .nm { font-size: 11px; font-weight: 650; min-height: 24px; }
.hpbar { height: 4px; background: var(--line); margin: 4px 0; overflow: hidden; border-radius: 99px; }
.hpbar > i { display: block; height: 100%; background: var(--text); }
.en { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 3px; }
.en i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.mid { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 8px; }
.turn-badge { font-size: 12px; font-weight: 650; }
.controls { display: flex; gap: 6px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.controls input[type=range] { flex: 1; min-width: 100px; }
.logbox { max-height: 62vh; overflow: auto; }
.mini { width: 44px; border: 1px solid var(--line); background: var(--bg); padding: 0; border-radius: 6px; color: inherit; font: inherit; cursor: pointer; }
.mini img { width: 100%; height: 40px; object-fit: cover; object-position: top; display: block; }
.mini .nm { font-size: 9px; font-weight: 650; padding: 3px 4px; min-height: 24px; }
.mini.back {
  height: 64px; display: grid; place-items: center; font-size: 10px; color: var(--muted);
  background: var(--raised);
}
.mini-row { display: flex; flex-wrap: wrap; gap: 4px; }
.flash, .winner { text-align: center; margin-top: 6px; font-weight: 650; }
.search {
  width: 100%; padding: 9px 12px; margin-bottom: 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit;
}
#card-preview[hidden] { display: none !important; }
#card-preview { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; }
.preview-bg { position: absolute; inset: 0; border: 0; background: var(--preview); cursor: pointer; }
.preview-panel { position: relative; width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.preview-panel img { width: 100%; display: block; max-height: 70vh; object-fit: contain; }
.empty { color: var(--muted); padding: 12px 14px; }
.foot { border-top: 1px solid var(--line); box-shadow: inset 0 2px 0 var(--hair); padding: 20px 0 32px; color: var(--muted); font-size: 13px; background: var(--panel); }
.foot p { margin: 0 0 6px; }
body.is-replay .foot { display: none; }
body.is-replay main.wrap {
  max-width: min(1280px, 100%);
  padding-top: 12px;
  padding-bottom: 12px;
  min-height: calc(100dvh - 58px);
  height: calc(100dvh - 58px);
  display: flex;
  flex-direction: column;
}
.replay-app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.replay-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.replay-bar h1 { font-size: 18px; margin: 0; }
.replay-bar .kicker { margin: 0; }
.replay-bar #replay-meta { margin-left: auto; }
.replay-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 12px;
}
.replay-field, .replay-log {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.replay-now {
  flex-shrink: 0;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--now-fg);
  background: var(--now-bg);
  border-bottom: 1px solid var(--now-line);
}
.replay-field .board {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  padding: 10px 12px 14px;
}
.replay-field .pk { width: 76px; }
.replay-field .pk.active { width: 90px; }
.replay-field .pk img { height: 66px; }
.replay-field .pk.active img { height: 78px; }
.replay-field .mini { width: 40px; }
.replay-field .mini img { height: 36px; }
.replay-field .hands .mini-row { max-height: 84px; overflow: auto; }
.replay-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 0;
  flex-shrink: 0;
}
.replay-log-head h3 { margin: 0; }
.replay-hint {
  margin: 4px 12px 8px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.replay-log .logbox {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 0 0 12px;
}
.lg { padding: 4px 0 8px; }
.lg + .lg { border-top: 1px solid var(--line); }
.lg-h, .ln {
  display: block;
  width: 100%;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.lg-h {
  padding: 8px 12px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--log-head);
}
.lg-h:hover { background: var(--hover); }
.ln {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 12px 5px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--log-text);
  border-top: 0;
}
.ln:hover { background: var(--log-hover); }
.ln.on, .lg-h.on {
  background: var(--log-on);
  color: var(--log-on-fg);
  box-shadow: inset 3px 0 0 var(--log-head);
}
.lg.on { background: var(--log-group); }
.lk {
  flex: 0 0 58px;
  margin-top: 1px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.lt { min-width: 0; }
.log-who { color: var(--link); font-weight: 700; }
.ln.k-attack .lk, .ln.k-damage .lk { color: #f0a0a0; }
.ln.k-attack .lt, .ln.k-damage .lt { color: #f7c4c4; }
.ln.k-ko .lk, .ln.k-win .lk { color: #fdba74; }
.ln.k-ko .lt, .ln.k-win .lt { color: #ffd7a8; font-weight: 650; }
.ln.k-energy .lk, .ln.k-draw .lk, .ln.k-evolve .lk { color: #86efac; }
.ln.k-trainer .lk, .ln.k-ability .lk { color: #93c5fd; }
.ln.k-prize .lk { color: #fde68a; }
.ln.k-coin .lk, .ln.k-status .lk { color: #f9a8d4; }
.ln.k-setup .lk, .ln.k-switch .lk { color: #a5b4fc; }
.ln.k-timer { color: var(--muted); }
html[data-theme="light"] .ln.k-attack .lk, html[data-theme="light"] .ln.k-damage .lk { color: #b91c1c; }
html[data-theme="light"] .ln.k-attack .lt, html[data-theme="light"] .ln.k-damage .lt { color: #991b1b; }
html[data-theme="light"] .ln.k-ko .lk, html[data-theme="light"] .ln.k-win .lk { color: #c2410c; }
html[data-theme="light"] .ln.k-ko .lt, html[data-theme="light"] .ln.k-win .lt { color: #9a3412; }
html[data-theme="light"] .ln.k-energy .lk, html[data-theme="light"] .ln.k-draw .lk, html[data-theme="light"] .ln.k-evolve .lk { color: #15803d; }
html[data-theme="light"] .ln.k-trainer .lk, html[data-theme="light"] .ln.k-ability .lk { color: #1d4ed8; }
html[data-theme="light"] .ln.k-prize .lk { color: #a16207; }
html[data-theme="light"] .ln.k-coin .lk, html[data-theme="light"] .ln.k-status .lk { color: #be185d; }
html[data-theme="light"] .ln.k-setup .lk, html[data-theme="light"] .ln.k-switch .lk { color: #4338ca; }
.hide-timer .ln.k-timer { display: none; }
.replay-dock {
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}
.replay-dock .controls { margin: 0; }
.replay-keys { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 760px) {
  .player, .stats, .rules { display: block; }
  .menu { display: inline-block; }
  nav { display: none; width: 100%; margin-left: 0; }
  .top.open nav { display: flex; }
}
@media (max-width: 900px) {
  body.is-replay main.wrap { height: auto; min-height: calc(100dvh - 58px); }
  .replay-stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 48vh) minmax(220px, 40vh);
  }
  .replay-bar { flex-wrap: wrap; }
  .replay-bar #replay-meta { margin-left: 0; }
}
