:root {
  --ink: #132a3a;
  --ink-soft: #526875;
  --paper: #f4f1e8;
  --surface: #fffdf7;
  --surface-2: #e9eef0;
  --line: #ccd6d8;
  --navy: #123b52;
  --navy-2: #0b2b3f;
  --cyan: #2aa7b6;
  --cyan-soft: #d8f0f1;
  --gold: #e1a22a;
  --fire: #d75c3f;
  --water: #278ab7;
  --wind: #4b9a66;
  --shadow: 0 20px 60px rgba(18, 59, 82, 0.12);
  --radius: 16px;
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  /* ホーム画面から起動したとき、OS管理領域が白く抜けてもヘッダー色でつなぐ */
  background: var(--navy-2);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(rgba(18, 59, 82, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 59, 82, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1440px, 100%); min-height: 100dvh; margin: 0 auto; background: var(--paper); }

.site-header {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(22px, 5vw, 72px);
  color: #fff;
  background:
    radial-gradient(circle at 85% 20%, rgba(42, 167, 182, 0.35), transparent 24%),
    linear-gradient(115deg, var(--navy-2), var(--navy));
  border-bottom: 4px solid var(--gold);
}

.brand-lockup { display: flex; align-items: center; gap: 15px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 34px;
  font-weight: 800;
  transform: rotate(-3deg);
}

.eyebrow, .section-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}
.eyebrow { color: #b9d9df; }
.site-header h1 { margin: 0; font: 700 clamp(23px, 3vw, 34px)/1.1 Georgia, "Yu Mincho", serif; }
.prototype-badge {
  padding: 7px 11px;
  color: #f8d381;
  border: 1px solid rgba(248, 211, 129, 0.55);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

/* ---------------------------------------------------------------------------
   画面下のタブ。スマホで親指が届く位置に置くため上部ではなくここに固定する。
   --------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* iPhoneのホームインジケータぶんを足す。足さないと最下部が指で押しにくい */
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--navy-2);
  border-top: 3px solid var(--gold);
  box-shadow: 0 -8px 28px rgba(11, 43, 63, .25);
}
.nav-item {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 58px;
  padding: 7px 4px;
  color: #7fa3b3;
  background: transparent;
  border: 0;
  transition: color 140ms ease;
}
.nav-item.is-active { color: #fff; }
/* 選択中の目印。文字色だけだと暗い背景で差が分かりにくい */
.nav-item.is-active::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 44px;
  height: 3px;
  background: var(--cyan);
  transform: translateX(-50%);
}
.nav-icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { font-size: 11px; font-weight: 800; letter-spacing: .02em; }
@media (prefers-reduced-motion: reduce) { .nav-item { transition: none; } }

/* 下タブに隠れないよう、本文の下に逃がす */
.tab-panel { padding: clamp(28px, 5vw, 64px) clamp(18px, 5vw, 72px) calc(88px + env(safe-area-inset-bottom)); }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.section-kicker { color: var(--cyan); }
.panel-heading h2 { margin: 0 0 8px; font: 700 clamp(27px, 4vw, 42px)/1.15 Georgia, "Yu Mincho", serif; }
.panel-heading p { max-width: 760px; margin: 0; color: var(--ink-soft); line-height: 1.8; }
.selection-meter { text-align: right; color: var(--navy); }
.selection-meter strong { display: block; font: 800 40px/1 Georgia, serif; }
.selection-meter span { font-size: 10px; font-weight: 800; letter-spacing: 0.15em; color: var(--ink-soft); }

.intent-grid label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfcacc;
  border-radius: 8px;
  outline: none;
}
select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(42, 167, 182, 0.13); }

/* ---------------------------------------------------------------------------
   キャラ一覧。スマホ基準で組み、広い画面では列を増やすだけにする。
   SRは37体しかないので絞り込みは置かず、全件をタップで選ぶ。
   カードは「顔が見分けられる最小」に寄せてあり、以前の 155x225px から
   スマホで4列並ぶ大きさまで落としてある。
   --------------------------------------------------------------------------- */
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.character-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  gap: 5px;
  width: 100%;
  padding: 5px 5px 7px;
  text-align: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(18, 59, 82, 0.05);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
  /* 属性は文字を置かず、この色で示す（下の ::before と枠に使う） */
  --attr: var(--line);
}
.character-card[data-attr="火"] { --attr: var(--fire); }
.character-card[data-attr="水"] { --attr: var(--water); }
.character-card[data-attr="風"] { --attr: var(--wind); }

/* カード全体は選択ボタン。Lvバッジだけ別のボタンとして上に重ねる */
.character-pick {
  display: grid;
  grid-template-rows: auto auto;
  gap: 5px;
  width: 100%;
  padding: 0;
  text-align: center;
  color: inherit;
  background: none;
  border: 0;
}
.character-art {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 1;
  background: linear-gradient(145deg, #dce9eb, #bfcfd3);
  border-radius: 7px;
  /* 属性色の細い縁。選択していなくても属性が一目で分かる */
  box-shadow: inset 0 0 0 2px var(--attr);
}
.character-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.character-fallback { display: grid; place-items: center; height: 100%; color: rgba(18,59,82,.35); font: 700 28px Georgia, serif; }

/* Lv・凸を開くボタン。指で押せる高さ（24px＋周囲の余白）を確保する */
.level-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 5px;
  color: #fff;
  background: rgba(11, 43, 63, .86);
  border: 0;
  border-radius: 5px;
  font: 800 10px/1.6 system-ui, sans-serif;
}
/* 見た目は小さいままタップ領域だけ広げる（実寸 31x20 では指で押しづらい） */
.level-chip::before { content: ""; position: absolute; inset: -9px -8px -12px; }
.level-chip i { font-style: normal; color: var(--gold); }
.level-chip:active { background: var(--cyan); }
@media (hover: hover) { .level-chip:hover { background: var(--cyan); } }

.character-info { display: block; min-width: 0; }
.character-info strong {
  display: block;
  font-size: 11px;
  line-height: 1.25;
  /* 名前は最長でも6字程度。溢れたら省略してカードの高さを揃える */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.character-meta {
  display: block;
  margin-top: 1px;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 未選択は沈ませ、選択中を前に出す。37件のうち手持ちだけを目で追えるように */
.character-card:not(.is-selected) { background: #f1f0ea; }
.character-card:not(.is-selected) .character-pick { opacity: .45; }
.character-card.is-selected { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(42, 167, 182, .18); }
.character-card.is-selected::after {
  content: "✓";
  position: absolute;
  /* 右上はLvバッジが使うので左に置く */
  top: -5px;
  left: -5px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #fff;
  background: var(--cyan);
  border: 2px solid var(--surface);
  border-radius: 50%;
  font: 900 10px/1 system-ui, sans-serif;
}
.character-card:active { transform: scale(.96); }

@media (hover: hover) {
  .character-card:hover { border-color: var(--cyan); box-shadow: 0 4px 14px rgba(18, 59, 82, .12); }
}
@media (prefers-reduced-motion: reduce) {
  .character-card { transition: none; }
  .character-card:active { transform: none; }
}

/* 画面が広いときだけカードを大きくする。狭いほうを既定にしてある */
@media (min-width: 700px) {
  .character-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 11px; }
  .character-info strong { font-size: 12px; }
  .character-meta { font-size: 10px; }
  .level-chip { font-size: 10px; }
}

/* Safariとホーム画面アプリの保存領域は別なので、最下部に小さな引き継ぎ欄を置く。 */
.data-transfer {
  margin-top: 24px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .5);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.data-transfer summary {
  padding: 11px 13px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.data-transfer-body { padding: 0 13px 13px; }
.data-transfer-body > p:first-child { margin: 0 0 12px; font-size: 10px; line-height: 1.6; }
.transfer-label { display: block; margin-top: 10px; font-size: 10px; font-weight: 800; }
.transfer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-top: 5px; }
.transfer-row input {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfcacc;
  border-radius: 7px;
  outline: none;
  font: 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.transfer-row input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(42, 167, 182, .13); }
.transfer-button {
  min-width: 62px;
  height: 40px;
  padding: 0 12px;
  color: var(--navy);
  background: var(--cyan-soft);
  border: 1px solid #a8d8dc;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 900;
}
.transfer-restore { color: #fff; background: var(--cyan); border-color: var(--cyan); }
.transfer-status { min-height: 1.4em; margin: 8px 0 0; font-size: 10px; font-weight: 800; }
.transfer-status[data-state="success"] { color: #277447; }
.transfer-status[data-state="error"] { color: #a13e2b; }

.primary-button, .analyze-button {
  border: 0;
  color: #fff;
  background: var(--cyan);
  border-radius: 9px;
  font-weight: 900;
}
.primary-button { min-height: 46px; padding: 0 19px; }
.primary-button:hover, .analyze-button:hover { background: #218e9c; }

.owned-warning { margin: 0 0 16px; padding: 12px 14px; color: #7a3b20; background: #fff0df; border: 1px solid #efcfaa; border-left: 4px solid var(--fire); font-size: 13px; font-weight: 800; line-height: 1.55; }
.owned-warning[hidden] { display: none; }
.intent-card { padding: clamp(20px, 3vw, 32px); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--cyan); box-shadow: var(--shadow); }
.intent-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.intent-title-row > div { display: flex; align-items: center; gap: 12px; }
.step-chip { padding: 6px 8px; color: var(--cyan); background: var(--cyan-soft); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.intent-title-row h3 { margin: 0; font: 700 22px Georgia, "Yu Mincho", serif; }
.intent-title-row p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.build-requirement { margin: -10px 0 18px; padding: 9px 11px; color: var(--ink-soft); background: #f2f5f4; border-left: 3px solid #aebec1; font-size: 12px; font-weight: 800; line-height: 1.55; }
.build-requirement.is-unmet { color: #7a3b20; background: #fff0df; border-left-color: var(--fire); }
.intent-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.threat-details { margin: 24px 0 12px; padding-top: 20px; border-top: 1px solid var(--line); }
.threat-summary { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--navy); font: 700 16px Georgia, "Yu Mincho", serif; cursor: pointer; list-style: none; }
.threat-summary::-webkit-details-marker { display: none; }
.threat-summary::after { content: "▸"; margin-left: auto; color: var(--ink-soft); font-size: 12px; transition: transform 140ms ease; }
.threat-details[open] > .threat-summary::after { transform: rotate(90deg); }
.threat-details .threat-grid { margin-top: 12px; }
.threat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.analyze-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 58px; margin-top: 22px; padding: 0 22px; }
.analyze-button small { opacity: .72; font-size: 9px; letter-spacing: .14em; }
.analyze-button:disabled { cursor: not-allowed; opacity: .52; }
.form-error { margin: 14px 0 0; padding: 10px 12px; color: #8a2e20; background: #fae2dc; border-left: 3px solid var(--fire); font-size: 13px; }

.empty-result { margin-top: 26px; padding: 70px 24px; text-align: center; color: var(--ink-soft); border: 1px dashed #b7c5c8; background: rgba(255,255,255,.36); }
.empty-glyph { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 18px; color: var(--cyan); border: 2px solid var(--cyan); border-radius: 50%; }
.empty-glyph svg { width: 42px; height: 42px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.empty-result h3 { margin: 0 0 8px; color: var(--ink); }
.empty-result p { max-width: 600px; margin: 0 auto; line-height: 1.8; }

/* ジョブ×属性を指定しない探索の順位表 */
.exploration-summary {
  margin-top: 28px;
  padding: clamp(18px, 3vw, 28px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  box-shadow: 0 10px 30px rgba(18, 59, 82, .07);
}
.combo-lead { margin: 0 0 14px; color: var(--ink-soft); font-size: 13px; line-height: 1.7; }
.combo-lead strong { color: var(--navy); }
.combo-list { display: grid; gap: 5px; }
.combo-row {
  display: grid;
  grid-template-columns: 26px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #f3f6f5;
  border-radius: 8px;
  font-size: 13px;
}
.combo-row.is-top { background: var(--cyan-soft); box-shadow: inset 0 0 0 1px var(--cyan); }
.combo-rank { color: var(--ink-soft); font: 800 13px/1 Georgia, serif; text-align: center; }
.combo-name { font-weight: 800; color: var(--navy); }
.combo-scenario { color: var(--ink-soft); font-size: 11px; }
.combo-score { min-width: 48px; text-align: right; font: 800 15px/1 Georgia, serif; color: var(--navy); }
.combo-skip { margin: 14px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.7; }
.combo-skip small { color: #93a2a9; }

.result-shell { margin-top: 28px; }
.caveat { margin: 12px 0 0; padding: 10px 13px; color: #6f5a27; background: #fff0c9; border-left: 3px solid var(--gold); font-size: 12px; line-height: 1.6; }
.evaluation-evidence, .experience-budget { margin: 10px 0 0; padding: 10px 13px; color: var(--navy); background: #eaf5f5; border-left: 3px solid var(--cyan); font-size: 11px; line-height: 1.6; }
.experience-budget span { display: block; color: var(--ink-soft); }
.result-warnings { margin-top: 14px; padding: 10px 13px; color: #6f5a27; background: #fff8e7; border: 1px solid #ead7a4; font-size: 10px; line-height: 1.55; }
.result-warnings p { margin: 3px 0; }

.result-block { margin-top: 20px; padding: clamp(20px, 3vw, 30px); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(18,59,82,.07); }
.result-shell > .result-block:first-child { margin-top: 0; }
.result-block-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.result-block-title h3 { margin: 0; font: 700 21px Georgia, "Yu Mincho", serif; }
.result-block-title span { color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.scenario-bars { display: grid; gap: 12px; }
.scenario-bar-row { display: grid; grid-template-columns: minmax(155px, 230px) 1fr 50px; align-items: center; gap: 12px; font-size: 12px; font-weight: 800; }
.scenario-bar { height: 8px; overflow: hidden; background: #dfe7e7; border-radius: 9px; }
.scenario-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), #5ec5cc); border-radius: inherit; }

.candidate-groups { display: grid; gap: 24px; }
.candidate-group-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.candidate-group-title h4 { margin: 0; color: var(--navy); font-size: 15px; }
.candidate-group-title span { color: var(--ink-soft); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.candidate-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.candidate-card { display: grid; grid-template-columns: minmax(90px, .5fr) minmax(120px, .7fr) auto; align-items: center; gap: 12px; min-width: 0; padding: 10px 14px; text-align: left; color: var(--ink); background: #f2f5f4; border: 1px solid var(--line); border-radius: 9px; transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease; }
.candidate-card:hover { transform: translateY(-2px); border-color: var(--cyan); }
.candidate-card.is-active { color: #fff; background: var(--navy); border-color: var(--navy); box-shadow: 0 8px 22px rgba(18,59,82,.2); }
.candidate-rank { color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .07em; }
.candidate-card.is-active .candidate-rank { color: #73d4dd; }
.candidate-score-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.candidate-score-row > strong { font: 800 23px/1 Georgia, serif; }
.candidate-score-row small { overflow: hidden; color: var(--ink-soft); font-size: 8px; line-height: 1.3; text-align: right; white-space: nowrap; text-overflow: ellipsis; }
.candidate-card.is-active small { color: #c2d5da; }
.candidate-icons { display: flex; align-items: center; justify-self: end; padding-left: 4px; }
.candidate-icon { position: relative; width: 24px; height: 24px; overflow: hidden; margin-left: -5px; color: var(--navy); background: #dce7e8; border: 2px solid #f2f5f4; border-radius: 50%; font-size: 9px; font-weight: 900; line-height: 20px; text-align: center; }
.candidate-icon:first-child { margin-left: 0; }
.candidate-card.is-active .candidate-icon { border-color: var(--navy); }
.candidate-icon img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

#candidate-detail { scroll-margin-top: 18px; }
.selected-candidate-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; padding: 24px 28px; color: #fff; background: var(--navy-2); border-left: 5px solid var(--cyan); }
.selected-candidate-head h3 { margin: 3px 0 4px; font: 700 25px Georgia, "Yu Mincho", serif; }
.selected-candidate-head p { margin: 0; color: #bcd1d7; font-size: 11px; }
.selected-candidate-head .selected-build-target { display: inline-block; margin-bottom: 5px; padding: 5px 8px; color: #08384c; background: #79d3dc; border-radius: 5px; font-size: 12px; font-weight: 900; }
.selected-score { text-align: right; }
.selected-score strong { display: block; color: #f3c866; font: 800 38px/1 Georgia, serif; }
.selected-score span { color: #bcd1d7; font-size: 10px; }
.candidate-tradeoff { margin: 0; padding: 11px 16px; color: var(--navy); background: #eaf5f5; border: 1px solid #cce2e3; border-top: 0; font-size: 11px; font-weight: 700; }
.score-breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; padding: 8px; background: #edf2f1; border: 1px solid var(--line); }
.score-part { display: flex; align-items: center; justify-content: space-between; gap: 5px; min-width: 0; padding: 7px 9px; background: #fff; border-radius: 6px; }
.score-part span { overflow: hidden; color: var(--ink-soft); font-size: 8px; font-weight: 800; white-space: nowrap; text-overflow: ellipsis; }
.score-part strong { color: var(--navy); font: 700 14px Georgia, serif; }

.deck-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; width: 100%; max-width: 600px; }
.deck-member { min-width: 0; overflow: hidden; background: #eff3f2; border: 1px solid var(--line); border-radius: 8px; }
.deck-member-art { width: 100%; height: auto; aspect-ratio: 1; background: #dce7e8; }
.deck-member-art img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.deck-member-body { padding: 7px; }
.deck-member-body strong { display: block; margin-bottom: 3px; overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.deck-member-body p { display: -webkit-box; min-height: 22px; margin: 0; overflow: hidden; color: var(--ink-soft); font-size: 8px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.equip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.equip-card { padding: 18px; background: #eef4f3; border-left: 4px solid var(--cyan); }
.equip-card .kind { color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.equip-card h4 { margin: 5px 0 4px; font-size: 17px; }
.equip-card .owner { color: var(--ink-soft); font-size: 11px; }
.equip-card p { margin: 12px 0 0; font-size: 12px; line-height: 1.65; }

.skill-columns { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(420px, 1.2fr); gap: 18px; align-items: start; }
.skill-panel { padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.skill-panel-gold { background: #fffaf0; border-top: 4px solid var(--gold); }
.skill-panel-blue { background: #f1f9f9; border-top: 4px solid var(--cyan); }
.skill-list { margin: 0; padding: 0; list-style: none; counter-reset: skill; }
.skill-list li { counter-increment: skill; display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 11px 0; border-top: 1px solid #dde4e4; }
.skill-list li::before { content: counter(skill, decimal-leading-zero); color: var(--cyan); font: italic 700 12px Georgia, serif; }
.skill-list strong { display: block; margin-bottom: 3px; font-size: 13px; }
.skill-list p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.skill-name-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.skill-name-row > strong { min-width: 0; }
.skill-group-chip { flex: 0 0 auto; padding: 3px 6px; color: #73551b; background: #fff0c9; border-radius: 4px; font-size: 8px; font-weight: 900; }
.skill-list .skill-reason { margin-top: 5px; color: #314f60; }
.skill-researching { display: inline-block; margin-top: 4px; padding: 3px 6px; color: #73551b; background: #fff0c9; border-radius: 4px; font-size: 9px; font-weight: 800; }
.blue-priority-section + .blue-priority-section { margin-top: 14px; padding-top: 12px; border-top: 2px solid #d9e5e6; }
.blue-priority-section h5 { margin: 0; color: #173f50; font-size: 12px; }
.blue-priority-description { margin: 3px 0 7px; color: var(--ink-soft); font-size: 9px; line-height: 1.45; }
.skill-list .skill-alternative { margin-top: 5px; padding: 6px 8px; color: #6f5a27; background: #fff7e2; border-left: 2px solid var(--gold); font-size: 9px; }
.skill-list .skill-alternative strong { display: inline; font-size: inherit; }
.skill-section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--navy); font: 700 18px Georgia, "Yu Mincho", serif; }
.skill-section-title span { padding: 3px 6px; color: #fff; background: var(--navy); border-radius: 4px; font: 900 8px/1.2 Arial, sans-serif; letter-spacing: .1em; }
.skill-panel-gold .skill-section-title span { color: #5a4216; background: #f1c75b; }
.skill-panel-blue .skill-section-title span { background: var(--cyan); }
.empty-skill { padding: 20px; color: var(--ink-soft); background: #eef2f1; font-size: 12px; }
.blue-plan { display: grid; gap: 14px; }
.blue-plan-note { display: grid; gap: 4px; padding: 12px 14px; color: var(--navy); background: #e8f5f5; border: 1px solid #c7e3e5; }
.blue-plan-note strong { font-size: 11px; }
.blue-plan-note span { color: var(--ink-soft); font-size: 10px; line-height: 1.55; }
.blue-plan-section { padding: 14px 16px; background: #f7f8f5; border: 1px solid #d8e0df; border-radius: 9px; }
.blue-plan-section.is-extra { background: #f1f2ef; }
.blue-plan-title { display: flex; gap: 10px; margin-bottom: 6px; }
.blue-plan-title > span { color: var(--cyan); font: italic 800 12px Georgia, serif; }
.blue-plan-title h5 { margin: 0; color: var(--navy); font-size: 13px; }
.blue-plan-title p { margin: 3px 0 0; color: var(--ink-soft); font-size: 9px; line-height: 1.5; }
.blue-conditional-note { padding: 12px; color: var(--ink-soft); background: #fff; border: 1px dashed #b9c8ca; font-size: 10px; line-height: 1.65; }

@media (max-width: 980px) {
  .intent-grid { grid-template-columns: 1fr 1fr; }
  .threat-grid { grid-template-columns: repeat(2, 1fr); }
  .score-breakdown { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .site-header { min-height: 92px; }
  .prototype-badge, .selection-meter { display: none; }
  .panel-heading { display: block; }

  /* スマホでは見出しが最初の一画面の1/3を占めていた。カードを先に見せる */
  .tab-panel { padding-top: 18px; padding-bottom: 96px; }
  .panel-heading { margin-bottom: 14px; }
  .panel-heading h2 { font-size: 22px; }
  .panel-heading p { font-size: 12px; line-height: 1.6; }
  .section-kicker { font-size: 9px; }
  .intent-grid, .threat-grid, .equip-grid, .skill-columns { grid-template-columns: 1fr; }
  /* キャラ一覧はスマホ基準で組んであるので、ここで上書きしない
     （以前は2列・高さ210pxを強制していて、基準側を縮めても効かなかった） */
  .candidate-card { grid-template-columns: 72px minmax(70px, 1fr) auto; gap: 8px; padding: 9px 10px; }
  .candidate-icon { width: 20px; height: 20px; margin-left: -4px; border-width: 1px; line-height: 18px; }
  .deck-member-body { padding: 4px; }
  .deck-member-body strong { font-size: 9px; }
  .deck-member-body p { display: none; }
  .score-breakdown { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .selected-candidate-head { align-items: flex-start; }
  .scenario-bar-row { grid-template-columns: 125px 1fr 42px; gap: 8px; font-size: 10px; }
  .analyze-button small { display: none; }
}

/* ---------------------------------------------------------------------------
   Lv・凸の編集シート。カードが小さいので直接は編集せず、下から出す。
   --------------------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(11, 43, 63, .45);
  backdrop-filter: blur(2px);
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  width: min(460px, 100%);
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 4px solid var(--gold);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 50px rgba(11, 43, 63, .3);
  animation: sheet-in 200ms cubic-bezier(.22, 1, .36, 1);
}
@keyframes sheet-in { from { transform: translateY(14px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.sheet-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-head h3 { margin: 0; font: 700 21px/1.2 Georgia, "Yu Mincho", serif; }
.sheet-close {
  flex: none;
  width: 34px; height: 34px;
  color: var(--ink-soft);
  background: #eef2f1;
  border: 0;
  border-radius: 50%;
  font-size: 13px;
}

.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.stepper-label { display: grid; color: var(--navy); font-size: 15px; font-weight: 800; }
.stepper-label small { color: var(--ink-soft); font-size: 10px; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 44px; height: 44px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 19px;
  font-weight: 800;
}
.stepper button:active { background: var(--cyan-soft); border-color: var(--cyan); }
.stepper output {
  min-width: 56px;
  text-align: center;
  font: 800 22px/1 Georgia, serif;
  color: var(--navy);
}

#sheet-level-range { width: 100%; margin: 4px 0 14px; accent-color: var(--cyan); }
.sheet-note { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.7; }

/* 全画面から開ける匿名フィードバック。下タブの少し上に小さく固定する。 */
.feedback-open {
  position: fixed;
  right: 14px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 25;
  min-height: 36px;
  padding: 0 13px;
  color: var(--navy);
  background: rgba(255, 253, 247, .94);
  border: 1px solid #aac6ca;
  border-radius: 999px;
  box-shadow: 0 5px 18px rgba(11, 43, 63, .16);
  font-size: 10px;
  font-weight: 900;
}
.feedback-sheet { border-top-color: var(--cyan); }
.feedback-label { display: grid; gap: 6px; margin-top: 13px; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.feedback-label:first-child { margin-top: 0; }
.feedback-label textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfcacc;
  border-radius: 8px;
  outline: none;
  font: inherit;
  line-height: 1.6;
}
.feedback-label textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(42, 167, 182, .13); }
.feedback-context-option { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--ink-soft); font-size: 11px; }
.feedback-context-option input { width: 17px; height: 17px; accent-color: var(--cyan); }
.feedback-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.feedback-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  color: #fff;
  background: var(--cyan);
  border: 0;
  border-radius: 9px;
  font-weight: 900;
}
.feedback-submit:disabled { cursor: wait; opacity: .55; }
.feedback-note { margin: 9px 0 0; color: var(--ink-soft); text-align: center; font-size: 9px; }
.feedback-status { min-height: 1.5em; margin: 8px 0 0; text-align: center; font-size: 11px; font-weight: 800; }
.feedback-status[data-state="success"] { color: #277447; }
.feedback-status[data-state="error"] { color: #a13e2b; }

/* ---------------------------------------------------------------------------
   スマホ横画面。
   横幅ではなく「横向きかつ高さが低い」を条件にし、タブレットやPCの
   通常レイアウトを巻き込まない。縦方向を使う下部ナビは右側へ逃がす。
   --------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  body { min-width: 0; }

  .site-header {
    min-height: 60px;
    padding: max(8px, env(safe-area-inset-top)) calc(76px + env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  }
  .brand-lockup { gap: 9px; }
  .brand-mark { width: 38px; height: 38px; font-size: 24px; }
  .eyebrow, .prototype-badge { display: none; }
  .site-header h1 { font-size: 20px; }

  .bottom-nav {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: calc(64px + env(safe-area-inset-right));
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
    border-top: 0;
    border-left: 3px solid var(--gold);
    box-shadow: -8px 0 28px rgba(11, 43, 63, .25);
  }
  .nav-item { min-height: 0; padding: 5px 3px; }
  .nav-item.is-active::before {
    top: 50%;
    left: -3px;
    width: 3px;
    height: 40px;
    transform: translateY(-50%);
  }
  .nav-icon { width: 19px; height: 19px; }
  .nav-label { font-size: 9px; }
  .feedback-open { right: calc(76px + env(safe-area-inset-right)); bottom: 10px; }

  .tab-panel {
    padding: 14px calc(78px + env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  }
  .panel-heading {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
  }
  .panel-heading h2 { margin-bottom: 2px; font-size: 20px; }
  .panel-heading p { margin: 0; font-size: 10px; line-height: 1.4; }
  .intent-card { padding: 14px 16px; }
  .intent-title-row { margin-bottom: 14px; }
  .intent-title-row h3 { font-size: 18px; }
  .build-requirement { margin: -4px 0 12px; padding: 7px 9px; font-size: 10px; }

  .intent-grid, .threat-grid {
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
    gap: 9px;
  }
  .intent-grid label { gap: 4px; font-size: 10px; }
  select { min-height: 38px; }
  .threat-details { margin-top: 14px; padding-top: 10px; }
  .threat-summary { padding: 4px 0; font-size: 14px; }
  .analyze-button { min-height: 46px; margin-top: 12px; }

  .empty-result { margin-top: 14px; padding: 28px 20px; }
  .empty-glyph { width: 52px; height: 52px; margin-bottom: 10px; }
  .empty-glyph svg { width: 30px; height: 30px; }
  .result-block { margin-top: 12px; padding: 14px 16px; }
  .result-block-title { margin-bottom: 10px; }
  .result-block-title h3 { font-size: 18px; }

  .candidate-card { grid-template-columns: minmax(118px, .6fr) minmax(118px, .7fr) auto; }
  .candidate-icon { width: 22px; height: 22px; line-height: 20px; }
  .selected-candidate-head { margin-top: 14px; padding: 14px 18px; }
  .selected-candidate-head h3 { font-size: 20px; }
  .selected-score strong { font-size: 30px; }
  .score-breakdown { grid-template-columns: repeat(6, minmax(0, 1fr)); }

  .deck-grid { max-width: none; }
  .deck-member-body { padding: 4px; }
  .deck-member-body strong { font-size: 9px; }
  .deck-member-body p { display: none; }
  .equip-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .equip-card { padding: 13px; }
  .skill-columns { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 10px; }
  .skill-panel { padding: 12px; }

  .sheet-backdrop { align-items: center; }
  .sheet {
    width: min(620px, calc(100% - 96px));
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-top: 4px solid var(--gold);
    border-radius: 14px;
  }
  .sheet-head { margin-bottom: 10px; }
  .stepper-row { margin-bottom: 8px; }
  .stepper button { width: 38px; height: 38px; }
}

/* ── 広告（A8.net）
   バナー実寸は468x60のPC向け。スマホ幅では枠に収まるまで縮める必要があるので、
   img は width:100% + height:auto にして縦横比だけHTML属性に任せる。
   aspect-ratio を併記するのは、画像が届く前から高さを確保して
   読み込み時に下の要素が飛ばないようにするため。 */
.ad-slot {
  display: block;
  margin: 20px 0 4px;
  text-align: center;
}
.ad-slot[hidden] { display: none; }

.ad-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: .08em;
}

.ad-banner {
  display: inline-block;
  max-width: 468px;
  width: 100%;
  line-height: 0;
  border-radius: 6px;
  overflow: hidden;
}

.ad-banner img {
  width: 100%;
  height: auto;
  aspect-ratio: 468 / 60;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* 計測用1x1。レイアウトに一切影響させない */
.ad-impression {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* grid の中に差し込む広告は、列に収まらず1行を丸ごと使わせる。
   character-grid も skill-columns も grid なので、列数に関わらず全幅にする。 */
.ad-in-grid,
.skill-columns > .ad-slot {
  grid-column: 1 / -1;
}

/* ══════════════════════════════════════════════════════
   冒険者ギルドの依頼書（段階1：階級章・蝋封・飾り罫）
   ══════════════════════════════════════════════════════ */

/* ── 蝋封の判子。STEP 1 / OPTION の角チップを丸い封蝋に置き換える。
   既存の .step-chip をそのまま上書きするので、HTML側は文字を変えるだけで済む。 */
.step-chip {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #fdf3e0;
  background:
    radial-gradient(circle at 34% 30%, #b8503f, #8d2f24 62%, #6d211a);
  border-radius: 50%;
  box-shadow:
    inset 0 1px 2px rgba(255, 235, 205, .45),
    inset 0 -2px 4px rgba(60, 12, 8, .55),
    0 2px 5px rgba(90, 30, 20, .35);
  font: 700 15px/1 Georgia, "Yu Mincho", serif;
  letter-spacing: 0;
  text-shadow: 0 1px 1px rgba(70, 16, 10, .6);
}
.step-chip-sub {
  width: 30px;
  height: 30px;
  background: radial-gradient(circle at 34% 30%, #4a7f8c, #2c5f6d 62%, #1e4954);
  font-size: 12px;
}

/* ── 階級章。得点の隣に並べる。
   数字は残す（消すと比較できなくなる）。★はあくまで一目での序列づけ。 */
.rank-stars {
  display: block;
  color: var(--gold);
  font-size: 13px;
  line-height: 1;
  letter-spacing: .06em;
  text-shadow: 0 1px 0 rgba(120, 80, 10, .25);
  white-space: nowrap;
}
.candidate-score-row .rank-stars { font-size: 11px; }
.selected-score .rank-stars { margin-bottom: 5px; font-size: 15px; color: #f3c866; }
.combo-score .rank-stars { font-size: 9px; }
.combo-score b { display: block; font: 800 15px/1 Georgia, serif; }
.combo-score { min-width: 62px; }

/* ── 見出しの飾り罫。左に菱形、右へ細い罫を引いて依頼書の項目らしくする。 */
.result-block-title h3,
.intent-title-row h3 {
  display: flex;
  align-items: center;
  gap: 9px;
}
.result-block-title h3::before,
.intent-title-row h3::before {
  content: "◆";
  color: var(--gold);
  font-size: .62em;
  line-height: 1;
}
.result-block-title h3::after {
  content: "";
  flex: 1;
  min-width: 18px;
  height: 1px;
  background: linear-gradient(90deg, var(--gold), rgba(225, 162, 42, 0));
}
.result-block-title { align-items: baseline; }
.result-block-title h3 { flex: 1; }

/* 見出しと右の補足が同じ行を奪い合うと「編成する六人」のような短い見出しでも
   折り返してしまう。見出しは折らず、余った幅を飾り罫に吸わせる。 */
.result-block-title { flex-wrap: wrap; }
.result-block-title h3 { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.result-block-title > span { flex: 0 1 auto; min-width: 0; }

/* ══════════════════════════════════════════════════════
   段階2：羊皮紙・紋章・二重罫
   ══════════════════════════════════════════════════════ */

/* ── 羊皮紙。方眼を外し、SVGのノイズで紙の繊維を出す。
   画像を外部から読まないのは、CSPと表示速度の都合（サイトは自己完結を保つ）。
   baseFrequency を粗（0.8）と細（0.04）で2枚重ね、繊維とムラを別々に作る。 */
body {
  background:
    /* 紙の繊維：細かい粒 */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.33 0 0 0 0 0.18 0 0 0 0.10 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23f)'/%3E%3C/svg%3E"),
    /* 染みムラ：大きなうねり */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.022' numOctaves='4'/%3E%3CfeColorMatrix values='0 0 0 0 0.46 0 0 0 0 0.35 0 0 0 0 0.16 0 0 0 0.13 0'/%3E%3C/filter%3E%3Crect width='420' height='420' filter='url(%23g)'/%3E%3C/svg%3E"),
    /* 四隅を焼いたような濃淡 */
    radial-gradient(120% 90% at 50% 0%, rgba(255, 252, 242, .85), transparent 60%),
    var(--paper);
  background-size: 140px 140px, 420px 420px, 100% 100%, auto;
}

.app-shell {
  background: transparent;
  box-shadow: 0 0 90px rgba(97, 74, 32, .1) inset;
}

/* ── 属性の紋章 */
.attr-emblem {
  width: 1em;
  height: 1em;
  margin-right: .35em;
  vertical-align: -.14em;
  flex: none;
}
.attr-火 { color: var(--fire); }
.attr-水 { color: var(--water); }
.attr-風 { color: var(--wind); }
.character-meta { display: flex; align-items: center; }
.selected-build-target .attr-emblem { color: #08384c; }
.candidate-card.is-active .attr-emblem { color: #9fe4ec; }

/* ── 依頼書の二重罫。外に金の細枠、内側に薄い罫を1本入れる。
   枠だけだと角が寂しいので、四隅へ小さな鉤飾りを重ねる。 */
.result-block,
.intent-card {
  position: relative;
  border: 1px solid rgba(150, 116, 48, .42);
  box-shadow:
    inset 0 0 0 1px rgba(255, 253, 246, .9),
    inset 0 0 0 5px rgba(180, 146, 74, .16),
    0 10px 30px rgba(90, 68, 26, .09);
}

/* 四隅の鉤飾り。上下2つの疑似要素で四隅ぶんを描く */
.result-block::before,
.result-block::after,
.intent-card::before,
.intent-card::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--gold);
  opacity: .55;
  pointer-events: none;
}
.result-block::before,
.intent-card::before {
  top: 6px; left: 6px;
  border-right: 0; border-bottom: 0;
}
.result-block::after,
.intent-card::after {
  right: 6px; bottom: 6px;
  border-left: 0; border-top: 0;
}

/* 上端の色帯は依頼書の趣に合わせて金へ寄せる */
.intent-card { border-top: 4px solid var(--gold); }
