/* ミニロボットバトル：構成主義（赤と黒・斜め・くさび）× モンドリアン（三原色と黒い線）× 工業製品（リベット・縞・計器） */
:root {
  --paper: #ece4d2; --paper2: #f6f1e6; --ink: #1a1918; --red: #c8261b; --red-d: #9e1c13; --blue: #1c4c9c; --yellow: #eebf22;
  --steel: #8e918f; --mute: #4a4744; --line: 4px; --gap: 14px;
  --f-disp: "Dela Gothic One", "Zen Kaku Gothic New", sans-serif;
  --f-num: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --f-body: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--f-body); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; touch-action: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: none; }
#ui > .modal, #ui > .result { pointer-events: auto; }
button { font: inherit; color: inherit; cursor: pointer; }
.jp { word-break: keep-all; overflow-wrap: anywhere; line-break: strict; }

/* ---------------------------------------------------------------- 上の帯 */
#top { position: absolute; left: 0; right: 0; top: 0; height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; pointer-events: auto; z-index: 5; }
#top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--line); background: var(--ink); transform-origin: left; }
#top::before { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--paper) 92%, transparent); }
#top > * { position: relative; }
.logo { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; }
.logo-mark { width: 30px; height: 30px; background: var(--ink); position: relative; flex: none; overflow: hidden; }
.logo-mark::before { content: ""; position: absolute; left: -2px; top: 6px; border-left: 28px solid var(--red); border-top: 9px solid transparent; border-bottom: 9px solid transparent; animation: wedge 4s ease-in-out infinite; }
.logo-mark::after { content: ""; position: absolute; right: 3px; bottom: 3px; width: 9px; height: 9px; background: var(--yellow); }
@keyframes wedge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
.logo-t { font-family: var(--f-disp); font-size: 17px; letter-spacing: .02em; white-space: nowrap; }
.top-r { display: flex; align-items: center; gap: 8px; }
.chip, .credits { display: flex; align-items: baseline; gap: 6px; height: 34px; padding: 0 10px; border: 3px solid var(--ink); background: var(--paper2); }
.chip .k, .credits .k { font: 600 11px var(--f-mono); letter-spacing: .08em; }
.chip b { font: 900 22px/28px var(--f-num); }
.credits { background: var(--ink); color: var(--yellow); min-width: 118px; justify-content: space-between; }
.credits .k { color: var(--paper); }
.credits b { font: 900 24px/28px var(--f-num); font-variant-numeric: tabular-nums; }
.iconbtn { width: 34px; height: 34px; border: 3px solid var(--ink); background: var(--paper2); position: relative; padding: 0; }
.iconbtn i { position: absolute; inset: 7px; background: linear-gradient(90deg, var(--ink) 0 22%, transparent 22% 39%, var(--ink) 39% 61%, transparent 61% 78%, var(--ink) 78%); clip-path: polygon(0 60%, 22% 60%, 22% 20%, 39% 20%, 39% 0, 61% 0, 61% 30%, 78% 30%, 78% 50%, 100% 50%, 100% 100%, 0 100%); }
.iconbtn.off i { opacity: .25; }
.iconbtn.off::after { content: ""; position: absolute; left: 3px; right: 3px; top: 50%; height: 3px; background: var(--red); transform: rotate(-35deg); }

/* ---------------------------------------------------------------- 画面 */
#screen { position: absolute; inset: 58px 0 0 0; }
#screen.full { inset: 0; }
#screen .scr { pointer-events: none; }
#screen .scr * { pointer-events: auto; }
#screen .title-comp, #screen .title-comp * { pointer-events: none; }
.scr { position: absolute; inset: 0; }

/* ボタン：板が押し込まれる */
.btn { --c: var(--ink); --t: var(--paper2); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 22px;
  font: 900 17px/1 var(--f-body); letter-spacing: .04em; color: var(--t); background: var(--c); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s; white-space: nowrap; }
.btn:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.btn.red { --c: var(--red); --t: #fff; }
.btn.blue { --c: var(--blue); --t: #fff; }
.btn.yellow { --c: var(--yellow); --t: var(--ink); }
.btn.paper { --c: var(--paper2); --t: var(--ink); }
.btn.big { min-height: 64px; font-size: 22px; padding: 0 30px; }
.btn.small { min-height: 38px; font-size: 14px; padding: 0 14px; box-shadow: 3px 3px 0 var(--ink); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn .arrow { width: 18px; height: 14px; background: currentColor; clip-path: polygon(0 35%, 60% 35%, 60% 0, 100% 50%, 60% 100%, 60% 65%, 0 65%); }

/* パネル：黒い枠・角のリベット */
.panel { position: relative; background: var(--paper2); border: var(--line) solid var(--ink); }
.panel.rv::before, .panel.rv::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d8dad8, #6f7270 70%); top: 5px; left: 5px; box-shadow: calc(100cqw - 22px) 0 0 0 #8e918f; }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--ink); color: var(--paper2); font: 900 14px var(--f-body); letter-spacing: .06em; }
.ph .n { font: 900 20px var(--f-num); color: var(--yellow); }
.hz { height: 10px; background: repeating-linear-gradient(-45deg, var(--yellow) 0 10px, var(--ink) 10px 20px); background-size: 28.28px 28.28px; animation: hz 1.6s linear infinite; }
@keyframes hz { to { background-position: 28.28px 0; } }
.k { font: 600 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; }
.num { font-family: var(--f-num); font-weight: 900; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 題名・最初の機体 */
.title-scr { display: grid; grid-template-columns: minmax(0, 1fr); align-content: end; padding: 24px; }
.title-comp { position: absolute; left: 0; right: 0; bottom: calc(100% + 14px); height: min(30vh, 230px); pointer-events: none; }
/* 飾りは文字の上の空いた所だけに置く（文字に重ねない） */
.title-comp .wedge { position: absolute; left: -24px; bottom: 0; width: min(640px, 94vw); height: 100%; background: var(--red); clip-path: polygon(0 0, 100% 52%, 0 100%); }
.title-comp .disc { position: absolute; left: min(360px, 58vw); bottom: 4%; height: 92%; aspect-ratio: 1; border-radius: 50%; background: var(--ink); }
.t-bar { display: block; width: min(420px, 72%); height: 14px; background: var(--ink); transform: rotate(-3deg); transform-origin: left; margin: 2px 0 6px; }
.title-text { position: relative; max-width: 560px; }
.title-text h1 { margin: 0; font-family: var(--f-disp); font-weight: 400; font-size: clamp(40px, 8.4vw, 92px); line-height: 1.24; letter-spacing: -.01em; color: var(--ink); }
.title-text h1 span { display: inline-block; }
.title-text h1 .r { color: var(--red); }
.title-text p { margin: 14px 0 22px; font: 700 clamp(14px, 1.7vw, 17px)/1.7 var(--f-body); max-width: 30em; background: var(--paper2); border-left: 8px solid var(--ink); padding: 10px 14px; }
.title-text .row { display: flex; gap: 14px; flex-wrap: wrap; }

.starter { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr; padding: 18px; gap: 12px; }
.starter-top { display: flex; justify-content: space-between; align-items: start; gap: 14px; }
.starter-h { background: var(--paper2); border: var(--line) solid var(--ink); padding: 10px 14px; max-width: 560px; }
.starter-go { flex: none; }
.starter-h h2 { margin: 0; font-family: var(--f-disp); font-weight: 400; font-size: clamp(26px, 4vw, 42px); }
.starter-h p { margin: 6px 0 0; font: 700 14px/1.6 var(--f-body); max-width: 40em; }
.starter-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; align-content: end; }
.scard { padding: 0; text-align: left; border: var(--line) solid var(--ink); background: var(--paper2); box-shadow: 6px 6px 0 var(--ink); transition: box-shadow .15s; display: flex; flex-direction: column; }
.scard:hover { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 var(--ink); }
.scard.on { outline: 6px solid var(--yellow); outline-offset: 0; }
.scard .sh { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: #fff; font: 400 24px var(--f-disp); }
.scard.hv .sh { background: var(--red); }
.scard.lt .sh { background: var(--blue); }
.scard .sh .k { color: #fff; }
.scard .sb { padding: 10px 14px 14px; font: 700 14px/1.65 var(--f-body); }

/* ---------------------------------------------------------------- 拠点（メニュー）：モンドリアンの格子 */
.hub { position: absolute; left: 18px; bottom: 18px; width: min(560px, calc(100% - 36px)); display: grid; grid-template-columns: 1.35fr 1fr; grid-template-rows: 1.25fr 1fr; gap: 0; border: 6px solid var(--ink); background: var(--ink); height: min(400px, 56vh); }
.tile { position: relative; overflow: hidden; border: 3px solid var(--ink); text-align: left; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; transition: filter .15s; background: var(--paper2); }
.tile .t { font: 400 clamp(22px, 3vw, 32px)/1.3 var(--f-disp); position: relative; z-index: 1; }
.tile { gap: 6px; }
.tile .s { font: 700 13px/1.5 var(--f-body); position: relative; z-index: 1; max-width: 18em; }
.tile .g { position: absolute; right: -8%; bottom: -12%; width: 56%; aspect-ratio: 1; opacity: .9; transition: transform .35s cubic-bezier(.2, 1.4, .4, 1); }
.tile:hover .g { transform: rotate(-12deg) scale(1.12); }
.tile.battle { background: var(--red); color: #fff; grid-row: 1 / 3; }
.tile.battle .g { background: var(--ink); clip-path: polygon(0 20%, 100% 50%, 0 80%); width: 80%; right: -16%; bottom: 8%; }
.tile.mission { background: var(--blue); color: #fff; }
.tile.mission .g { border-radius: 50%; background: var(--paper2); width: 46%; }
.tile.garage { background: var(--yellow); color: var(--ink); }
.tile.garage .g { background: conic-gradient(var(--ink) 0 25%, transparent 0 50%, var(--ink) 0 75%, transparent 0); border-radius: 50%; width: 46%; }
.tile.shop { background: var(--paper2); color: var(--ink); }
.tile .badge { position: absolute; right: 10px; top: 10px; z-index: 2; font: 900 13px var(--f-mono); background: var(--ink); color: var(--yellow); padding: 3px 7px; }
.hub-wrap { position: absolute; inset: 0; }
.hub.five { grid-template-columns: 1.35fr 1fr; grid-template-rows: 1fr 1fr 1fr; }
.hub.five .tile.battle { grid-row: 1 / 4; }

/* ---------------------------------------------------------------- 一覧つきの画面（ガレージ・ショップ・相手・依頼） */
.side { position: absolute; top: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.side.l { left: 12px; width: 300px; }
.side.r { right: 12px; width: 360px; }
.list { overflow: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; scrollbar-width: thin; }
.slots { display: grid; grid-template-columns: 1fr; gap: 0; }
.slot { display: grid; grid-template-columns: 74px 1fr; align-items: stretch; text-align: left; border: 0; border-bottom: 3px solid var(--ink); background: var(--paper2); padding: 0; min-height: 50px; }
.slot:last-child { border-bottom: 0; }
.slot .sk { display: flex; align-items: center; padding: 0 10px; background: var(--ink); color: var(--paper2); font: 900 13px var(--f-body); }
.slot .sn { display: flex; flex-direction: column; justify-content: center; padding: 4px 10px; font: 700 14px/1.3 var(--f-body); }
.slot .sn small { font: 600 11px var(--f-mono); color: var(--mute); }
.slot.on { background: var(--yellow); }
.slot.on .sk { background: var(--red); }
.slot:hover:not(.on) { background: #fff; }

.cat { display: flex; flex-direction: column; }
.pc { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; text-align: left; border: 0; border-bottom: 3px solid var(--ink); padding: 8px 10px; background: var(--paper2); position: relative; }
.pc:last-child { border-bottom: 0; }
.pc img { width: 76px; height: 76px; object-fit: contain; background: var(--paper); border: 2px solid var(--ink); }
.pc .pn { font: 900 15px/1.3 var(--f-body); }
.pc .pd { font: 500 12.5px/1.55 var(--f-body); margin-top: 3px; }
.pc .pt { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font: 600 11px var(--f-mono); border: 2px solid var(--ink); padding: 1px 6px; background: var(--paper2); }
.tag.eq { background: var(--ink); color: var(--yellow); }
.tag.lock { background: var(--paper); color: var(--mute); border-color: var(--mute); }
.tag.price { background: var(--yellow); }
.pc.on { background: #fff; box-shadow: inset 8px 0 0 var(--red); }
.pc.locked .pn, .pc.locked img { opacity: .55; }
.pc:hover { background: #fff; }

.stats { padding: 10px 12px 12px; display: grid; gap: 7px; }
.stat { display: grid; grid-template-columns: 78px 1fr 54px; align-items: center; gap: 8px; font: 700 12.5px var(--f-body); }
.stat .bar { position: relative; height: 12px; background: var(--paper); border: 2px solid var(--ink); overflow: hidden; }
.stat .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); width: 0; }
.stat .bar u { position: absolute; top: 0; bottom: 0; text-decoration: none; }
.stat .bar u.up { background: var(--blue); }
.stat .bar u.dn { background: repeating-linear-gradient(-45deg, var(--red) 0 4px, #e46a5f 4px 8px); }
.stat .v { text-align: right; font: 900 17px var(--f-num); }
.stat .v.up { color: var(--blue); }
.stat .v.dn { color: var(--red); }
.weight { padding: 10px 12px; border-top: 3px solid var(--ink); }
.weight .wb { position: relative; height: 18px; border: 3px solid var(--ink); background: var(--paper); margin-top: 6px; }
.weight .wb i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); }
.weight .wb .cap { position: absolute; top: -6px; bottom: -6px; width: 4px; background: var(--red); }
.weight.over .wb i { background: repeating-linear-gradient(-45deg, var(--red) 0 6px, var(--ink) 6px 12px); }
.warn { margin-top: 8px; font: 700 12.5px/1.5 var(--f-body); color: #fff; background: var(--red); padding: 6px 8px; }
.wpn { padding: 8px 12px 10px; border-top: 3px solid var(--ink); font: 700 12.5px/1.6 var(--f-body); }
.wpn b { font-family: var(--f-num); font-size: 16px; }

.bottom-bar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 12px; }
.seg { display: inline-flex; border: 3px solid var(--ink); background: var(--paper2); }
.seg button { border: 0; border-right: 3px solid var(--ink); background: none; padding: 0 14px; min-height: 40px; font: 900 13px var(--f-body); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--yellow); }

/* ステッカー */
.stk-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 3px solid var(--ink); }
.stk { aspect-ratio: 1; border: 0; border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); background: var(--paper) center/70% no-repeat; padding: 0; position: relative; }
.stk:nth-child(4n) { border-right: 0; }
.stk.on { background-color: var(--yellow); box-shadow: inset 0 0 0 4px var(--red); }
.stk.add { display: flex; align-items: center; justify-content: center; font: 900 12px/1.3 var(--f-body); background: var(--ink); color: var(--paper2); text-align: center; padding: 4px; }
.stk .x { position: absolute; right: 2px; top: 2px; width: 20px; height: 20px; border: 2px solid var(--ink); background: var(--paper2); font: 900 12px/14px var(--f-mono); padding: 0; }
.ctl { padding: 10px 12px; display: grid; gap: 8px; border-top: 3px solid var(--ink); }
.ctl label { display: grid; grid-template-columns: 54px 1fr 40px; align-items: center; gap: 8px; font: 700 12.5px var(--f-body); }
.ctl input[type=range] { width: 100%; accent-color: var(--red); }
.ctl .row { display: flex; gap: 8px; flex-wrap: wrap; }
.note { padding: 8px 12px; font: 500 12.5px/1.6 var(--f-body); }

/* 相手・依頼のカード */
.ladder { position: absolute; left: 12px; right: 12px; top: 12px; bottom: 12px; display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
.cls-col { display: flex; flex-direction: column; gap: 0; border: var(--line) solid var(--ink); background: var(--ink); align-self: start; }
.cls-row { display: grid; grid-template-columns: 54px 1fr; border: 0; border-bottom: 3px solid var(--ink); background: var(--paper2); text-align: left; padding: 0; min-height: 56px; }
.cls-row:last-child { border-bottom: 0; }
.cls-row .ck { display: flex; align-items: center; justify-content: center; font: 900 30px var(--f-num); background: var(--ink); color: var(--paper2); }
.cls-row .cd { padding: 8px 10px; font: 700 12.5px/1.5 var(--f-body); }
.cls-row.on { background: var(--yellow); }
.cls-row.on .ck { background: var(--red); color: #fff; }
.cls-row.locked { opacity: .5; }
.opp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-content: start; overflow: auto; padding: 4px 8px 12px 4px; }
.opp { text-align: left; padding: 0; border: var(--line) solid var(--ink); background: var(--paper2); box-shadow: 5px 5px 0 var(--ink); display: flex; flex-direction: column; transition: box-shadow .12s; }
.opp:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.opp .oh { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: var(--ink); color: var(--paper2); }
.opp .oh b { font: 400 19px var(--f-disp); }
.opp img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper); border-bottom: 3px solid var(--ink); display: block; }
.opp .ob { padding: 8px 10px 10px; font: 700 13px/1.55 var(--f-body); flex: 1; }
.opp .of { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-top: 3px solid var(--ink); }
.opp .of .num { font-size: 22px; }
.opp.won .oh { background: var(--blue); }
.stamp { position: absolute; right: 8px; top: 44px; font: 400 18px var(--f-disp); color: var(--red); border: 4px solid var(--red); padding: 2px 8px; transform: rotate(-12deg); background: color-mix(in srgb, var(--paper2) 80%, transparent); }

.board { position: absolute; inset: 12px; display: flex; flex-direction: column; gap: 12px; }
.board-h { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-h h2, .ladder h2 { margin: 0; font: 400 clamp(24px, 3.4vw, 36px) var(--f-disp); }
.mis-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; overflow: auto; padding: 4px 8px 14px 4px; align-content: start; }
.mis { text-align: left; padding: 0; border: var(--line) solid var(--ink); background: var(--paper2); box-shadow: 5px 5px 0 var(--ink); position: relative; transition: box-shadow .12s; display: flex; flex-direction: column; }
.mis:nth-child(3n+1) { transform: rotate(-.6deg); }
.mis:nth-child(3n+2) { transform: rotate(.5deg); }
.mis:hover { transform: translate(-2px, -3px) rotate(0); box-shadow: 8px 8px 0 var(--ink); }
.mis .mh { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px; border-bottom: 3px solid var(--ink); }
.mis .mh .cl { font: 600 11px var(--f-mono); }
.mis .mh b { display: block; font: 400 20px/1.25 var(--f-disp); margin-top: 3px; }
.mis .ic { width: 46px; height: 46px; }
.mis .mb { padding: 10px 12px; font: 700 13px/1.6 var(--f-body); flex: 1; }
.mis .mf { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-top: 3px solid var(--ink); gap: 10px; }
.diff { display: inline-flex; gap: 3px; }
.diff i { width: 12px; height: 16px; border: 2px solid var(--ink); background: var(--paper); transform: skewX(-12deg); }
.diff i.on { background: var(--red); }
.mis .rw { font: 900 24px var(--f-num); }
.mis.done .mh { background: var(--yellow); }

/* 説明の窓（依頼の打ち合わせ・結果） */
.modal { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(26, 25, 24, .45); pointer-events: auto; z-index: 8; padding: 16px; }
.mbox { width: min(620px, 100%); max-height: calc(100% - 20px); overflow: auto; background: var(--paper2); border: 6px solid var(--ink); box-shadow: 10px 10px 0 var(--ink); }
.mbox .mt { padding: 14px 16px; background: var(--blue); color: #fff; }
.mbox .mt.red { background: var(--red); }
.mbox .mt .cl { font: 600 12px var(--f-mono); color: #fff; }
.mbox .mt h3 { margin: 4px 0 0; font: 400 clamp(22px, 3.2vw, 30px)/1.25 var(--f-disp); }
.mbox .mc { padding: 16px; font: 700 15px/1.8 var(--f-body); }
.mbox .goal { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink); background: var(--yellow); font: 900 15px/1.4 var(--f-body); }
.mbox .goal .k { background: var(--ink); color: var(--yellow); padding: 3px 7px; }
.mbox .ma { display: flex; gap: 12px; justify-content: flex-end; padding: 14px 16px; flex-wrap: wrap; }

/* 結果 */
.result { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(236, 228, 210, .55); pointer-events: auto; z-index: 8; padding: 16px; }
.rbox { position: relative; width: min(640px, 100%); background: var(--paper2); border: 6px solid var(--ink); box-shadow: 12px 12px 0 var(--ink); overflow: hidden; }
.rbig { position: relative; height: 150px; overflow: hidden; background: var(--ink); }
.rbig .w { position: absolute; left: -10%; top: 0; bottom: 0; width: 80%; background: var(--red); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.rbig.lose .w { background: var(--blue); }
.rbig h2 { position: absolute; right: 22px; bottom: 6px; margin: 0; color: var(--paper2); font: 400 clamp(54px, 11vw, 96px)/1 var(--f-disp); }
.rrows { padding: 12px 16px; display: grid; gap: 6px; }
.rrow { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px dashed var(--steel); padding: 4px 0; font: 700 14px var(--f-body); }
.rrow .num { font-size: 22px; }
.rrow.total { border-bottom: 0; border-top: 4px solid var(--ink); padding-top: 8px; }
.rrow.total .num { font-size: 38px; color: var(--red); }
.rnote { padding: 0 16px 6px; font: 700 13px/1.6 var(--f-body); }
.ract { display: flex; justify-content: flex-end; gap: 12px; padding: 12px 16px 16px; flex-wrap: wrap; }

/* VS の画面 */
.vs { position: absolute; inset: 0; z-index: 9; pointer-events: none; overflow: hidden; }
.vs .a, .vs .b { position: absolute; top: 0; bottom: 0; width: 64%; display: flex; flex-direction: column; justify-content: center; padding: 0 6%; color: #fff; }
.vs .a { left: 0; background: var(--red); clip-path: polygon(0 0, 100% 0, 78% 100%, 0 100%); }
.vs .b { right: 0; background: var(--blue); clip-path: polygon(22% 0, 100% 0, 100% 100%, 0 100%); align-items: flex-end; text-align: right; }
.vs .k { color: #fff; font-size: 13px; }
.vs .nm { font: 400 clamp(30px, 6vw, 64px)/1.05 var(--f-disp); }
.vs .mid { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font: 900 clamp(80px, 16vw, 180px)/1 var(--f-num); color: var(--yellow); -webkit-text-stroke: 6px var(--ink); paint-order: stroke; }
.count { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font: 900 clamp(110px, 22vw, 220px)/1 var(--f-num); color: var(--ink); -webkit-text-stroke: 4px var(--paper2); paint-order: stroke; z-index: 9; pointer-events: none; }
.count.go { font: 400 clamp(60px, 12vw, 120px)/1 var(--f-disp); color: var(--red); }

/* ---------------------------------------------------------------- 試合中の表示 */
#hud { position: absolute; inset: 0; }
.hud-top { position: absolute; left: 12px; right: 12px; top: 10px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.hb { border: 3px solid var(--ink); background: color-mix(in srgb, var(--paper2) 88%, transparent); padding: 6px 8px; }
.hb .nm { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font: 900 13px var(--f-body); }
.hb .nm .num { font-size: 22px; }
.ap { position: relative; height: 16px; border: 2px solid var(--ink); background: var(--paper); margin-top: 4px; overflow: hidden; }
.ap i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); transition: width .12s; }
.ap b { position: absolute; left: 0; top: 0; bottom: 0; background: var(--red); transition: width .6s .25s; }
.ap i { z-index: 1; }
.hb.enemy .ap i { background: var(--red); left: auto; right: 0; }
.hb.enemy .ap b { background: var(--ink); left: auto; right: 0; opacity: .35; }
.hb.enemy { text-align: right; }
.en { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; height: 10px; margin-top: 5px; }
.en i { background: var(--paper); border: 1px solid var(--ink); }
.en i.on { background: var(--blue); }
.en.heat i.on { background: var(--red); }
.timer { min-width: 96px; text-align: center; background: var(--ink); color: var(--yellow); border: 3px solid var(--ink); font: 900 38px/1 var(--f-num); padding: 4px 10px 2px; font-variant-numeric: tabular-nums; }
.timer.low { color: #fff; background: var(--red); }
.obj { margin-top: 6px; font: 900 13px/1.4 var(--f-body); background: var(--yellow); border: 3px solid var(--ink); padding: 4px 8px; text-align: center; }
.hud-br { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 10px; align-items: end; }
.wbox { border: 3px solid var(--ink); background: color-mix(in srgb, var(--paper2) 88%, transparent); padding: 6px 10px; min-width: 150px; }
.wbox .num { font-size: 24px; white-space: nowrap; }
.wbox .wv, .wbox .sv { font-family: var(--f-body); font-weight: 900; }
.wbox .rl { height: 6px; background: var(--paper); border: 1px solid var(--ink); margin-top: 3px; }
.wbox .rl i { display: block; height: 100%; background: var(--red); width: 0; }
.ret { position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none; will-change: transform; }
.ret i { position: absolute; width: 18px; height: 18px; border: 4px solid var(--red); }
.ret i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.ret i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.ret i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.ret i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.ret span { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 4px; font: 900 14px var(--f-num); background: var(--ink); color: var(--yellow); padding: 1px 5px; white-space: nowrap; }
.ret.far i { border-color: var(--ink); opacity: .6; }
.ret .rot { position: absolute; inset: 14px; border: 3px solid var(--red); transform: rotate(45deg); animation: spin 2.4s linear infinite; }
.ret.far .rot { border-color: var(--ink); opacity: .4; }
@keyframes spin { to { transform: rotate(405deg); } }
.dmg { position: absolute; left: 0; top: 0; font: 900 26px var(--f-num); color: var(--ink); -webkit-text-stroke: 4px var(--paper2); paint-order: stroke; pointer-events: none; white-space: nowrap; will-change: transform, opacity; }
.dmg.big { font-size: 40px; color: var(--red); }
.dmg.g { color: var(--blue); }
.dmg.me { color: var(--red); }
.callout { position: absolute; left: 50%; top: 26%; transform: translate(-50%, -50%); font: 400 clamp(26px, 5vw, 44px) var(--f-disp); color: var(--paper2); background: var(--ink); padding: 6px 18px; pointer-events: none; white-space: nowrap; }
.callout.red { background: var(--red); }
.flashv { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 0 var(--red); }
.help { position: absolute; left: 14px; bottom: 14px; max-width: 520px; font: 700 12.5px/1.6 var(--f-body); background: color-mix(in srgb, var(--paper2) 88%, transparent); border: 3px solid var(--ink); padding: 6px 10px; }
.pausebtn { pointer-events: auto; }

/* スマホの操作（指の時は右下の武器の表示と操作の説明を出さない：ボタンに出す） */
#hud.touch .hud-br, #hud.touch .help { display: none; }
#touch { position: absolute; inset: 0; }
#touch .stick { position: absolute; left: 0; bottom: 0; width: 50%; height: 62%; pointer-events: auto; }
#touch .knob { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border: 4px solid var(--ink); border-radius: 50%; background: color-mix(in srgb, var(--paper2) 45%, transparent); display: none; }
#touch .knob i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: var(--ink); }
#touch .pads { position: absolute; right: 12px; bottom: calc(12px + var(--safe-b)); width: 210px; height: 210px; pointer-events: none; }
.pad { position: absolute; border: 4px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font: 900 14px var(--f-body); pointer-events: auto; user-select: none; -webkit-user-select: none; color: var(--ink); background: color-mix(in srgb, var(--paper2) 80%, transparent); overflow: hidden; }
.pad.fire { right: 0; bottom: 0; width: 104px; height: 104px; background: var(--red); color: #fff; font-size: 17px; }
.pad.sub { right: 112px; bottom: 6px; width: 74px; height: 74px; background: var(--blue); color: #fff; }
.pad.dash { right: 4px; bottom: 114px; width: 74px; height: 74px; background: var(--yellow); }
.pad.jump { right: 100px; bottom: 96px; width: 66px; height: 66px; }
.pad.on { filter: brightness(.8); transform: scale(.94); }
.pad .cd { position: absolute; inset: 0; background: rgba(26, 25, 24, .55); transform-origin: bottom; transform: scaleY(0); }
.pad span { position: relative; }
.tbtn { position: absolute; top: 74px; right: 12px; pointer-events: auto; }

/* ---------------------------------------------------------------- 画面の切り替え（斜めの板が横切る） */
#wipe { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
#wipe i { position: absolute; top: -20%; bottom: -20%; width: 170%; left: -35%; transform: translateX(-200%); }
#wipe .w1 { background: var(--ink); }
#wipe .w2 { background: var(--red); }
#wipe .w3 { background: var(--yellow); }
#toast { position: absolute; right: 12px; top: 70px; display: flex; flex-direction: column; gap: 8px; z-index: 15; align-items: end; }
.toast { pointer-events: none; background: var(--ink); color: var(--paper2); font: 700 14px/1.5 var(--f-body); padding: 10px 14px 10px 22px; border: 3px solid var(--ink); max-width: min(380px, calc(100vw - 24px)); position: relative; }
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: repeating-linear-gradient(-45deg, var(--yellow) 0 6px, var(--ink) 6px 12px); }
#boot { position: absolute; inset: 0; display: grid; place-items: center; background: var(--paper); z-index: 30; }
.boot-bar { width: min(320px, 70vw); height: 18px; border: 4px solid var(--ink); }
.boot-bar i { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s; }

/* ---------------------------------------------------------------- 画面の幅ごと */
@media (max-width: 1080px) {
  .side.r { width: 330px; }
  .side.l { width: 250px; }
  .opp-grid, .mis-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  #top { height: 52px; padding: 0 10px; }
  #screen { top: 52px; }
  .logo-t { font-size: 14px; }
  .credits { min-width: 96px; }
  .chip, .credits, .iconbtn { height: 32px; }
  /* ガレージ・ショップ：上に機体、下に一覧 */
  .side.l { left: 8px; right: 8px; top: auto; bottom: auto; width: auto; position: absolute; }
  .side.r { left: 8px; right: 8px; width: auto; top: 44%; bottom: 8px; }
  .garage .side.l { top: 8px; }
  .slots.compact { grid-template-columns: repeat(4, 1fr); }
  .slots.compact .slot { grid-template-columns: 1fr; border-bottom: 0; border-right: 3px solid var(--ink); min-height: 40px; }
  .slots.compact .slot:nth-child(4n) { border-right: 0; }
  .slots.compact .slot:nth-child(-n+4) { border-bottom: 3px solid var(--ink); }
  .slots.compact .slot .sk { justify-content: center; padding: 0 2px; font-size: 12px; text-align: center; }
  .slots.compact .slot .sn { display: none; }
  .ladder { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .cls-col { flex-direction: row; }
  .cls-row { flex: 1; grid-template-columns: 1fr; border-bottom: 0; border-right: 3px solid var(--ink); min-height: 0; }
  .cls-row:last-child { border-right: 0; }
  .cls-row .cd { display: none; }
  .cls-row .ck { font-size: 24px; padding: 4px 0; }
  .hub { height: min(360px, 50vh); }
  .starter-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .scard .sb { font-size: 12.5px; }
  .scard .sh { font-size: 19px; }
  .help { display: none; }
}
@media (max-width: 560px) {
  .opp-grid, .mis-grid { grid-template-columns: 1fr; }
  .hud-top { grid-template-columns: 1fr 1fr; left: 8px; right: 8px; gap: 6px; }
  .hud-top .mid { grid-column: 1 / 3; grid-row: 1; justify-self: center; }
  .timer { font-size: 28px; min-width: 70px; padding: 3px 8px 1px; }
  .hb .nm { font-size: 11.5px; }
  .hb .nm .num { font-size: 18px; }
  .hud-br { display: none; }
  .starter-cards { grid-template-columns: 1fr; gap: 8px; }
  .starter-top { flex-direction: column; align-items: stretch; }
  .starter-h { padding: 8px 10px; }
  .starter-h p { font-size: 12.5px; }
  .starter-go .btn { width: 100%; min-height: 52px; font-size: 18px; }
  .starter { padding: 10px; gap: 8px; }
  .scard .stats { padding: 6px 10px 8px; gap: 4px; }
  .tile:not(.battle) .s { display: none; }
  .tile .t { font-size: 22px; }
  .scard .sb { display: none; }
  .title-scr { padding: 16px; }
  .logo-t { display: none; }
  .stat { grid-template-columns: 66px 1fr 48px; }
  .vs .a, .vs .b { width: 72%; }
}
@media (prefers-reduced-motion: reduce) {
  .hz, .logo-mark::before, .ret .rot { animation: none; }
}
