/* =========================================================
   新クトゥルフ神話TRPG 探索者シート
   公式7版シート風:羊皮紙調の紙面 + 深緑のバナー + 明朝体
   ========================================================= */

:root {
  --paper: #f5f0e1;          /* 羊皮紙 */
  --paper-dark: #ece4cf;     /* 記入ボックスの下地 */
  --ink: #2b2a24;            /* 本文の墨色 */
  --green-deep: #1e3a2b;     /* セクションバナー */
  --green-mid: #2f5b40;      /* アクセント */
  --green-pale: #dfe7dc;     /* バナー内の文字・淡い緑 */
  --line: #9a8f6e;           /* 罫線(古紙のセピア) */
  --line-soft: #c4b995;      /* 薄い罫線 */
  --font-serif: "Noto Serif JP", "Yu Mincho", "YuMincho",
                "Hiragino Mincho ProN", "MS PMincho", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px 12px 48px;
  background:
    radial-gradient(ellipse at top, rgba(30, 58, 43, 0.35), transparent 60%),
    #14231a;
  font-family: var(--font-serif);
  color: var(--ink);
  line-height: 1.5;
}

.sheet {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 32px 36px;
  background:
    linear-gradient(rgba(255, 252, 240, 0.35), rgba(233, 223, 196, 0.35)),
    var(--paper);
  border: 2px solid var(--green-deep);
  outline: 1px solid var(--line);
  outline-offset: -6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

/* ---------- タイトル ---------- */

.sheet-header {
  text-align: center;
  border-bottom: 3px double var(--green-deep);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.sheet-header__eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--green-mid);
}

.sheet-header__title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--green-deep);
}

.sheet-header__title span {
  display: block;
  font-size: 16px;
  letter-spacing: 0.5em;
  margin-top: 4px;
  color: var(--ink);
}

/* ---------- セクション共通 ---------- */

.section {
  margin-bottom: 26px;
}

.section__title {
  margin: 0 0 10px;
  padding: 5px 14px;
  background: var(--green-deep);
  color: var(--green-pale);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.25em;
  border-left: 6px solid var(--green-mid);
}

.section__note {
  margin: -4px 0 10px;
  font-size: 11px;
  color: #6d6552;
}

/* ---------- 入力欄共通 ---------- */

input[type="text"],
textarea {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-dark);
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 4px 6px;
  width: 100%;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-bottom: 2px solid var(--green-mid);
  background: #f2ecd8;
}

textarea {
  border: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line);
  resize: vertical;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--green-mid);
  flex: none;
}

/* 自動計算欄(読み取り専用) */
input.is-auto {
  background: transparent;
  border-bottom: 1px dotted var(--line-soft);
  color: #55503f;
  cursor: default;
}

input.is-auto:focus {
  border-bottom: 1px dotted var(--line-soft);
  background: transparent;
}

/* ラベル付きフィールド */

.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--green-deep);
}

/* ---------- パーソナルデータ ---------- */

.personal-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px 14px;
}

.personal-grid .field--wide  { grid-column: span 3; }
.personal-grid .field        { grid-column: span 2; }
.personal-grid .field--narrow{ grid-column: span 1; }

/* ---------- 職業入力欄(候補リストつき)と職業情報 ---------- */

.field--occupation {
  position: relative;
}

.field--occupation input {
  padding-right: 26px;
}


.occ-open {
  position: absolute;
  right: 2px;
  bottom: 4px;
  width: 22px;
  height: 20px;
  padding: 0;
  border: none;
  background: none;
  font-size: 10px;
  color: var(--green-mid);
  cursor: pointer;
}

.occ-open:hover {
  color: var(--green-deep);
}

/* 職業の全件メニュー(▼で開く。入力済みでも全職業から再選択できる) */
.occ-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 280px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--green-deep);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.occ-menu[hidden] {
  display: none;
}

.occ-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px dotted var(--line-soft);
  padding: 5px 12px;
  cursor: pointer;
}

.occ-menu__item:hover,
.occ-menu__item.is-active {
  background: var(--green-pale);
}

.occ-menu__item.is-current {
  font-weight: 700;
  color: var(--green-deep);
  background: rgba(47, 91, 64, 0.12);
}

.occ-menu__item.is-current::before {
  content: "✓ ";
}

.occupation-info {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 240, 0.5);
  padding: 10px 14px;
}

.occupation-info__row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  padding: 2px 0;
}

.occupation-info__row b {
  flex: none;
  width: 8.5em;
  color: var(--green-deep);
  font-size: 12px;
}

.occupation-info__row span {
  flex: 1;
}

.occupation-info__note {
  margin: 8px 0 0;
  font-size: 10px;
  color: #6d6552;
  border-top: 1px dotted var(--line-soft);
  padding-top: 6px;
}

.occupation-info__row.is-over span {
  color: #8c2f2f;
  font-weight: 700;
}

/* 職業技能のハイライト */
.skill--occ {
  background: rgba(47, 91, 64, 0.12);
  box-shadow: inset 3px 0 0 var(--green-mid);
}

.skill--occ-choice {
  background: rgba(47, 91, 64, 0.05);
  box-shadow: inset 3px 0 0 var(--line-soft);
  cursor: pointer;
}

.skill--occ-choice:hover {
  background: rgba(47, 91, 64, 0.12);
}

/* 選択済みの候補(クリックで解除できる) */
.skill--occ-chosen {
  cursor: pointer;
}

.skill--occ-chosen .skill__name::before {
  content: "✓ ";
  color: var(--green-mid);
  font-weight: 700;
}

/* グループの選択数が上限のときの点滅 */
.skill--deny {
  background: #f6e0e0 !important;
  box-shadow: inset 3px 0 0 #8c2f2f !important;
}

/* ---------- 能力値 ---------- */

.char-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
}

.char-box {
  position: relative;
  border: 1px solid var(--line);
  background: rgba(255, 252, 240, 0.5);
  padding: 6px 6px 8px;
  text-align: center;
}

/* 能力値の一括ロール */
.section__note--chars {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.char-roll-all {
  flex: none;
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--green-deep);
  background: rgba(255, 252, 240, 0.6);
  border: 1px solid var(--green-mid);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.char-roll-all:hover {
  background: var(--green-pale);
}

.char-roll-all:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* 能力値・幸運のダイス決定ボタン */
.char-roll {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.char-roll:hover {
  opacity: 1;
  transform: rotate(-18deg) scale(1.25);
}

.char-roll:disabled {
  cursor: wait;
  opacity: 0.3;
}

input.is-rolling {
  color: #8b8468;
}

input.rolled {
  animation: dice-pop 0.3s ease-out;
}

.char-box__label {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  margin-bottom: 4px;
}

.char-box__label b {
  font-size: 14px;
  color: var(--green-deep);
  letter-spacing: 0.08em;
}

.char-box__label small {
  font-size: 10px;
  color: #6d6552;
}

.char-box__main {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  padding: 4px 2px;
}

.char-box__subs {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.char-box__subs input {
  text-align: center;
  font-size: 11px;
  padding: 2px;
}

.char-box--single .char-box__main {
  margin-top: 2px;
}

/* 6版: 能力値8つ+派生3つ(アイデア/幸運/知識)を8列で折り返す */
.char-grid--six {
  grid-template-columns: repeat(8, 1fr);
}

/* ---------- ステータス ---------- */

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.status-box {
  position: relative;
  border: 1px solid var(--line);
  background: rgba(255, 252, 240, 0.5);
  padding: 8px 10px 10px;
}

.status-box .char-roll {
  top: 4px;
  right: 4px;
}

.status-box__title {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--green-deep);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 3px;
}

.status-box__title small {
  font-size: 10px;
  color: var(--green-mid);
  letter-spacing: 0.1em;
}

.status-box__values {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.status-box__values label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-box__values span {
  font-size: 10px;
  color: #6d6552;
}

.status-box__values input {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.status-box__slash {
  padding-bottom: 6px;
  color: var(--line);
}

.status-box__checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 8px;
}

.status-box__checks label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

/* ---------- 戦闘 ---------- */

.combat-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 200px));
  gap: 10px 14px;
  margin-bottom: 12px;
}

.weapon-table,
.fellow-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 252, 240, 0.5);
}

.weapon-table th,
.fellow-table th {
  background: var(--green-mid);
  color: var(--green-pale);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 5px 4px;
  border: 1px solid var(--green-deep);
}

.weapon-table td,
.fellow-table td {
  border: 1px solid var(--line-soft);
  padding: 0;
}

.weapon-table td input,
.fellow-table td input {
  border-bottom: none;
  background: transparent;
  text-align: center;
  padding: 6px 4px;
}

.weapon-table .weapon-table__name {
  width: 26%;
}

.weapon-table td:first-child input {
  text-align: left;
}

/* ---------- 技能 ---------- */

.skill-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px 20px;
}

.skill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border-bottom: 1px dotted var(--line-soft);
}

.skill__name {
  flex: 1;
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-wrap: wrap;
}

.skill__name small {
  font-size: 10px;
  color: #6d6552;
}

.skill__values {
  display: flex;
  gap: 3px;
  flex: none;
  align-items: center;
}

.skill__values input {
  width: 34px;
  text-align: center;
  font-size: 13px;
  padding: 2px;
}

.skill__values input:nth-child(2),
.skill__values input:nth-child(3) {
  width: 30px;
  font-size: 11px;
  color: #55503f;
}

/* 合計値(基本値+振り分け、または選択難易度の値) */
.skill__values input.skill__total {
  width: 38px;
  font-size: 13px;
  font-weight: 700;
  color: var(--green-deep);
  background: rgba(47, 91, 64, 0.08);
  border-bottom: 2px solid var(--green-mid);
  cursor: default;
}

.skill__values input.skill__total--alt {
  color: #7a5c00;
  background: rgba(176, 141, 42, 0.12);
  border-bottom-color: #b08d2a;
}


input.skill__genre {
  width: 72px;
  font-size: 12px;
  padding: 1px 3px;
}

input.skill__custom-name {
  font-size: 13px;
  padding: 2px 4px;
}

/* 技能セクションの設定行(上限フラグ+難易度一括切替) */
.skill-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 10px;
}

.skill-limit {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #6d6552;
  cursor: pointer;
}

.skill-diff-global {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--green-deep);
}

.skill-diff-global select {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--ink);
  background: var(--paper-dark);
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 2px 4px;
  cursor: pointer;
}

.skill-diff-global select:focus {
  outline: none;
  border-bottom: 2px solid var(--green-mid);
}

/* 上限で自動修正されたときのフラッシュ */
input.is-capped {
  background: #f6e0e0;
  border-bottom-color: #8c2f2f;
  color: #8c2f2f;
}

/* ---------- バックストーリー ---------- */

.backstory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}

/* ---------- 装備と所持品 ---------- */

.gear-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px 16px;
}

.cash-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- 仲間の探索者・メモ ---------- */

.fellows-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: start;
}

.fellow-table td input {
  text-align: left;
}

/* ---------- フッター ---------- */

.sheet-footer {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 3px double var(--green-deep);
  text-align: center;
}

.sheet-footer p {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: #6d6552;
}

/* ---------- 版タブ ---------- */

.edition-tabs {
  max-width: 960px;
  margin: 0 auto 2px;
  display: flex;
  gap: 4px;
  padding: 0 4px;
}

.edition-tabs__tab {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #9db3a0;
  text-decoration: none;
  background: rgba(30, 58, 43, 0.55);
  border: 1px solid var(--green-mid);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 7px 20px 5px;
}

.edition-tabs__tab:hover {
  color: var(--green-pale);
  background: var(--green-mid);
}

.edition-tabs__tab.is-active {
  color: var(--green-deep);
  background: var(--paper);
  border-color: var(--green-deep);
}

/* ---------- ツールバー ---------- */

.toolbar {
  max-width: 960px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar__status {
  flex: 1;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #9db3a0;
}

.toolbar button {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--green-pale);
  background: var(--green-deep);
  border: 1px solid var(--green-mid);
  padding: 6px 14px;
  cursor: pointer;
}

.toolbar button:hover {
  background: var(--green-mid);
}

.toolbar button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.toolbar .toolbar__danger {
  background: #4a2020;
  border-color: #7a3a3a;
}

.toolbar .toolbar__danger:hover {
  background: #6b2c2c;
}

/* ---------- ダイスロール ---------- */

.dice-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--green-pale);
  background: var(--green-deep);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, background 0.15s ease;
  z-index: 50;
}

.dice-fab:hover {
  background: var(--green-mid);
  transform: scale(1.08) rotate(-12deg);
}

.dice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 14, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.dice-overlay[hidden] {
  display: none;
}

.dice-panel {
  width: min(540px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--paper);
  border: 2px solid var(--green-deep);
  outline: 1px solid var(--line);
  outline-offset: -5px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  padding: 0 18px 16px;
  font-family: var(--font-serif);
}

.dice-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--green-deep);
  margin: 0 -18px 14px;
  padding: 8px 16px;
}

.dice-panel__header h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.25em;
  color: var(--green-pale);
}

.dice-panel__close {
  background: none;
  border: none;
  color: var(--green-pale);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.dice-panel__close:hover {
  color: #fff;
}

.dice-form {
  display: flex;
  gap: 8px;
}

.dice-form input {
  flex: 1;
  font-size: 16px;
  letter-spacing: 0.05em;
}

.dice-form button {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--green-pale);
  background: var(--green-deep);
  border: 1px solid var(--green-deep);
  padding: 6px 18px;
  cursor: pointer;
}

.dice-form button:hover {
  background: var(--green-mid);
}

.dice-error {
  min-height: 1.2em;
  margin: 4px 0 2px;
  font-size: 12px;
  color: #8c2f2f;
}

.dice-save {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.dice-save input {
  width: 160px;
  font-size: 13px;
}

.dice-save button {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--green-deep);
  background: rgba(255, 252, 240, 0.6);
  border: 1px solid var(--green-mid);
  padding: 4px 14px;
  cursor: pointer;
}

.dice-save button:hover {
  background: var(--green-pale);
}

.dice-quick-groups {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.dice-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.dice-group__head {
  flex: none;
  min-width: 84px;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  border-right: 2px solid var(--line-soft);
  padding-right: 6px;
}

.dice-group__name {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--green-deep);
}

.dice-group__del {
  flex: none;
  font-size: 11px;
  line-height: 1;
  color: #8b8468;
  background: none;
  border: none;
  padding: 0 2px;
  cursor: pointer;
}

.dice-group__del:hover {
  color: #8c2f2f;
}

.dice-group__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dice-chip {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 240, 0.6);
  overflow: hidden;
}

.dice-chip__roll {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  color: var(--green-deep);
  background: none;
  border: none;
  padding: 3px 4px 3px 12px;
  cursor: pointer;
}

.dice-chip__del {
  font-size: 11px;
  color: #8b8468;
  background: none;
  border: none;
  padding: 0 8px 0 4px;
  cursor: pointer;
}

.dice-chip:hover {
  background: var(--green-pale);
  border-color: var(--green-mid);
}

.dice-chip__del:hover {
  color: #8c2f2f;
}

.dice-preset-io {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.dice-preset-io span {
  flex: 1;
  font-size: 10px;
  color: #8b8468;
}

.dice-preset-io button {
  font-family: var(--font-serif);
  font-size: 11px;
  color: var(--green-deep);
  background: rgba(255, 252, 240, 0.6);
  border: 1px solid var(--line);
  padding: 3px 10px;
  cursor: pointer;
}

.dice-preset-io button:hover {
  background: var(--green-pale);
  border-color: var(--green-mid);
}

.dice-stage {
  min-height: 130px;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse at center, rgba(47, 91, 64, 0.12), transparent 70%),
    rgba(255, 252, 240, 0.5);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.dice-dice {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.die {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fffdf4;
  border: 2px solid var(--green-mid);
  border-radius: 9px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-size: 18px;
  font-weight: 700;
  color: var(--green-deep);
}

.die.rolling {
  animation: dice-shake 0.12s linear infinite;
  color: #8b8468;
}

.die.settled {
  animation: dice-pop 0.28s ease-out;
}

.die.crit {
  border-color: #b08d2a;
  background: #faf0cd;
  color: #7a5c00;
  box-shadow: 0 0 10px rgba(176, 141, 42, 0.7);
}

.die.fumble {
  border-color: #8c2f2f;
  background: #f6e0e0;
  color: #8c2f2f;
  box-shadow: 0 0 10px rgba(140, 47, 47, 0.55);
}

@keyframes dice-shake {
  0%   { transform: rotate(-7deg) translateY(-2px); }
  50%  { transform: rotate(7deg) translateY(2px); }
  100% { transform: rotate(-7deg) translateY(-2px); }
}

@keyframes dice-pop {
  0%   { transform: scale(1.6); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.dice-total {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dice-total.show {
  display: flex;
  animation: dice-pop 0.3s ease-out;
}

.dice-total small {
  font-size: 11px;
  color: #6d6552;
}

.dice-total b {
  font-size: 36px;
  line-height: 1.1;
  color: var(--green-deep);
}

.dice-history {
  margin-top: 12px;
}

.dice-history h3 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--green-deep);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 2px;
}

.dice-history ol {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 150px;
  overflow-y: auto;
}

.dice-history li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  padding: 3px 2px;
  border-bottom: 1px dotted var(--line-soft);
}

.dice-history__time {
  color: #8b8468;
  font-size: 10px;
  flex: none;
}

.dice-history__formula {
  font-weight: 700;
  flex: none;
}

.dice-history__detail {
  flex: 1;
  color: #6d6552;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-history__total {
  flex: none;
  font-size: 14px;
  color: var(--green-deep);
}

/* ---------- ヘルプ ---------- */

.help-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(223, 231, 220, 0.7);
  background: transparent;
  color: var(--green-pale);
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex: none;
  padding: 0;
}

.help-btn:hover {
  background: var(--green-mid);
  border-color: var(--green-pale);
}

.section__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dice-panel__header h2 {
  flex: 1;
}

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 14, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 120;
}

.help-overlay[hidden] {
  display: none;
}

.help-panel {
  width: min(720px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 2px solid var(--green-deep);
  outline: 1px solid var(--line);
  outline-offset: -5px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  font-family: var(--font-serif);
}

.help-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--green-deep);
  padding: 8px 16px;
  flex: none;
}

.help-panel__header h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.2em;
  color: var(--green-pale);
}

.help-panel__close {
  background: none;
  border: none;
  color: var(--green-pale);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.help-panel__close:hover {
  color: #fff;
}

.help-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}

.help-nav a {
  font-size: 11px;
  font-weight: 700;
  color: var(--green-deep);
  text-decoration: none;
  background: rgba(255, 252, 240, 0.6);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
}

.help-nav a:hover {
  background: var(--green-pale);
  border-color: var(--green-mid);
}

.help-body {
  position: relative;
  overflow-y: auto;
  padding: 6px 22px 20px;
  font-size: 13px;
  line-height: 1.7;
}

.help-body h3 {
  margin: 20px 0 8px;
  padding: 4px 10px;
  font-size: 14px;
  letter-spacing: 0.15em;
  color: var(--green-pale);
  background: var(--green-deep);
  border-left: 5px solid var(--green-mid);
}

.help-body h4 {
  margin: 14px 0 4px;
  font-size: 13px;
  color: var(--green-deep);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 2px;
}

.help-body p {
  margin: 6px 0;
}

.help-body ul,
.help-body ol {
  margin: 6px 0;
  padding-left: 22px;
}

.help-body li {
  margin: 3px 0;
}

.help-body b {
  color: var(--green-deep);
}

.help-body code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  background: rgba(47, 91, 64, 0.1);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 0 4px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  background: rgba(255, 252, 240, 0.5);
  font-size: 12px;
}

.help-table th {
  background: var(--green-mid);
  color: var(--green-pale);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border: 1px solid var(--green-deep);
  text-align: left;
}

.help-table td {
  border: 1px solid var(--line-soft);
  padding: 4px 8px;
}

/* ---------- レスポンシブ ---------- */

@media (max-width: 800px) {
  .sheet { padding: 20px 12px 28px; }
  .personal-grid { grid-template-columns: repeat(2, 1fr); }
  .personal-grid .field--wide,
  .personal-grid .field { grid-column: span 2; }
  .personal-grid .field--narrow { grid-column: span 1; }
  .char-grid { grid-template-columns: repeat(3, 1fr); }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .combat-summary { grid-template-columns: 1fr 1fr; }
  .skill-grid,
  .backstory-grid,
  .gear-grid,
  .fellows-grid { grid-template-columns: 1fr; }
  .weapon-table { display: block; overflow-x: auto; }

  /* 版タブ・ツールバー: 折り返しと等幅化 */
  .edition-tabs { padding: 0 2px; gap: 2px; }
  .edition-tabs__tab {
    flex: 1;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.02em;
    padding: 8px 4px 6px;
  }
  .toolbar { flex-wrap: wrap; }
  .toolbar__status {
    flex-basis: 100%;
    order: 9;
    text-align: right;
    font-size: 10px;
  }
  .toolbar button {
    flex: 1 1 40%;
    padding: 9px 4px;
    letter-spacing: 0.05em;
    white-space: nowrap;
  }

  /* 見出し脇の行を折り返し可能に */
  .section__note--chars { flex-wrap: wrap; }
  .skill-options { flex-wrap: wrap; }

  /* iOSのフォーカス時自動ズーム防止: 編集する入力は16px以上にする */
  input[type="text"],
  textarea,
  select {
    font-size: 16px;
  }
  input[type="checkbox"] { width: 18px; height: 18px; }

  /* タップしやすいボタンサイズ */
  .char-roll { width: 28px; height: 28px; font-size: 17px; opacity: 0.6; }
  .help-btn { width: 22px; height: 22px; font-size: 13px; }
  .occ-open { width: 32px; height: 26px; font-size: 12px; bottom: 6px; }
  .field--occupation input { padding-right: 36px; }
  .occ-menu__item { padding: 9px 14px; font-size: 15px; }
  .dice-chip__roll { padding: 7px 6px 7px 14px; font-size: 14px; }
  .dice-chip__del { padding: 0 12px 0 6px; font-size: 14px; }
  .dice-panel__close, .help-panel__close { font-size: 26px; padding: 0 8px; }

  /* 技能行: 幅を16pxフォントに合わせて調整(半分/1/5は読み取り専用なので小さいまま) */
  .skill__values input { width: 44px; }
  .skill__values input:nth-child(2),
  .skill__values input:nth-child(3) { width: 36px; font-size: 13px; }
  .skill__values input.skill__total { width: 46px; }
  input.skill__genre { width: 90px; font-size: 16px; } /* 編集可能欄なので16px(iOSズーム防止) */

  /* 武器表: 横スクロール時に各列が使える幅を確保 */
  .weapon-table td input { min-width: 72px; font-size: 14px; }
  .weapon-table td:first-child input { min-width: 120px; }

  /* ダイスパネル */
  .dice-save { flex-wrap: wrap; }
  .dice-save input { flex: 1; min-width: 130px; }
  .dice-form input { min-width: 0; }
  .dice-preset-io { flex-wrap: wrap; }
  .dice-preset-io span { flex-basis: 100%; }

  /* 職業情報パネル: ラベルを1行に */
  .occupation-info__row { flex-wrap: wrap; gap: 2px 10px; }
  .occupation-info__row b { width: auto; flex-basis: 100%; }
}

/* ---------- 印刷 ---------- */

@media print {
  body {
    background: #fff;
    padding: 0;
  }
  .dice-fab,
  .dice-overlay,
  .toolbar,
  .edition-tabs,
  .help-overlay,
  .help-btn,
  .char-roll,
  .char-roll-all,
  .occ-open,
  .occ-menu,
  .occupation-info,
  .skill-options {
    display: none !important;
  }
  .sheet {
    max-width: none;
    border: 1px solid var(--green-deep);
    box-shadow: none;
  }
  .section { break-inside: avoid; }
  #section-skills,
  #section-backstory { break-inside: auto; }
  .skill { break-inside: avoid; }
  input[type="text"],
  textarea {
    background: transparent;
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
