:host {
  display: block; color: #000; font: 400 15px/1.6 var(--body);
  color-scheme: light;
  --bg: #fff; --bg2: #f6f6f2; --panel: #fff; --line: #cfcfcf; --edge: #000; --ink: #000; --ink2: #333; --ink3: #666;
  --think: #9a6500; --auto: #4f8a74; --auto-dim: #e5efea; --vista: #d4714e; --vista-dim: #f8e6de; --pz: #4b4fb8; --pz-dim: #eef0fc; --rt: #a85600; --rt-dim: #fdf2e4; --win: #12853c; --dead: #f93c31;
  --mark: #ffdc00; --well: #fafaf7; --key: #fff;
  --display: Inter, system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.06; text-wrap: balance }
h2 { font-size: clamp(32px, 4.6vw, 54px); font-weight: 800; letter-spacing: -.02em }
h3 { font-size: 21px; font-weight: 700 }
p { margin: 0 }
button, select { font: inherit; color: inherit }
:focus-visible { outline: 2px solid var(--think); outline-offset: 2px }
/* duel */
.cases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 26px }
.case { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; align-items: center; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; transition: border-color .2s, transform .2s }
.case:hover { transform: translateY(-2px) }
.case[aria-pressed="true"] { border-color: var(--think); box-shadow: 0 0 0 1px var(--think) }
.case .th { aspect-ratio: 16/9; border-radius: 5px; background-image: url(assets/wall.webp); background-size: 1200% 1000% }
.case b { display: block; font: 700 16px/1.2 var(--display) }
.case span { color: var(--ink3); font-size: 13.5px; line-height: 1.3; display: block }
.arena { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px }
.side { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px }
.side.v { --c: var(--vista) } .side.a { --c: var(--auto) }
.sidehead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 2px 4px 8px }
.sidehead b { font: 700 18px var(--display); color: var(--c) }
.sidehead span { font: 400 13px var(--mono); color: var(--ink3) }
.scr { position: relative; aspect-ratio: 16/9; border-radius: 7px; overflow: hidden; background-color: #05070c; background-repeat: no-repeat; box-shadow: inset 0 0 0 1px var(--line) }
.ly { position: absolute; inset: 0; background-repeat: no-repeat; will-change: opacity }
.chip { z-index: 2; position: absolute; left: 8px; top: 8px; font: 500 12.5px var(--mono); padding: 3px 8px; border-radius: 4px; background: rgba(5, 7, 12, .82); color: var(--ink) }
.chip.th { color: var(--think) } .chip.pl { color: var(--auto) }
.stamp { z-index: 3; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5, 7, 12, .62); font: 800 clamp(20px, 3.3vw, 40px)/1.1 var(--display); text-align: center; padding: 10px }
.stamp.win { color: var(--win) } .stamp.out { color: var(--vista) }
.gauges { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 9px }
.gauges div { min-width: 0 }
.gauges b { display: block; font: 600 clamp(17px, 2vw, 23px) var(--mono); font-variant-numeric: tabular-nums; line-height: 1.15 }
.gauges span { color: var(--ink3); font-size: 12.5px }
.bar { position: relative; height: 9px; border-radius: 4px; background: var(--bg); margin-top: 8px; overflow: hidden }
.bar i { display: block; height: 100%; background: var(--c); width: 0 }
.bar.hit { box-shadow: inset 0 0 0 2px var(--dead) }
.gauges .dk b { color: var(--dead) }
.dead { z-index: 2; position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-align: center; box-shadow: inset 0 0 0 3px var(--dead), inset 0 0 70px rgba(255, 45, 45, .55); background: rgba(70, 0, 0, .28) }
.dead.on { display: flex }
.dead b { font: 800 clamp(16px, 2.3vw, 28px)/1.1 var(--display); color: #fff; background: var(--dead); padding: 3px 12px; border-radius: 5px }
.dead span { font: 600 clamp(11px, 1vw, 13px) var(--mono); color: #fff; background: rgba(5, 7, 12, .72); padding: 2px 8px; border-radius: 4px }
.term { height: 196px; margin-top: 9px; overflow-y: auto; scrollbar-width: thin; background: var(--well); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; font: 400 13px/1.45 var(--mono); color: var(--ink2); white-space: pre-wrap; overflow-wrap: anywhere }
.term .ts { color: var(--ink3) }
.term .bul { color: var(--c) }
.term .wait { color: var(--think) }
.term .call { color: var(--c) }
.term .src { color: var(--ink2); display: block; margin: 2px 0 0 12px }
.term .cur { display: inline-block; width: .55em; height: 1em; vertical-align: -2px; background: var(--think); animation: blink 1s steps(2) infinite }
@keyframes blink { 50% { opacity: 0 } }
.term p { margin: 0 0 7px }
.term p.died { color: var(--dead); font-weight: 700 }
.deck { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px }
.play { border: 0; background: var(--think); color: #1b1404; border-radius: 7px; padding: 8px 20px; font-weight: 600; cursor: pointer; min-width: 92px }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--panel) }
.seg button { border: 0; background: none; padding: 7px 12px; font-size: 14.5px; cursor: pointer; color: var(--ink2); border-right: 1px solid var(--line) }
.seg button:last-child { border-right: 0 }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg) }
.seg button:disabled { opacity: .35; cursor: not-allowed }
.now { margin-left: auto; font: 600 22px var(--mono); font-variant-numeric: tabular-nums; color: var(--think) }
.race { width: 100%; display: block; margin-top: 12px; touch-action: none; cursor: ew-resize; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px }
.race text { font: 400 13px var(--mono); fill: var(--ink3) }
.key { display: flex; gap: 16px; flex-wrap: wrap; color: var(--ink3); font-size: 13.5px; margin-top: 7px }
.key i { display: inline-block; width: 16px; height: 3px; vertical-align: 4px; margin-right: 6px }
.pad { display: grid; grid-template-columns: minmax(0, 1fr) 46px; gap: 10px; align-items: center; margin-top: 9px }
.kb { width: 100%; display: block }
.kb rect { fill: var(--key); stroke: var(--line); transition: fill .06s }
.kb text { fill: var(--ink3); font: 500 11px var(--mono); text-anchor: middle }
.kb .on rect { fill: var(--c) } .kb .on text { fill: #05070c }
.ms { width: 46px; display: block } .ms path { fill: var(--key); stroke: var(--line) } .ms .btn.on { fill: var(--c) }
.cursor { position: absolute; z-index: 2; width: 20px; height: 26px; margin: -2px 0 0 -2px; filter: drop-shadow(0 1px 2px #000); transition: left .08s linear, top .08s linear }
.cursor path { fill: #fff; stroke: #05070c; stroke-width: 1.4 }
.ctrl { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; --c: var(--auto) }
.ctrlh { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14.5px; color: var(--ink2) }
.ctrlh b { font: 700 18px var(--display); color: var(--auto) }
.ctrlh span { font: 500 13px var(--mono); color: var(--ink3) } .ctrlh span.live { color: var(--auto) }
.codebox { height: 300px; overflow: auto; margin-top: 8px; background: var(--well); border: 1px solid var(--line); border-radius: 7px; padding: 8px 0; font: 400 13px/1.55 var(--mono) }
.cl { display: grid; grid-template-columns: 42px minmax(max-content, 1fr); color: var(--ink2); white-space: pre; border-left: 3px solid transparent }
.cl i { font-style: normal; color: var(--ink3); text-align: right; padding-right: 12px; user-select: none }
.cl.on { background: var(--auto-dim); border-left-color: var(--auto); color: var(--ink) } .cl.on i { color: var(--auto) }
.cl .cm { color: #707070 } .cl .kw { color: #7a3fb0 } .cl .st { color: #1c7a3e } .cl .ap { color: var(--auto) }
.codebox .none { color: var(--ink3); padding: 8px 14px; font-family: var(--body); font-size: 15px }
@media (prefers-reduced-motion: reduce) { .term .cur { animation: none } .tile, .case { transition: none } html { scroll-behavior: auto } }
#duel { padding-block: 0 56px }
.stage { max-width: 1700px; margin: 0 auto; padding: 8px max(14px, env(safe-area-inset-right, 0px)) 8px max(14px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 8px }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap }
.top h2 { font-size: 21px; letter-spacing: -.01em; margin-right: 6px }
.cases { display: flex; gap: 6px; margin: 0; flex-wrap: wrap }
.case { grid-template-columns: 36px auto; gap: 7px; padding: 3px 9px 3px 4px; border-radius: 7px }
.case b { font-size: 13.5px; white-space: nowrap } .case span { display: none }
.deck { margin: 0 0 0 auto; gap: 8px; flex-wrap: nowrap }
.play { padding: 5px 14px; min-width: 76px; font-size: 14.5px }
.seg button { padding: 5px 10px; font-size: 13.5px }
.now { margin-left: 4px; font-size: 19px; min-width: 3.1ch; text-align: right }
.arena { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .78fr); gap: 8px }
.side { display: flex; flex-direction: column; min-height: 0; padding: 7px; border-radius: 10px }
.sidehead { padding: 0 3px 5px } .sidehead b { font-size: 15px } .sidehead span { font-size: 12px }
.scr { flex: none }
.chip { font-size: 11.5px; padding: 2px 6px; left: 6px; top: 6px }
.mid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px; align-items: center; margin-top: 6px }
.pad { margin: 0; grid-template-columns: minmax(0, 1fr) 28px; gap: 6px }
.ms { width: 28px }
.gauges { margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 8px }
.gauges div { display: flex; align-items: baseline; gap: 5px; min-width: 0 }
.gauges b { font-size: 16px } .gauges span { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.bar { height: 4px; margin-top: 5px }
.term { flex: 1 1 0; min-height: 90px; height: auto; margin-top: 6px; padding: 6px 9px; font-size: 12px; line-height: 1.4 }
.term p { margin-bottom: 5px }
.ctrl { margin: 0; display: flex; flex-direction: column; min-height: 0; padding: 7px; border-radius: 10px }
.ctrlh { padding: 0 3px 5px; gap: 2px 10px; font-size: 13px } .ctrlh b { font-size: 15px } .ctrlh span { font-size: 11.5px }
.codebox { flex: 1 1 0; min-height: 0; height: auto; margin-top: 0; font-size: 11.5px; line-height: 1.5; padding: 5px 0 }
.cl { grid-template-columns: 30px minmax(max-content, 1fr) } .cl i { padding-right: 8px }
.race { margin: 0; height: 96px; flex: none; border-radius: 8px }
.race text { font-size: var(--fs, 12px) }
.after { padding-top: 26px } .after .lede { margin-top: 0 } .after .key { margin-top: 10px }
@media (min-width: 1000px) and (min-height: 600px) {
  .stage { height: calc(100dvh - 52px - env(safe-area-inset-top, 0px)) }
  .arena { flex: 1 1 0; min-height: 0 }
  .side, .ctrl { height: 100% }
  .side { container-type: size }
  .scr { aspect-ratio: 16/9; width: min(100cqw, calc(47cqh * 16 / 9)); align-self: center }
}
@media (max-width: 999px), (max-height: 599px) {
  .arena { grid-template-columns: minmax(0, 1fr) }
  .top h2 { width: 100% } .deck { margin-left: 0 }
  .term { flex: none; height: 170px } .codebox { flex: none; height: 230px }
  .race { height: 118px }
}
.mid { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr) }
.gauges { grid-template-columns: minmax(0, 1fr) }
.gauges div span { font-size: 11px }
.gauges b { font-size: 14.5px; min-width: 2.7ch }
#duel { padding: 0; margin-top: 18px }
.stage { background: #fff; border: 1px solid #000; padding: 8px }
.top h2 { font-size: 18px; font-weight: 800; letter-spacing: 0 }
.play { background: var(--mark); color: #000; border: 1px solid #000; border-radius: 0 }
.seg, .seg button { border-radius: 0 } .seg { border-color: #000 } .seg button { border-right-color: #000 }
.seg button[aria-pressed="true"] { background: #000; color: #fff }
.case { border-color: #000; border-radius: 0; background: #fff }
.case[aria-pressed="true"] { background: var(--mark); border-color: #000; box-shadow: none } .case b { color: #000 } .case span { color: var(--ink2) }
.case .th { border-radius: 0 }
.side, .ctrl { border: 1px solid #000; border-radius: 0; background: #fff }
.sidehead, .ctrlh { margin: -7px -7px 7px; padding: 3px 8px; background: var(--c); color: #fff; align-items: center }
.sidehead b, .ctrlh b { color: #fff; font: 500 12px var(--mono); text-transform: uppercase }
.sidehead span, .ctrlh span, .ctrlh span.live { color: #fff; font-size: 11px }
.side.v .sidehead b::before, .side.a .sidehead b::before, .ctrlh b::before { display: inline-block; min-width: 16px; margin-right: 7px; background: #fff; color: #000; text-align: center }
.side.v .sidehead b::before { content: "1" } .side.a .sidehead b::before { content: "2" } .ctrlh b::before { content: "3" }
.scr { border-radius: 0; box-shadow: 0 0 0 1px #000 }
.chip, .dead b, .dead span { border-radius: 0 }
.vid { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: fill; display: none } .scr.hasvid .vid { display: block }
.re { z-index: 2; position: absolute; right: 6px; bottom: 6px; display: none; padding: 2px 6px; background: rgba(5, 7, 12, .82); color: #fff; font: 500 10.5px var(--mono); text-transform: uppercase } .scr.hasvid .re { display: block }
.chip { color: #fff } .chip.th { color: #ffbe45 } .chip.pl { color: #7fe3f0 }
.stamp.win { color: #7cf0a4 } .stamp.out { color: #ff9d8a }
.bar { background: var(--bg2); border-radius: 0; box-shadow: inset 0 0 0 1px var(--line) }
.term, .codebox { border-color: #999; border-radius: 0 }
.kb rect, .ms path { stroke: #999 }
.race { background: #fff; border: 1px solid #000; border-radius: 0 }

.top h2 { font-size: 23px; font-weight: 820; line-height: 1.15 }
#duel { margin: 0 }
#c-note { margin: 8px 0; color: var(--ink3); font-size: 13px }
.inspector { color: var(--ink2); font-size: 13px }
@media (max-width: 999px), (max-height: 599px) {
  .arena { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .ctrl { grid-column: 1 / -1 }
}
@media (max-width: 600px) {
  .mid { grid-template-columns: minmax(0, 1fr) }
  .sidehead { display: grid; gap: 1px }
  .cases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100% }
  .case { grid-template-columns: minmax(16px, 30px) minmax(0, 1fr); padding-right: 3px }
  .case b { white-space: normal }
  .pad { grid-template-columns: minmax(0, 1fr) 18px }
  .ms { width: 18px }
  .term { overflow-wrap: anywhere }
  .deck { flex-wrap: wrap }
}
