/*
 * UNDER LAYERS — 侵入モード(hack.html)。docs/raid-ui.md
 * kb.css(土台)と fx.css(再生ビューア)の上に、一覧・出撃準備・対戦の操作パネル・リザルトを足す。
 * 色: 赤 = 侵入モード・危険(本番の侵入ボタン・放棄・敗北)、シアン = 侵入者の道具(プログラム・対象の選択)、
 *     アンバー = 注意(押せない理由・応答待ち・通信エラー)、緑 = 本文。
 */

.page-hack {
	--acc: var(--cyan);
	--acc-hi: #a9eef8;
	--acc-line: #23525b;
	--acc-bg: rgba(111, 214, 232, .08);
}

.raid-main {
	max-width: 980px;
}

/* ============================================================ 見出し */

.raid-lead {
	margin: 4px 0 0;
	font-size: var(--fs-s);
}

.raid-mode {
	margin: 4px 0 0;
	font-size: var(--fs-xs);
	color: var(--sub);
}

.raid-mode .k {
	color: var(--muted);
}

.raid-app > * + *,
.raid-lobby > * + * {
	margin-top: 22px;
}

.raid-app {
	display: block;
	margin-top: 18px;
}

/* ============================================================ 一覧(公開防壁・練習) */

.targets { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.targets.is-practice { grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.target { border: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; min-width: 0; align-content: start; }
.target.is-mine { border-style: dashed; }
.tg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.tg-head .nm { color: var(--fg-hi); font-size: var(--fs-m); overflow-wrap: anywhere; }
.tg-author { color: var(--sub); font-size: var(--fs-s); overflow-wrap: anywhere; }
.tg-mine { color: var(--warn); font-size: var(--fs-xs); border: 1px solid var(--warn); padding: 0 4px; }
/* システムの防壁(演習壁)の印。帯ごとに色を変える */
.tg-sys { color: var(--fg-hi); font-size: var(--fs-xs); border: 1px solid currentColor; padding: 0 4px; white-space: nowrap; }
.tg-sys.is-easy { color: var(--fg); }
.tg-sys.is-normal { color: var(--warn); }
.tg-sys.is-hard { color: var(--alert); }
.tg-facts { color: var(--sub); font-size: var(--fs-xs); margin-left: auto; white-space: nowrap; }
.tg-comment { margin: 0; font-size: var(--fs-s); overflow-wrap: anywhere; }
.tg-prof { display: grid; gap: 6px; min-width: 0; }
.tg-label { margin: 0; font-size: var(--fs-s); }
.tg-label b { color: var(--fg); font-weight: normal; font-size: var(--fs-m); }
.tg-axes .axis { grid-template-columns: 3.2em minmax(0, 12em) 2em; }
.tg-axes .axis .v { text-align: right; }
.tg-axes .meter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; height: 8px; }
.tg-axes .meter i { background: var(--bg-2); }
.tg-axes .meter i.on { background: var(--fg); }
.tg-axes .lv-high .meter i.on { background: var(--fg-hi); }
.tg-tags { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: var(--fs-s); }
.tg-tags .n { color: var(--muted); margin-right: 3px; }
.tg-rec { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: var(--fs-xs); color: var(--sub); }
.tg-mine-rec { color: var(--acc); }
.tg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; border-top: 1px dotted var(--line); padding-top: 8px; margin-top: auto; }
.tg-secret { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--sub); font-size: var(--fs-s); }
.tg-secret .redact { display: inline-block; width: 64px; height: 10px; background: repeating-linear-gradient(-45deg, var(--line) 0 3px, transparent 3px 6px); border: 1px solid var(--line); }
.tg-foot .btn[disabled] { opacity: .55; cursor: not-allowed; }
.tg-go-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 8px; margin-left: auto; }
.tg-reg { color: var(--warn); font-size: var(--fs-xs); }
.tg-secret.is-practice::before { content: "◇"; color: var(--warn); }
.tg-intro, .tg-note { margin: 0 0 10px; font-size: var(--fs-s); }
.tg-note { margin: 10px 0 0; }
.tg-warn { margin: 0 0 10px; padding: 6px 8px; color: var(--warn); border: 1px dashed var(--warn); font-size: var(--fs-s); }
.tg-prof.is-compact .tg-axes .axis { grid-template-columns: 3.2em minmax(0, 9em) 2em; }

.tg-go.btn.sm:not(.alert-btn) {
	color: var(--acc);
	border-color: var(--acc-line);
}

/* ============================================================ 出撃準備 */

.su-body {
	display: grid;
	gap: 14px;
}

.su-target {
	display: grid;
	gap: 6px;
	padding: 8px 10px;
	border: 1px solid var(--line);
	background: repeating-linear-gradient(-45deg, rgba(255, 64, 64, .04) 0 6px, transparent 6px 12px);
}

.su-th {
	margin: 0;
	overflow-wrap: anywhere;
}

.su-th b {
	color: var(--fg-hi);
	font-weight: normal;
	font-size: var(--fs-l);
}

.su-cols {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 14px;
	align-items: start;
}

.su-list {
	display: grid;
	gap: 12px;
	min-width: 0;
}

.su-group {
	display: grid;
	gap: 4px;
}

.su-gh {
	margin: 0 0 2px;
	color: var(--acc);
	font-size: var(--fs-s);
	font-weight: normal;
	letter-spacing: .06em;
}

.su-opt {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	column-gap: 8px;
	align-items: baseline;
	padding: 6px 8px;
	border: 1px solid var(--line);
	cursor: pointer;
}

.su-opt:hover,
.su-opt:focus-within {
	border-color: var(--acc-line);
	background: var(--acc-bg);
}

.su-opt:has(input:checked) {
	border-color: var(--acc);
	background: var(--acc-bg);
	box-shadow: inset 3px 0 0 var(--acc);
}

.su-opt input {
	accent-color: var(--acc);
	margin: 0;
	grid-row: span 2;
	align-self: center;
}

.su-nm {
	color: var(--fg-hi);
	overflow-wrap: anywhere;
}

.su-sub {
	grid-column: 2;
	font-size: var(--fs-xs);
	overflow-wrap: anywhere;
}

.su-opt.is-bad {
	cursor: not-allowed;
	opacity: .7;
}

.su-err {
	grid-column: 2;
	color: var(--alert-hi);
	font-size: var(--fs-xs);
}

/* 自分の侵入構成の [編集] [削除](選択の行の下に離して置く。2026-11-19) */
.su-row {
	display: grid;
	gap: 4px;
	border: 1px solid var(--line);
	padding-bottom: 6px;
}
/* 枠は行全体(選ぶ部分 + [編集] [削除])に付ける。ボタンを枠の外に出さない(2026-11-20 制作者の指摘⑥) */
.su-row > .su-opt {
	border: 0;
	box-shadow: none;
}
.su-row:hover,
.su-row:focus-within {
	border-color: var(--acc-line);
}
.su-row:has(.su-opt input:checked) {
	border-color: var(--acc);
	background: var(--acc-bg);
	box-shadow: inset 3px 0 0 var(--acc);
}
.su-row > .su-opt:hover,
.su-row > .su-opt:focus-within,
.su-row > .su-opt:has(input:checked) {
	background: none;
}
.su-row-acts {
	padding: 0 6px;
}
.su-row-acts {
	display: flex;
	justify-content: flex-end;
	gap: 14px;
}
.su-row-acts .btn {
	min-height: 40px;
	min-width: 5em;
}
@media (max-width: 759px) {
	.su-row-acts .btn { min-height: 44px; min-width: 6em; }
	.su-row-acts { gap: 16px; }
}
/* 構成ごとのジョブ(docs/job-loadout-design.md §2.4): 札は並びの左(縮めて省略。行の高さを変えない)、[ジョブ] は [編集] [削除] の前。
   759px 以下は札を 1 行に、ボタンを次の行に(ボタン 3 つが 360px に収まるよう間と幅を詰める) */
.su-row.has-job .su-row-acts { flex-wrap: wrap; align-items: center; row-gap: 6px; }
.su-job { display: flex; align-items: center; flex: 1 1 0; min-width: 0; margin-right: auto; }
@media (max-width: 759px) {
	.su-row.has-job .su-job { flex-basis: 100%; }
	.su-row.has-job .su-row-acts { gap: 6px 10px; }
	.su-row.has-job .su-row-acts .btn { min-width: 5em; }
}

.su-none {
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 8px;
	font-size: var(--fs-s);
	padding: 8px;
	border: 1px dashed var(--warn);
	color: var(--warn);
}

.su-side {
	position: sticky;
	top: 10px;
	display: grid;
	gap: 10px;
	min-width: 0;
}

.su-preview {
	padding: 8px 10px;
	border: 1px solid var(--acc-line);
	min-height: 120px;
}

.su-pv-h {
	margin: 0 0 6px;
	overflow-wrap: anywhere;
}

.su-pv-h b {
	color: var(--acc-hi);
	font-weight: normal;
}

.su-progs {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 3px 10px;
	font-size: var(--fs-s);
}

.su-progs .rd-key {
	min-width: 1.4em;
	padding: 0 2px;
}

.su-lo-cm {
	margin: 0 0 6px;
	font-size: var(--fs-xs);
	overflow-wrap: anywhere;
}

.su-progs li {
	display: flex;
	gap: 6px;
	align-items: baseline;
	min-width: 0;
}

.su-buttons {
	justify-content: flex-start;
	margin-top: 0;
}

/* ============================================================ ダイブ・対戦(全画面) */

.raid-stage {
	display: none;
}

html.raid-on {
	overflow: hidden;
}

html.raid-on .raid-stage {
	display: block;
	position: fixed;
	inset: 0;
	z-index: 60;
	background: var(--bg);
}

html.raid-on .raid-main,
html.raid-on .site-footer {
	visibility: hidden;
}

/* ---- ダイブ開始の演出 */
.rd-intro {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: grid;
	place-content: center;
	justify-items: center;
	gap: 18px;
	padding: 16px;
	background: var(--bg-deep);
	transition: opacity .3s ease;
}

.rd-intro.is-out {
	opacity: 0;
}

.rd-tunnel {
	position: relative;
	width: 140px;
	height: 140px;
}

.rd-tunnel i {
	position: absolute;
	inset: calc(var(--k) * 12px);
	border: 1px solid var(--fg);
	opacity: calc(1 - var(--k) * .15);
	animation: rd-dive 1.1s linear infinite;
	animation-delay: calc(var(--k) * -.22s);
}

@keyframes rd-dive {
	from { transform: scale(1.6); opacity: 0; }
	30% { opacity: .9; }
	to { transform: scale(.2); opacity: 0; }
}

.rd-term {
	margin: 0;
	min-width: min(420px, 86vw);
	min-height: 7.5em;
	color: var(--fg);
	font-family: var(--mono);
	font-size: var(--fs-s);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* 対戦中の通知: 左下だと操作パネル(ターン終了ボタン)に重なるので、上の帯の下(盤面の上端)に出す */
html.raid-on .toasts {
	top: 40px;
	bottom: auto;
	left: auto;
	right: 12px;
}

@media (max-width: 759px) {
	html.raid-on .toasts {
		left: 10px;
		right: 10px;
	}
}

/* ---- 対戦画面 */
.rd-battle {
	display: flex;
	flex-direction: column;
	height: 100%;
	height: 100dvh;
}

.rd-bar {
	flex: none;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 10px;
	padding: 5px 10px;
	border-bottom: 1px solid var(--alert);
	background: linear-gradient(90deg, rgba(255, 64, 64, .14), transparent 60%);
	font-size: var(--fs-s);
	min-width: 0;
}

.rd-bar-k {
	color: var(--alert-hi);
	letter-spacing: .08em;
}

.rd-bar-t {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1 1 10em;
}

.rd-bar-t b {
	color: var(--fg-hi);
	font-weight: normal;
}

.rd-kind {
	padding: 0 5px;
	color: var(--bg);
	background: var(--alert);
	font-size: var(--fs-xs);
}

.rd-kind.is-practice {
	background: var(--acc);
}

.rd-seq {
	color: var(--sub);
	font-size: var(--fs-xs);
}

/* 失効までの残り時間(サーバーの侵入だけ)。5分を切ると色を変え、0 になったら赤で知らせる */
.rd-ttl {
	color: var(--sub);
	font-size: var(--fs-xs);
	white-space: nowrap;
}

.rd-ttl.is-warn {
	color: var(--warn, #ffb000);
}

.rd-ttl.is-over {
	color: var(--alert-hi);
}

.rd-viewer {
	flex: 1 1 auto;
	min-height: 0;
	position: relative;
}

.rd-viewer > .rp {
	height: 100%;
}

/* 戦闘中は侵入者の視点に固定する(視点の切り替えは戦闘後の見返しのダイアログだけ。侵入でも作戦記録でも。player.js の perspectiveToggle: false も同じ)。
   リザルトは操作パネルの代わりにページで出す */
.rd-viewer .rp-pers,
.rd-viewer .rp-result,
.rd-viewer .rp-meta {
	display: none !important;
}

/* 対象の候補の層(盤面を押しても選べる) */
.rd-viewer .rp-layer.rd-cand {
	cursor: crosshair;
	outline: 2px dashed var(--acc);
	outline-offset: 2px;
}

/* ---- 操作パネル */
.rd-panel {
	flex: none;
	display: grid;
	gap: 6px;
	max-height: 46vh;
	max-height: 46dvh;
	overflow: auto;
	padding: 8px 10px 10px;
	border-top: 1px solid var(--acc-line);
	background: var(--bg-1);
	overscroll-behavior: contain;
}

.rd-status {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px 14px;
	font-size: var(--fs-s);
	min-width: 0;
}

.rd-st-turn {
	color: var(--fg-hi);
}

.rd-st-cpu {
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

.rd-st-cpu .k {
	color: var(--acc);
	font-size: var(--fs-xs);
}

.rd-st-cpu b {
	color: var(--acc-hi);
	font-weight: normal;
}

.rd-pips {
	display: inline-flex;
	gap: 2px;
}

.rd-pips i {
	width: 9px;
	height: 11px;
	border: 1px solid var(--acc-line);
}

.rd-pips i.on {
	background: var(--acc);
	border-color: var(--acc);
}

.rd-st-pos {
	color: var(--sub);
	overflow-wrap: anywhere;
}

.rd-turnmsg {
	margin-left: auto;
	color: var(--fg);
}

.rd-wait {
	margin-left: auto;
	color: var(--warn);
}

.rd-error {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 10px;
	padding: 5px 8px;
	color: var(--warn);
	border: 1px solid var(--warn);
	font-size: var(--fs-s);
}

.rd-error[hidden] {
	display: none;
}

.rd-progs {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
	gap: 5px;
}

.rd-prog {
	display: grid;
	grid-template-columns: 1.4em minmax(0, 1fr) auto;
	grid-template-rows: auto auto;
	column-gap: 6px;
	align-items: baseline;
	min-width: 0;
	min-height: 44px;
	padding: 4px 7px;
	color: var(--acc-hi);
	background: var(--bg);
	border: 1px solid var(--acc-line);
	font: inherit;
	font-size: var(--fs-s);
	text-align: left;
	cursor: pointer;
}

.rd-prog:hover,
.rd-prog:focus-visible {
	border-color: var(--acc);
	background: var(--acc-bg);
	outline: none;
	box-shadow: 0 0 0 1px var(--acc);
}


.rd-prog.is-multi .rd-ps {
	color: var(--acc);
}

.rd-prog[aria-disabled="true"] {
	color: var(--sub);
	border-color: var(--line);
	cursor: not-allowed;
}

.rd-prog.is-blocked {
	color: var(--sub);
	border-color: var(--line);
}

.rd-prog.is-blocked .rd-key {
	background: var(--line);
	color: var(--sub);
}

.rd-prog.is-blocked .rd-ps {
	color: var(--warn);
}

.rd-key {
	grid-row: span 2;
	align-self: center;
	color: var(--bg);
	background: var(--acc);
	text-align: center;
	font-size: var(--fs-xs);
	line-height: 1.5;
}

.rd-prog[aria-disabled="true"] .rd-key {
	background: var(--line);
	color: var(--sub);
}

.rd-pn {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rd-pc {
	color: var(--fg);
}

.rd-pc.is-tax {
	color: var(--warn);
}

.rd-ps {
	grid-column: 2 / 4;
	color: var(--sub);
	font-size: var(--fs-xs);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---- 選択中のプログラムの拡大表示(操作パネルのすぐ上に重ねる。docs/raid-ui.md §2) */
.rd-dock {
	position: relative;
	flex: none;
	height: 0;
	z-index: 15;
}

.rd-sheet {
	position: absolute;
	right: 10px;
	bottom: 6px;
	width: min(560px, calc(100% - 20px));
	display: flex;
	flex-direction: column;
	color: var(--fg);
	background: var(--bg-1);
	border: 1px solid var(--acc);
	box-shadow: 0 0 0 1px var(--bg), 0 -6px 24px rgba(0, 0, 0, .6), 0 0 18px rgba(111, 214, 232, .14);
	animation: rd-sheet-in .14s ease-out;
}

.rd-sheet[hidden] {
	display: none;
}

@keyframes rd-sheet-in {
	from { opacity: 0; transform: translateY(8px); }
}

.rd-sh-head {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	grid-template-rows: auto auto;
	column-gap: 10px;
	align-items: baseline;
	padding: 8px 12px 6px;
	border-bottom: 1px solid var(--acc-line);
	background: var(--acc-bg);
}

.rd-sh-head .rd-key {
	grid-column: 1;
	grid-row: 1 / 3;
	align-self: center;
	min-width: 1.8em;
	font-size: var(--fs-m);
	line-height: 1.6;
}

.rd-sh-name {
	grid-column: 2;
	grid-row: 1;
	margin: 0;
	color: var(--acc-hi);
	font-size: var(--fs-xl);
	font-weight: normal;
	line-height: 1.2;
	overflow-wrap: anywhere;
}

.rd-sh-cost {
	grid-column: 3;
	grid-row: 1 / 3;
	align-self: center;
	color: var(--fg-hi);
	font-size: var(--fs-l);
}

.rd-sh-cost.is-tax {
	color: var(--warn);
}

.rd-sh-fam {
	grid-column: 2;
	grid-row: 2;
	color: var(--sub);
	font-size: var(--fs-xs);
}

.rd-sh-hint {
	margin: 0;
	padding: 4px 12px;
	color: var(--bg);
	background: var(--acc);
	font-size: var(--fs-s);
}

.rd-sh-hint.is-bad {
	color: var(--bg);
	background: var(--warn);
}

.rd-sh-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	display: grid;
	gap: 7px;
	padding: 8px 12px;
	align-content: start;
}

.rd-sh-body p {
	margin: 0;
}

.rd-sh-text {
	color: var(--fg-hi);
	font-size: var(--fs-m);
	line-height: 1.55;
	overflow-wrap: anywhere;
}

.rd-sh-flavor {
	color: var(--sub);
	font-size: var(--fs-xs);
	font-style: italic;
}

.rd-sh-state {
	font-size: var(--fs-s);
}

.rd-sh-state.is-ok {
	color: var(--fg);
}

.rd-sh-state.is-bad {
	color: var(--warn);
}

.rd-sh-tgts {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
	gap: 5px;
}

.rd-sh-tgts .btn.sm.rd-tgt {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0 8px;
	min-width: 0;
	min-height: 36px;
	padding: 4px 8px;
	color: var(--acc-hi);
	border-color: var(--acc-line);
	text-align: left;
	white-space: normal;
	overflow-wrap: anywhere;
	line-height: 1.3;
}

.rd-sh-tgts .btn.sm.rd-tgt.is-here {
	box-shadow: inset 0 -2px 0 var(--acc-line);
}

.rd-sh-tgts .btn.sm.rd-tgt.is-on {
	color: var(--bg);
	background: var(--acc);
	border-color: var(--acc);
}

.rd-sh-tgts .btn.sm.rd-tgt::before,
.rd-sh-tgts .btn.sm.rd-tgt::after {
	content: none;
}

.rd-sh-kbd {
	margin-left: .6em;
	font-size: var(--fs-xs);
	opacity: .75;
}

.rd-tgt-f {
	color: var(--sub);
	font-size: var(--fs-xs);
}

.rd-tgt.is-on .rd-tgt-f {
	color: var(--bg);
}

.rd-sh-fc {
	padding: 6px 8px;
	border: 1px dashed var(--acc-line);
	font-size: var(--fs-s);
}

.rd-sh-fc .k {
	color: var(--acc);
	font-size: var(--fs-xs);
}

.rd-sh-fc ul {
	margin: 2px 0 0;
	padding-left: 1.2em;
}

.rd-sh-fc li {
	overflow-wrap: anywhere;
}

.rd-sh-fc li.is-breach {
	color: var(--fg-hi);
}

.rd-sh-note {
	margin-top: 3px !important;
	color: var(--sub);
	font-size: 10px;
}

.rd-sh-foot {
	flex: none;
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
	gap: 8px;
	padding: 8px 12px 10px;
	border-top: 1px solid var(--acc-line);
}

.rd-sh-foot .btn {
	min-height: 44px;
	min-width: 0;
	white-space: normal;
}

.rd-sh-run {
	color: var(--bg);
	background: var(--acc);
	border-color: var(--acc);
	font-size: var(--fs-l);
}

.rd-sh-run[aria-disabled="true"] {
	color: var(--sub);
	background: transparent;
	border-color: var(--line);
	cursor: not-allowed;
}

.rd-sh-x {
	color: var(--sub);
}

/* 選択中のプログラムのボタン */
.rd-prog.is-selected {
	border-color: var(--acc);
	background: rgba(111, 214, 232, .2);
	box-shadow: 0 0 0 1px var(--acc), inset 3px 0 0 var(--acc);
}

.rd-prog.is-selected .rd-ps {
	color: var(--acc-hi);
}

/* 選択中の対象の層 */
.rd-viewer .rp-layer.rd-cand-on {
	outline-style: solid;
	outline-width: 3px;
}

.rd-info {
	margin: 0;
	min-height: 2.6em;
	color: var(--fg);
	font-size: var(--fs-xs);
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.rd-info b {
	color: var(--acc-hi);
	font-weight: normal;
}

.rd-why {
	color: var(--warn);
}

/* 選択中は拡大表示に効果が出ているので、パネルの効果文は隠す(高さは保つ) */
.rd-panel.has-sel .rd-info {
	visibility: hidden;
}

.rd-info-tip {
	color: var(--sub);
}

/* 自動戦闘(A)と速度。ON の間はボタンを反転し、状態行に「自動戦闘中」 */
.rd-autobox {
	display: inline-flex;
	align-items: stretch;
	gap: 4px;
}

.rd-acts .rd-auto {
	min-height: 32px;
	letter-spacing: .04em;
}

.rd-acts .rd-auto.is-on {
	color: var(--bg);
	background: var(--acc);
	border-color: var(--acc);
}

.rd-acts .rd-auto-speed {
	color: var(--sub);
}

/* 序章を制圧するまでは閉じている(押すと条件を案内する。docs/raid-ui.md §10) */
.rd-acts .rd-auto.is-locked {
	color: var(--muted);
	border-style: dashed;
	cursor: help;
}

.rd-battle.is-auto .rd-turnmsg {
	color: var(--acc);
}

.rd-battle.is-auto .rd-turnmsg::before {
	content: "▶ ";
}

.rd-acts {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 12px;
	align-items: center;
}

.rd-acts .btn[aria-disabled="true"] {
	opacity: .5;
	cursor: not-allowed;
}

.rd-acts .rd-end.is-ready {
	color: var(--bg);
	background: var(--fg);
}

.rd-battle[data-busy="1"] .rd-prog,
.rd-battle[data-busy="1"] .rd-acts .btn {
	cursor: progress;
}

/* 狭い画面だけ: 状態行の安定度・逆探知・状態異常 */
.rd-st-mini {
	display: none;
	flex-wrap: wrap;
	gap: 2px 8px;
	color: var(--sub);
}

.rd-st-mini b {
	color: var(--fg);
	font-weight: normal;
}

.rd-st-mini .is-bad b {
	color: var(--alert-hi);
}

.rd-st-mini .rd-st-sts {
	color: var(--warn);
}

/* ============================================================ リザルト */

.rs-verdict {
	margin: 0 0 4px;
	font-size: var(--fs-m);
}

.rs-verdict b {
	color: var(--fg-hi);
	font-weight: normal;
	font-size: var(--fs-xl);
}

.rs.is-lose .rs-verdict b {
	color: var(--alert-hi);
}

.rs-vs {
	margin: 0;
	font-size: var(--fs-s);
	overflow-wrap: anywhere;
}

.rs-rec {
	margin: 6px 0 0;
	font-size: var(--fs-s);
}

.rs-rec .k {
	color: var(--sub);
}

.rs-reward {
	margin: 6px 0 0;
	font-size: var(--fs-s);
}

.rs-reward .k {
	color: var(--sub);
}

.rs-reward b {
	color: var(--acc-hi);
	font-weight: normal;
}

.rs-reward .rs-reward-cur .cur {
	vertical-align: -3px;
	margin-right: 2px;
}

.tg-reward .cur {
	vertical-align: -3px;
	margin-right: 2px;
}

.rs-rec b {
	color: var(--acc-hi);
	font-weight: normal;
}

.rs-h3 {
	margin: 16px 0 6px;
	color: var(--fg);
	font-size: var(--fs-m);
	font-weight: normal;
	border-bottom: 1px dotted var(--line);
}

.rs-table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--fs-s);
}

.rs-table caption {
	caption-side: bottom;
	padding-top: 4px;
	color: var(--sub);
	font-size: var(--fs-xs);
	text-align: left;
}

.rs-table th,
.rs-table td {
	padding: 3px 6px;
	border-bottom: 1px solid var(--line);
	text-align: left;
}

.rs-table th {
	color: var(--sub);
	font-weight: normal;
	font-size: var(--fs-xs);
}

.rs-table td.num,
.rs-table th.num {
	text-align: right;
}

.rs-card {
	color: var(--acc-hi);
}

.rs-reveal {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 4px;
	font-size: var(--fs-s);
}

.rs-L {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 8px;
	padding: 4px 8px;
	border: 1px solid var(--line);
	min-width: 0;
}

.rs-L.is-breached {
	border-color: var(--line);
	background: repeating-linear-gradient(-45deg, rgba(127, 221, 87, .05) 0 4px, transparent 4px 8px);
}

.rs-L.is-unknown {
	border-style: dashed;
	color: var(--sub);
}

.rs-L.is-core {
	border-color: var(--alert);
}

.rs-Ln {
	color: var(--muted);
}

.rs-q {
	color: var(--muted);
	letter-spacing: .1em;
}

.rs-pct {
	margin-left: auto;
	color: var(--sub);
	font-size: var(--fs-xs);
}

.rs-flag {
	color: var(--fg-hi);
	font-size: var(--fs-xs);
}

.rs-note {
	margin: 6px 0 0;
	font-size: var(--fs-xs);
}

.rs-buttons {
	justify-content: flex-start;
}

/* ============================================================ 狭い画面 */

@media (max-width: 759px) {
	.tg-facts { margin-left: 0; width: 100%; }
	.su-cols { grid-template-columns: minmax(0, 1fr); }
	.su-side { position: static; }
	/* 狭い画面: 一覧が長いので [ダイブ開始] [戻る] を画面の下に貼り付ける */
	.su-buttons { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 12px; background: var(--bg-1); border-top: 1px solid var(--line); }
	.raid-setup { padding-bottom: 64px; }
	/* 固定バーは .mainblock(position: relative; z-index: 10)の重なり文脈の中にあるので、後に来る .site-footer(同じ z-index: 10)の
	   下に潜る。狭い画面では .mainblock をフッターより1つ上にする(フッターと重なるのは固定のものだけ)。
	   一番下までスクロールしてもフッターの最後の行が固定バーに隠れないよう、バーの高さだけ下に余白を足す */
	.mainblock { z-index: 11; }
	body:has(.su-buttons) { padding-bottom: 60px; }
	/* 対戦中の狭い画面: 盤面を広く残すため、ビューアの見出し・音・速度の行を畳み、ボタンを1行にする */
	.rd-viewer .rp-head,
	.rd-viewer .rp-speeds { display: none; }
	/* 盤面を広く: 再生の操作ボタンの列は畳む(シークバー・←→ キーで巻き戻せる)。「今の手」は3行に */
	.rd-viewer .rp-transport { display: none; }
	.rd-viewer .rp-controls { padding: 4px 8px; gap: 4px 8px; }
	.rd-viewer .rp-caption { height: calc(3 * 1.4em + 6px); padding: 3px 8px; }
	/* 侵入者の HUD: 安定度・逆探知・状態異常だけの2〜3行に(ターン・演算力は下の操作パネルに出ている)。
	   盤面を今いる層まで送ると HUD は上に隠れるので、安定度・逆探知・状態は操作パネルの状態行にも出す(.rd-st-mini) */
	.rd-viewer .rp-hud { gap: 2px; padding: 4px 8px; }
	.rd-st-mini { display: inline-flex; }
	.rd-viewer .rp-who,
	.rd-viewer .rp-turn,
	.rd-viewer .rp-gauge.cpu { display: none; }
	.rd-viewer .rp-gauge { grid-template-columns: 5.6em minmax(0, 1fr) 4.2em; gap: 6px; font-size: var(--fs-xs); }
	.rd-viewer .rp-scroll { padding-top: 6px; }
	/* 操作パネル: 縦に積む(行が重ならないように)。プログラムは3列の1行ボタン */
	.rd-panel { display: flex; flex-direction: column; max-height: 46vh; max-height: 46dvh; padding: 6px 8px 8px; gap: 5px; }
	.rd-panel > * { flex: none; }
	.rd-status { gap: 2px 8px; font-size: var(--fs-xs); }
	.rd-progs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
	.rd-prog { min-height: 32px; grid-template-columns: 1.3em minmax(0, 1fr) auto; grid-template-rows: auto; column-gap: 3px; padding: 2px 4px; align-items: center; }
	.rd-prog .rd-key { grid-row: auto; }
	.rd-prog .rd-pn { font-size: var(--fs-xs); }
	.rd-prog .rd-pc { font-size: 10px; }
	.rd-prog .rd-ps { display: none; }
	.rd-prog.is-blocked { border-style: dashed; }
	.rd-prog.is-multi .rd-pc::after { content: " ◎"; color: var(--acc); }
	.rd-info { min-height: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
	.rd-acts { gap: 6px; }
	.rd-acts .btn { padding: 4px 8px; font-size: var(--fs-s); }
	.rd-acts .rd-end { flex: 1 1 auto; }
	/* 自動戦闘は親指で押しやすく(高さ 40px 以上)。狭い画面では行を占有する */
	.rd-autobox { flex: 1 1 100%; }
	.rd-acts .rd-auto { flex: 1 1 auto; min-height: 40px; font-size: var(--fs-m); }
	.rd-acts .rd-auto-speed { min-height: 40px; }
	/* 拡大表示: 操作パネルの上に画面幅のシートで出す。[実行]は下端の右(親指の位置)、高さ 44px 以上 */
	.rd-sheet { left: 0; right: 0; bottom: 0; width: auto; border-left: 0; border-right: 0; border-bottom: 0; }
	.rd-sh-head { padding: 6px 10px 5px; column-gap: 8px; }
	.rd-sh-name { font-size: var(--fs-l); }
	.rd-sh-hint { padding: 3px 10px; font-size: var(--fs-xs); }
	.rd-sh-body { padding: 6px 10px; gap: 5px; }
	.rd-sh-text { font-size: var(--fs-s); }
	.rd-sh-tgts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
	.rd-sh-tgts .btn.sm.rd-tgt { min-height: 40px; padding: 3px 6px; }
	.rd-sh-foot { padding: 6px 10px 8px; }
	.rd-sh-foot .btn { min-height: 48px; padding-left: 6px; padding-right: 6px; white-space: nowrap; }
	.rd-sh-kbd { display: none; }
	/* 選択中は拡大表示に効果が出ているので、パネルの効果文の行は畳む */
	.rd-panel.has-sel .rd-info { display: none; }
	.rs-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	.rs-buttons .btn { min-width: 0; padding-left: 4px; padding-right: 4px; font-size: var(--fs-s); white-space: normal; }
	.rd-seq { display: none; }
	.rd-turnmsg, .rd-wait { margin-left: 0; }
	.rs-table th:nth-child(7), .rs-table td:nth-child(7) { display: none; }
	.rs-table th, .rs-table td { padding: 3px 4px; }
}

/* 低い画面(狭い画面の横持ち・小型端末): 拡大表示の対象と見込みを優先し、フレーバーは畳む */
@media (max-width: 759px) and (max-height: 600px) {
	.rd-sh-flavor { display: none; }
	.rd-sh-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---- 狭い画面の上の帯と、操作パネルの畳む / 広げる(2026-11-12 制作者の指摘④。docs/raid-ui.md §2)
   上の帯 .rd-vitals: 相手の今の層(n/N層・耐久・盾・硬化)と自分(安定・逆探知・膜・状態)の2行。押すと盤面を今の層へ送る。
   操作パネル: 既定は畳んだ表示(.rd-battle:not(.is-wide))。プログラムは横に流す1列、効果文は出さず、操作は1行。
   「▴ 広げる」で今までの表示(3列・効果文・自動戦闘の行)。PC の幅では帯も畳むボタンも出さない(今までどおり) */
.rd-vitals,
.rd-fold { display: none; }

@media (max-width: 759px) {
	.rd-vitals {
		flex: none;
		display: grid;
		gap: 1px;
		width: 100%;
		margin: 0;
		padding: 3px 8px;
		color: var(--fg);
		background: var(--bg-1);
		border: 0;
		border-bottom: 1px solid var(--line-hi);
		font: inherit;
		font-size: var(--fs-xs);
		line-height: 1.35;
		text-align: left;
		cursor: pointer;
	}
	.rd-vt-row { display: flex; align-items: center; gap: 0 8px; min-width: 0; white-space: nowrap; overflow: hidden; }
	.rd-vt-k { flex: none; padding: 0 3px; color: var(--bg); background: var(--alert); font-size: 10px; }
	.rd-vt-row.is-me .rd-vt-k { background: var(--acc); }
	.rd-vt-pos b { color: var(--fg-hi); font-weight: normal; }
	.rd-vt-nm { color: var(--sub); }
	.rd-vt-pos { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
	.rd-vt-g { flex: none; display: inline-flex; align-items: center; gap: 3px; color: var(--sub); }
	.rd-vt-g b { color: var(--fg-hi); font-weight: normal; }
	.rd-vt-g.is-low b { color: var(--alert-hi); }
	.rd-vt-ok { flex: none; color: var(--acc-hi); }
	.rd-vt-sts { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--warn); }
	.rd-vt-bar { display: inline-block; width: 34px; height: 5px; border: 1px solid var(--line-hi); }
	.rd-vt-bar i { display: block; height: 100%; background: var(--fg); }
	.rd-vt-bar.is-int i { background: var(--alert); }
	.rd-vt-bar.is-trc i { background: var(--warn); }
	.rd-vt-bar.is-stb i { background: var(--acc); }
	.rd-vitals:focus-visible { outline: 1px dashed var(--fg-hi); outline-offset: -2px; }
	/* 帯に出しているので、操作パネルの状態行の小さい安定度・逆探知と現在地は出さない */
	.rd-status .rd-st-mini,
	.rd-status .rd-st-pos { display: none; }

	.rd-strow { display: flex; align-items: center; gap: 6px; min-width: 0; }
	.rd-strow .rd-status { flex: 1 1 auto; }
	.rd-fold { display: inline-block; flex: none; min-height: 30px; padding: 2px 10px; font-size: var(--fs-xs); white-space: nowrap; }

	/* 畳んだ表示(既定) */
	.rd-battle:not(.is-wide) .rd-panel { max-height: 34vh; max-height: 34dvh; gap: 4px; padding: 4px 8px calc(6px + max(env(safe-area-inset-bottom, 0px), var(--kb-sa-b, 0px))); }
	.rd-battle:not(.is-wide) .rd-progs {
		display: flex;
		flex-wrap: nowrap;
		gap: 4px;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x proximity;
		scrollbar-width: thin;
		padding-bottom: 2px;
	}
	.rd-battle:not(.is-wide) .rd-prog { flex: 0 0 auto; width: 8.6em; min-height: 36px; scroll-snap-align: start; }
	.rd-battle:not(.is-wide) .rd-info { display: none; }
	.rd-battle:not(.is-wide) .rd-acts { flex-wrap: nowrap; gap: 4px; }
	.rd-battle:not(.is-wide) .rd-acts .btn { min-height: 40px; padding: 2px 6px; }
	.rd-battle:not(.is-wide) .rd-acts .rd-end { flex: 1 1 auto; min-width: 0; white-space: normal; line-height: 1.15; }
	.rd-battle:not(.is-wide) .rd-end-k,
	.rd-battle:not(.is-wide) .rd-sp-k { display: none; }
	.rd-battle:not(.is-wide) .rd-end-c { display: block; font-size: 10px; color: inherit; opacity: .8; }
	.rd-battle:not(.is-wide) .rd-autobox { flex: 0 0 auto; display: flex; gap: 4px; }
	.rd-battle:not(.is-wide) .rd-acts .rd-auto { flex: 0 0 auto; min-height: 40px; font-size: var(--fs-s); }
	.rd-battle:not(.is-wide) .rd-acts .rd-auto-speed { min-height: 40px; }
	/* 広げた表示: 今までの表示。下端のセーフエリアだけ足す */
	.rd-battle.is-wide .rd-panel { padding-bottom: calc(8px + max(env(safe-area-inset-bottom, 0px), var(--kb-sa-b, 0px))); }
}

/* 低い PC の画面(高さ 700px 以下): 見出しの帯を畳み、操作パネルの効果文の1行も畳んで、相手の防壁の領域(層の列)を残す。
   こちら側の HUD は固定のまま(fx.css の「PC: こちら側(HUD)は固定」) */
@media (min-width: 760px) and (max-height: 700px) {
	.rd-viewer .rp-head { display: none; }
}

@media (min-width: 760px) and (max-height: 620px) {
	.rd-battle .rd-info { display: none; }
}

/* 低い画面: 広げた表示でも盤面がなるべく半分残るように */
@media (max-width: 759px) and (max-height: 600px) {
	.rd-battle.is-wide .rd-panel { max-height: 42vh; max-height: 42dvh; }
	.rd-battle:not(.is-wide) .rd-panel { max-height: 36vh; max-height: 36dvh; }
}
.rd-vt-cpu { display: none; }

/* とても低い画面(横持ち・高さ 420px 以下): 上の帯は1行に並べ、ターン・演算力も帯に出す。畳んだ操作パネルは
   状態行をやめて「プログラムの列 + 広げる」「操作の行」の2行にする(盤面を画面の半分以上残す) */
@media (max-width: 759px) and (max-height: 420px) {
	.rd-vitals { display: flex; gap: 0 14px; padding: 2px 8px; }
	.rd-vt-row { flex: 0 1 auto; }
	.rd-vt-cpu { display: inline-flex; }
	.rd-battle:not(.is-wide) .rd-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
	.rd-battle:not(.is-wide) .rd-strow { display: contents; }
	.rd-battle:not(.is-wide) .rd-status { display: none; }
	.rd-battle:not(.is-wide) .rd-fold { grid-column: 2; grid-row: 1; }
	.rd-battle:not(.is-wide) .rd-progs { grid-column: 1; grid-row: 1; }
	.rd-battle:not(.is-wide) .rd-panel > :not(.rd-strow):not(.rd-progs) { grid-column: 1 / -1; }
	.rd-battle:not(.is-wide) .rd-acts .btn { min-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
	.rd-tunnel i { animation: none; transform: scale(calc(1 - var(--k) * .15)); }
	.rd-intro { transition: none; }
}

/* ============================================================ サーバーの侵入状況(一覧の上) */

.raid-status .box-body {
	display: grid;
	gap: 6px;
}

.raid-status .rs-rec {
	margin: 0;
}

.raid-active .tg-warn {
	margin: 0;
}

.raid-active .buttons {
	justify-content: flex-start;
	margin-top: 8px;
}

/* 狭い画面ではナビ(資料室まで5項目)を括弧の中で折り返し、音のスイッチと重ならないようにする */
@media (max-width: 559px) {
	.page-hack .group { white-space: normal; }
}

/* 開幕の反応の再生中(raid/battle.js): 操作パネルの上の案内と [スキップ]。終わるまでパネルは押せない */
.rd-opening {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 4px 10px;
	border-top: 1px solid var(--warn);
	color: var(--warn);
	background: rgba(232, 193, 90, .08);
	font-size: var(--fs-s);
}

.rd-opening[hidden] { display: none; }
.rd-battle.is-opening .rd-panel { opacity: .55; }

/* 決着: 戦いの記録 #N へのリンク(docs/records-brief.md) */
.rs-record { margin: 0 0 10px; font-size: var(--fs-s); }
.rs-record .btn { margin-right: 4px; }
