:root {
  --bg: #f7f2e8;
  --bg-deep: #efe7d6;
  --card: #fffdf8;
  --card-soft: #f3ecdc;
  --border: rgba(139, 105, 52, 0.28);
  --gold: #a8802f;
  --gold-soft: #8a6a28;
  --cream: #3d3226;
  --cream-dim: #6f5f4b;
  --shadow: 0 12px 30px rgba(90, 70, 40, 0.14);
  --radius: 14px;
  --serif: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", YuMincho, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", YuMincho, serif;
  --en: Georgia, "Times New Roman", serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ink-bg: #241c10;
  --ink-bg-t: rgba(30, 23, 12, 0.93);
  --ink-text: #f2ead8;
  --ink-dim: #cfc4ae;
  --ink-gold: #e0c27a;
  --wine: #5a1f1a;
  --l0: #4a7a4e;
  --l1: #4a6b9a;
  --l2: #a8712f;
  --l3: #9a4038;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--cream);
  background:
    radial-gradient(circle at 8% 8%, rgba(168, 128, 47, 0.055), transparent 28rem),
    linear-gradient(180deg, var(--bg) 0%, #faf7f0 42%, var(--bg) 100%);
  font-family: var(--sans);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

::selection {
  color: var(--card);
  background: rgba(168, 128, 47, 0.85);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
summary {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 5px;
}

a {
  color: var(--gold-soft);
  text-decoration: none;
}

a:hover {
  color: var(--gold);
}

h1,
h2,
h3,
h4 {
  color: var(--gold-soft);
  font-family: var(--serif);
  letter-spacing: 0.04em;
  text-wrap: balance;
}

.confidential-banner {
  position: relative;
  z-index: 60;
  padding: 6px 14px;
  color: #f5e3d8;
  background: var(--wine);
  border-bottom: 1px solid rgba(245, 227, 216, 0.18);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.6;
  text-align: center;
}

.public-api-key-notice {
  display: block;
  width: 100%;
  padding: 9px 16px;
  color: #241c10;
  border: 0;
  border-bottom: 1px solid rgba(168, 128, 47, 0.45);
  background: #f4dfaa;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.55;
  text-align: center;
  cursor: pointer;
}

.public-api-key-notice:hover {
  background: #ecd18d;
}

.public-api-key-notice[hidden] {
  display: none;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  width: 100%;
  margin: 0;
  padding: 17px max(24px, calc((100vw - 1240px) / 2));
  color: var(--ink-text);
  background: var(--ink-bg-t);
  border-bottom: 1px solid rgba(224, 194, 122, 0.24);
  backdrop-filter: blur(6px);
}

.site-header button:focus-visible,
.site-header [tabindex]:focus-visible {
  outline-color: var(--ink-gold);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 15px;
}

.brand-mark {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--ink-gold);
  border: 1px solid rgba(224, 194, 122, 0.42);
  border-radius: 50%;
  background: rgba(224, 194, 122, 0.045);
  box-shadow: inset 0 0 16px rgba(224, 194, 122, 0.06);
  font-family: var(--serif);
  font-size: 1.42rem;
  line-height: 1;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.7rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.4em;
  line-height: 1.5;
  text-transform: uppercase;
}

.site-header .eyebrow {
  color: rgba(224, 194, 122, 0.86);
}

.site-header h1 {
  margin: 0;
  color: var(--ink-text);
  font-family: var(--display);
  font-size: clamp(1.25rem, 2.4vw, 1.65rem);
  font-weight: 600;
  letter-spacing: 0.07em;
  line-height: 1.25;
}

.site-header h1 span {
  margin-left: 0.35em;
  color: var(--ink-gold);
  font-family: var(--sans);
  font-size: 0.58em;
  letter-spacing: 0.1em;
}

.header-meta {
  margin: 4px 0 0;
  color: var(--ink-dim);
  font-size: 0.7rem;
  line-height: 1.55;
}

.data-status {
  flex: 0 0 auto;
  padding: 5px 11px;
  color: var(--ink-dim);
  border: 1px solid rgba(224, 194, 122, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.69rem;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 9px;
}

.build-stamp {
  color: rgba(207, 196, 174, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.58rem;
  letter-spacing: 0;
  white-space: nowrap;
}

.site-mode-toggle {
  min-height: 35px;
  padding: 5px 12px;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.5);
  border-radius: 999px;
  background: rgba(224, 194, 122, 0.1);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.site-mode-toggle:hover {
  color: var(--ink-bg);
  border-color: var(--ink-gold);
  background: var(--ink-gold);
}

.site-mode-toggle:disabled {
  cursor: wait;
  opacity: 0.52;
}

.is-play-mode .site-mode-toggle {
  color: var(--ink-bg);
  background: var(--ink-gold);
}

.data-status::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  content: "";
  border-radius: 50%;
  background: var(--l2);
}

.data-status.is-ready::before {
  background: #6d9a65;
  box-shadow: 0 0 7px rgba(109, 154, 101, 0.65);
}

.data-status.is-error::before {
  background: #c45a50;
}

.tab-nav {
  position: sticky;
  z-index: 50;
  top: 0;
  overflow-x: auto;
  color: var(--ink-text);
  background: var(--ink-bg);
  border-bottom: 1px solid rgba(224, 194, 122, 0.3);
  box-shadow: 0 5px 18px rgba(55, 40, 17, 0.14);
}

.tab-nav-inner {
  display: flex;
  gap: 4px;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(224, 194, 122, 0.4) transparent;
}

.tab-button {
  position: relative;
  flex: 0 0 auto;
  min-width: 92px;
  padding: 12px 15px 11px;
  color: var(--ink-dim);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: var(--serif);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

/* hidden属性は常に勝つ（.class{display:grid} 等がUAの[hidden]を上書きして隠れない事故の根治） */
[hidden] {
  display: none !important;
}

.tab-button[hidden] {
  display: none;
}

.tab-button:hover {
  color: var(--ink-gold);
  background: rgba(224, 194, 122, 0.035);
}

.tab-button.is-active {
  color: var(--ink-gold);
  border-bottom-color: var(--ink-gold);
}

.tab-button:focus-visible {
  outline-color: var(--ink-gold);
  outline-offset: -3px;
}

.app-shell {
  width: min(1240px, 100%);
  min-height: 65vh;
  margin: 0 auto;
  padding: 34px 24px 80px;
}

.tab-panel[hidden] {
  display: none;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 26px;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--border);
}

.section-heading > div {
  position: relative;
}

.section-heading .section-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading .section-kicker::before {
  width: 34px;
  height: 1px;
  content: "";
  background: var(--gold);
}

.section-heading h2 {
  margin: 0;
  color: var(--gold-soft);
  font-family: var(--display);
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

.section-heading > p {
  max-width: 610px;
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.84rem;
  text-align: right;
}

.loading-card,
.empty-state {
  display: grid;
  min-height: 190px;
  place-items: center;
  padding: 24px;
  color: var(--cream-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card-soft);
  font-size: 0.84rem;
  text-align: center;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.meta-card {
  min-height: 104px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.meta-card-label {
  display: block;
  margin-bottom: 7px;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.67rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.28em;
  line-height: 1.5;
  text-transform: uppercase;
}

.meta-card-value {
  display: block;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.55;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(400px, 1.45fr);
  gap: 18px;
}

.content-panel,
.review-section {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.content-panel h3,
.review-section h3 {
  margin: 0 0 16px;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 1.08rem;
  letter-spacing: 0.04em;
}

.chapter-list {
  display: grid;
}

.chapter-item {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--bg-deep);
}

.chapter-number {
  color: #9a8b74;
  font-family: var(--en);
  font-size: 0.75rem;
  font-style: italic;
}

.chapter-title {
  color: var(--cream);
  font-size: 0.83rem;
}

.spoiler-legend {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.spoiler-legend-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 9px;
  color: var(--cream-dim);
  font-size: 0.7rem;
}

.timeline {
  position: relative;
  display: grid;
}

.timeline::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 90px;
  width: 1px;
  content: "";
  background: var(--border);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 77px 1fr;
  gap: 28px;
  min-height: 57px;
  padding: 7px 0 12px;
}

.timeline-item::before {
  position: absolute;
  top: 14px;
  left: 86px;
  width: 7px;
  height: 7px;
  content: "";
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 1px rgba(168, 128, 47, 0.25);
}

.timeline-date {
  color: var(--gold-soft);
  font-family: var(--en);
  font-size: 0.75rem;
  font-style: italic;
}

.timeline-event {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  color: var(--cream);
  font-size: 0.82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 3px 9px;
  color: var(--card);
  border: 0;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.45;
  white-space: nowrap;
}

.badge-l0 { background: var(--l0); }
.badge-l1 { background: var(--l1); }
.badge-l2 { background: var(--l2); }
.badge-l3 { background: var(--l3); }

.scene-workspace {
  display: grid;
  grid-template-columns: minmax(350px, 0.86fr) minmax(480px, 1.35fr);
  gap: 18px;
  align-items: start;
}

.scene-browser,
.scene-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.scene-browser {
  position: sticky;
  top: 66px;
  max-height: calc(100vh - 92px);
  overflow: hidden;
}

.filter-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 15px;
  border-bottom: 1px solid var(--border);
  background: var(--card-soft);
}

.filter-stack label:last-child {
  grid-column: 1 / -1;
}

label {
  color: var(--cream-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 5px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: inset 0 1px 2px rgba(90, 70, 40, 0.035);
}

input,
select {
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  padding: 11px 13px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #9a8d7c;
}

.result-count {
  padding: 8px 15px;
  color: var(--cream-dim);
  font-size: 0.7rem;
}

.scene-list {
  max-height: calc(100vh - 318px);
  overflow-y: auto;
  scrollbar-color: rgba(168, 128, 47, 0.45) transparent;
}

.scene-list-item {
  width: 100%;
  padding: 13px 15px;
  color: var(--cream);
  border: 0;
  border-top: 1px solid var(--bg-deep);
  background: var(--card);
  text-align: left;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.scene-list-item:hover {
  background: #faf6ed;
}

.scene-list-item.is-selected {
  background: var(--card-soft);
  box-shadow: inset 3px 0 var(--gold);
}

.scene-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.scene-id {
  color: var(--gold-soft);
  font-family: var(--en);
  font-size: 0.68rem;
  font-style: italic;
  letter-spacing: 0.05em;
}

.scene-list-title {
  display: block;
  margin-bottom: 4px;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 0.91rem;
  font-weight: 600;
}

.scene-list-summary {
  display: -webkit-box;
  overflow: hidden;
  color: var(--cream-dim);
  font-size: 0.73rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.missing-mark {
  color: var(--l3);
  font-size: 0.71rem;
  font-weight: 700;
}

.scene-detail {
  min-height: 620px;
  padding: 28px clamp(22px, 3.4vw, 44px) 44px;
}

.scene-detail-header {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.scene-detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.scene-detail h3 {
  margin: 0;
  color: var(--gold-soft);
  font-family: var(--display);
  font-size: clamp(1.28rem, 2.5vw, 1.8rem);
  font-weight: 700;
  line-height: 1.5;
}

.scene-summary-box {
  margin: 0 0 24px;
  padding: 12px 15px;
  color: var(--cream-dim);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--card-soft);
  font-size: 0.83rem;
  white-space: pre-wrap;
}

.prose {
  max-width: 46em;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 0.91rem;
  line-height: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.subsection {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--bg-deep);
}

.subsection h4 {
  margin: 0 0 12px;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 1.02rem;
}

.source-note {
  margin: -8px 0 18px;
  color: var(--cream-dim);
  font-size: 0.73rem;
}

.npc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.npc-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.npc-card-header {
  padding: 18px 19px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fffdf8, #faf6ec);
}

.npc-card h3 {
  margin: 0;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 1.08rem;
}

.npc-reading {
  margin: 2px 0 0;
  color: #94846f;
  font-size: 0.68rem;
}

.npc-role {
  margin: 8px 0 0;
  color: var(--cream-dim);
  font-size: 0.76rem;
}

.npc-card-body {
  display: grid;
  gap: 16px;
  padding: 17px 19px 19px;
}

.field-block h4 {
  margin: 0 0 5px;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.65rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.field-block p {
  margin: 0;
  color: var(--cream);
  font-size: 0.81rem;
  white-space: pre-wrap;
}

.sample-lines {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 0.8rem;
}

.sample-lines li + li {
  margin-top: 6px;
}

.truth-details {
  border-top: 1px dashed var(--border);
  background: #faf3ef;
}

.truth-details summary {
  padding: 12px 19px;
  color: var(--l3);
  font-size: 0.77rem;
  font-weight: 700;
  list-style-position: inside;
}

.truth-content {
  margin: 0 18px 18px;
  padding: 11px 13px;
  color: #63413d;
  border: 1px solid rgba(154, 64, 56, 0.22);
  border-radius: 8px;
  background: var(--card);
  font-family: var(--serif);
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.notice-panel {
  margin-bottom: 17px;
  padding: 14px 17px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
  font-size: 0.8rem;
}

.notice-panel p {
  margin: 5px 0 0;
}

.gold-notice {
  border-left: 3px solid var(--gold);
}

.danger-notice {
  color: #6d3d37;
  border-color: rgba(154, 64, 56, 0.34);
  border-left: 3px solid var(--l3);
  background: #faf3ef;
}

.inline-filters {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 19px;
}

.inline-filters label {
  width: min(260px, 32%);
}

.inline-count {
  margin-left: auto;
  padding-bottom: 9px;
}

.fact-list {
  display: grid;
  gap: 8px;
}

.fact-item {
  display: grid;
  grid-template-columns: 68px auto auto 1fr;
  align-items: start;
  gap: 11px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(90, 70, 40, 0.055);
}

.fact-id {
  padding-top: 2px;
  color: var(--gold-soft);
  font-family: var(--en);
  font-size: 0.73rem;
  font-style: italic;
}

.audience-tag {
  display: inline-block;
  padding: 2px 7px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-soft);
  font-size: 0.65rem;
  white-space: nowrap;
}

.fact-statement {
  margin: 0;
  color: var(--cream);
  font-size: 0.82rem;
}

.character-generator,
.character-library,
.scenario-selection,
.play-controls-panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.scenario-card-list {
  display: grid;
  gap: 18px;
}

.scenario-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.scenario-group-heading h4 {
  margin: 0;
  font-size: 1rem;
}

.scenario-group-heading span {
  color: var(--cream-dim);
  font-size: 0.8125rem;
}

.scenario-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* 本編の4章：広い幅は横一列、600〜1099pxは2×2、600px未満は1列。高さはそろえる。 */
.scenario-card-grid.is-campaign {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 1fr;
}

@media (max-width: 1099px) {
  .scenario-card-grid.is-campaign {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 599px) {
  .scenario-card-grid.is-campaign {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
  }

  /* 基本の指定（後ろにある）に勝つよう、1段だけ具体的にする。 */
  .scenario-card .scenario-card-top strong {
    font-size: 1rem;
  }
}

#selected-scenario-summary {
  font-size: 0.8125rem;
}

/* プレイモード初見ユーザー向けの「はじめかた」ガイド */
.play-onboarding {
  margin: 0 0 18px;
  padding: 14px 18px;
  border: 1px solid rgba(168, 128, 47, 0.45);
  border-radius: 12px;
  background: rgba(168, 128, 47, 0.07);
}

.play-onboarding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-family: var(--serif);
  font-size: 0.94rem;
}

.play-onboarding ol {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  line-height: 1.75;
}

/* 収録シナリオ一覧のネタバレ警告パネル（開示前はカードを出さない） */
.scenario-spoiler-gate {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 14px 16px;
  border: 1px dashed rgba(168, 128, 47, 0.55);
  border-radius: 11px;
  background: rgba(168, 128, 47, 0.07);
}

.scenario-spoiler-gate-title {
  font-family: var(--serif);
  font-size: 0.92rem;
  font-weight: 700;
}

.scenario-spoiler-gate-text {
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.78rem;
  line-height: 1.7;
}

.scenario-spoiler-gate-button {
  font-size: 0.8rem;
}

/* シナリオ選択のカード（2026-11-13 見やすさの手直し）
   左に章の番号（I〜IV）を大きく、右に題・惹句・札。iPad/スマホでも読める大きさとコントラストにする。 */
.scenario-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  column-gap: 14px;
  min-width: 0;
  min-height: 72px;
  padding: 14px 16px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card-soft);
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.scenario-card.has-numeral {
  grid-template-columns: 2.1rem minmax(0, 1fr);
}

.scenario-card:hover:not(:disabled) {
  border-color: var(--gold);
  box-shadow: 0 7px 18px rgba(90, 70, 40, 0.12);
  transform: translateY(-1px);
}

.scenario-card.is-selected {
  border-color: var(--gold);
  background: #fff7e4;
  box-shadow: inset 0 0 0 2px var(--gold), 0 7px 18px rgba(90, 70, 40, 0.1);
}

.scenario-card-numeral {
  color: var(--gold);
  font-family: var(--en);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  letter-spacing: -0.02em;
  padding-top: 1px;
}

.scenario-card-body {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
}

.scenario-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
}

.scenario-card-top strong {
  min-width: 0;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.scenario-card-selected-mark {
  flex: 0 0 auto;
  padding: 2px 9px;
  color: #fffdf8;
  border-radius: 999px;
  background: #7a5c1f;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
}

.scenario-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
}

.scenario-card-badge,
.scenario-card-chip {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.scenario-card-badge {
  color: #3b6640;
  border: 1px solid rgba(74, 122, 78, 0.38);
  background: rgba(74, 122, 78, 0.07);
}

.scenario-card-badge.is-free {
  color: #7a5c1f;
  border-color: rgba(168, 128, 47, 0.45);
  background: rgba(168, 128, 47, 0.08);
}

.scenario-card-badge.is-locked {
  color: var(--l3);
  border-color: rgba(154, 64, 56, 0.3);
  background: rgba(154, 64, 56, 0.06);
}

.scenario-card-chip {
  color: #5c4d3b;
  border: 1px solid var(--border);
  background: rgba(255, 253, 248, 0.6);
  font-weight: 600;
}

.scenario-card-description {
  display: -webkit-box;
  overflow: hidden;
  color: #5c4d3b;
  font-size: 0.875rem;
  line-height: 1.6;
  /* 対応ブラウザでは、日本語を文節の切れ目で折り返す（未対応のブラウザは今までどおり）。 */
  word-break: auto-phrase;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* 収録シナリオのあらすじは文面を変えないので、今までどおり3行まで見せる。 */
.scenario-card-grid.is-authored .scenario-card-description {
  -webkit-line-clamp: 3;
}

.session-launch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.32);
  border-radius: var(--radius);
  background: var(--ink-bg);
  box-shadow: var(--shadow);
}

.session-launch > div {
  display: grid;
  gap: 3px;
}

.session-launch strong {
  color: var(--ink-text);
  font-family: var(--serif);
  font-size: 0.86rem;
}

.demo-preparation[hidden],
.demo-session[hidden] {
  display: none;
}

.session-phase-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

body:not(.is-focus-mode) .session-phase-bar {
  display: none;
}

.session-focus-label {
  margin-left: auto;
  color: var(--gold-soft);
  font-family: var(--en);
  font-size: 0.64rem;
  font-style: italic;
  letter-spacing: 0.22em;
}

.mobile-quick-generate {
  display: none;
}

.session-workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.4fr) minmax(0, 0.6fr);
}

.session-log-column,
.session-play-column {
  min-width: 0;
}

.session-log-column {
  border-right: 1px solid var(--border);
}

@media (min-width: 481px) {
  .session-workspace {
    /* 横持ちスマホ(高さ約390px)でも入力欄が画面内に収まるよう、下限を下げる */
    height: clamp(360px, calc(100dvh - 230px), 900px);
  }

  .session-log-column,
  .session-play-column {
    min-height: 0;
    height: 100%;
  }

  .session-log-column {
    overflow: hidden;
  }

  .session-log-column .chat-messages {
    height: 100%;
    min-height: 0;
  }

  .session-play-column {
    align-self: stretch;
    max-height: none;
    overflow-y: auto;
    scrollbar-color: rgba(168, 128, 47, 0.4) transparent;
  }

  .session-play-column > .play-chat-composer {
    position: sticky;
    z-index: 4;
    bottom: 41px;
    background: var(--card);
    box-shadow: 0 -8px 20px rgba(30, 23, 12, 0.12);
  }

  .chat-shell.is-novel-mode .session-play-column > .play-chat-composer {
    bottom: 41px;
  }

  .session-play-column > .chat-footer {
    position: sticky;
    z-index: 5;
    bottom: 0;
    min-height: 41px;
    background: var(--card-soft);
    box-shadow: 0 -4px 12px rgba(30, 23, 12, 0.08);
  }
}

.session-chat-shell .display-mode-switch {
  display: none;
}

.character-library-note {
  margin: -6px 0 14px;
  color: var(--cream-dim);
  font-size: 0.72rem;
}

.character-library-actions,
.character-library-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.character-library-current,
.character-library-list {
  padding: 12px 14px;
  border: 1px solid var(--bg-deep);
  border-radius: 10px;
  background: var(--card-soft);
}

.character-library-list {
  margin-top: 10px;
}

.character-library-current h4,
.character-library-list h4 {
  margin: 0;
  color: var(--gold-soft);
  font-size: 0.78rem;
}

.character-library-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--cream-dim);
  font-size: 0.68rem;
}

.character-library-rows {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.character-library-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.character-library-row > div:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.character-library-row strong {
  overflow: hidden;
  color: var(--cream);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-library-row span,
.character-library-empty {
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.65rem;
}

.character-library-row .button {
  min-height: 31px;
  padding: 5px 9px;
  font-size: 0.65rem;
}

.play-panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--bg-deep);
}

.play-panel-heading.compact {
  align-items: center;
}

.play-panel-heading h3 {
  margin: 0;
  color: var(--gold-soft);
  font-size: 1.05rem;
}

.play-panel-heading p {
  max-width: 680px;
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.72rem;
  text-align: right;
}

.play-panel-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.62rem;
  font-style: italic;
  letter-spacing: 0.25em;
}

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

.ho-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 112px;
  padding: 12px 13px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fdfaf4;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.ho-option:hover {
  border-color: var(--gold);
}

.ho-option.is-selected {
  border-color: rgba(168, 128, 47, 0.64);
  background: var(--card-soft);
  box-shadow: inset 0 0 0 1px rgba(168, 128, 47, 0.1);
}

.ho-option.is-ai-controlled {
  border-color: rgba(168, 128, 47, 0.82);
  box-shadow: inset 0 0 0 1px rgba(168, 128, 47, 0.2);
}

.ho-option-main {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 9px;
  cursor: pointer;
}

.ho-option input {
  width: 17px;
  height: 17px;
  min-height: 0;
  margin: 3px 0 0;
  accent-color: var(--gold-soft);
}

.ho-option-id {
  display: block;
  color: var(--gold-soft);
  font-family: var(--en);
  font-size: 0.72rem;
  font-style: italic;
  letter-spacing: 0.12em;
}

.ho-option-name {
  display: block;
  margin-top: 2px;
  color: var(--cream);
  font-family: var(--serif);
  font-size: 0.76rem;
  line-height: 1.5;
}

.ho-controller-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  margin-top: auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.ho-controller-button {
  min-height: 28px;
  padding: 3px 5px;
  color: var(--cream-dim);
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 0.63rem;
  font-weight: 700;
}

.ho-controller-button.is-active {
  color: var(--card);
  background: var(--gold-soft);
}

.ho-controller-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.generator-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.generator-summary,
.play-scale-summary {
  color: var(--cream-dim);
  font-size: 0.72rem;
}

.generator-error {
  margin: 13px 0 0;
}

.character-sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.character-sheet-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffefb;
  box-shadow: 0 7px 20px rgba(90, 70, 40, 0.09);
}

.sheet-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--card-soft);
}

/* シートは情報量が多いため、HO/CUSTOMごとの開閉をsummaryに集約する。 */
.character-sheet-card > .sheet-card-header {
  list-style: none;
}

.character-sheet-card > .sheet-card-header::-webkit-details-marker {
  display: none;
}

.character-sheet-card:not([open]) > .sheet-card-header {
  border-bottom-color: transparent;
}

.sheet-disclosure-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  color: var(--cream-dim);
  font-size: 0.66rem;
  font-weight: 700;
}

.sheet-disclosure-label::after {
  content: "＋";
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--gold-soft);
}

.character-sheet-card[open] .sheet-disclosure-label::after {
  content: "−";
}

.sheet-card-body {
  animation: sheet-open 160ms ease-out;
}

.sheet-body-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 15px 0;
}

@keyframes sheet-open {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.sheet-card-header h4 {
  margin: 0;
  color: var(--gold-soft);
  font-size: 0.9rem;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-control-badge {
  display: inline-block;
  padding: 2px 8px;
  color: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.sheet-card-header p {
  margin: 1px 0 0;
  color: var(--cream-dim);
  font-size: 0.66rem;
}

.sheet-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

/* 持ち込みPCは手入力項目が多いため、既存シートの質感を保ちつつ編集領域を区切る。 */
.custom-pc-card {
  border-color: rgba(168, 128, 47, 0.58);
}

.custom-sheet-header {
  align-items: flex-start;
}

.custom-sheet-actions {
  max-width: 230px;
}

.custom-controller-switch {
  flex: 0 0 auto;
}

.custom-pc-delete {
  min-height: 31px;
  padding: 5px 9px;
  font-size: 0.66rem;
}

.sheet-name-reroll {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 0.68rem;
}

.sheet-fields {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 9px;
  padding: 13px 15px 0;
}

.sheet-fields label:last-child {
  grid-column: 1 / -1;
}

.sheet-fields input {
  min-height: 37px;
  font-size: 0.76rem;
}

.custom-sheet-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.custom-sheet-fields label:last-child {
  grid-column: auto;
}

.custom-stat-grid,
.custom-derived-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.custom-stat-grid {
  padding: 13px 15px;
}

.custom-number-field {
  display: grid;
  gap: 4px;
  color: var(--cream-dim);
  font-family: var(--en);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.custom-number-field input {
  width: 100%;
  min-width: 0;
  min-height: 35px;
  padding: 6px;
  text-align: center;
}

.custom-derived-section {
  margin: 0 15px 13px;
  padding: 10px;
  border: 1px solid var(--bg-deep);
  border-radius: 9px;
  background: var(--card-soft);
}

.custom-derived-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--cream-dim);
  font-size: 0.68rem;
}

.custom-derived-header .button {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.66rem;
}

.custom-pc-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 13px 15px;
  border-top: 1px solid var(--bg-deep);
}

.custom-textarea-field {
  display: grid;
  gap: 5px;
  color: var(--cream-dim);
  font-size: 0.67rem;
  font-weight: 700;
}

.custom-textarea-field textarea {
  min-height: 104px;
  resize: vertical;
  font-size: 0.73rem;
  line-height: 1.55;
}

.custom-skill-hint {
  grid-column: 1 / -1;
  color: var(--cream-dim);
  font-size: 0.69rem;
}

.ia-import-section {
  padding: 12px 15px;
  border-top: 1px solid var(--bg-deep);
}

.ia-import-toggle {
  width: 100%;
}

.ia-import-panel {
  display: grid;
  gap: 8px;
  margin-top: 9px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card-soft);
}

.ia-import-panel[hidden] {
  display: none;
}

.ia-import-guide {
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.68rem;
  line-height: 1.55;
}

.ia-import-panel textarea {
  min-height: 112px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.67rem;
}

.sheet-tachie-section {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 13px 15px 0;
  padding: 10px 12px;
  border: 1px solid var(--bg-deep);
  border-radius: 9px;
  background: var(--card-soft);
}

.sheet-tachie-picker {
  display: grid;
  flex: 1 1 auto;
  gap: 5px;
  min-width: 0;
}

.sheet-tachie-picker > span {
  color: var(--cream-dim);
  font-size: 0.67rem;
  font-weight: 700;
}

.sheet-tachie-picker input[type="file"] {
  width: 100%;
  min-width: 0;
  color: var(--cream-dim);
  font-size: 0.67rem;
}

.sheet-tachie-picker input[type="file"]::file-selector-button {
  margin-right: 8px;
  padding: 5px 9px;
  color: var(--gold-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
  font-size: 0.66rem;
  font-weight: 700;
}

.sheet-tachie-preview {
  display: flex;
  align-items: flex-end;
  flex: 0 0 auto;
  gap: 8px;
}

.sheet-tachie-preview img {
  display: block;
  width: auto;
  max-width: 72px;
  height: 60px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(50, 38, 18, 0.2));
}

.sheet-tachie-delete {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 0.65rem;
}

.sheet-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 13px 15px;
}

.sheet-stat {
  padding: 6px 5px;
  border: 1px solid var(--bg-deep);
  border-radius: 7px;
  background: var(--card);
  text-align: center;
}

.sheet-stat span {
  display: block;
  color: var(--cream-dim);
  font-family: var(--en);
  font-size: 0.59rem;
  font-style: italic;
}

.sheet-stat strong {
  display: block;
  color: var(--cream);
  font-size: 0.88rem;
}

.sheet-derived {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 15px 13px;
}

.derived-pill {
  padding: 3px 8px;
  color: var(--gold-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-soft);
  font-size: 0.68rem;
  font-weight: 700;
}

.sheet-section {
  padding: 12px 15px;
  border-top: 1px solid var(--bg-deep);
}

.sheet-section-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--cream-dim);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sheet-skill-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.skill-roll-button {
  min-width: 0;
  padding: 6px 7px;
  overflow: hidden;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
  font-size: 0.67rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-roll-button:hover {
  color: var(--gold-soft);
  border-color: var(--gold);
  background: #fbf6e9;
}

.skill-roll-button strong {
  float: right;
  color: var(--gold-soft);
}

.sheet-notes {
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.68rem;
  line-height: 1.65;
}

.sheet-unspent {
  color: var(--l3);
}

.play-control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
  gap: 12px;
}

.control-field-note {
  color: var(--cream-dim);
  font-size: 0.58rem;
  font-weight: 500;
}

.script-restart-button[hidden] {
  display: none;
}

.next-chapter-button {
  min-height: 40px;
}

.progress-summary-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  margin-top: 13px;
  padding: 10px 12px;
  color: var(--cream-dim);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--card-soft);
  font-size: 0.7rem;
}

.progress-summary-row[hidden] {
  display: none;
}

.progress-summary-row > span:first-child {
  color: var(--gold-soft);
  font-weight: 700;
  white-space: nowrap;
}

.sidequest-panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(168, 128, 47, 0.42);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.sidequest-panel[hidden],
.sidequest-current[hidden] {
  display: none;
}

.authored-scenario-panel {
  border-color: rgba(168, 128, 47, 0.42);
  background:
    linear-gradient(135deg, rgba(168, 128, 47, 0.035), transparent 38%),
    var(--card);
}

.authored-scenario-panel.has-major-spoiler {
  border-color: rgba(154, 64, 56, 0.42);
  background:
    linear-gradient(135deg, rgba(154, 64, 56, 0.035), transparent 38%),
    var(--card);
}

.authored-heading-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.authored-logline {
  margin: 0 0 15px;
  padding: 13px 15px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: #fcf7f0;
  font-family: var(--serif);
  font-size: 0.79rem;
  line-height: 1.85;
}

.authored-scenario-panel.has-major-spoiler .authored-logline {
  border-left-color: var(--l3);
}

.authored-config-status.is-major-spoiler {
  padding: 5px 9px;
  color: var(--l3);
  border: 1px solid rgba(154, 64, 56, 0.24);
  border-radius: 8px;
  background: #faf3ef;
  font-weight: 700;
}

.authored-info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.45fr) minmax(0, 1.5fr);
  gap: 10px;
}

.authored-info-grid > div {
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card-soft);
}

.authored-info-grid span {
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.58rem;
  font-style: italic;
  letter-spacing: 0.14em;
}

.authored-info-grid strong {
  color: var(--cream);
  font-size: 0.7rem;
  line-height: 1.65;
}

.authored-pc-preset {
  margin-top: 13px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fffefb;
}

.authored-pc-preset h4 {
  margin: 0 0 9px;
  font-size: 0.85rem;
}

.authored-pc-preset dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.authored-pc-preset dl > div {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 10px;
  padding-top: 7px;
  border-top: 1px solid var(--bg-deep);
}

.authored-pc-preset dt {
  color: var(--gold-soft);
  font-size: 0.67rem;
  font-weight: 700;
}

.authored-pc-preset dd {
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.69rem;
  line-height: 1.7;
}

.authored-ending-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 13px;
  padding: 13px 15px;
  color: var(--cream-dim);
  border: 1px solid rgba(154, 64, 56, 0.28);
  border-radius: 10px;
  background: #faf3ef;
}

.authored-ending-row > div {
  display: grid;
  gap: 2px;
}

.authored-ending-row strong {
  color: var(--l3);
  font-size: 0.72rem;
  line-height: 1.7;
}

.sidequest-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sidequest-config-grid label {
  display: flex;
  flex-direction: column;
}

.field-help {
  display: block;
  margin-top: 4px;
  color: var(--cream-dim);
  font-size: 0.65rem;
  line-height: 1.55;
}

.sidequest-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.sidequest-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 13px 15px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: var(--card-soft);
  font-size: 0.7rem;
}

.sidequest-current > div:first-child {
  display: grid;
  gap: 2px;
}

.sidequest-current strong {
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 0.9rem;
}

.sidequest-current-label {
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.58rem;
  font-style: italic;
  letter-spacing: 0.18em;
}

.sidequest-ending-box {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidequest-ending-box > span {
  color: var(--gold-soft);
  font-weight: 700;
}

.sidequest-history-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 19px;
  padding-top: 15px;
  border-top: 1px solid var(--bg-deep);
}

.sidequest-history-heading h4 {
  margin: 0;
  font-size: 0.85rem;
}

.sidequest-history-heading span {
  color: var(--cream-dim);
  font-size: 0.65rem;
}

.sidequest-slot-list {
  display: grid;
  gap: 8px;
  margin-top: 9px;
}

.sidequest-slot-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fffefb;
}

.sidequest-slot-item.is-active {
  border-color: var(--gold);
  background: #fbf6e9;
}

.sidequest-slot-summary {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sidequest-slot-summary strong {
  overflow: hidden;
  color: var(--cream);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidequest-slot-summary span {
  color: var(--cream-dim);
  font-size: 0.63rem;
}

.sidequest-slot-actions {
  display: flex;
  gap: 6px;
}

.settings-panel {
  margin-bottom: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.settings-panel > summary {
  padding: 12px 17px;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 0.82rem;
  font-weight: 700;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(230px, 1fr) minmax(190px, 0.7fr) auto;
  align-items: end;
  gap: 13px;
  padding: 4px 17px 14px;
}

.settings-actions {
  display: flex;
  gap: 8px;
}

.security-note {
  margin: 0;
  padding: 10px 17px;
  color: var(--cream-dim);
  border-top: 1px solid var(--bg-deep);
  background: #fbf8f1;
  font-size: 0.69rem;
}

.bridge-mode-status {
  margin: 0;
  padding: 9px 17px 11px;
  color: var(--gold-soft);
  border-top: 1px solid var(--bg-deep);
  background: #fbf5e7;
  font-size: 0.7rem;
  font-weight: 700;
}

/* 接続設定を独立タブへ集約し、各会話画面には現在値だけを小さく残す。 */
.connection-status-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 0 0 16px auto;
  padding: 6px 10px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.67rem;
  box-shadow: 0 3px 10px rgba(90, 70, 40, 0.07);
}

.connection-status-link strong {
  overflow: hidden;
  max-width: 340px;
  color: var(--gold-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-hub {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.settings-hub-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bg-deep);
}

.settings-hub-heading h3 {
  margin: 2px 0 0;
}

.connection-status-pill {
  padding: 4px 10px;
  color: var(--gold-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-soft);
  font-size: 0.68rem;
  font-weight: 700;
}

.settings-connection-select {
  display: grid;
  gap: 5px;
  max-width: 520px;
  margin: 16px 0;
  color: var(--cream-dim);
  font-size: 0.72rem;
  font-weight: 700;
}

.provider-settings-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
}

.provider-settings-grid[hidden] {
  display: none;
}

.provider-settings-grid label {
  display: grid;
  gap: 4px;
  color: var(--cream-dim);
  font-size: 0.69rem;
  font-weight: 700;
}

.connection-notes {
  margin-top: 14px;
  padding: 12px 14px;
  border-top: 1px solid var(--bg-deep);
  color: var(--cream-dim);
  font-size: 0.7rem;
}

.connection-notes p {
  margin: 4px 0;
}

.public-key-guide {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--card-soft);
}

.public-key-guide summary {
  color: var(--gold-soft);
  font-weight: 700;
  cursor: pointer;
}

.public-key-guide-body p {
  margin: 10px 0 0;
  color: var(--cream-dim);
  font-size: 0.76rem;
  line-height: 1.75;
}

.experimental-settings {
  margin-top: 18px;
}

.focus-mode-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gold-soft);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.focus-mode-toggle-label input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--gold);
}

.focus-mode-note {
  margin: 14px 0 0;
  color: var(--cream-dim);
  font-size: 0.72rem;
}

.library-tab-card {
  margin-bottom: 0;
}

.authored-session-list {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.55);
}

.authored-session-list > summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  color: var(--gold-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.authored-session-list .sidequest-slot-list {
  padding: 0 10px 10px;
}

.npc-bridge-mode-status {
  margin: 0 0 12px;
  border: 1px solid rgba(168, 128, 47, 0.28);
  border-radius: 9px;
}

.button {
  min-height: 39px;
  padding: 8px 14px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: transform 0.2s var(--ease-out), border-color 0.2s ease, background 0.2s ease, filter 0.2s ease;
}

.button:hover:not(:disabled) {
  border-color: var(--gold);
  background: #fbf6e9;
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button-primary {
  color: var(--ink-bg);
  border-color: #b88f39;
  background: linear-gradient(180deg, #e0c27a, #c9a24d);
  box-shadow: 0 7px 16px rgba(168, 128, 47, 0.22);
}

.button-primary:hover:not(:disabled) {
  color: var(--ink-bg);
  background: linear-gradient(180deg, #e7ce91, #d2ad59);
  filter: brightness(1.02);
}

.button-quiet {
  color: var(--gold-soft);
}

.button-danger {
  color: var(--l3);
  border-color: rgba(154, 64, 56, 0.28);
  background: #faf3ef;
}

.chat-shell {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.chat-toolbar,
.chat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 15px;
  background: var(--card-soft);
}

.chat-toolbar {
  border-bottom: 1px solid var(--border);
}

.chat-toolbar strong {
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 0.88rem;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--l0);
  box-shadow: 0 0 0 3px rgba(74, 122, 78, 0.12);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.display-mode-switch,
.speech-mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
}

.novel-speed-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  font-size: 0.62rem;
}

.novel-speed-switch[hidden] {
  display: none;
}

.novel-autoplay-toggle {
  min-height: 34px;
  padding: 4px 10px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  font-size: 0.66rem;
  font-weight: 700;
}

.novel-autoplay-toggle[hidden] {
  display: none;
}

.novel-autoplay-toggle.is-active {
  color: var(--ink-bg);
  border-color: var(--ink-gold);
  background: var(--ink-gold);
}

.novel-speed-switch span {
  padding-inline: 5px 3px;
}

.novel-speed-switch button {
  min-width: 29px;
  min-height: 28px;
  padding: 2px 6px;
  color: var(--cream-dim);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 0.66rem;
  font-weight: 700;
}

.novel-speed-switch button.is-active {
  color: var(--ink-bg);
  background: var(--ink-gold);
}

.display-mode-button,
.speech-mode-button {
  min-height: 32px;
  padding: 4px 11px;
  color: var(--cream-dim);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 0.7rem;
  font-weight: 700;
}

.display-mode-button.is-active,
.speech-mode-button.is-active {
  color: var(--ink-bg);
  background: var(--ink-gold);
  box-shadow: 0 2px 8px rgba(90, 70, 40, 0.16);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 480px;
  padding: 24px;
  overflow-y: auto;
  background:
    linear-gradient(rgba(255, 253, 248, 0.9), rgba(255, 253, 248, 0.9)),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(139, 105, 52, 0.04) 34px 35px);
  scroll-behavior: smooth;
  scrollbar-color: rgba(168, 128, 47, 0.4) transparent;
}

.chat-welcome {
  max-width: 650px;
  margin: auto;
  color: var(--cream-dim);
  font-size: 0.84rem;
  text-align: center;
}

.chat-welcome .moon {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 2rem;
}

.message {
  max-width: min(78%, 780px);
}

.message-user {
  align-self: flex-end;
}

.message-assistant {
  align-self: flex-start;
}

.message-system {
  align-self: center;
  max-width: 100%;
}

.message-system .message-label {
  display: none;
}

.message-system .message-bubble {
  padding: 5px 12px;
  color: var(--cream-dim);
  border-style: dashed;
  border-radius: 999px;
  background: rgba(243, 236, 220, 0.74);
  box-shadow: none;
  font-size: 0.68rem;
}

.message-label {
  margin: 0 5px 4px;
  color: var(--cream-dim);
  font-family: var(--en);
  font-size: 0.63rem;
  font-style: italic;
  letter-spacing: 0.12em;
}

.message-user .message-label {
  text-align: right;
}

.message-user.message-pc .message-label {
  color: var(--gold-soft);
  font-weight: 700;
}

.message-user.message-pl .message-label {
  color: #77736c;
  font-family: var(--sans);
  font-style: normal;
  letter-spacing: 0.04em;
}

.message-user.message-pl .message-bubble {
  color: #595650;
  border-color: rgba(88, 84, 76, 0.28);
  background: #f2f0eb;
}

.message-bubble {
  padding: 12px 15px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--card-soft);
  box-shadow: 0 5px 15px rgba(90, 70, 40, 0.08);
  font-size: 0.78rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.message-characterized {
  display: flex;
  align-self: stretch;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
}

.character-dialogue {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(88%, 780px);
  margin-right: auto;
}

.character-dialogue.is-player {
  margin-right: 0;
  margin-left: auto;
}

.character-avatar {
  position: relative;
  display: inline-grid;
  overflow: hidden;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  color: #fff;
  border: 2px solid hsl(var(--avatar-hue) 42% 78%);
  border-radius: 50%;
  background: hsl(var(--avatar-hue) 38% 43%);
  box-shadow: 0 4px 12px rgba(72, 53, 27, 0.18);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.character-avatar img {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
  object-fit: cover;
  object-position: 50% 12%;
}

.character-dialogue-content {
  min-width: 0;
}

.character-dialogue-name {
  margin: 0 4px 4px;
  color: var(--gold-soft);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.35;
}

.character-dialogue-bubble {
  padding: 11px 14px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 4px 13px 13px 13px;
  background: var(--card-soft);
  box-shadow: 0 5px 15px rgba(90, 70, 40, 0.08);
  font-size: 0.84rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.character-dialogue.is-player .character-dialogue-bubble {
  border-color: rgba(168, 128, 47, 0.5);
  background: var(--card);
}

.chat-narration {
  width: min(calc(88% - 56px), 724px);
  margin-right: auto;
  margin-left: 56px;
  padding: 5px 12px;
  color: #766b5e;
  border-left: 2px solid rgba(139, 105, 52, 0.22);
  font-family: var(--serif);
  font-size: 0.8rem;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-script-narration .chat-narration {
  color: var(--cream-dim);
}

.message-user .message-bubble {
  border-color: rgba(168, 128, 47, 0.5);
  border-bottom-right-radius: 3px;
  background: var(--card);
}

.message-assistant .message-bubble {
  border-bottom-left-radius: 3px;
  background: var(--card-soft);
}

.message-dice .message-bubble {
  color: var(--gold-soft);
  border-color: rgba(168, 128, 47, 0.42);
  background: #fbf4df;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-weight: 700;
}

.message-script .message-bubble {
  font-family: var(--serif);
  line-height: 1.85;
}

.message-script-scene_header {
  align-self: stretch;
  max-width: 100%;
  text-align: center;
}

.message-script-scene_header .message-bubble {
  color: var(--gold-soft);
  border-color: rgba(168, 128, 47, 0.5);
  background: #fbf4df;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.message-script-secret .message-bubble {
  border-color: rgba(111, 75, 129, 0.42);
  background: #f8f0fb;
}

.log-rewind-row {
  display: flex;
  justify-content: flex-start;
  width: min(78%, 780px);
  margin-top: -8px;
}

.log-rewind-button {
  min-height: 40px;
  padding: 7px 12px;
  color: var(--cream-dim);
  border-color: rgba(139, 105, 52, 0.2);
  background: rgba(255, 253, 248, 0.68);
  box-shadow: none;
  font-size: 0.7rem;
}

.log-rewind-button:hover:not(:disabled) {
  color: var(--gold-soft);
  border-color: rgba(168, 128, 47, 0.48);
}

.log-rewind-button.is-danger {
  color: var(--l3);
  border-color: rgba(154, 64, 56, 0.38);
  background: #faf3ef;
}

.chat-error {
  margin: 0 17px 11px;
  padding: 10px 12px;
  color: #6d3d37;
  border: 1px solid rgba(154, 64, 56, 0.35);
  border-radius: 8px;
  background: #faf3ef;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.scene-suggestion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 17px 11px;
  padding: 6px 8px 6px 12px;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.45);
  border-radius: 8px;
  background: var(--ink-bg-t);
  font-size: 0.82rem;
}

.scene-suggestion[hidden] {
  display: none;
}

.scene-suggestion-text {
  flex: 1 1 12em;
  min-width: 0;
}

.scene-suggestion .button {
  min-height: 36px;
  padding: 4px 12px;
}

.scene-suggestion-dismiss {
  min-width: 36px;
}

.chat-error-action {
  display: block;
  margin-top: 8px;
  min-height: 40px;
}

.script-control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 15px;
  /* 新しい待ちで操作欄までスクロールする時、下に張り付いた入力欄・上に張り付いたタブの裏に潜らせない。
     下の値は app.js が入力欄の実測の高さで上書きする。 */
  scroll-margin-top: 72px;
  scroll-margin-bottom: var(--script-control-scroll-margin, 180px);
  border-top: 1px solid rgba(168, 128, 47, 0.34);
  background: #f9f3e6;
}

.script-control-panel[hidden] {
  display: none;
}

.script-control-status {
  flex: 0 0 auto;
  color: var(--gold-soft);
  font-family: var(--en);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.script-control-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.script-control-actions .button {
  min-height: 31px;
  padding: 5px 9px;
  font-size: 0.65rem;
}

.script-control-actions .is-visited {
  color: var(--l0);
  border-color: rgba(74, 122, 78, 0.4);
}

.script-control-hint {
  color: var(--cream-dim);
  font-size: 0.67rem;
}

/* おまかせ進行：進み方の切り替え（おまかせ／じっくり）。操作欄のいちばん上に小さく。 */
.script-control-panel {
  flex-wrap: wrap;
}

.script-pacing-row {
  display: flex;
  flex: 1 0 100%;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.script-pacing-row[hidden] {
  display: none;
}

.script-pacing-label {
  color: var(--gold-soft);
  font-size: 0.66rem;
  font-weight: 800;
}

.script-pacing-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(168, 128, 47, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.script-pacing-option {
  min-height: 28px;
  padding: 2px 10px;
  color: var(--cream-dim);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 0.66rem;
  font-weight: 700;
  cursor: pointer;
}

.script-pacing-option.is-active {
  color: var(--ink-bg);
  background: var(--ink-gold);
}

.script-pacing-note {
  color: var(--cream-dim);
  font-size: 0.64rem;
}

/* ボタン1つで振る判定：「🎲 〈技能〉を振る」を目立たせ、申告の2つは小さく残す。 */
.script-control-actions .script-one-tap-button {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.74rem;
}

.script-control-actions .script-control-minor {
  min-height: 26px;
  padding: 3px 7px;
  font-size: 0.6rem;
  opacity: 0.85;
}

/* 選ぶ（s049〈ルル救出作戦〉）：表示名の下に、元の本文の一文を小さく添える。 */
.script-control-actions .script-choice-button {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: 100%;
  text-align: left;
  white-space: normal;
}

.script-choice-label {
  font-size: 0.74rem;
  font-weight: 800;
}

.script-choice-desc {
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.85;
  overflow-wrap: anywhere;
}

.novel-stage {
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: flex-end;
  /* 立ち絵の下が文章ウィンドウで見切れないよう、16:9 より少し縦長にする（11/1 KASO「比率は多少いじってよい」） */
  /* 余白は上と左右だけ広く取り、下は 8px に詰める（11/16 KASO「背景の下の方が少し開いていて気になる。
     キャラクターとテキストウィンドウを下げて」）。窓が下がった分だけ、立ち絵の床（--novel-floor-reserve）も下がる。
     640px 以下は下の別の決まり（余白 10px・6px）のまま。 */
  --novel-pad: clamp(14px, 2.1vw, 26px);
  --novel-pad-bottom: 8px;
  --novel-floor-reserve: calc(var(--novel-pad-bottom) + 72px);
  width: 100%;
  min-height: 0;
  aspect-ratio: 3 / 2;
  padding: var(--novel-pad) var(--novel-pad) var(--novel-pad-bottom);
  /* はみ出しは切るだけで、中身を動かせる箱にしない（clip）。hidden だと、背景を大きく敷いた分だけ中身が動かせて、
     章の札や立ち絵の頭が上へずれて切れることがあった。clip が使えない環境は hidden のまま（app.js が位置を戻す）。 */
  overflow: hidden;
  overflow: clip;
  background-color: var(--ink-bg);
  background-position: center;
  background-size: cover;
  isolation: isolate;
}

.novel-stage[hidden] {
  display: none;
}

.novel-speaker[hidden],
.novel-next-button[hidden],
.play-speaker-label[hidden],
.dice-bar[hidden],
.chat-composer[hidden] {
  display: none;
}

.novel-stage::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, rgba(30, 23, 12, 0.05) 40%, rgba(30, 23, 12, 0.46) 100%);
}

/* 背景の層。ぼかしで縁が透けないよう、舞台より少し大きく敷く */
.novel-bg {
  position: absolute;
  z-index: -2;
  inset: -24px;
  background-color: var(--ink-bg);
  background-position: center;
  background-size: cover;
  pointer-events: none;
  transition: filter 0.3s ease;
}

/* スチル（出来事の一枚絵・16:9）：左右を切らずに、絵の全体を舞台の上端に合わせて見せる。
   舞台は 3:2 なので、絵の下に少し余る分は、文章ウィンドウの後ろに隠れる。 */
.novel-bg.is-still {
  inset: 0;
  background-position: center top;
  background-size: 100% auto;
  background-repeat: no-repeat;
}

/* リプレイ動画のノベル型と同じく、立ち絵が出ている間は背景をぼかして少し暗くする
   （ぼかしは舞台の幅の約0.5%＝1920pxで10px相当。切り替えは0.3秒） */
.novel-stage:has(.novel-tachie:not([hidden])) .novel-bg {
  filter: blur(clamp(2px, 0.3vw, 8px)) brightness(0.86);
}

/* 立ち絵の置き方：頭のてっぺんを舞台の上から7%に（リプレイ動画のノベル型と同じ）。
   股は「床」＝文章ウィンドウ（1行・名札あり）の上端より少し下に置き、窓で隠れるのは絵の下端だけにする
   （11/1 KASO「立ち絵の下の方が見切れている」）。床の高さは --novel-floor-reserve（舞台の下端からの距離）。
   頭と股の位置は立ち絵ごとに manifest.json の head_top / crotch（絵の上端0〜下端1）。
   頭の上に掲げた物（槍・剣）は数えないので、舞台の上へはみ出してよい。 */
.novel-tachie {
  --tachie-head-top: 0;
  --tachie-crotch: 1;
  position: absolute;
  z-index: 0;
  top: calc(7% - (93% - var(--novel-floor-reserve)) * var(--tachie-head-top) / (var(--tachie-crotch) - var(--tachie-head-top)));
  left: 50%;
  width: auto;
  height: calc((93% - var(--novel-floor-reserve)) / (var(--tachie-crotch) - var(--tachie-head-top)));
  max-width: none;
  max-height: none;
  /* 暗くする時と関数の並びをそろえる（そろっていないと明暗がなめらかに変わらない）。
     影（drop-shadow）は付けない：絵の四角い枠で影が切れて、立ち絵のまわりに「うっすら黒いモヤ」が四角く見えていた
     （11/18 KASO「立ち絵にうっすらと黒いモヤが表示されている」。切り抜きそのものは、人物から離れた所に残りなし）。 */
  filter: brightness(1);
  /* 絵の下端の切り口は、窓が短い時（地の文・1行）にも見えないよう細くぼかす。 */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  pointer-events: none;
  opacity: 1;
  translate: -50% 0;
  transform: translateY(0);
  transition: opacity 0.16s ease, transform 0.2s ease, filter 0.16s ease;
}

/* 二人のときの立ち位置（中心）。リプレイの左右（1920pxで460/1460）より少し内側 */
.novel-tachie[data-slot="left"] {
  left: 27%;
}

.novel-tachie[data-slot="right"] {
  left: 73%;
}

.novel-tachie[hidden] {
  display: none;
}

/* 話していない人は、リプレイと同じく透かさずに暗くする（重なっても透けない） */
.novel-tachie.is-dim {
  z-index: -1;
  filter: brightness(0.55);
}

.novel-tachie.is-fading,
.novel-tachie.is-entering {
  opacity: 0;
  transform: translateY(5px);
}

.novel-scene-badge {
  position: absolute;
  z-index: 1;
  top: 14px;
  left: 14px;
  max-width: calc(100% - 28px);
  padding: 7px 14px;
  overflow: hidden;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.72);
  border-radius: 999px;
  background: rgba(30, 23, 12, 0.88);
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.28);
  font-family: var(--serif);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* RP待ちなどの小さな案内。文章ウィンドウのすぐ上に出す */
.novel-script-hint {
  position: relative;
  z-index: 2;
  max-width: min(100%, 980px);
  margin: 0 auto 26px;
  padding: 4px 12px;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.55);
  border-radius: 999px;
  background: rgba(30, 23, 12, 0.78);
  font-family: var(--serif);
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.novel-script-hint[hidden],
.novel-thinking[hidden] {
  display: none;
}

/* 返事を待つ間の「考え中」。控えめにゆっくり点滅させる */
.novel-thinking {
  align-self: flex-start;
  color: var(--ink-gold);
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  line-height: 1.2;
  animation: novel-thinking-blink 1.6s ease-in-out infinite;
}

@keyframes novel-thinking-blink {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.9; }
}

.novel-transition {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.novel-scene-badge[hidden],
.novel-transition[hidden] {
  display: none;
}

/* 情報の札（ニュース・メモ・見つけたもの）。画面の中央に出して、読み終えるまで待つ（2026-11-17）。
   札の外は押せるまま（pointer-events: none）。札を出している間は、下の窓をしまう（同じ文が二重に見えないように）。 */
.novel-info-card {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 14, 6, 0.42);
  pointer-events: none;
  animation: novel-info-card-in 0.28s ease-out both;
}

.novel-info-card[hidden] {
  display: none;
}

.novel-info-card-paper {
  display: flex;
  flex-direction: column;
  width: min(100%, 600px);
  max-height: min(78dvh, 640px);
  padding: 20px 24px 12px;
  color: #33291d;
  border: 1px solid rgba(139, 105, 52, 0.45);
  border-radius: 6px;
  background: linear-gradient(180deg, #fffdf6, #f6efdf);
  box-shadow: 0 22px 60px rgba(10, 7, 2, 0.5), 0 0 0 6px rgba(255, 253, 246, 0.12);
  cursor: pointer;
  pointer-events: auto;
}

.novel-info-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.novel-info-card-label {
  padding: 2px 12px;
  color: #fffdf6;
  border-radius: 999px;
  background: #7a5a22;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.novel-info-card-page {
  color: #6f5f4b;
  font-size: 0.8rem;
}

.novel-info-card-label[hidden],
.novel-info-card-page[hidden],
.novel-info-card-title[hidden] {
  display: none;
}

.novel-info-card-title {
  margin-bottom: 8px;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
}

.novel-info-card-text {
  overflow-y: auto;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.95;
}

.novel-info-card-text p {
  margin: 0 0 0.7em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.novel-info-card-text p:last-child {
  margin-bottom: 0;
}

.novel-info-card-text p.is-earlier {
  color: #7b6d58;
}

.novel-info-card-next {
  align-self: flex-end;
  min-height: 40px;
  margin-top: 8px;
  padding: 6px 12px;
  color: #7a5a22;
  border: 0;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* 判定のダイスの演出（2026-11-18 KASO「ダイスロールした感を出すために、十面ダイスの立体が動いているような演出を」）。
   画面の中央に、振る人ごとに1行（顔・名前・技能・十面ダイス2個・出目）。転がり終えたら出目と成否を出して、少し見せてから閉じる。
   押すと、転がっている間は結果へ飛び、結果が出ていれば閉じる。 */
.dice-overlay {
  position: fixed;
  z-index: 65;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 14, 6, 0.5);
  cursor: pointer;
  animation: novel-info-card-in 0.2s ease-out both;
}

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

.dice-overlay-panel {
  display: grid;
  gap: 10px;
  width: min(100%, 560px);
  max-height: 86dvh;
  padding: 16px 18px 14px;
  overflow-y: auto;
  color: #f2ead8;
  border: 1px solid rgba(224, 194, 122, 0.4);
  border-radius: 14px;
  background: rgba(30, 23, 12, 0.94);
  box-shadow: 0 22px 60px rgba(10, 7, 2, 0.55);
}

.dice-overlay-rows {
  display: grid;
  gap: 8px;
}

.dice-overlay-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  grid-template-areas: "who dice" "skill dice" "mark dice";
  align-items: center;
  gap: 0 12px;
  padding: 8px 10px;
  border: 1px solid rgba(224, 194, 122, 0.18);
  border-radius: 10px;
  background: rgba(255, 253, 246, 0.05);
}

.dice-overlay-who {
  display: flex;
  grid-area: who;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.95rem;
}

.dice-overlay-who .character-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
}

.dice-overlay-who strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-overlay-skill {
  grid-area: skill;
  color: #e0c27a;
  font-size: 0.82rem;
}

.dice-overlay-canvas {
  display: block;
  grid-area: dice;
  width: 168px;
  height: 80px;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 70%, rgba(243, 234, 214, 0.2), rgba(243, 234, 214, 0.05));
}

/* 振る人が少ない時は、ダイスを大きく見せる */
.dice-overlay-rows[data-count="1"] .dice-overlay-row {
  grid-template-columns: minmax(0, 1fr) 280px;
}

.dice-overlay-rows[data-count="1"] .dice-overlay-canvas {
  width: 280px;
  height: 132px;
}

.dice-overlay-rows[data-count="2"] .dice-overlay-row {
  grid-template-columns: minmax(0, 1fr) 232px;
}

.dice-overlay-rows[data-count="2"] .dice-overlay-canvas {
  width: 232px;
  height: 110px;
}

.dice-overlay-mark {
  grid-area: mark;
  min-height: 1.5em;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.dice-overlay.is-done .dice-overlay-mark {
  opacity: 1;
}

.dice-overlay-row.is-success {
  border-color: rgba(143, 196, 120, 0.7);
}

.dice-overlay-row.is-success .dice-overlay-mark {
  color: #b9e3a2;
}

.dice-overlay-row.is-failure {
  border-color: rgba(214, 120, 104, 0.55);
}

.dice-overlay-row.is-failure .dice-overlay-mark {
  color: #f0a898;
}

.dice-overlay-result {
  min-height: 1.6em;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  text-indent: 0.3em;
}

.dice-overlay-result.is-success {
  color: #b9e3a2;
}

.dice-overlay-result.is-failure {
  color: #f0a898;
}

@media (max-width: 480px) {
  .dice-overlay-panel {
    padding: 12px 12px 10px;
  }

  .dice-overlay-row,
  .dice-overlay-rows[data-count="2"] .dice-overlay-row {
    grid-template-columns: minmax(0, 1fr) 132px;
    padding: 6px 8px;
  }

  .dice-overlay-canvas,
  .dice-overlay-rows[data-count="2"] .dice-overlay-canvas {
    width: 132px;
    height: 64px;
  }

  /* 1人だけの時は、名前の下にダイスを大きく置く */
  .dice-overlay-rows[data-count="1"] .dice-overlay-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "who" "skill" "dice" "mark";
    gap: 4px 0;
  }

  .dice-overlay-rows[data-count="1"] .dice-overlay-canvas {
    justify-self: center;
    width: min(100%, 260px);
    height: 122px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dice-overlay {
    animation: none;
  }
}

/* 話を聞く場面の、質問の選択肢 */
.script-topic-list {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  gap: 8px;
}

.script-topic-button {
  min-height: 40px;
  text-align: left;
}

.script-topic-button.is-asked {
  opacity: 0.72;
}

.novel-stage.has-info-card .novel-window,
.novel-stage.has-info-card .novel-script-hint {
  visibility: hidden;
}

@keyframes novel-info-card-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .novel-info-card {
    animation: none;
  }
}

@media (max-width: 480px) {
  .novel-info-card {
    padding: 10px;
  }

  .novel-info-card-paper {
    padding: 16px 16px 8px;
  }

  .novel-info-card-text {
    font-size: 1rem;
    line-height: 1.85;
  }
}

.novel-window {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 980px);
  /* 高さは本文に追従させる。1行なら薄く、増えた分だけ伸び、上限で内部スクロール */
  height: auto;
  min-height: 0;
  max-height: 45%;
  margin: 0 auto;
  padding: 15px 28px 20px;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.72);
  border-radius: 12px;
  background: rgba(30, 23, 12, 0.88);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.novel-speaker {
  position: absolute;
  top: -19px;
  left: 24px;
  min-width: 120px;
  padding: 7px 18px;
  color: var(--ink-bg);
  border: 1px solid rgba(255, 253, 248, 0.32);
  border-radius: 8px;
  background: var(--ink-gold);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.28);
  font-family: var(--serif);
  font-weight: 700;
  text-align: center;
}

/* 判定のダイス（2026-11-18 KASO「別ウィンドウではなく、盤面のテキストウィンドウの右上に表示して。テキストウィンドウ上で
   成功か失敗か判定して表示して」）。話者の札と同じく、窓の上の縁にまたがって、右上に置く。成否は窓の中の行に出す。 */
.novel-dice {
  position: absolute;
  z-index: 3;
  top: -76px;
  right: 14px;
  width: 224px;
  height: 106px;
  pointer-events: none;
}

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

/* ダイスを出している間は、窓の上の案内（話す場面の一行）を隠す（重ならないように） */
.novel-stage.has-dice .novel-script-hint {
  visibility: hidden;
}

.novel-dice-lines {
  display: grid;
  gap: 2px;
}

.novel-dice-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.7em;
  line-height: 1.55;
  transition: opacity 0.18s ease;
}

.novel-dice-line.is-pending {
  opacity: 0.5;
}

.novel-dice-line.is-rolling {
  opacity: 1;
}

.novel-dice-who {
  font-weight: 700;
}

.novel-dice-skill {
  opacity: 0.86;
  font-size: 0.92em;
}

.novel-dice-mark {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.novel-dice-line.is-success .novel-dice-mark {
  color: #f3d98f;
}

.novel-dice-line.is-failure .novel-dice-mark {
  color: #e2a9a0;
}

.novel-dice-verdict {
  margin-top: 4px;
  font-size: 1.18em;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.novel-dice-verdict:empty {
  display: none;
}

.novel-dice-verdict.is-success {
  color: #f3d98f;
}

.novel-dice-verdict.is-failure {
  color: #e2a9a0;
}

@media (max-width: 640px) {
  .novel-dice {
    top: -52px;
    right: 6px;
    width: 148px;
    height: 70px;
  }

  .novel-dice-line {
    font-size: 0.94em;
    line-height: 1.45;
  }
}

/* ネームプレート表示中は本文の開始位置を下げ、枠と文字の重なりを防ぐ */
.novel-window:has(.novel-speaker:not([hidden])) {
  padding-top: 32px;
}

.novel-text {
  flex: 0 1 auto;
  min-height: 1.8em;
  overflow-y: auto;
  font-family: var(--serif);
  font-size: clamp(0.9rem, 1.5vw, 1.02rem);
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.novel-char {
  animation: novel-char-in 0.16s ease-out both;
}

@keyframes novel-char-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.novel-next-button {
  position: absolute;
  right: 19px;
  bottom: 12px;
  padding: 2px 8px;
  color: var(--ink-gold);
  border: 0;
  background: transparent;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
}

.roll-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.message .roll-suggestions {
  justify-content: flex-start;
  padding-left: 2px;
}

.roll-suggestion-button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--gold-soft);
  border: 1px solid rgba(168, 128, 47, 0.5);
  border-radius: 9px;
  background: #fffaf0;
  box-shadow: 0 4px 12px rgba(90, 70, 40, 0.1);
  font-size: 0.7rem;
  font-weight: 700;
}

.roll-suggestion-button:hover:not(:disabled) {
  border-color: var(--gold);
  background: #fff5dc;
}

.novel-roll-suggestions {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  align-items: flex-end;
  flex-direction: column;
  width: auto;
  max-width: min(64%, 340px);
  margin-top: 0;
  gap: 6px;
}

.novel-roll-suggestions:empty {
  display: none;
}

.novel-roll-callout {
  padding: 7px 12px;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.72);
  border-radius: 10px;
  background: rgba(30, 23, 12, 0.88);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  font-family: var(--serif);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  animation: novel-roll-callout-in 0.35s ease-out;
}

@keyframes novel-roll-callout-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.novel-roll-suggestions .roll-suggestion-button {
  color: var(--ink-gold);
  border-color: rgba(224, 194, 122, 0.68);
  background: rgba(30, 23, 12, 0.9);
}

.chat-shell.is-novel-mode .play-chat-composer {
  position: sticky;
  z-index: 4;
  bottom: 0;
  box-shadow: 0 -8px 20px rgba(30, 23, 12, 0.12);
}

.dice-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border-top: 1px solid var(--border);
  background: var(--card-soft);
}

.dice-button {
  color: var(--gold-soft);
  border-color: rgba(168, 128, 47, 0.52);
  background: #fffaf0;
}

.custom-dice-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.custom-dice-label input {
  width: 90px;
  min-height: 37px;
  margin: 0;
}

.dice-hint {
  margin-left: auto;
  color: var(--cream-dim);
  font-size: 0.66rem;
}

/* 場面転換ピッカー */
.scene-change-button {
  white-space: nowrap;
}

.scene-picker {
  width: min(560px, calc(100vw - 24px));
  max-height: min(80vh, 720px);
  padding: 0;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.scene-picker::backdrop {
  background: rgba(36, 28, 16, 0.55);
}

.scene-picker-form {
  display: grid;
  gap: 10px;
  padding: 16px 18px 18px;
}

.scene-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scene-picker-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.scene-picker-note {
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.74rem;
  line-height: 1.6;
}

.scene-picker-note code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--card-soft);
  font-size: 0.72rem;
}

#scene-picker-search {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fffdf8;
  font: inherit;
  font-size: 16px;
}

.scene-picker-notify {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cream-dim);
  font-size: 0.76rem;
}

.scene-picker-list {
  display: grid;
  gap: 4px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}

.scene-picker-group {
  margin: 8px 0 2px;
  color: var(--gold-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.scene-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  text-align: left;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fffdf8;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.scene-picker-item:hover,
.scene-picker-item:focus-visible {
  border-color: var(--gold);
  background: #fbf3e2;
}

.scene-picker-item.is-current {
  border-color: var(--gold);
  background: #f3e7c9;
}

.scene-picker-item small {
  flex: none;
  color: var(--cream-dim);
  font-size: 0.66rem;
}

.scene-picker-empty {
  padding: 14px 6px;
  color: var(--cream-dim);
  font-size: 0.78rem;
}

/* 会話・ノベルのどちらでも技能へ到達できる常設パレット。 */
.chat-palette {
  border-top: 1px solid var(--border);
  background: #fffcf5;
}

.chat-palette > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  color: var(--gold-soft);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 800;
  list-style-position: inside;
}

.chat-palette-summary {
  margin-left: auto;
  color: var(--cream-dim);
  font-size: 0.64rem;
  font-weight: 500;
}

.chat-palette-body {
  display: grid;
  gap: 7px;
  max-height: 250px;
  padding: 0 10px 10px;
  overflow-y: auto;
}

.chat-palette-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.chat-palette-tab {
  flex: 0 0 auto;
  min-height: 29px;
  padding: 4px 9px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-soft);
  font-size: 0.62rem;
  font-weight: 700;
}

.chat-palette-tab.is-active {
  color: var(--ink-bg);
  border-color: var(--ink-gold);
  background: var(--ink-gold);
}

.chat-palette-pc {
  display: grid;
  gap: 6px;
  padding: 5px 6px;
  border: 1px solid var(--bg-deep);
  border-radius: 9px;
  background: var(--card);
}

.chat-palette-pc-heading {
  display: inline-flex;
  align-items: baseline;
  flex: 0 0 auto;
  gap: 3px;
  max-width: 100%;
  padding-top: 3px;
  white-space: nowrap;
}

.chat-palette-pc-heading strong {
  color: var(--cream);
  overflow: hidden;
  font-size: 0.62rem;
  text-overflow: ellipsis;
}

.chat-palette-pc-heading span {
  color: var(--cream-dim);
  font-family: var(--en);
  font-size: 0.52rem;
}

.chat-palette-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.chat-palette-roll-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  color: var(--gold-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fffaf0;
  font-size: 0.64rem;
  font-weight: 700;
  text-align: left;
}

.chat-palette-roll-button:hover:not(:disabled) {
  border-color: var(--gold);
  background: #fff3d4;
}

.chat-palette-roll-button.is-kp-requested {
  color: #69480d;
  border-color: var(--gold);
  background: #fff0bf;
  box-shadow: 0 4px 12px rgba(139, 105, 52, 0.2);
}

.chat-palette-roll-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-palette-kp-badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  color: var(--ink-bg);
  border-radius: 999px;
  background: var(--ink-gold);
  font-size: 0.55rem;
  font-weight: 900;
  white-space: nowrap;
}

.chat-palette-request {
  margin: 0;
  padding: 4px 7px;
  color: var(--gold-soft);
  border-left: 3px solid var(--gold);
  background: #fff7e4;
  font-size: 0.59rem;
  font-weight: 700;
}

.chat-palette-empty {
  align-self: center;
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.67rem;
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 13px 15px;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.play-chat-composer {
  grid-template-columns: minmax(155px, 0.28fr) 1fr auto;
}

.play-input-controls {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 7px;
}

.play-speaker-label {
  display: grid;
  gap: 2px;
  color: var(--cream-dim);
  font-size: 0.66rem;
}

.play-speaker-label select {
  min-height: 34px;
  margin: 0;
  padding-block: 4px;
}

.speech-shortcut {
  color: var(--cream-dim);
  font-size: 0.62rem;
  line-height: 1.35;
}

.speech-shortcut kbd {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--card-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chat-composer textarea {
  min-height: 76px;
  margin: 0;
  background: #fffefb;
}

.speech-input-field {
  min-width: 0;
}

.speech-textarea-wrap {
  position: relative;
}

.speech-input-field textarea {
  display: block;
  width: 100%;
  padding-right: 54px;
}

.speech-input-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--gold-soft);
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card-soft);
  box-shadow: 0 3px 10px rgba(90, 70, 40, 0.12);
  cursor: pointer;
  font-size: 1rem;
}

.speech-input-button:hover:not(:disabled) {
  color: var(--gold);
  border-color: var(--gold);
  background: var(--card);
}

.speech-input-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.speech-input-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.speech-input-button[hidden] {
  display: none;
}

.speech-input-button.is-listening {
  color: #fff;
  border-color: var(--l3);
  background: var(--l3);
  animation: speech-input-pulse 1.2s ease-in-out infinite;
}

.speech-input-preview,
.speech-input-note {
  min-height: 1.4em;
  margin: 5px 4px 0;
  color: var(--cream-dim);
  font-size: 0.66rem;
  line-height: 1.4;
}

.speech-input-preview {
  opacity: 0.72;
}

@keyframes speech-input-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(154, 64, 56, 0.34); }
  50% { box-shadow: 0 0 0 7px rgba(154, 64, 56, 0); }
}

.send-button {
  align-self: stretch;
  min-width: 84px;
  border-radius: 10px;
}

.send-button.is-stop {
  color: #fff;
  border-color: #8f3d37;
  background: #9a4038;
  box-shadow: 0 5px 14px rgba(126, 46, 40, 0.2);
}

.send-button.is-stop:hover {
  background: #7f302b;
}

.streaming-message {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
}

.streaming-waiting {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 9px;
  padding: 10px 14px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--card-soft);
  box-shadow: 0 5px 15px rgba(90, 70, 40, 0.07);
  font-family: var(--serif);
  font-size: 0.76rem;
}

.streaming-dots {
  min-width: 1.35em;
  color: var(--gold-soft);
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  animation: streaming-dots-pulse 1.05s ease-in-out infinite;
}

.streaming-bubble {
  max-width: min(88%, 780px);
  border-bottom-left-radius: 3px;
}

.novel-stage > .streaming-message.is-novel-waiting {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 14px;
  width: auto;
}

.novel-stage > .streaming-message .streaming-waiting {
  color: var(--ink-dim);
  border-color: rgba(224, 194, 122, 0.5);
  background: rgba(30, 23, 12, 0.86);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

@keyframes streaming-dots-pulse {
  0%, 100% { opacity: 0.3; transform: translateY(1px); }
  50% { opacity: 1; transform: translateY(-1px); }
}

.chat-footer {
  color: var(--cream-dim);
  border-top: 1px solid var(--border);
  font-size: 0.67rem;
}

.usage-display {
  color: var(--gold-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  text-align: right;
}

.npc-progress-gate {
  display: grid;
  grid-template-columns: 1fr minmax(250px, 0.34fr);
  align-items: end;
  gap: 20px;
  margin-bottom: 16px;
  padding: 16px 18px;
  color: var(--cream);
  border: 1px solid rgba(168, 128, 47, 0.48);
  border-radius: var(--radius);
  background: #fff8e8;
  box-shadow: 0 8px 22px rgba(90, 70, 40, 0.1);
}

.npc-progress-gate h3 {
  margin: 0 0 5px;
  color: var(--gold-soft);
  font-size: 0.95rem;
}

.npc-progress-gate p {
  max-width: 820px;
  margin: 0;
  color: var(--cream-dim);
  font-size: 0.72rem;
  line-height: 1.65;
}

.npc-progress-gate label {
  display: grid;
  gap: 6px;
  color: var(--gold-soft);
  font-size: 0.7rem;
  font-weight: 700;
}

.npc-progress-gate select {
  width: 100%;
  min-height: 42px;
  margin: 0;
  background: var(--card);
}

.npc-chat-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(520px, 1.8fr);
  gap: 18px;
  align-items: start;
}

.npc-chat-sidebar {
  position: sticky;
  top: 66px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.npc-chat-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-soft);
}

.npc-chat-sidebar-head strong {
  display: block;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 0.9rem;
}

.npc-chat-eyebrow {
  display: block;
  margin-bottom: 1px;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.6rem;
  font-style: italic;
  letter-spacing: 0.24em;
}

.npc-chat-list {
  display: grid;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  scrollbar-color: rgba(168, 128, 47, 0.42) transparent;
}

.npc-select-item {
  width: 100%;
  padding: 12px 15px;
  color: var(--cream);
  border: 0;
  border-top: 1px solid var(--bg-deep);
  background: var(--card);
  text-align: left;
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.npc-select-item:first-child {
  border-top: 0;
}

.npc-select-item:hover:not(:disabled) {
  background: #faf6ed;
}

.npc-select-item.is-selected {
  background: var(--card-soft);
  box-shadow: inset 3px 0 var(--gold);
}

.npc-select-item:disabled {
  cursor: wait;
  opacity: 0.62;
}

.npc-select-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 700;
}

.npc-select-identity {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.npc-edited-badge {
  flex: 0 0 auto;
  padding: 2px 6px;
  color: #6f5422;
  border: 1px solid rgba(168, 128, 47, 0.48);
  border-radius: 999px;
  background: #fff4d7;
  font-family: var(--sans);
  font-size: 0.55rem;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
}

.npc-select-check {
  display: inline-grid;
  place-items: center;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  color: var(--card);
  border: 1px solid rgba(168, 128, 47, 0.58);
  border-radius: 50%;
  background: var(--card);
  font-family: var(--sans);
  font-size: 0.48rem;
  line-height: 1;
}

.npc-select-item.is-selected .npc-select-check {
  color: var(--card);
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

.npc-select-scene {
  display: block;
  overflow: hidden;
  color: var(--cream-dim);
  font-size: 0.68rem;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.npc-chat-shell {
  min-width: 0;
}

.npc-chat-topbar {
  min-height: 64px;
}

.npc-chat-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.npc-chat-identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.npc-mode-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
}

.is-play-mode .npc-mode-switch,
.is-play-mode .npc-secret-badge {
  display: none;
}

.npc-mode-button {
  min-width: 72px;
  padding: 6px 13px;
  color: var(--cream-dim);
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
  transition: color 0.18s ease, background 0.18s ease;
}

.npc-mode-button:hover:not(:disabled) {
  color: var(--gold-soft);
}

.npc-mode-button.is-active {
  color: var(--card);
  background: var(--gold-soft);
  box-shadow: 0 3px 8px rgba(90, 70, 40, 0.16);
}

.npc-mode-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.npc-context-strip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 15px;
  color: var(--cream-dim);
  border-bottom: 1px solid var(--border);
  background: #fbf8f1;
  font-size: 0.72rem;
}

.npc-context-label {
  flex: 0 0 auto;
  padding-top: 1px;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.62rem;
  font-style: italic;
  letter-spacing: 0.18em;
}

.npc-chat-subbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.npc-model-label {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
}

.npc-model-label select {
  width: 180px;
  min-height: 36px;
  margin: 0;
  padding-block: 6px;
  font-size: 0.7rem;
}

.npc-mode-description {
  flex: 1 1 auto;
  color: var(--cream-dim);
  font-size: 0.68rem;
  line-height: 1.5;
}

.npc-chat-subbar .toolbar-actions {
  flex: 0 0 auto;
}

.npc-chat-messages {
  order: 1;
  height: 500px;
}

.npc-chat-conversation {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--card);
}

.npc-chat-conversation.has-tachie {
  grid-template-columns: minmax(0, 1fr) minmax(110px, 150px);
}

.npc-chat-tachie {
  order: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  height: 500px;
  margin: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, var(--card) 12%, var(--card-soft) 100%);
}

.npc-chat-tachie[hidden] {
  display: none;
}

.npc-chat-tachie img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 8px 12px rgba(50, 38, 18, 0.24));
}

.npc-chat-composer textarea {
  min-height: 76px;
}

.npc-prompt-editor {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: #fffaf0;
}

.npc-prompt-editor[hidden] {
  display: none;
}

.npc-prompt-editor-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.npc-prompt-editor-heading h3 {
  margin: 0;
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 1rem;
}

.npc-prompt-editor-heading label {
  display: grid;
  min-width: 220px;
  gap: 5px;
  color: var(--gold-soft);
  font-size: 0.68rem;
  font-weight: 700;
}

.npc-prompt-editor-heading select {
  min-height: 40px;
  margin: 0;
}

.npc-prompt-editor-note {
  margin: 10px 0 13px;
  color: var(--cream-dim);
  font-size: 0.7rem;
  line-height: 1.6;
}

.npc-prompt-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.npc-prompt-fields label {
  display: grid;
  gap: 5px;
  color: var(--gold-soft);
  font-size: 0.66rem;
  font-weight: 700;
}

.npc-prompt-fields textarea {
  width: 100%;
  margin: 0;
  resize: vertical;
  background: var(--card);
  font-size: 0.76rem;
  line-height: 1.55;
}

.npc-prompt-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.npc-prompt-editor-status {
  min-height: 1.5em;
  margin: 8px 0 0;
  color: var(--cream-dim);
  font-size: 0.68rem;
}

.is-play-mode .npc-author-edit-control {
  display: none !important;
}

.log-observer-summary {
  display: grid;
  grid-template-columns: minmax(140px, 0.55fr) minmax(140px, 0.55fr) minmax(340px, 1.45fr) auto;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.log-summary-card {
  display: flex;
  min-height: 88px;
  padding: 14px 16px;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 7px 20px rgba(90, 70, 40, 0.08);
}

.log-summary-card span {
  color: var(--cream-dim);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.log-summary-card strong {
  color: var(--gold-soft);
  font-family: var(--serif);
  font-size: 1.55rem;
  line-height: 1.35;
}

.log-usage-card strong {
  margin-top: 5px;
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.7;
}

.log-export-all {
  min-width: 200px;
  min-height: 88px;
  line-height: 1.55;
}

.log-observer-workspace {
  display: grid;
  grid-template-columns: minmax(650px, 1.55fr) minmax(310px, 0.75fr);
  gap: 17px;
  align-items: start;
}

.log-list-panel,
.log-detail-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.log-detail-panel {
  position: sticky;
  top: 66px;
  max-height: calc(100vh - 92px);
}

.log-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-soft);
}

.log-panel-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.log-detail-kicker {
  display: block;
  margin-bottom: 1px;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.6rem;
  font-style: italic;
  letter-spacing: 0.18em;
}

.log-table-scroll {
  width: 100%;
  overflow-x: auto;
}

.log-observer-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  color: var(--cream);
  font-size: 0.72rem;
}

.log-observer-table th,
.log-observer-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.log-observer-table th {
  color: var(--gold-soft);
  background: var(--card-soft);
  font-family: var(--serif);
  font-size: 0.68rem;
  white-space: nowrap;
}

.log-observer-table tbody tr {
  cursor: pointer;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

.log-observer-table tbody tr:nth-child(even) {
  background: #fdfaf4;
}

.log-observer-table tbody tr:hover,
.log-observer-table tbody tr.is-selected {
  background: #f7efdf;
}

.log-observer-table tbody tr.is-selected {
  box-shadow: inset 3px 0 0 var(--gold);
}

.log-type-cell,
.log-count-cell,
.log-date-cell {
  white-space: nowrap;
}

.log-type-cell {
  color: var(--gold-soft);
  font-weight: 700;
}

.log-label-cell {
  min-width: 260px;
  line-height: 1.55;
}

.log-row-actions {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}

.log-row-actions .button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 0.64rem;
}

.log-observer-empty {
  min-height: 160px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.log-detail-meta {
  padding: 10px 15px;
  color: var(--cream-dim);
  border-bottom: 1px solid var(--border);
  background: #fdfaf4;
  font-size: 0.64rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.log-detail-content {
  display: grid;
  gap: 11px;
  max-height: calc(100vh - 236px);
  padding: 15px;
  overflow: auto;
  background: linear-gradient(180deg, var(--card) 0%, #fcf8f0 100%);
}

.log-detail-message {
  display: grid;
  gap: 4px;
}

.log-detail-message-label {
  color: var(--cream-dim);
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.log-detail-message.user.pc .log-detail-message-label {
  color: var(--gold-soft);
}

.log-detail-message-body {
  padding: 10px 11px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.75rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-detail-message.assistant .log-detail-message-body,
.log-detail-message.system .log-detail-message-body {
  background: var(--card-soft);
}

.log-detail-message.system .log-detail-message-body {
  color: var(--cream-dim);
  font-size: 0.68rem;
}

.log-detail-json {
  min-height: 180px;
  margin: 0;
  padding: 13px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.68rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.review-section + .review-section {
  margin-top: 17px;
}

.review-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.count-pill {
  padding: 3px 9px;
  color: var(--l2);
  border: 1px solid rgba(168, 113, 47, 0.24);
  border-radius: 999px;
  background: #fbf3e8;
  font-size: 0.7rem;
  font-weight: 700;
}

.missing-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.missing-summary-item {
  padding: 5px 9px;
  color: var(--l3);
  border: 1px solid rgba(154, 64, 56, 0.2);
  border-radius: 999px;
  background: #faf3ef;
  font-size: 0.7rem;
}

.table-scroll {
  overflow-x: auto;
}

.spoiler-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--cream);
  font-size: 0.78rem;
}

.spoiler-table th,
.spoiler-table td {
  padding: 9px 11px;
  border: 1px solid var(--border);
  text-align: center;
}

.spoiler-table th {
  color: var(--gold-soft);
  background: var(--card-soft);
  font-family: var(--serif);
  font-size: 0.7rem;
}

.spoiler-table th:first-child,
.spoiler-table td:first-child {
  min-width: 180px;
  text-align: left;
}

.spoiler-table tbody tr:nth-child(even) {
  background: #fdfaf4;
}

.spoiler-table tfoot {
  color: var(--gold-soft);
  background: var(--card-soft);
  font-weight: 700;
}

.appendix-raw {
  max-height: 650px;
  margin: 0;
  padding: 19px;
  overflow: auto;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
  font-family: var(--serif);
  font-size: 0.78rem;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-panel {
  margin-bottom: 21px;
  padding: 17px;
  color: #6d3d37;
  border: 1px solid rgba(154, 64, 56, 0.38);
  border-left: 3px solid var(--l3);
  border-radius: var(--radius);
  background: #faf3ef;
  white-space: pre-wrap;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 22px max(24px, calc((100vw - 1240px) / 2));
  color: var(--ink-dim);
  border-top: 1px solid rgba(224, 194, 122, 0.22);
  background: var(--ink-bg);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
}

.site-footer[hidden] {
  display: none;
}

#public-rights-note {
  width: 100%;
  line-height: 1.7;
  white-space: pre-wrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  margin: 24px;
}

@media (max-width: 1080px) {
  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .npc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }

  .settings-actions {
    grid-column: 1 / -1;
  }

  .ho-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .play-control-grid {
    grid-template-columns: 1fr 1fr;
  }

  .next-chapter-button {
    grid-column: 1 / -1;
  }

  .log-observer-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-usage-card,
  .log-export-all {
    grid-column: 1 / -1;
  }
}

@media (max-width: 880px) {
  .provider-settings-grid {
    grid-template-columns: 1fr;
  }

  .provider-settings-grid .settings-actions {
    flex-wrap: wrap;
  }

  .site-header {
    padding-inline: 20px;
  }

  .app-shell {
    padding: 28px 18px 60px;
  }

  .scene-workspace {
    grid-template-columns: 1fr;
  }

  .npc-chat-workspace {
    grid-template-columns: 1fr;
  }

  .npc-chat-sidebar {
    position: static;
  }

  .npc-chat-list {
    max-height: 310px;
  }

  .log-observer-workspace {
    grid-template-columns: 1fr;
  }

  .log-detail-panel {
    position: static;
    max-height: none;
  }

  .log-detail-content {
    max-height: 560px;
  }

  .scene-browser {
    position: static;
    max-height: none;
  }

  .scene-list {
    max-height: 420px;
  }

  .scene-detail {
    min-height: 420px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 7px;
  }

  .section-heading > p {
    text-align: left;
  }

  .play-panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .play-panel-heading p {
    text-align: left;
  }

  .character-sheet-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .settings-hub {
    padding: 15px 13px;
  }

  .settings-hub-heading,
  .sheet-card-header {
    align-items: flex-start;
  }

  .connection-status-link {
    width: 100%;
    justify-content: space-between;
  }

  .connection-status-link strong {
    max-width: 62vw;
  }

  .sheet-disclosure-label {
    font-size: 0;
  }

  .confidential-banner {
    padding-inline: 10px;
    font-size: 0.67rem;
  }

  .site-header {
    align-items: flex-start;
    gap: 8px;
    padding-inline: 13px;
    padding-block: 14px;
  }

  .brand-block {
    flex: 1 1 170px;
    min-width: 0;
  }

  .header-actions {
    margin-left: auto;
  }

  .site-mode-toggle {
    min-height: 32px;
    padding-inline: 9px;
    font-size: 0.64rem;
  }

  .brand-mark,
  .data-status {
    display: none;
  }

  .header-meta {
    max-width: 100%;
  }

  .tab-nav-inner {
    padding: 0 7px;
  }

  .tab-button {
    min-width: auto;
    padding-inline: 12px;
    font-size: 0.84rem;
  }

  .app-shell {
    padding-inline: 13px;
  }

  .character-generator,
  .play-controls-panel,
  .sidequest-panel {
    padding: 16px 13px;
  }

  .sidequest-config-grid {
    grid-template-columns: 1fr;
  }

  .authored-info-grid {
    grid-template-columns: 1fr;
  }

  .sidequest-actions,
  .sidequest-current {
    align-items: stretch;
    flex-direction: column;
  }

  .sidequest-ending-box {
    align-items: stretch;
    flex-direction: column;
  }

  .authored-heading-meta,
  .authored-ending-row {
    align-items: stretch;
    flex-direction: column;
  }

  .authored-pc-preset dl > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .sidequest-slot-item {
    grid-template-columns: 1fr;
  }

  .sidequest-slot-actions .button {
    flex: 1;
  }

  .log-observer-summary {
    grid-template-columns: 1fr 1fr;
  }

  .log-usage-card,
  .log-export-all {
    grid-column: 1 / -1;
  }

  .ho-selector,
  .play-control-grid {
    grid-template-columns: 1fr;
  }

  .next-chapter-button {
    grid-column: auto;
  }

  .generator-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sheet-fields {
    grid-template-columns: 1fr;
  }

  .sheet-fields label:last-child {
    grid-column: auto;
  }

  .sheet-tachie-section {
    align-items: stretch;
    flex-direction: column;
  }

  .sheet-tachie-preview {
    justify-content: space-between;
  }

  .sheet-skill-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .progress-summary-row {
    grid-template-columns: 1fr;
  }

  .meta-grid,
  .npc-grid {
    grid-template-columns: 1fr;
  }

  .timeline::before {
    left: 76px;
  }

  .timeline-item {
    grid-template-columns: 64px 1fr;
    gap: 23px;
  }

  .timeline-item::before {
    left: 72px;
  }

  .timeline-event {
    flex-direction: column;
    gap: 5px;
  }

  .filter-stack {
    grid-template-columns: 1fr;
  }

  .filter-stack label:last-child {
    grid-column: auto;
  }

  .scene-detail {
    padding: 22px 17px 34px;
  }

  .inline-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-filters label {
    width: 100%;
  }

  .inline-count {
    margin-left: 0;
    padding-left: 0;
  }

  .fact-item {
    grid-template-columns: 56px 1fr;
  }

  .fact-item .badge,
  .fact-item .audience-tag {
    justify-self: start;
  }

  .fact-statement {
    grid-column: 1 / -1;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    grid-column: auto;
    flex-direction: column;
  }

  .chat-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .npc-chat-identity,
  .npc-mode-switch {
    width: 100%;
  }

  .npc-progress-gate {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .npc-mode-switch {
    border-radius: 10px;
  }

  .npc-mode-button {
    border-radius: 7px;
  }

  .npc-chat-subbar {
    align-items: stretch;
    flex-direction: column;
  }

  .npc-model-label {
    align-items: stretch;
    flex-direction: column;
  }

  .npc-model-label select {
    width: 100%;
  }

  .npc-chat-subbar .toolbar-actions {
    width: 100%;
  }

  .npc-chat-subbar .toolbar-actions .button {
    flex: 1;
  }

  .npc-prompt-editor-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .npc-prompt-editor-heading label {
    min-width: 0;
  }

  .npc-prompt-fields {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .button {
    flex: 1;
  }

  .chat-messages {
    height: 420px;
    padding: 18px 11px;
  }

  .message {
    max-width: 92%;
  }

  .dice-bar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .dice-hint {
    width: 100%;
    margin-left: 0;
  }

  .chat-composer {
    grid-template-columns: 1fr;
  }

  .play-chat-composer {
    grid-template-columns: 1fr;
  }

  .play-input-controls {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: end;
  }

  .speech-shortcut {
    grid-column: 1 / -1;
  }

  .novel-stage {
    --novel-floor-reserve: 81px;
    min-height: 0;
    aspect-ratio: 4 / 3;
    padding: 10px;
  }

  .novel-window {
    min-height: 0;
    padding: 16px 18px 20px;
  }

  .novel-speaker {
    left: 13px;
    min-width: 105px;
    padding: 5px 13px;
    font-size: 0.82rem;
  }

  .novel-text {
    font-size: 14px;
    line-height: 1.9;
  }

  .npc-chat-conversation.has-tachie {
    grid-template-columns: minmax(0, 1fr) minmax(82px, 24%);
  }

  .npc-chat-tachie {
    height: 420px;
  }

  .npc-chat-tachie img {
    max-height: 230px;
  }

  .send-button {
    min-height: 45px;
  }

  .chat-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .usage-display {
    text-align: left;
  }

  .character-library-actions,
  .character-library-row,
  .character-library-row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .character-library-actions .button,
  .character-library-row-actions .button {
    width: 100%;
  }

  .chat-palette-pc {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-palette-pc-heading {
    max-width: 100%;
  }

  .script-control-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .script-control-actions {
    justify-content: flex-start;
  }

  .custom-sheet-header,
  .custom-pc-details {
    grid-template-columns: 1fr;
  }

  .custom-sheet-header {
    flex-direction: column;
  }

  .custom-sheet-actions {
    justify-content: flex-start;
    width: 100%;
    max-width: none;
  }

  .custom-sheet-fields {
    grid-template-columns: 1fr;
  }

  .custom-stat-grid,
  .custom-derived-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-footer {
    flex-direction: column;
    padding-inline: 16px;
  }
}

@media (max-width: 480px) {
  .site-header {
    flex-wrap: wrap;
  }

  .brand-block {
    flex-basis: 100%;
  }

  .header-actions {
    width: 100%;
  }

  .site-mode-toggle {
    width: 100%;
    min-height: 44px;
  }

  .tab-nav,
  .tab-nav-inner {
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .tab-button {
    min-height: 44px;
    padding: 11px 10px 10px;
    font-size: 0.78rem;
  }

  .app-shell {
    width: 100%;
    padding: 20px 8px 48px;
  }

  .chat-shell,
  .novel-stage,
  .novel-window,
  .npc-chat-shell {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .novel-stage {
    --novel-floor-reserve: 61px;
    min-height: 0;
    padding: 6px;
  }

  .novel-window {
    height: auto;
    min-height: 0;
    /* スマホはステージ自体が低い(≈200px)ので、2〜3行を確保するには上限を広げる */
    max-height: 58%;
    padding: 14px 12px 16px;
    border-radius: 9px;
  }

  .novel-window:has(.novel-speaker:not([hidden])) {
    padding-top: 26px;
  }

  .novel-text {
    min-height: 1.8em;
    font-size: 0.8rem;
    line-height: 1.65;
  }

  .novel-roll-suggestions {
    top: 8px;
    right: 8px;
    max-width: 58%;
  }

  .novel-roll-callout {
    padding: 5px 9px;
    font-size: 0.72rem;
  }

  .novel-scene-badge {
    top: 9px;
    left: 9px;
    max-width: calc(100% - 18px);
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  .chat-toolbar,
  .chat-footer,
  .npc-chat-subbar,
  .npc-context-strip {
    padding-inline: 10px;
  }

  .npc-chat-sidebar-head {
    padding: 11px 12px;
  }

  .npc-chat-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(165px, 68vw);
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
  }

  .npc-select-item {
    min-height: 70px;
    padding: 10px 11px;
    border-top: 0;
    border-left: 1px solid var(--bg-deep);
    scroll-snap-align: start;
  }

  .npc-select-item:first-child {
    border-left: 0;
  }

  .npc-chat-conversation,
  .npc-chat-conversation.has-tachie {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
  }

  .npc-chat-conversation.has-tachie .npc-chat-messages {
    padding-right: 64px;
  }

  .npc-chat-tachie {
    position: absolute;
    z-index: 2;
    right: 0;
    bottom: 0;
    width: 76px;
    height: 175px;
    border: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 253, 248, 0.9));
    pointer-events: none;
  }

  .npc-chat-tachie img {
    max-height: 160px;
  }

  .chat-messages,
  .npc-chat-messages {
    height: min(420px, 55vh);
    padding: 15px 9px;
  }

  .message {
    max-width: 96%;
  }

  .message.message-characterized {
    max-width: 100%;
  }

  .character-dialogue {
    gap: 7px;
    width: 98%;
  }

  .character-avatar {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    font-size: 0.84rem;
  }

  .character-dialogue-name {
    font-size: 0.62rem;
  }

  .character-dialogue-bubble {
    padding: 9px 10px;
    font-size: 0.78rem;
  }

  .chat-narration {
    width: calc(100% - 45px);
    margin-left: 45px;
    padding-inline: 8px;
    font-size: 0.74rem;
  }

  .message-bubble {
    padding: 10px 11px;
    font-size: 0.8rem;
  }

  .chat-composer {
    gap: 8px;
    padding: 10px;
  }

  .chat-composer textarea,
  .npc-chat-composer textarea {
    min-height: 92px;
    font-size: 16px;
  }

  .chat-composer .button,
  .npc-chat-subbar .button,
  .npc-prompt-editor-actions .button,
  .script-control-actions .button,
  .script-pacing-option,
  .roll-suggestion-button,
  .dice-button,
  .scene-change-button,
  .speech-mode-button,
  .speech-input-button,
  .play-speaker-label select {
    min-height: 44px;
  }

  .speech-input-button {
    min-width: 44px;
  }

  /* 台本の操作欄：スマホでも読める大きさに（ボタン13px以上・補助の文12px以上）。
     長いボタン名（「くわしく調べる（〈生物学〉…）」「■村長の家（行くと戻れません）」）は、はみ出さずに折り返す。 */
  .script-control-status {
    font-size: 0.75rem;
  }

  .script-control-hint,
  .script-control-actions .script-control-hint,
  .script-pacing-label,
  .script-pacing-note {
    font-size: 0.78rem;
  }

  .script-pacing-option {
    font-size: 0.8125rem;
  }

  .script-control-actions .button,
  .script-control-actions .button.script-control-minor {
    max-width: 100%;
    min-height: 44px;
    padding: 8px 13px;
    /* 1行なら今の丸い形のまま、折り返して高くなった時は角の丸い四角にする（999px だと楕円に崩れる） */
    border-radius: 22px;
    font-size: 0.8125rem;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .script-control-actions .script-one-tap-button {
    font-size: 0.9rem;
  }

  /* 判定の待ち：「対象」の案内と「🎲 振る」は1段ずつ使い、「成功として進む／失敗として進む」を同じ段に並べる。 */
  .script-control-actions .script-control-hint,
  .script-control-actions .script-one-tap-button {
    flex: 1 0 100%;
  }

  .script-control-actions .script-one-tap-button {
    text-align: center;
  }

  /* 選ぶ（〈ルル救出作戦〉）：説明が2行になるので、選択肢は1つずつ幅いっぱいに縦に並べる。 */
  .script-control-actions .script-choice-button {
    flex: 1 0 100%;
    border-radius: 14px;
  }

  .script-choice-label {
    font-size: 0.875rem;
  }

  .script-choice-desc {
    font-size: 0.75rem;
    line-height: 1.6;
  }

  .chat-palette-tab {
    min-height: 40px;
    padding: 6px 11px;
    font-size: 0.8125rem;
  }

  /* 入口のシナリオ選択：3列ではカードが細すぎて題が1字ずつ割れるので、1列にする（番外編も同じ）。 */
  .scenario-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .scenario-card {
    min-height: 64px;
    padding: 12px 14px;
  }

  .scenario-card-top strong {
    font-size: 1rem;
  }

  .scenario-card-numeral {
    font-size: 1.625rem;
  }

  /* 本文の窓の「▼ つぎへ」を押しやすい高さに。本文の最後の行と重なっても読めるよう、窓と同じ色の下地を敷く。 */
  .novel-next-button {
    right: 6px;
    bottom: 4px;
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(30, 23, 12, 0.92);
  }

  /* 立ち絵に重なる案内の帯を細く・小さく */
  .novel-script-hint {
    max-width: 100%;
    margin-bottom: 8px;
    padding: 2px 10px;
    font-size: 0.68rem;
    line-height: 1.5;
  }

  /* iOS Safariは16px未満の入力にフォーカスすると画面をズームする（送信後もズームが残る） */
  .play-speaker-label select,
  .custom-dice-label input,
  .auto-cast-depth-label select,
  .chat-palette-tabs select {
    font-size: 16px;
  }

  .npc-prompt-editor {
    padding: 13px 10px;
  }

  .npc-prompt-fields textarea {
    font-size: 16px;
  }

  .npc-prompt-editor-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chat-palette > summary {
    min-height: 44px;
    padding: 5px 8px;
    font-size: 0.8rem;
  }

  .chat-palette-body {
    padding-inline: 6px;
  }

  .chat-palette-pc {
    gap: 3px;
    padding: 4px;
  }


  .character-sheet-card {
    border-radius: 9px;
  }

  .sheet-card-header {
    gap: 7px;
    padding: 10px;
  }

  .sheet-card-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .sheet-card-body,
  .sheet-fields {
    min-width: 0;
  }

  .sheet-fields {
    padding-inline: 10px;
  }

  .sheet-fields input,
  .sheet-fields textarea,
  .sheet-fields select {
    max-width: 100%;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html,
  .chat-messages {
    scroll-behavior: auto;
  }

  .button,
  .tab-button,
  .scene-list-item,
  .novel-tachie,
  .novel-bg {
    transition: none;
  }

  .novel-char {
    animation: none;
  }

  .streaming-dots {
    animation: none;
  }

  .novel-thinking {
    animation: none;
    opacity: 0.7;
  }

  .speech-input-button.is-listening {
    animation: none;
  }
}

@media (max-width: 640px) and (min-width: 481px) {
  .session-play-column > .play-chat-composer,
  .chat-shell.is-novel-mode .play-chat-composer {
    bottom: 64px;
  }

  .session-play-column > .chat-footer {
    min-height: 64px;
  }
}

@media (max-width: 1080px) and (min-width: 481px) {
  .scenario-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-workspace {
    grid-template-columns: minmax(0, 0.42fr) minmax(0, 0.58fr);
  }

  .session-chat-shell .chat-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  #panel-demo {
    margin-inline: -4px;
  }

  body.is-focus-mode .demo-preparation,
  body.is-focus-mode .session-focus-label,
  body.is-focus-mode #back-to-preparation-button,
  body.is-focus-mode .session-chat-shell > .chat-toolbar,
  body.is-focus-mode .session-play-column > .dice-bar {
    display: none;
  }

  body.is-focus-mode #panel-demo.has-party-validation-error .demo-preparation {
    display: block;
  }

  .session-phase-bar {
    justify-content: stretch;
    margin-bottom: 7px;
  }

  .mobile-quick-generate {
    display: block;
    width: 100%;
    min-height: 44px;
  }

  .session-chat-shell {
    overflow: visible;
    border-radius: 10px;
  }

  .session-workspace {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .session-log-column,
  .session-play-column {
    display: contents;
  }

  .session-play-column {
    max-height: none;
    overflow: visible;
  }

  .session-log-column .chat-messages {
    order: 2;
    height: min(390px, 48vh);
    min-height: 250px;
    border-top: 1px solid var(--border);
  }

  .session-play-column > .novel-stage {
    order: 1;
  }

  .session-play-column > .chat-error {
    order: 3;
  }

  .session-play-column > .scene-suggestion {
    order: 3;
  }

  /* 台本の操作欄（▶ 次へ・判定・探索）は舞台のすぐ下に置く。舞台と同じ order にして、
     元の並び（舞台 → 操作欄）のまま会話の記録（order: 2）より上に来るようにする。
     本文を読んで、すぐ下で押せる（記録を挟んで往復スクロールしない）。 */
  .session-play-column > .script-control-panel {
    order: 1;
  }

  .session-play-column > .chat-palette {
    order: 5;
  }

  .session-play-column > .play-chat-composer {
    order: 6;
  }

  .session-play-column > .chat-footer {
    order: 7;
  }

  .session-play-column .novel-stage {
    aspect-ratio: 4 / 3;
  }

  .chat-palette-body {
    max-height: 205px;
  }

  .chat-palette-pc {
    display: grid;
  }

  .chat-palette-roll-button {
    min-height: 44px;
    padding: 6px 8px;
    font-size: 0.8125rem;
  }

  .chat-palette-kp-badge {
    font-size: 0.75rem;
  }

  .play-chat-composer {
    position: static;
    box-shadow: none;
  }
}

/* ── 自律NPCエージェント（site2から移植 2026-08-23） ── */
.auto-cast-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.auto-cast-toggle {
  padding: 5px 11px;
  color: var(--cream-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.18s var(--ease-out), border-color 0.18s var(--ease-out), background 0.18s var(--ease-out);
}
.auto-cast-toggle.is-active {
  color: var(--ink-bg);
  border-color: rgba(168, 128, 47, 0.7);
  background: var(--ink-gold);
  font-weight: 700;
}
.auto-cast-depth-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--cream-dim);
  font-size: 0.68rem;
}
.auto-cast-depth-label select {
  min-height: 0;
  margin: 0;
  padding: 3px 6px;
  font-size: 0.7rem;
}

/* ≤480px: 上の .auto-cast-depth-label select(0.7rem) より後ろに置き、iOSのフォーカス時ズームを防ぐ */
@media (max-width: 480px) {
  .auto-cast-depth-label select {
    min-height: 36px;
    font-size: 16px;
  }
}

/* ======================================================================
   最初の画面の2つの入口（すぐ遊ぶ／探索者を作る）と、既定の探索者のカード
   ====================================================================== */
.play-entry {
  margin-bottom: 14px;
}

.play-entry-title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 1.02rem;
}

.play-entry-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.play-entry-option {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 12px 16px;
  color: var(--cream);
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
}

.play-entry-option strong {
  font-family: var(--display);
  font-size: 1rem;
}

.play-entry-option span {
  color: var(--cream-dim);
  font-size: 0.74rem;
}

.play-entry-option.is-active {
  border-color: var(--gold);
  background: var(--card-soft);
  box-shadow: inset 0 0 0 2px var(--gold), var(--shadow);
}

.play-entry-option:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.play-entry-option:focus-visible,
.premade-card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.quick-play-panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.premade-card-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.premade-card {
  --pc-color: #8a7a62;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  color: var(--cream);
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--pc-color) 45%, var(--border));
  border-top: 5px solid var(--pc-color);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc-color) 12%, var(--card)) 0%, var(--card) 55%);
  cursor: pointer;
  font: inherit;
  transition: transform 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.premade-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.premade-card.is-selected {
  border-color: var(--pc-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc-color) 55%, transparent), var(--shadow);
}

.premade-card-figure {
  display: block;
  height: 230px;
  overflow: hidden;
  background: color-mix(in srgb, var(--pc-color) 8%, var(--card-soft));
}

.premade-card-figure img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 2%;
}

.premade-card-body {
  display: grid;
  gap: 4px;
  padding: 10px 12px 12px;
}

.premade-card-ho {
  color: color-mix(in srgb, var(--pc-color) 70%, var(--cream));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.premade-card-name {
  font-family: var(--display);
  font-size: 1.08rem;
}

.premade-card-reading {
  color: var(--cream-dim);
  font-size: 0.7rem;
}

.premade-card-profile {
  font-size: 0.78rem;
  line-height: 1.6;
}

.premade-card-badge {
  justify-self: start;
  margin-top: 4px;
  padding: 2px 10px;
  color: #fff;
  border-radius: 999px;
  background: var(--pc-color);
  font-size: 0.7rem;
  font-weight: 700;
}

.premade-card.is-companion .premade-card-badge {
  color: var(--cream);
  background: color-mix(in srgb, var(--pc-color) 18%, var(--card));
}

.premade-art-credit {
  margin: 6px 0 0;
  color: var(--cream-dim);
  font-size: 0.66rem;
  text-align: right;
}

.premade-solo-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 8px;
  cursor: pointer;
  font-size: 0.84rem;
}

.premade-solo-toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--gold);
}

.premade-companion-note {
  margin: 0 0 10px;
  color: var(--cream-dim);
  font-size: 0.76rem;
}

.premade-start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.premade-start-summary {
  color: var(--cream-dim);
  font-size: 0.8rem;
}

.premade-start-button {
  min-height: 48px;
  padding-inline: 24px;
}

.character-builder-guide {
  margin: 0 0 12px;
  color: var(--cream-dim);
  font-size: 0.78rem;
  line-height: 1.7;
}

/* 「すぐ遊ぶ」では、作る画面用の「探索者クイック生成」を出さない（選んだ探索者を作り直さないため）。 */
.is-quick-entry .mobile-quick-generate {
  display: none !important;
}

@media (max-width: 1100px) {
  .premade-card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .play-entry-switch {
    grid-template-columns: 1fr;
  }

  .quick-play-panel {
    padding: 14px;
  }

  .premade-card-list {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* スマホでは立ち絵を左、文を右に置いた横長のカードを縦に並べる。 */
  .premade-card {
    flex-direction: row;
    border-top-width: 1px;
    border-left: 5px solid var(--pc-color);
    min-height: 150px;
  }

  /* 立ち絵は頭を上に、ひざ上まで。左右の切れは余白の分だけ（肩・腕が枠に収まる幅）。 */
  .premade-card-figure {
    flex: 0 0 116px;
    height: auto;
    min-height: 150px;
  }

  .premade-card-figure img {
    width: 120%;
    max-width: none;
    margin: 4px 0 0 -10%;
  }

  .premade-start-row {
    flex-direction: column;
    align-items: stretch;
  }

  .premade-start-button {
    width: 100%;
  }
}

/* スマホ幅のノベル表示では、下に張り付く入力欄を低くする（舞台と台詞の窓を隠さないため）。
   PC/PLの切り替え・入力欄（2行ぶん）・送信を1段に並べ、ショートカットの案内は畳む。 */
@media (max-width: 640px) {
  .chat-shell.is-novel-mode .play-chat-composer {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 6px;
    padding: 8px 10px;
  }

  .chat-shell.is-novel-mode .play-chat-composer .play-input-controls {
    display: flex;
  }

  .chat-shell.is-novel-mode .play-chat-composer .speech-shortcut {
    display: none;
  }

  .chat-shell.is-novel-mode .play-chat-composer textarea {
    height: 56px;
    min-height: 56px;
    padding-block: 8px;
  }

  .chat-shell.is-novel-mode .play-chat-composer .speech-input-button {
    right: 6px;
    bottom: 8px;
    width: 38px;
    height: 38px;
  }

  .chat-shell.is-novel-mode .play-chat-composer .send-button {
    min-width: 64px;
    min-height: 56px;
    padding-inline: 12px;
  }
}

/* ≤480px：入力欄の案内の文（場面で app.js が差し替える）が、マイクの分の右の余白のせいで2行では切れる。
   入力欄を少し高くし、右の余白をマイクの幅ぎりぎりまで詰め、案内だけ少し小さくして3行に収める
   （入力する文字は16pxのまま＝iOSのズームを防ぐ）。上の 640px の高さより後ろに置く。 */
@media (max-width: 480px) {
  .chat-shell.is-novel-mode .play-chat-composer textarea {
    height: 64px;
    min-height: 64px;
    padding-right: 46px;
  }

  .chat-shell.is-novel-mode .play-chat-composer textarea::placeholder {
    font-size: 11px;
    line-height: 1.25;
  }
}

/* 最初の秘匿のシーン：札はチャットの秘匿と同じ紫の系統（その人だけが読む文） */
.novel-speaker.is-secret {
  color: #fff;
  max-width: calc(100% - 48px);
  border-color: rgba(230, 210, 240, 0.45);
  background: #6f4b81;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.novel-window.is-ho-opening {
  border-color: rgba(168, 130, 190, 0.55);
}

/* 探索者の欄（パレット）の「最初の秘匿を読み直す」 */
.ho-opening-reread {
  flex: 1 1 100%;
  margin: 4px 0 2px;
  font-size: 0.7rem;
}

.ho-opening-reread-button {
  display: inline-block;
  padding: 3px 9px;
  color: #6f4b81;
  border: 1px solid rgba(111, 75, 129, 0.42);
  border-radius: 999px;
  background: #f8f0fb;
  cursor: pointer;
  list-style: none;
}

.ho-opening-reread-button::-webkit-details-marker {
  display: none;
}

.ho-opening-reread-body {
  margin-top: 6px;
  padding: 8px 11px;
  border: 1px solid rgba(111, 75, 129, 0.42);
  border-radius: 9px;
  background: #f8f0fb;
  color: #3d2b47;
  font-family: var(--serif);
  line-height: 1.75;
}

.ho-opening-reread-label {
  margin-bottom: 4px;
  color: #6f4b81;
  font-weight: 700;
}

.ho-opening-reread-body p {
  margin: 0 0 4px;
}

/* ── 指で触る端末（iPad など）だけ：押す所と文字を大きく（2026-11-13）──
   <html class="is-touch"> は app.js の setupTouchUi が (pointer: coarse) の時だけ付ける。
   マウスで使うパソコンには一切効かない。スマホの幅（≤480px）は既存の決まりに任せる。 */
@media (min-width: 481px) {
  /* 本文の窓：文字を16px以上に。「▼ つぎへ」は40pxの高さ・窓と同じ色の下地で、本文と重なっても読める。 */
  html.is-touch .novel-text {
    font-size: 1.04rem;
  }

  html.is-touch .novel-window {
    padding-bottom: 26px;
  }

  html.is-touch .novel-next-button {
    right: 8px;
    bottom: 4px;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(30, 23, 12, 0.92);
    font-size: 0.85rem;
  }

  html.is-touch .novel-script-hint {
    font-size: 0.8rem;
  }

  /* 台本の操作欄：ボタン44px・14px前後、案内と状態の文は12.8px。長い名前は折り返す。 */
  html.is-touch .script-control-status {
    font-size: 0.8rem;
  }

  html.is-touch .script-control-hint,
  html.is-touch .script-control-actions .script-control-hint,
  html.is-touch .script-control-actions .script-control-hint.script-control-minor,
  html.is-touch .script-pacing-label,
  html.is-touch .script-pacing-note {
    font-size: 0.8rem;
    opacity: 1;
  }

  html.is-touch .script-pacing-option {
    min-height: 40px;
    padding: 4px 14px;
    font-size: 0.875rem;
  }

  html.is-touch .script-control-actions {
    gap: 8px;
  }

  html.is-touch .script-control-actions .button,
  html.is-touch .script-control-actions .button.script-control-minor {
    max-width: 100%;
    min-height: 44px;
    padding: 8px 15px;
    border-radius: 22px;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
    opacity: 1;
  }

  html.is-touch .script-control-actions .script-one-tap-button {
    font-size: 0.95rem;
  }

  /* 〈ルル救出作戦〉の3択：説明が長いので、1つずつ幅いっぱいに縦に並べる。 */
  html.is-touch .script-control-actions .script-choice-button {
    flex: 1 0 100%;
    border-radius: 14px;
    text-align: left;
  }

  html.is-touch .script-choice-label {
    font-size: 0.95rem;
  }

  html.is-touch .script-choice-desc {
    font-size: 0.8125rem;
    line-height: 1.6;
  }

  /* 表示の切り替え・読む速さ・PC/PL・自動再生・NPC自律・自動転換：40px以上 */
  html.is-touch .display-mode-button,
  html.is-touch .speech-mode-button,
  html.is-touch .novel-autoplay-toggle,
  html.is-touch .auto-cast-toggle {
    min-height: 40px;
    font-size: 0.8125rem;
  }

  html.is-touch .novel-speed-switch {
    font-size: 0.75rem;
  }

  html.is-touch .novel-speed-switch button {
    min-width: 40px;
    min-height: 40px;
    font-size: 0.8125rem;
  }

  html.is-touch .auto-cast-depth-label {
    font-size: 0.8rem;
  }

  html.is-touch .auto-cast-depth-label select {
    min-height: 40px;
  }

  /* チャットパレット：タブ40px・技能ボタン44px・13.5px前後 */
  html.is-touch .chat-palette-tab {
    min-height: 40px;
    padding: 6px 12px;
    font-size: 0.8125rem;
  }

  html.is-touch .chat-palette-summary,
  html.is-touch .chat-palette-pc-heading strong {
    font-size: 0.8rem;
  }

  html.is-touch .chat-palette-pc-heading span {
    font-size: 0.7rem;
  }

  html.is-touch .chat-palette-buttons {
    gap: 6px;
  }

  html.is-touch .chat-palette-roll-button {
    min-height: 44px;
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  html.is-touch .chat-palette-kp-badge {
    font-size: 0.7rem;
  }

  /* サイコロ欄・ロール提案・入力欄まわり：44px */
  html.is-touch .roll-suggestion-button,
  html.is-touch .dice-button,
  html.is-touch .dice-bar .button,
  html.is-touch .scene-change-button,
  html.is-touch .speech-input-button,
  html.is-touch .send-button,
  html.is-touch .play-speaker-label select,
  html.is-touch .custom-dice-label input {
    min-height: 44px;
  }

  html.is-touch .roll-suggestion-button {
    font-size: 0.8125rem;
  }

  html.is-touch .speech-input-button {
    min-width: 44px;
  }

  /* iOS は16px未満の入力欄にフォーカスすると画面を拡大してしまう */
  html.is-touch .play-chat-composer textarea,
  html.is-touch .custom-dice-label input,
  html.is-touch .play-speaker-label select {
    font-size: 16px;
  }

  html.is-touch .play-speaker-label {
    font-size: 0.75rem;
  }
}

/* 指で触る端末だけ：右の列の「内側スクロール」をやめ、ページ全体でスクロールさせる（2026-11-13）。
   入れ子のスクロールは指では狙いにくく、横持ち（1366×1024）ではサイコロ欄・チャットパレットが
   下に張り付いた入力欄の裏に入ったままになっていた。
   ・右の列は中身の高さのまま伸ばす（入力欄と下の帯は、今度は画面の下端に張り付く）。
   ・左の会話の記録は、今までと同じ高さの窓のまま、タブの下に張り付けて、自分の中でスクロールする。
   ・外枠の overflow: hidden は張り付き（sticky）を殺すので、角の切り抜きだけ残す clip にする。 */
@media (min-width: 481px) {
  html.is-touch .session-chat-shell {
    overflow: clip;
  }

  html.is-touch .session-workspace {
    height: auto;
    align-items: start;
  }

  html.is-touch .session-play-column {
    height: auto;
    overflow: visible;
  }

  html.is-touch .session-log-column {
    position: sticky;
    top: 53px;
    height: clamp(360px, calc(100dvh - 230px), 900px);
  }
}

/* ── アプリ版（iPad・スマホ）で小さすぎた文字を読める大きさに（2026-11-13）──
   基準：12px 未満を無くす／文として読む物と押す物は 13px 以上／飾りの英字の小見出し・小さな札は 12px。
   パソコン（is-touch なし・481px 以上）には効かない。スマホ幅（≤480px）は下の別のかたまり。 */
@media (min-width: 481px) {
  /* 飾りの英字の小見出し・小さな札・build の日時：12px */
  html.is-touch .eyebrow,
  html.is-touch .section-kicker,
  html.is-touch .play-panel-kicker,
  html.is-touch .npc-chat-eyebrow,
  html.is-touch .npc-context-label,
  html.is-touch .ai-control-badge,
  html.is-touch .chat-palette-kp-badge,
  html.is-touch .speech-shortcut,
  html.is-touch .build-stamp {
    font-size: 0.75rem;
  }

  /* 文として読む物：13px */
  html.is-touch label,
  html.is-touch .confidential-banner,
  html.is-touch .header-meta,
  html.is-touch .data-status,
  html.is-touch .play-entry-option span,
  html.is-touch .play-panel-heading p,
  html.is-touch .character-builder-guide,
  html.is-touch .ho-option-id,
  html.is-touch .ho-option-name,
  html.is-touch .generator-summary,
  html.is-touch .play-scale-summary,
  html.is-touch .control-field-note,
  html.is-touch .progress-summary-row,
  html.is-touch .sheet-card-header p,
  html.is-touch .sheet-tachie-picker > span,
  html.is-touch .sheet-section-title,
  html.is-touch .sheet-notes,
  html.is-touch .derived-pill,
  html.is-touch .premade-card-ho,
  html.is-touch .premade-card-reading,
  html.is-touch .premade-art-credit,
  html.is-touch .premade-card-profile,
  html.is-touch .premade-companion-note,
  html.is-touch .premade-start-summary,
  html.is-touch .play-speaker-label,
  html.is-touch .character-library-current h4,
  html.is-touch .character-library-list-heading h4,
  html.is-touch .message-label,
  html.is-touch .message-bubble,
  html.is-touch .message-system .message-bubble,
  html.is-touch .character-dialogue-name,
  html.is-touch .chat-narration,
  html.is-touch .dice-hint,
  html.is-touch .chat-palette-request,
  html.is-touch .chat-palette-empty,
  html.is-touch .chat-palette-summary,
  html.is-touch .chat-palette-pc-heading strong,
  html.is-touch .chat-palette-pc-heading span,
  html.is-touch .ho-opening-reread,
  html.is-touch .chat-footer,
  html.is-touch .site-footer,
  html.is-touch .character-library-note,
  html.is-touch .character-library-row span,
  html.is-touch .character-library-empty,
  html.is-touch .character-library-list-heading,
  html.is-touch .npc-progress-gate p,
  html.is-touch .npc-progress-gate label,
  html.is-touch .source-note,
  html.is-touch .count-pill,
  html.is-touch .npc-select-scene,
  html.is-touch .npc-context-strip,
  html.is-touch .npc-mode-description,
  html.is-touch .connection-status-pill,
  html.is-touch .settings-connection-select,
  html.is-touch .provider-settings-grid label,
  html.is-touch .bridge-mode-status,
  html.is-touch .connection-notes,
  html.is-touch .focus-mode-note,
  html.is-touch .focus-mode-toggle-label,
  html.is-touch .scenario-spoiler-gate-text,
  html.is-touch .novel-speed-switch,
  html.is-touch .auto-cast-depth-label,
  html.is-touch .custom-number-field,
  html.is-touch .custom-derived-header,
  html.is-touch .custom-textarea-field,
  html.is-touch .custom-skill-hint,
  html.is-touch .ia-import-guide,
  html.is-touch .field-help,
  html.is-touch .security-note,
  html.is-touch .sidequest-current,
  html.is-touch .sidequest-current-label,
  html.is-touch .sidequest-history-heading span,
  html.is-touch .sidequest-slot-summary strong,
  html.is-touch .sidequest-slot-summary span,
  html.is-touch .authored-session-list > summary,
  html.is-touch .authored-logline,
  html.is-touch .authored-info-grid span,
  html.is-touch .authored-info-grid strong,
  html.is-touch .authored-pc-preset dt,
  html.is-touch .authored-pc-preset dd,
  html.is-touch .authored-ending-row strong,
  html.is-touch .chat-error,
  html.is-touch .streaming-waiting,
  html.is-touch .speech-input-note,
  html.is-touch .scene-picker-note,
  html.is-touch .scene-picker-note code,
  html.is-touch .scene-picker-notify,
  html.is-touch .scene-picker-group,
  html.is-touch .scene-picker-item small,
  html.is-touch .scene-picker-empty,
  html.is-touch .novel-roll-callout,
  html.is-touch .premade-card-badge,
  html.is-touch .npc-edited-badge,
  html.is-touch .npc-reading,
  html.is-touch .npc-prompt-editor-heading label,
  html.is-touch .npc-prompt-editor-note,
  html.is-touch .npc-prompt-fields label,
  html.is-touch .npc-prompt-editor-status,
  html.is-touch .novel-script-hint,
  html.is-touch .script-control-status,
  html.is-touch .script-control-hint,
  html.is-touch .script-control-actions .script-control-hint,
  html.is-touch .script-control-actions .script-control-hint.script-control-minor,
  html.is-touch .script-pacing-label,
  html.is-touch .script-pacing-note {
    font-size: 0.8125rem;
  }

  /* 押す物：13px・高さ40px */
  html.is-touch .button,
  html.is-touch .character-library-row .button,
  html.is-touch .custom-derived-header .button,
  html.is-touch .custom-pc-delete,
  html.is-touch .sheet-tachie-delete,
  html.is-touch .npc-mode-button,
  html.is-touch .sheet-name-reroll,
  html.is-touch .site-mode-toggle,
  html.is-touch .ho-controller-button,
  html.is-touch .connection-status-link,
  html.is-touch .ho-opening-reread-button,
  html.is-touch .chat-palette > summary {
    min-height: 40px;
    font-size: 0.8125rem;
  }

  html.is-touch input[type="file"],
  html.is-touch .sheet-tachie-picker input[type="file"],
  html.is-touch input[type="file"]::file-selector-button {
    font-size: 0.8125rem;
  }

  /* 入力欄：16px（iOS は16px未満の入力欄にフォーカスすると画面を拡大してしまう） */
  html.is-touch input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  html.is-touch select,
  html.is-touch textarea {
    font-size: 16px;
  }

  html.is-touch .connection-status-link,
  html.is-touch .ho-opening-reread-button {
    display: inline-flex;
    align-items: center;
  }

  html.is-touch .ho-opening-reread-button {
    padding: 6px 14px;
  }

  /* 明るい地の上の薄い金色の小さな文字：コントラスト比 4.5 以上にする（#8a6a28・#a8802f → #7a5c20） */
  html.is-touch .section-kicker,
  html.is-touch .play-panel-kicker,
  html.is-touch .ho-option-id,
  html.is-touch .sheet-title-row h4,
  html.is-touch .derived-pill,
  html.is-touch .progress-summary-row > span:first-child,
  html.is-touch #play-table-title,
  html.is-touch .usage-display,
  html.is-touch .character-library-current h4,
  html.is-touch .character-library-list-heading h4,
  html.is-touch .npc-chat-eyebrow,
  html.is-touch .npc-context-label,
  html.is-touch #npc-chat-count,
  html.is-touch .npc-chat-identity strong,
  html.is-touch .npc-chat-sidebar-head strong,
  html.is-touch .npc-select-name,
  html.is-touch .connection-status-pill {
    color: #7a5c20;
  }

  /* 暗い地の「READY TO PLAY」は元の金色のまま（暗くすると読めなくなる） */
  html.is-touch .session-launch .play-panel-kicker {
    color: var(--gold);
  }

  /* 場面転換の「KPに伝えて…」：チェックの四角が横いっぱいに伸びていたのを、ふつうの大きさに */
  html.is-touch .scene-picker-notify input[type="checkbox"] {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    min-height: 0;
  }

  /* 下の帯：「待機中」を1字ずつ折らない（長い状態の文は折り返してよい） */
  html.is-touch .chat-footer > [role="status"] {
    min-width: 4em;
  }

  /* 「カスタム」「つづけて」：文字を大きくしても1語の途中で折らない */
  html.is-touch .custom-dice-label,
  html.is-touch .auto-cast-depth-label {
    white-space: nowrap;
  }

  html.is-touch .dice-bar {
    flex-wrap: wrap;
  }

  /* 能力値（STR など）の名前：13px */
  html.is-touch .sheet-stat span {
    font-size: 0.8125rem;
  }

  /* 「上限89%」を途中で折らない */
  html.is-touch .sheet-section-title > span:last-child:not(:first-child) {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* 技能のボタン：13px・高さ40px。長い名前（制作:スイーツ など）は切らずに折り返し、数値は右に寄せる */
  html.is-touch .skill-roll-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-height: 40px;
    padding: 5px 8px;
    font-size: 0.8125rem;
    line-height: 1.3;
    white-space: normal;
  }

  html.is-touch .skill-roll-button span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  html.is-touch .skill-roll-button strong {
    flex: 0 0 auto;
    float: none;
  }
}

/* 探索者カードの「開閉」：640px 以下は既存の決まりで文字を消して印だけにしているので、それより広い時だけ 13px に */
@media (min-width: 641px) {
  html.is-touch .sheet-disclosure-label {
    font-size: 0.8125rem;
  }
}

/* ヘッダー：題（夢ティ プレイモード）を言葉の途中で折らない（2026-11-13）。
   幅が足りない時（指で触る端末、または 1180px 以下）は、題の段と「build の日時・読込の状態・切り替え」の段の2段に組む。
   スマホ幅（≤480px）は既存の決まりのまま。 */
@media (min-width: 481px) and (max-width: 1180px) {
  .site-header {
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .brand-block,
  .header-actions {
    flex: 1 1 100%;
    min-width: 0;
  }

  .site-header h1 {
    white-space: nowrap;
  }

  .header-actions {
    justify-content: flex-end;
  }

  .data-status {
    flex: 0 1 auto;
    min-width: 0;
    border-radius: 14px;
    white-space: normal;
  }
}

@media (min-width: 481px) {
  html.is-touch .site-header {
    flex-wrap: wrap;
    row-gap: 10px;
  }

  html.is-touch .brand-block,
  html.is-touch .header-actions {
    flex: 1 1 100%;
    min-width: 0;
  }

  html.is-touch .site-header h1 {
    white-space: nowrap;
  }

  html.is-touch .header-actions {
    justify-content: flex-end;
  }

  html.is-touch .data-status {
    flex: 0 1 auto;
    min-width: 0;
    border-radius: 14px;
    white-space: normal;
  }

  /* 題の「プレイモード」：題の 0.58 倍のまま、ただし 13px より小さくしない */
  html.is-touch .site-header h1 span {
    font-size: max(0.8125rem, 0.58em);
  }
}

/* スマホ幅（≤480px）：上の iPad 向けと同じ決まり（スマホは指で触るので is-touch の有無を問わない）。
   既存のスマホ向けの指定より後ろに置き、html を付けて1段だけ強くする。 */
@media (max-width: 480px) {
  /* 飾りの英字の小見出し・小さな札・build の日時：12px */
  html .eyebrow,
  html .section-kicker,
  html .play-panel-kicker,
  html .npc-chat-eyebrow,
  html .npc-context-label,
  html .ai-control-badge,
  html .chat-palette-kp-badge,
  html .speech-shortcut,
  html .build-stamp {
    font-size: 0.75rem;
  }

  /* 文として読む物：13px */
  html label,
  html .confidential-banner,
  html .header-meta,
  html .data-status,
  html .play-entry-option span,
  html .play-panel-heading p,
  html .character-builder-guide,
  html .ho-option-id,
  html .ho-option-name,
  html .generator-summary,
  html .play-scale-summary,
  html .control-field-note,
  html .progress-summary-row,
  html .sheet-card-header p,
  html .sheet-tachie-picker > span,
  html .sheet-section-title,
  html .sheet-notes,
  html .derived-pill,
  html .premade-card-ho,
  html .premade-card-reading,
  html .premade-art-credit,
  html .premade-card-profile,
  html .premade-companion-note,
  html .premade-start-summary,
  html .play-speaker-label,
  html .character-library-current h4,
  html .character-library-list-heading h4,
  html .message-label,
  html .message-bubble,
  html .message-system .message-bubble,
  html .character-dialogue-name,
  html .chat-narration,
  html .dice-hint,
  html .chat-palette-request,
  html .chat-palette-empty,
  html .chat-palette-summary,
  html .chat-palette-pc-heading strong,
  html .chat-palette-pc-heading span,
  html .ho-opening-reread,
  html .chat-footer,
  html .site-footer,
  html .character-library-note,
  html .character-library-row span,
  html .character-library-empty,
  html .character-library-list-heading,
  html .npc-progress-gate p,
  html .npc-progress-gate label,
  html .source-note,
  html .count-pill,
  html .npc-select-scene,
  html .npc-context-strip,
  html .npc-mode-description,
  html .connection-status-pill,
  html .settings-connection-select,
  html .provider-settings-grid label,
  html .bridge-mode-status,
  html .connection-notes,
  html .focus-mode-note,
  html .focus-mode-toggle-label,
  html .scenario-spoiler-gate-text,
  html .novel-speed-switch,
  html .auto-cast-depth-label,
  html .custom-number-field,
  html .custom-derived-header,
  html .custom-textarea-field,
  html .custom-skill-hint,
  html .ia-import-guide,
  html .field-help,
  html .security-note,
  html .sidequest-current,
  html .sidequest-current-label,
  html .sidequest-history-heading span,
  html .sidequest-slot-summary strong,
  html .sidequest-slot-summary span,
  html .authored-session-list > summary,
  html .authored-logline,
  html .authored-info-grid span,
  html .authored-info-grid strong,
  html .authored-pc-preset dt,
  html .authored-pc-preset dd,
  html .authored-ending-row strong,
  html .chat-error,
  html .streaming-waiting,
  html .speech-input-note,
  html .scene-picker-note,
  html .scene-picker-note code,
  html .scene-picker-notify,
  html .scene-picker-group,
  html .scene-picker-item small,
  html .scene-picker-empty,
  html .novel-roll-callout,
  html .premade-card-badge,
  html .npc-edited-badge,
  html .npc-reading,
  html .npc-prompt-editor-heading label,
  html .npc-prompt-editor-note,
  html .npc-prompt-fields label,
  html .npc-prompt-editor-status,
  html .novel-script-hint,
  html .script-control-status,
  html .script-control-hint,
  html .script-control-actions .script-control-hint,
  html .script-control-actions .script-control-hint.script-control-minor,
  html .script-pacing-label,
  html .script-pacing-note {
    font-size: 0.8125rem;
  }

  /* 押す物：13px・高さ40px */
  html .button,
  html .character-library-row .button,
  html .custom-derived-header .button,
  html .custom-pc-delete,
  html .sheet-tachie-delete,
  html .npc-mode-button,
  html .sheet-name-reroll,
  html .site-mode-toggle,
  html .ho-controller-button,
  html .connection-status-link,
  html .ho-opening-reread-button,
  html .chat-palette > summary {
    min-height: 40px;
    font-size: 0.8125rem;
  }

  html input[type="file"],
  html input[type="file"]::file-selector-button {
    font-size: 0.8125rem;
  }

  /* 入力欄：16px（iOS は16px未満の入力欄にフォーカスすると画面を拡大してしまう） */
  html input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  html select,
  html textarea {
    font-size: 16px;
  }

  html .connection-status-link,
  html .ho-opening-reread-button {
    display: inline-flex;
    align-items: center;
  }

  html .ho-opening-reread-button {
    padding: 6px 14px;
  }

  /* 明るい地の上の薄い金色の小さな文字：コントラスト比 4.5 以上にする（#8a6a28・#a8802f → #7a5c20） */
  html .section-kicker,
  html .play-panel-kicker,
  html .ho-option-id,
  html .sheet-title-row h4,
  html .derived-pill,
  html .progress-summary-row > span:first-child,
  html #play-table-title,
  html .usage-display,
  html .character-library-current h4,
  html .character-library-list-heading h4,
  html .npc-chat-eyebrow,
  html .npc-context-label,
  html #npc-chat-count,
  html .npc-chat-identity strong,
  html .npc-chat-sidebar-head strong,
  html .npc-select-name,
  html .connection-status-pill {
    color: #7a5c20;
  }

  /* 暗い地の「READY TO PLAY」は元の金色のまま（暗くすると読めなくなる） */
  html .session-launch .play-panel-kicker {
    color: var(--gold);
  }

  /* 場面転換の「KPに伝えて…」：チェックの四角が横いっぱいに伸びていたのを、ふつうの大きさに */
  html .scene-picker-notify input[type="checkbox"] {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    min-height: 0;
  }

  /* 下の帯：「待機中」を1字ずつ折らない（長い状態の文は折り返してよい） */
  html .chat-footer > [role="status"] {
    min-width: 4em;
  }

  /* 「カスタム」「つづけて」：文字を大きくしても1語の途中で折らない */
  html .custom-dice-label,
  html .auto-cast-depth-label {
    white-space: nowrap;
  }

  html .dice-bar {
    flex-wrap: wrap;
  }

  /* 能力値（STR など）の名前：13px */
  html .sheet-stat span {
    font-size: 0.8125rem;
  }

  /* 「上限89%」を途中で折らない */
  html .sheet-section-title > span:last-child:not(:first-child) {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* 技能のボタン：13px・高さ40px。長い名前（制作:スイーツ など）は切らずに折り返し、数値は右に寄せる */
  html .skill-roll-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-height: 40px;
    padding: 5px 8px;
    font-size: 0.8125rem;
    line-height: 1.3;
    white-space: normal;
  }

  html .skill-roll-button span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  html .skill-roll-button strong {
    flex: 0 0 auto;
    float: none;
  }

  /* スマホだけ：タブ・本文の窓・会話の記録の文字 */
  html .tab-button,
  html .character-dialogue-bubble,
  html .novel-roll-callout,
  html .novel-scene-badge,
  html .site-mode-toggle,
  html .confidential-banner {
    font-size: 0.8125rem;
  }

  html .site-header h1 span {
    font-size: max(0.8125rem, 0.58em);
  }

  html .confidential-banner {
    letter-spacing: 0;
    text-wrap: balance;
  }

  html .novel-text {
    font-size: 0.875rem;
  }

  /* 本文の窓の操作・表示の切り替え（iPad 向けの既存の決まりに合わせる） */
  html .display-mode-button,
  html .speech-mode-button,
  html .novel-autoplay-toggle,
  html .auto-cast-toggle,
  html .novel-speed-switch button,
  html .novel-next-button,
  html .sheet-tachie-picker input[type="file"] {
    font-size: 0.8125rem;
  }

  html .script-control-actions .button,
  html .script-control-actions .button.script-control-minor,
  html .script-control-actions .script-control-hint.script-control-minor {
    opacity: 1;
  }

  html .script-control-actions .button.script-control-minor {
    font-size: 0.8125rem;
  }

  /* 技能のボタン：スマホ幅では3列だと長い名前が入らないので2列に */
  html .sheet-skill-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ≤480px：入力欄の案内の文を 11px → 12px に。長い案内（約37字）は4行になるので、入力欄をその分だけ高くする。 */
@media (max-width: 480px) {
  .chat-shell.is-novel-mode .play-chat-composer textarea {
    height: 78px;
    min-height: 78px;
  }

  .chat-shell.is-novel-mode .play-chat-composer textarea::placeholder {
    font-size: 12px;
  }
}

/* クリティカルチケット（CT）と、致命的失敗の影響の札・選択のボタン（2026-11-18） */
.roll-rule-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  color: var(--gold-soft);
  border: 1px solid rgba(168, 128, 47, 0.4);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.roll-rule-badge.is-warning {
  color: var(--l3);
  border-color: rgba(154, 64, 56, 0.4);
}

.roll-rule-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.roll-rule-hint {
  flex: 1 1 100%;
  color: var(--cream-dim);
  font-size: 0.78rem;
}

.roll-rule-button,
.script-ct-button {
  min-height: 40px;
}

/* 舞台の上（判定の提案と同じ所）に出す時は、絵の上でも読めるよう、濃い色の板に載せる */
.novel-roll-suggestions .roll-rule-actions {
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid rgba(168, 128, 47, 0.5);
  border-radius: 12px;
  background: rgba(30, 23, 12, 0.86);
}

.novel-roll-suggestions .roll-rule-hint {
  color: #f3ead7;
}

/* チャット表示の時の、判定のあとの選択（入力欄の上） */
.chat-roll-actions .roll-rule-actions {
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid rgba(168, 128, 47, 0.5);
  border-radius: 12px;
  background: rgba(30, 23, 12, 0.86);
}

.chat-roll-actions .roll-rule-hint {
  color: #f3ead7;
}

/* 舞台の上の選択の板は、舞台からはみ出さない（長いボタンの字は折り返す） */
.novel-roll-suggestions .roll-rule-actions {
  box-sizing: border-box;
  max-width: 100%;
}

.novel-roll-suggestions .roll-rule-button {
  max-width: 100%;
  white-space: normal;
  text-align: left;
}

/* スマホの幅：場所の札の下に、舞台の幅いっぱいで出す（右へはみ出して切れないように） */
@media (max-width: 640px) {
  .novel-roll-suggestions:has(.roll-rule-actions) {
    top: 52px;
    right: 10px;
    left: 10px;
    max-width: none;
    align-items: stretch;
  }
}

/* ======================================================================
   戦闘（アプリが仕切る）：左上の行動順・舞台の敵・当たり外れの動き
   2026-11-18 KASO「戦闘中、画面の左上にDEX順に…順番を表示／ズーグも表示して、攻撃が当たったかなどのエフェクトも」
   ====================================================================== */
/* 戦闘の間は、左上の場所の札をしまう（同じ所に行動順を出すので） */
.novel-stage.is-battle .novel-scene-badge {
  display: none;
}

.battle-order {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 12px;
  width: min(46%, 250px);
  max-height: calc(100% - 150px);
  padding: 8px 10px 9px;
  overflow: hidden auto;
  color: #f3ead7;
  border: 1px solid rgba(224, 194, 122, 0.72);
  border-radius: 12px;
  background: rgba(24, 18, 10, 0.9);
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.32);
  font-size: 0.78rem;
  line-height: 1.35;
}

.battle-order[hidden],
.battle-enemies[hidden] {
  display: none;
}

.battle-order-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(224, 194, 122, 0.4);
  font-family: var(--serif);
  letter-spacing: 0.04em;
}

.battle-order-round {
  color: #e7c873;
  font-weight: 700;
}

.battle-order-note {
  color: rgba(243, 234, 215, 0.72);
  font-size: 0.68rem;
}

.battle-order-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.battle-order-row {
  position: relative;
  display: grid;
  grid-template-columns: 1.1em minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 6px;
}

.battle-order-mark {
  color: #e7c873;
  font-size: 0.7rem;
}

.battle-order-name {
  overflow: hidden;
  color: #f3ead7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-order-meta {
  color: rgba(243, 234, 215, 0.78);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.battle-order-row.is-enemy .battle-order-name {
  color: #ffc7b6;
}

/* 味方のNPC（AIフリー進行）：探索者と同じ見た目に、名前の後ろへ小さく「味方」。 */
.battle-order-row.is-ally .battle-order-name::after {
  content: "味方";
  margin-left: 0.35em;
  font-size: 0.75em;
  opacity: 0.7;
}

.battle-order-row.is-current {
  background: rgba(231, 200, 115, 0.24);
  box-shadow: inset 0 0 0 1px rgba(231, 200, 115, 0.7);
  font-weight: 700;
}

.battle-order-row.is-acted {
  opacity: 0.78;
}

.battle-order-row.is-current .battle-order-name,
.battle-order-row.is-current .battle-order-meta {
  color: #fff6dc;
}

.battle-order-row.is-down {
  opacity: 0.45;
}

.battle-order-row.is-down .battle-order-name {
  text-decoration: line-through;
}

.battle-order-row.is-hurt {
  animation: battle-row-hurt 620ms ease-out;
}

/* 舞台の敵（文章の窓の上・右寄りに並べる） */
.battle-enemies {
  position: absolute;
  z-index: 1;
  right: 4%;
  bottom: 30%;
  left: 36%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3%;
  height: 25%;
  pointer-events: none;
}

.battle-enemy {
  position: relative;
  display: flex;
  flex: 0 1 22%;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  max-width: 150px;
  height: 100%;
  padding: 0;
  color: #f3ead7;
  border: 0;
  background: none;
  pointer-events: auto;
  transition: opacity 420ms ease, filter 420ms ease, transform 420ms ease;
}

.battle-enemy:disabled {
  cursor: default;
}

.battle-enemy.is-targetable {
  cursor: pointer;
}

.battle-enemy.is-targetable:hover .battle-enemy-image,
.battle-enemy.is-targetable:focus-visible .battle-enemy-image {
  filter: drop-shadow(0 0 10px rgba(231, 200, 115, 0.95));
}

.battle-enemy-image {
  display: block;
  width: auto;
  max-width: 100%;
  min-height: 0;
  max-height: calc(100% - 22px);
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
}

.battle-enemy-name {
  margin-top: 2px;
  padding: 1px 8px;
  border: 1px solid rgba(224, 194, 122, 0.55);
  border-radius: 999px;
  background: rgba(24, 18, 10, 0.86);
  font-size: 0.68rem;
  line-height: 1.4;
  white-space: nowrap;
}

.battle-enemy.is-current .battle-enemy-name {
  color: #1e170c;
  border-color: #e7c873;
  background: #e7c873;
  font-weight: 700;
}

.battle-enemy.is-down {
  opacity: 0.16;
  filter: grayscale(1);
  transform: translateY(8%) rotate(8deg);
  pointer-events: none;
}

/* 当たり外れの数字・ことば（敵の上・行動順の行の横にふわっと出す） */
.battle-float {
  position: absolute;
  z-index: 4;
  top: 4%;
  left: 50%;
  padding: 1px 8px;
  color: #fff;
  border-radius: 8px;
  background: rgba(24, 18, 10, 0.78);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, 0);
  animation: battle-float-up 1100ms ease-out forwards;
}

.battle-float.is-hit { color: #ffb4a2; }
.battle-float.is-miss { color: #cfd8e3; }
.battle-float.is-dodge { color: #a8e6c1; }
.battle-float.is-critical { color: #ffe08a; }
.battle-float.is-down { color: #ffd0d0; }

.battle-order-row .battle-float {
  top: -2px;
  right: 4px;
  left: auto;
  font-size: 0.86rem;
  transform: none;
  animation-name: battle-float-side;
}

.battle-enemy.fx-lunge { animation: battle-lunge 420ms ease-out; }
.battle-enemy.fx-hit .battle-enemy-image { animation: battle-hit 460ms ease-out; }
.battle-enemy.fx-dodge { animation: battle-dodge 520ms ease-out; }

/* 探索者が傷を負った時：舞台のふちが赤く光る */
.battle-flash {
  position: absolute;
  z-index: 2;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(160, 20, 20, 0) 45%, rgba(170, 24, 24, 0.62) 100%);
  pointer-events: none;
}

.battle-flash.is-on {
  animation: battle-flash 520ms ease-out;
}

/* 操作のボタン（攻撃の方法・相手） */
.battle-control-row {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.battle-control-label {
  flex: 0 0 auto;
  color: var(--gold-deep, #8a6a1f);
  font-size: 0.76rem;
  font-weight: 700;
}

.battle-attack-button.is-selected {
  box-shadow: inset 0 0 0 2px #8a6a1f;
  font-weight: 700;
}

@keyframes battle-float-up {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.85); }
  18% { opacity: 1; transform: translate(-50%, -6px) scale(1.12); }
  70% { opacity: 1; transform: translate(-50%, -22px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(1); }
}

@keyframes battle-float-side {
  0% { opacity: 0; transform: translateY(4px); }
  20% { opacity: 1; transform: translateY(-2px); }
  75% { opacity: 1; transform: translateY(-8px); }
  100% { opacity: 0; transform: translateY(-12px); }
}

@keyframes battle-lunge {
  0% { transform: translate(0, 0) scale(1); }
  45% { transform: translate(-16%, 6%) scale(1.14); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes battle-hit {
  0% { transform: translateX(0); filter: brightness(2.2) saturate(0.4) drop-shadow(0 0 12px rgba(255, 60, 60, 0.95)); }
  20% { transform: translateX(-7%); }
  40% { transform: translateX(6%); filter: brightness(1.5) drop-shadow(0 0 10px rgba(255, 60, 60, 0.8)); }
  60% { transform: translateX(-4%); }
  80% { transform: translateX(2%); }
  100% { transform: translateX(0); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55)); }
}

@keyframes battle-dodge {
  0% { transform: translateX(0); }
  40% { transform: translateX(22%) rotate(6deg); }
  100% { transform: translateX(0); }
}

@keyframes battle-flash {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes battle-row-hurt {
  0% { background: rgba(200, 40, 40, 0.75); }
  100% { background: transparent; }
}

/* スマホの幅：舞台が低いので、行動順は詰めて8人ぶんを入れ、敵は右半分に並べる */
@media (max-width: 640px) {
  .battle-order {
    top: 6px;
    left: 6px;
    width: 46%;
    max-height: calc(100% - 92px);
    padding: 4px 6px 5px;
    font-size: 0.62rem;
    line-height: 1.24;
  }

  .battle-order-head {
    margin-bottom: 2px;
    padding-bottom: 2px;
  }

  .battle-order-note {
    font-size: 0.5rem;
  }

  .battle-order-list {
    gap: 0;
  }

  .battle-order-row {
    grid-template-columns: 0.9em minmax(0, 1fr) auto;
    gap: 2px;
    padding: 0 3px;
  }

  .battle-order-meta {
    font-size: 0.52rem;
  }

  .battle-enemies {
    right: 1%;
    bottom: 30%;
    left: 48%;
    gap: 1%;
    height: 40%;
  }

  .battle-enemy {
    flex-basis: 24%;
  }

  .battle-enemy-name {
    padding: 0 3px;
    font-size: 0.5rem;
  }

  .battle-float {
    font-size: 0.82rem;
  }
}

/* 動きを減らす設定の時は、数字・ことばだけを出して、揺れ・光は出さない */
@media (prefers-reduced-motion: reduce) {
  .battle-enemy.fx-lunge,
  .battle-enemy.fx-dodge,
  .battle-enemy.fx-hit .battle-enemy-image,
  .battle-flash.is-on,
  .battle-order-row.is-hurt {
    animation: none;
  }

  .battle-float,
  .battle-order-row .battle-float {
    animation-duration: 1600ms;
  }
}

/* 「戦闘を切り上げる」は、目立たせない（押し間違えないよう、右の端へ） */
.battle-abandon-button {
  margin-left: auto;
  opacity: 0.78;
  font-size: 0.74rem;
}

/* ======================================================================
   探索者のいまの状態（耐久力・MP・正気度）。舞台のすぐ下に、いつも出す
   2026-11-19 KASO「クトゥルフ神話TRPGのシステムを丸ごと」
   ====================================================================== */
.party-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}

.party-status[hidden] {
  display: none;
}

.party-status-card {
  display: flex;
  flex: 1 1 150px;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  min-width: 0;
  padding: 5px 9px;
  color: #3d3226;
  border: 1px solid rgba(138, 106, 31, 0.35);
  border-radius: 10px;
  background: rgba(255, 252, 244, 0.92);
  font-size: 0.74rem;
  line-height: 1.35;
}

.party-status-card.is-companion {
  background: rgba(250, 245, 232, 0.7);
}

.party-status-card.is-flagged {
  border-color: rgba(160, 40, 40, 0.6);
  background: rgba(255, 240, 236, 0.95);
}

.party-status-name {
  flex: 1 1 100%;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-status-meter {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.party-status-label {
  color: #8a6a1f;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.party-status-meter.is-low .party-status-value {
  color: #a02828;
  font-weight: 700;
}

.party-status-flag {
  padding: 0 6px;
  color: #fff;
  border-radius: 999px;
  background: #a02828;
  font-size: 0.64rem;
  font-weight: 700;
}

.script-san-button {
  min-height: 40px;
}

@media (max-width: 640px) {
  .party-status {
    gap: 4px;
    margin: 6px 0 2px;
  }

  .party-status-card {
    flex: 1 1 calc(50% - 4px);
    gap: 1px 6px;
    padding: 4px 7px;
    font-size: 0.68rem;
  }
}

/* 持ち物（手に入れた武器・装備）の札と、武器を選ぶ窓（2026-11-19） */
.party-status-gear {
  font-size: 0.72rem;
  color: var(--text-muted, #b9b2a3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16em;
}

/* 武器を選ぶ窓：候補が多いので、2列に詰めて、小さめのボタンで並べる（舞台からはみ出さない・あふれたら中で送る） */
.roll-rule-actions.armory-pick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* 行の高さは中身に合わせる（窓が低い時に、行が押しつぶされて字が欠けないように。あふれた分は、窓の中で送る） */
  grid-auto-rows: max-content;
  gap: 6px;
  max-height: min(64vh, 440px);
  overflow-y: auto;
  align-items: stretch;
}

.roll-rule-actions.armory-pick .roll-rule-hint {
  grid-column: 1 / -1;
}

.roll-rule-actions.armory-pick .roll-rule-button {
  height: auto;
  min-height: 34px;
  font-size: 0.78rem;
  line-height: 1.3;
  padding: 0.35em 0.7em;
  text-align: left;
  white-space: normal;
}

.novel-roll-suggestions:has(.armory-pick) {
  width: min(520px, calc(100% - 24px));
  max-width: none;
}

/* スマホの幅：武器を選ぶ窓は、舞台の中に収めて、あふれた分は窓の中で送る */
@media (max-width: 640px) {
  .novel-roll-suggestions:has(.armory-pick) {
    top: 44px;
    bottom: 6px;
    width: auto;
  }

  .roll-rule-actions.armory-pick {
    max-height: 100%;
    padding: 8px 10px;
  }

  .roll-rule-actions.armory-pick .roll-rule-hint {
    font-size: 0.7rem;
    line-height: 1.4;
  }

  .roll-rule-actions.armory-pick .roll-rule-button {
    min-height: 30px;
    font-size: 0.72rem;
    padding: 0.3em 0.6em;
  }
}

/* 数値つきの場面・フリーの戦闘の数値の板（#encounter-board。「いまの状態」の欄の下）。スマホの幅でも1行に収める。 */
.encounter-board {
  display: grid;
  gap: 4px;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid rgba(201, 169, 106, 0.35);
  border-radius: 8px;
  background: rgba(20, 16, 28, 0.6);
  font-size: 0.82rem;
}
.encounter-board[hidden] { display: none; }
.encounter-board-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.encounter-board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(48px, 30%);
  align-items: center;
  gap: 8px;
}
.encounter-board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.encounter-board-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.encounter-board-bar { position: relative; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.encounter-board-fill { position: absolute; inset: 0 auto 0 0; width: var(--fill, 0%); background: #c9a96a; }
.encounter-board-finish { justify-self: end; }
.battle-order-counters { margin-top: 4px; font-size: 0.75em; opacity: 0.85; }

/* 一般公開版：くわしい画面から、かんたん画面へ戻るボタン（上の帯と同じ形で、色だけ落ち着かせる） */
.public-easy-return {
  color: #f2ead8;
  background: #3a2f1c;
  border-bottom-color: rgba(224, 194, 122, 0.35);
}

.public-easy-return:hover {
  background: #4a3c24;
}

