:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e1e4eb;
  --text: #1c2130;
  --text-muted: #6b7280;
  --primary: #4c6fff;
  --primary-hover: #3d5ce0;
  --primary-soft: #eef1ff;
  --success: #1f9d55;
  --warn: #b5750a;
  --danger: #d64545;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --hexa-badge-bg: #e7ecff;
  --hexa-badge-fg: #3a52c8;
  --kishin-badge-bg: #ffe9ec;
  --kishin-badge-fg: #c8395a;
  --dragon-badge-bg: #eae3ff;
  --dragon-badge-fg: #5b3ec8;
  --limit-plus: #1f7a4d;
  --limit-minus: #c2410c;
}

* {
  box-sizing: border-box;
}

/* [hidden]属性は、同じ要素にdisplayを設定するクラス（.field-row等の
   display:flexなど）より本来優先されるべきだが、詳細度の関係で上書き
   されてしまうため、明示的に最優先で効かせる。 */
[hidden] {
  display: none !important;
}

body {
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

.app {
  max-width: min(96vw, 1440px);
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.app-header {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
}

/* ヘッダー右側のアイコンボタン群（テーマ切替）を横並びにする */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ライト/ダーク切り替えボタン（アイコンはJSで指定） */
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--primary);
  background: var(--surface-2);
}

/* 発動確率カードの「1人選択/全員」と「すべて/通常時/ドラ補正時」を横並びにする行 */
.segmented-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem 1.25rem;
  margin-bottom: 1.1rem;
}

.card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.battle-bar {
  margin-bottom: 1rem;
}

.battle-bar .field-row {
  margin-bottom: 0;
}

.tab-bar {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-grow {
  flex: 1 1 260px;
}

.field-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

select, input[type="text"] {
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

select:focus, input[type="text"]:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}

select#battle-select, select#player-select {
  width: 100%;
}

.btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: var(--border);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
}

.btn-small {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}

.status {
  margin: 0.3rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-wrap {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 0.3rem;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* セグメントコントロール */

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.segmented-option {
  position: relative;
  cursor: pointer;
}

.segmented-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-option span {
  display: block;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented-option input:checked + span {
  background: var(--primary);
  color: white;
}

/* 特性リスト編集 */

.trait-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 420px;
  overflow-y: auto;
}

.trait-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

.trait-row.dragging {
  opacity: 0.4;
}

.trait-row.drag-over {
  border-color: var(--primary);
}

.trait-row-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.trait-row-disabled .trait-name {
  opacity: 0.5;
}

.trait-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  user-select: none;
}

.trait-name {
  flex: 1;
  font-size: 0.88rem;
}

.trait-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}

.kind-badge {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
  vertical-align: middle;
}

.trait-settings-btn, .trait-remove-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  border-radius: 6px;
}

.trait-settings-btn:hover {
  background: var(--border);
  color: var(--text);
}

.trait-remove-btn:hover {
  background: #fbe4e4;
  color: var(--danger);
}

.trait-list .empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  background: none;
  border: none;
  padding: 0.4rem 0;
}

.trait-settings-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.trait-settings-panel .field-label {
  font-size: 0.72rem;
}

.trait-settings-panel select, .trait-settings-panel input[type="text"] {
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
}

.trait-settings-panel .checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.discover-panel, .action-skills-list-wrap {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.discover-list, .action-skills-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.discover-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
}

.discover-row:hover {
  background: var(--surface-2);
}

.action-skill-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
}

.action-skill-row:hover {
  background: var(--surface-2);
}

.action-skill-row .skill-name {
  flex: 1;
}

.action-skill-row .skill-count {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.action-skill-row .type-options {
  display: flex;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.action-skill-row .ap-cost-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.action-skill-row .ap-cost-field input {
  width: 4.5rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

/* モード選択（カテゴリ・サブラベル） */

#category-segmented {
  margin-top: 0.6rem;
}

.subs-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.subs-options {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

/* 第2軸（加算/減算など）は第1軸と同じ行に並べる。判定はANDで独立しているため、
   区切り線で別グループであることを示す。空のときは区切り線も出さない。 */
.subs-options-axis2:not(:empty) {
  padding-left: 0.8rem;
  border-left: 1px solid var(--border);
}

.sub-option {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* スキル一覧 */

.discover-row .skill-name {
  flex: 1;
}

.discover-row .skill-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* 結果ヘッダー（見出し + ダウンロードボタン） */

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

/* 見出しを持たずボタンだけの結果ヘッダー（分析タブ）は右寄せにする */
.result-header-btn-only {
  justify-content: flex-end;
}

/* result-header内にボタンが複数あるとき、まとめて1要素として右端に固める
   （.result-headerのspace-betweenは2要素想定のため、3要素だと中央に間延びする） */
.result-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* 結果の対象（バトル・モード）。画像ダウンロードの上に常に表示する */
.result-meta {
  margin: 0.4rem 0 0.6rem;
  font-size: 0.92rem;
}

.result-meta strong {
  font-weight: 600;
}

/* 個人結果のギルド内順位・MVPバッジ */
.rank-badge {
  display: inline-block;
  margin-right: 0.3rem;
  padding: 0 0.3rem;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.mvp-badge {
  padding: 0 0.3rem;
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
}

/* 対戦サマリーの見出し（勝敗＋対戦相手） */
.summary-head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin: 0 0 0.7rem;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border-left: 5px solid var(--border);
  background: var(--surface-2);
}
.summary-head.win { border-left-color: #2f9e58; }
.summary-head.lose { border-left-color: #d8524a; }
.summary-judge {
  font-size: 1.3rem;
  font-weight: 700;
}
.summary-head.win .summary-judge { color: #2f9e58; }
.summary-head.lose .summary-judge { color: #d8524a; }
.summary-vs { color: var(--text); font-size: 0.95rem; }
.summary-enemy { color: var(--text-muted); }

/* 統計: 公式データと未照合（ログ推定）の印 */
.est-mark {
  color: var(--text-muted);
  font-size: 0.8em;
  cursor: help;
}

/* 統計タブ: 前衛/後衛の表見出し */
.stats-section-title {
  margin: 1rem 0 0.4rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.stats-section-title:first-child {
  margin-top: 0;
}

/* 結果テーブル */

#result {
  font-size: 0.92rem;
  line-height: 1.6;
}

#result .warn {
  color: var(--warn);
}

#result .error {
  color: var(--danger);
}

table.prob-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

table.prob-table th, table.prob-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

table.prob-table th {
  background: var(--surface-2);
  font-size: 0.76rem;
  color: var(--text-muted);
}

table.prob-table td.prob-cell {
  font-weight: 700;
}

td.clickable, th.clickable {
  cursor: pointer;
}

td.clickable:hover {
  background: var(--primary-soft);
}

/* スキル名クリックで詳細ポップアップ */
.skill-name-clickable {
  cursor: pointer;
  text-decoration: underline dotted var(--text-muted);
  text-underline-offset: 2px;
}

.skill-name-clickable:hover {
  color: var(--primary);
  text-decoration-color: var(--primary);
}

.skill-detail-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.skill-detail-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.skill-detail-cat {
  font-size: 0.82rem;
}

.skill-detail-text {
  line-height: 1.7;
  white-space: pre-wrap;
}

/* 全員比較表: 縦横ともにコンテナ内スクロールにし、プレイヤー名（ヘッダー行）と
   スキル名（先頭列）を2方向とも固定する。 */
.matrix-scroll {
  overflow: auto;
  max-height: 72vh;
  border-radius: 8px;
}

table.matrix-table {
  white-space: nowrap;
  font-size: 0.82rem;
}

table.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
}

table.matrix-table thead th:first-child {
  left: 0;
  z-index: 3;
}

table.matrix-table th.player-col {
  min-width: 76px;
  max-width: 110px;
  text-align: center;
  white-space: normal;
}

table.matrix-table td.trait-name-cell {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  font-weight: 600;
  white-space: normal;
  min-width: 140px;
  max-width: 180px;
  font-size: 0.82rem;
}

table.matrix-table td.prob-cell {
  text-align: center;
}

.hit-count, .fired-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* 根拠ログ: 上限値操作特性のときだけ出る総量・平均のサマリー行 */
.log-limit-summary {
  margin: 0 0 0.7rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.85rem;
  font-weight: 600;
}

/* 統計タブ: 上限値統計。数値は右寄せで桁を比較しやすくする */

table.limit-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.limit-table td.trait-name-cell {
  text-align: left;
}

/* 2段ヘッダーの1段目（グループ見出し）。クリックで開閉するので中央寄せ＋区切り線 */
table.limit-table thead th.limit-group-head {
  text-align: center;
  border-left: 2px solid var(--border);
}

/* 2段ヘッダーなので、1段目のプレイヤー列（rowspan=2）だけを横方向にも固定する */
table.limit-table thead th.limit-name-head {
  position: sticky;
  left: 0;
  z-index: 3;
}

.limit-caret {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* 上限値統計の根拠ログ。基本は1行（左詰め）で、横幅に収まらないときだけ折り返す。
   折り返しは内訳(.limit-log-detail)の中だけで起き、日時・名前・合計の
   サマリー部(.limit-log-summary-row)の下には回り込まない。 */
.limit-log-header {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: 0.6rem;
}

.limit-log-summary-row {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  flex: 0 0 auto;
}

.limit-log-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.76rem;
}

.limit-log-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.limit-log-chip .limit-log-stat {
  font-weight: 600;
}

.limit-log-chip .limit-log-cause {
  color: var(--text-muted);
}

.limit-zero {
  color: var(--text-muted);
}

.limit-plus {
  color: var(--limit-plus);
}

.limit-minus {
  color: var(--limit-minus);
}

/* 能力別の内訳行はプレイヤー行より一段弱く見せる */
table.limit-table tr.limit-stat-row td {
  font-size: 0.76rem;
  background: var(--surface-2);
}

table.limit-table tr.limit-stat-row td.limit-stat-name {
  padding-left: 1.6rem;
  font-weight: 400;
  background: var(--surface-2);
}

/* 統計タブ: 対戦サマリーカード */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}

.summary-tile {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.summary-tile.win { border-left: 3px solid var(--success); }
.summary-tile.lose { border-left: 3px solid var(--danger); }

.summary-tile .summary-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.summary-tile .summary-value {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 0.15rem;
  /* BPは最大10^25級の巨大数になり得るのでタイル幅で折り返す（はみ出し防止）。 */
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

/* ヘキサ観測タブ */
table.hexa-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

table.hexa-table th, table.hexa-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

table.hexa-table th {
  background: var(--surface-2);
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}

table.hexa-table td.hexa-rate {
  white-space: nowrap;
}

/* 所持列: ヘキサ/鬼神バッジを縦積み・横幅統一（3文字の「ヘキサ」に合わせる） */
td.hexa-hold .hexa-trait-badge {
  display: block;
  width: 4.5em;
  text-align: center;
  margin: 0.15rem 0;
}

.hexa-rate-line {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0.1rem 0;
}

/* 平均発動率列のバッジも「ヘキサ」幅に統一して縦に揃える */
.hexa-rate-line .hexa-trait-badge {
  width: 4.5em;
  text-align: center;
}

.hexa-rate-val {
  font-weight: 700;
}

/* 観測明細列: 折りたたみ/展開しても列幅（＝行の横幅）が変わらないよう固定幅 */
table.hexa-table th.hexa-detail-col,
table.hexa-table td.hexa-detail-col {
  width: 24em;
  min-width: 24em;
}

.hexa-detail-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hexa-update-date {
  color: var(--text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.hexa-detail-toggle {
  white-space: nowrap;
}

.hexa-detail-body {
  margin-top: 0.35rem;
}

/* 観測明細は1観測1行（改行） */
.hexa-detail-item {
  padding: 0.05rem 0;
  white-space: nowrap;
}

.hexa-trait-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-right: 0.2rem;
  white-space: nowrap;
}
/* 色はCSS変数経由にする（:root[data-theme="dark"]の直接色指定だと、画像DL撮影用
   クローンへのCSS変数上書きだけでは効かず、実ページのdata-theme属性を一時的に
   書き換える必要が出てちらつきの原因になるため。変数化すればクローン側の
   インライン変数上書きだけで常にライト配色を再現できる）。 */
.hexa-trait-badge.hexa { background: var(--hexa-badge-bg); color: var(--hexa-badge-fg); }
.hexa-trait-badge.kishin { background: var(--kishin-badge-bg); color: var(--kishin-badge-fg); }
.hexa-trait-badge.not-possessed { background: var(--surface-2); color: var(--text-muted); }

/* ドラ観測: 使用ドラゴン（ドラブレ名）のバッジ。1名につき縦積み。 */
td.dragon-hold .dragon-name-badge {
  display: block;
  width: max-content;
  max-width: 12em;
  margin: 0.15rem 0;
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--dragon-badge-bg);
  color: var(--dragon-badge-fg);
  white-space: nowrap;
}

.hexa-obs-detail {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.hexa-current-unknown {
  color: var(--text-muted);
  font-style: italic;
}

/* 統計タブ: ドラブレ履歴 */

.dragon-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 420px;
  overflow-y: auto;
}

.dragon-history-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.85rem;
}

.dragon-history-row.ally { border-left: 3px solid var(--primary); }
.dragon-history-row.enemy { border-left: 3px solid var(--danger); }

/* 発動済みで発動時ログを開ける行 */
.dragon-history-row.dh-clickable { cursor: pointer; }
.dragon-history-row.dh-clickable:hover { background: var(--primary-soft); }

.dragon-history-row .dh-time {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.dragon-history-row .dh-main {
  flex: 1;
}

.dragon-history-row .dh-status {
  font-size: 0.78rem;
  white-space: nowrap;
}

.dragon-history-row .dh-status.fired { color: var(--success); }
.dragon-history-row .dh-status.unfired { color: var(--text-muted); }

table.prob-table tr.sub-row td {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.82rem;
}

table.prob-table tr.sub-row td.trait-name-cell {
  font-weight: 400;
  font-style: italic;
}

/* 画像ダウンロード用: 特性数が多い表で一定行数ごとに複製される見出し行 */
tr.repeated-header-row th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* モーダル（ログ詳細） */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 760px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.modal-body {
  /* 注意: display:flexにすると、モーダル内に多数(100件超)の.log-entryが
     並ぶ際にChromiumの入れ子flexレイアウトでテキストが描画されない不具合が
     発生したため、通常のブロックレイアウト+margin-bottomで積む。 */
  overflow-y: auto;
  padding: 0.75rem 1.25rem 1.25rem;
}

.log-entry {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.log-entry:last-child {
  margin-bottom: 0;
}

.log-entry-fired {
  border-color: #b7e6c5;
}

.log-entry-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  font-size: 0.82rem;
}

.log-entry-fired .log-entry-header {
  background: #e8f8ee;
}

.log-entry-toggle {
  color: var(--text-muted);
  font-size: 0.75rem;
  width: 0.9rem;
}

.log-entry-timestamp {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.log-entry-actor {
  color: #7a3fd6;
  font-weight: 600;
  flex: 1;
}

.log-entry-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.log-entry-fired .log-entry-badge {
  color: var(--success);
}

.log-entry-body {
  padding: 0.55rem 0.75rem 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.55;
  background: var(--surface);
  color: var(--text);
}

.log-line {
  padding: 0.05rem 0;
}

/* 対象特性の発動行のハイライト（ライト。ダークは下で上書き）。 */
.log-line-match {
  background: #ffe9a6;
  color: #4a3500;
  border-radius: 4px;
  padding: 0.15rem 0.3rem;
  font-weight: 700;
}

.skill-usage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.skill-usage-row:hover {
  border-color: #7a3fd6;
}

.skill-usage-count {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.log-back-btn {
  display: inline-block;
  margin-bottom: 0.6rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
}

.log-back-btn:hover {
  border-color: #7a3fd6;
}

:root[data-theme="dark"] {
  --bg: #14161c;
  --surface: #1c1f28;
  --surface-2: #262a35;
  --border: #333846;
  --text: #e7e9ee;
  --text-muted: #9aa1b0;
  --primary: #7c93ff;
  --primary-hover: #93a5ff;
  --primary-soft: #2a2f56;
  --success: #4fd17c;
  --warn: #e0a638;
  --danger: #f0716f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  --hexa-badge-bg: #26305a;
  --hexa-badge-fg: #aab8ff;
  --kishin-badge-bg: #4a2330;
  --kishin-badge-fg: #ff9fb2;
  --dragon-badge-bg: #33285a;
  --dragon-badge-fg: #c3b0ff;
  --limit-plus: #5ad195;
  --limit-minus: #ff9a6b;
}

:root[data-theme="dark"] .log-entry-fired {
  border-color: #235c3d;
}

:root[data-theme="dark"] .log-entry-fired .log-entry-header {
  background: #163326;
}

:root[data-theme="dark"] .log-line-match {
  background: #6b5417;
  color: #ffe9b0;
}

:root[data-theme="dark"] .log-entry-actor {
  color: #c9a3ff;
}

:root[data-theme="dark"] .trait-remove-btn:hover {
  background: #4a2323;
}

@media (max-width: 560px) {
  .app {
    padding: 1rem 0.6rem 3rem;
  }
  .card {
    padding: 0.9rem;
  }
}

/* 特性スキル選択のツールバー（発動実績フィルタ + 一括選択/解除 + 件数） */
.skill-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.8rem 0 0.6rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
}

.skill-toolbar .checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  cursor: pointer;
  white-space: nowrap;
}

.skill-toolbar .toolbar-spacer {
  flex: 1 1 auto;
}

.skill-toolbar .hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 選択リストのスキル名: クリックで説明ポップアップ */
.trait-name-clickable {
  cursor: pointer;
  text-decoration: underline dotted var(--text-muted);
  text-underline-offset: 3px;
}

.trait-name-clickable:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ドラ観測: 竜名/ドラブレ名クリックで出す効果ポップアップ */
.dragon-effect-link {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.dragon-effect-block + .dragon-effect-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.dragon-effect-block h4 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.dragon-effect-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.dragon-effect-tag {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.dragon-effect-text {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.7;
}

/* 未選択時の案内カード（統計タブなど、対象バトルが決まるまで中身を出さない画面用） */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1.25rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.9rem;
}

/* 合言葉ログイン画面（templates/login.html） */
.login-app {
  max-width: 26rem;
  padding-top: 12vh;
}

.login-app h1 {
  font-size: 1.15rem;
  margin: 0 0 0.4rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.login-error {
  color: var(--danger);
}
