/* かんたん開始（easy_ui.js）の見た目。
   ・全部、<html> に easy-ui の印が付いている時だけ効く（今までの画面には影響しない）。
   ・easy-wizard＝はじめの画面と質問／easy-playing＝物語の画面（舞台と入力欄だけ）。 */

/* ======================================================================
   今までの画面の部品をしまう
   ====================================================================== */
html.easy-ui .site-header,
html.easy-ui .site-footer,
html.easy-ui #tab-nav,
html.easy-ui #demo-preparation,
html.easy-ui .session-phase-bar,
html.easy-ui .session-chat-shell > .chat-toolbar,
html.easy-ui .session-play-column > .chat-footer,
html.easy-ui #script-control-status,
html.easy-ui .speech-shortcut {
  display: none !important;
}

html.easy-ui.easy-wizard #app,
html.easy-ui.easy-wizard .easy-topbar {
  display: none !important;
}

html.easy-ui.easy-wizard body {
  background: var(--ink-bg);
}

/* ======================================================================
   はじめの画面と質問
   ====================================================================== */
.easy-start {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 34px);
  padding: clamp(18px, 4vw, 48px) 16px clamp(28px, 6vw, 64px);
  color: var(--ink-text);
}

.easy-start[hidden] {
  display: none;
}

.easy-backdrop {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(24, 18, 9, 0.68), rgba(24, 18, 9, 0.86)),
    url("./assets/bg/ch1/003.jpg") center / cover no-repeat,
    var(--ink-bg);
}

.easy-frame {
  width: min(100%, 720px);
}

.easy-start[data-step="chapter"] .easy-frame {
  width: min(100%, 820px);
}

.easy-start[data-step="who"] .easy-frame {
  width: min(100%, 1040px);
}

.easy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 12px;
}

.easy-back {
  min-height: 44px;
  padding: 6px 14px 6px 6px;
  color: var(--ink-gold);
  border: 0;
  background: none;
  font-size: 0.95rem;
  font-weight: 700;
}

.easy-back[hidden],
.easy-progress[hidden] {
  display: none;
}

.easy-back:focus-visible,
.easy-start .easy-button:focus-visible,
.easy-topbar-button:focus-visible {
  outline-color: var(--ink-gold);
}

.easy-progress {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.easy-progress-dot {
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: rgba(242, 234, 216, 0.25);
}

.easy-progress-dot.is-done {
  background: rgba(224, 194, 122, 0.6);
}

.easy-progress-dot.is-current {
  background: var(--ink-gold);
}

.easy-body {
  padding: clamp(20px, 4vw, 40px);
  color: var(--cream);
  border: 1px solid rgba(224, 194, 122, 0.35);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 24px 60px rgba(10, 7, 2, 0.45);
}

.easy-body.is-entering {
  animation: easy-step-in 0.28s var(--ease-out) both;
}

@keyframes easy-step-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .easy-body.is-entering {
    animation: none;
  }
}

.easy-kicker {
  margin: 0;
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.75rem;
  font-style: italic;
  letter-spacing: 0.28em;
}

.easy-question {
  margin: 6px 0 20px;
  font-family: var(--display);
  font-size: clamp(1.3rem, 3.4vw, 1.85rem);
  font-weight: 600;
  line-height: 1.5;
  text-wrap: balance;
  word-break: auto-phrase;
}

.easy-question:focus {
  outline: none;
}

.easy-lead {
  margin: -8px 0 20px;
  color: #5c4d3b;
  font-size: 0.95rem;
  line-height: 1.75;
  text-wrap: balance;
  word-break: auto-phrase;
}

/* --- はじめの画面（カードに入れず、背景の上にじかに置く） --- */
.easy-body[data-step="welcome"] {
  padding: 0;
  color: var(--ink-text);
  text-align: center;
  border: 0;
  background: none;
  box-shadow: none;
}

.easy-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  color: var(--ink-gold);
  border: 1px solid rgba(224, 194, 122, 0.5);
  border-radius: 50%;
  font-size: 1.6rem;
}

.easy-body[data-step="welcome"] .easy-kicker {
  color: var(--ink-gold);
}

.easy-welcome-title {
  display: grid;
  gap: 12px;
  margin: 14px 0 20px;
  font-family: var(--display);
  font-weight: 500;
}

.easy-welcome-small {
  color: var(--ink-dim);
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  letter-spacing: 0.32em;
  text-indent: 0.32em;
}

.easy-welcome-name {
  padding: 16px 0;
  color: #fff7e2;
  border-top: 1px solid rgba(224, 194, 122, 0.4);
  border-bottom: 1px solid rgba(224, 194, 122, 0.4);
  font-size: clamp(1.6rem, 5.6vw, 2.9rem);
  letter-spacing: 0.06em;
  line-height: 1.45;
  text-wrap: balance;
  word-break: auto-phrase;
}

.easy-body[data-step="welcome"] .easy-lead {
  margin: 0;
  color: var(--ink-dim);
}

.easy-actions {
  display: grid;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.easy-actions .easy-button {
  min-width: min(320px, 78vw);
}

.easy-note-line {
  margin: 14px 0 0;
  color: var(--ink-dim);
  font-size: 0.85rem;
}

/* 一般公開版だけに出す、シナリオ本編のネタバレ注意。 */
.easy-spoiler-notice {
  width: min(100%, 620px);
  margin: 24px auto 0;
  padding: 16px 18px;
  color: var(--ink-text);
  text-align: left;
  border: 1px solid rgba(224, 194, 122, 0.5);
  border-radius: 14px;
  background: rgba(24, 18, 9, 0.62);
}

.easy-spoiler-notice h2 {
  margin: 0 0 8px;
  color: var(--ink-gold);
  font-family: var(--display);
  font-size: 1rem;
}

.easy-spoiler-notice p {
  margin: 6px 0 0;
  color: var(--ink-dim);
  font-size: 0.85rem;
  line-height: 1.75;
}

/* --- ボタン --- */
.easy-button {
  min-height: 52px;
  padding: 10px 28px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 0.2s var(--ease-out), filter 0.2s ease, border-color 0.2s ease;
}

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

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

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

.easy-button-primary:hover:not(:disabled) {
  filter: brightness(1.04);
}

.easy-button-small {
  min-height: 44px;
  padding: 8px 20px;
  font-size: 0.9rem;
}

.easy-body[data-step="welcome"] .easy-button:not(.easy-button-primary) {
  color: var(--ink-text);
  border-color: rgba(242, 234, 216, 0.45);
  background: rgba(36, 28, 16, 0.5);
}

.easy-link {
  display: block;
  min-height: 44px;
  margin: 10px auto 0;
  padding: 6px 10px;
  color: #7a5c20;
  border: 0;
  background: none;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- はい／いいえ --- */
.easy-choices.is-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.easy-choice {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  min-height: 150px;
  padding: 18px 14px;
  color: var(--cream);
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf8, #f8f1e1);
  transition: transform 0.2s var(--ease-out), border-color 0.2s ease, box-shadow 0.2s ease;
}

.easy-choice:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.easy-choice.is-selected {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2px var(--gold);
}

.easy-choice-en {
  color: var(--gold);
  font-family: var(--en);
  font-size: 0.75rem;
  font-style: italic;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.easy-choice-label {
  font-family: var(--display);
  font-size: clamp(1.3rem, 3.6vw, 1.7rem);
  font-weight: 600;
  line-height: 1.4;
}

.easy-choice-note {
  color: #5c4d3b;
  font-size: 0.85rem;
  line-height: 1.6;
  word-break: auto-phrase;
}

/* --- 章と探索者のカード --- */
.easy-cards {
  display: grid;
  gap: 12px;
}

.easy-cards.is-chapters {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.easy-cards.is-people {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.easy-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  color: var(--cream);
  text-align: left;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  transition: transform 0.2s var(--ease-out), border-color 0.2s ease, box-shadow 0.2s ease;
}

.easy-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.easy-card.is-selected {
  border-color: var(--gold);
  background: #fbf5e4;
  box-shadow: inset 0 0 0 2px var(--gold), var(--shadow);
}

.easy-card-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.easy-card-title {
  font-family: var(--display);
  font-size: 1.1rem;
  line-height: 1.45;
}

.easy-card-text {
  color: #5c4d3b;
  font-size: 0.85rem;
  line-height: 1.65;
}

.easy-chapter-numeral {
  flex: none;
  min-width: 1.5em;
  color: var(--gold);
  font-family: var(--en);
  font-size: 1.9rem;
  line-height: 1.15;
  text-align: center;
}

.easy-chip {
  justify-self: start;
  margin-top: 4px;
  padding: 2px 10px;
  color: #7a5c20;
  border-radius: 999px;
  background: rgba(168, 128, 47, 0.14);
  font-size: 0.75rem;
  font-weight: 700;
}

.easy-chip.is-free {
  color: #3d5a85;
  background: rgba(74, 107, 154, 0.12);
}

.easy-pc-card {
  --pc-color: #8a7a62;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
  padding: 0;
  border-top: 5px solid var(--pc-color);
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc-color) 12%, var(--card)) 0%, var(--card) 55%);
}

.easy-pc-card.is-selected {
  border-color: var(--pc-color);
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc-color) 18%, var(--card)) 0%, var(--card) 60%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc-color) 55%, transparent), var(--shadow);
}

.easy-pc-figure {
  display: block;
  height: 220px;
  overflow: hidden;
  background: color-mix(in srgb, var(--pc-color) 8%, var(--card-soft));
}

.easy-pc-figure img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 2%;
}

.easy-pc-card .easy-card-body {
  padding: 10px 14px 14px;
}

.easy-pc-role {
  color: color-mix(in srgb, var(--pc-color) 70%, var(--cream));
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.easy-pc-reading {
  color: var(--cream-dim);
  font-size: 0.75rem;
}

.easy-selected-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 10px;
  color: #fff;
  border-radius: 999px;
  background: var(--pc-color);
  font-size: 0.75rem;
  font-weight: 700;
}

.easy-credit {
  margin: 8px 0 0;
  color: var(--cream-dim);
  font-size: 0.75rem;
}

.easy-confirm {
  position: sticky;
  z-index: 2;
  bottom: 12px;
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.easy-confirm .easy-button {
  min-width: min(320px, 100%);
}

/* まだ押せない時も、下の文字が透けないように塗りつぶす。 */
.easy-confirm .easy-button:disabled {
  color: #8a7c66;
  border-color: var(--border);
  background: #ece3cf;
  box-shadow: none;
  opacity: 1;
}

/* --- 準備完了 --- */
.easy-byo-box {
  margin: 0 0 18px;
  padding: 16px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card-soft);
}

.easy-byo-box h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 1.1rem;
}

.easy-byo-label {
  display: block;
  margin: 0 0 7px;
  color: var(--gold-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.easy-provider-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.easy-provider-button {
  min-width: 0;
  min-height: 46px;
  padding: 8px 10px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.9rem;
  font-weight: 700;
}

.easy-provider-button.is-selected {
  color: #5b4314;
  border-color: var(--gold);
  background: #f3e4bd;
  box-shadow: inset 0 0 0 1px var(--gold);
}

.easy-key-area {
  min-width: 0;
  margin-top: 14px;
}

.easy-key-input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 10px 12px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fffdf8;
  font: inherit;
}

.easy-key-input:focus {
  border-color: var(--gold);
  outline: 2px solid color-mix(in srgb, var(--gold) 30%, transparent);
  outline-offset: 1px;
}

.easy-key-set {
  display: inline-block;
  margin: 0 10px 0 0;
  color: #416b42;
  font-size: 0.9rem;
  font-weight: 700;
}

.easy-key-change {
  display: inline-block;
  min-height: 36px;
  margin: 0;
  color: #6b521f;
}

.easy-key-guide {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.easy-key-guide p {
  margin: 6px 0 0;
  color: #5c4d3b;
  font-size: 0.78rem;
  line-height: 1.65;
}

.easy-key-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
}

.easy-key-links a {
  color: #6f5318;
  font-size: 0.8rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-underline-offset: 3px;
}

.easy-key-unknown {
  margin: 14px 0 0;
  padding: 10px 12px;
  color: #7a4f16;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: #fff8e8;
  font-size: 0.86rem;
  line-height: 1.7;
}

.easy-byo-start-actions {
  min-width: 0;
}

.easy-byo-continue {
  display: block;
  max-width: 100%;
  margin: 10px auto 0;
}

.easy-read-only {
  max-width: 100%;
  line-height: 1.55;
  white-space: normal;
}

.easy-summary {
  margin: 0 0 14px;
  border-top: 1px solid var(--border);
}

.easy-summary-row {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}

.easy-summary-row dt {
  color: var(--gold-soft);
  font-size: 0.85rem;
  font-weight: 700;
}

.easy-summary-row dd {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
}

.easy-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: #b9ad98;
}

.easy-connection-row[data-tone="ok"] .easy-dot {
  background: var(--l0);
}

.easy-connection-row[data-tone="ng"] .easy-dot {
  background: var(--l3);
}

.easy-connection-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #faf3ef;
}

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

.easy-connection-help p {
  flex: 1 1 260px;
  margin: 0;
  color: #7a2f28;
  font-size: 0.85rem;
  line-height: 1.7;
}

.easy-howto {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card-soft);
}

.easy-howto h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 0.95rem;
}

.easy-howto ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: easy-howto;
}

.easy-howto li {
  display: grid;
  grid-template-columns: 1.9em minmax(0, 1fr);
  column-gap: 8px;
  font-size: 0.9rem;
  line-height: 1.7;
  counter-increment: easy-howto;
}

.easy-howto li::before {
  grid-row: 1 / span 2;
  width: 1.7em;
  height: 1.7em;
  margin-top: 0.1em;
  color: var(--ink-text);
  border-radius: 50%;
  background: var(--gold-soft);
  font-family: var(--en);
  font-size: 0.85rem;
  line-height: 1.7em;
  text-align: center;
  content: counter(easy-howto);
}

.easy-howto li strong,
.easy-howto li span {
  grid-column: 2;
}

.easy-warning {
  margin: 0 0 14px;
  padding: 10px 14px;
  color: #7a2f28;
  border-left: 4px solid var(--l3);
  border-radius: 6px;
  background: #faf3ef;
  font-size: 0.9rem;
  line-height: 1.7;
}

.easy-error {
  margin: 0 0 12px;
  color: var(--l3);
  font-size: 0.9rem;
  font-weight: 700;
}

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

@media (max-width: 899px) {
  .easy-cards.is-people {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 559px) {
  .easy-choices.is-two,
  .easy-cards.is-chapters,
  .easy-cards.is-people {
    grid-template-columns: minmax(0, 1fr);
  }

  .easy-choice {
    min-height: 112px;
  }

  .easy-pc-card {
    flex-direction: row;
  }

  .easy-pc-figure {
    flex: none;
    width: 108px;
    height: auto;
    min-height: 168px;
  }

  .easy-pc-figure img {
    width: 170%;
    max-width: none;
    margin: 4% 0 0 -35%;
  }

  .easy-summary-row {
    grid-template-columns: 5.5em minmax(0, 1fr);
  }

  .easy-provider-choices {
    grid-template-columns: minmax(0, 1fr);
  }

  .easy-byo-box {
    padding: 14px 12px;
  }
}

/* ======================================================================
   物語の画面（舞台と入力欄だけ）
   ====================================================================== */
.easy-topbar,
.easy-log-bar {
  display: none;
}

html.easy-ui.easy-playing .easy-topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px max(16px, calc((100vw - var(--easy-play-width)) / 2));
  color: var(--ink-text);
  border-bottom: 1px solid rgba(224, 194, 122, 0.24);
  background: var(--ink-bg-t);
  backdrop-filter: blur(6px);
}

html.easy-ui {
  /* 舞台（3:2）と入力欄が、画面の高さに収まる幅まで。 */
  --easy-play-width: clamp(320px, calc((100dvh - 310px) * 1.5), 1040px);
}

.easy-topbar-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.easy-topbar-mark {
  color: var(--ink-gold);
}

.easy-topbar-title strong {
  overflow: hidden;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.easy-topbar-chapter {
  flex: none;
  color: var(--ink-gold);
  font-size: 0.85rem;
  white-space: nowrap;
}

.easy-topbar-actions {
  display: flex;
  flex: none;
  gap: 8px;
}

.easy-topbar-button {
  min-height: 40px;
  padding: 6px 16px;
  color: var(--ink-text);
  border: 1px solid rgba(224, 194, 122, 0.45);
  border-radius: 999px;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 700;
}

.easy-topbar-button:hover {
  border-color: var(--ink-gold);
}

html.easy-ui.easy-playing .app-shell {
  width: min(var(--easy-play-width), 100%);
  min-height: 0;
  padding: 12px 12px 40px;
}

/* 記録の列をしまって、舞台と入力欄を1列に。ページ全体でスクロールする。 */
html.easy-ui .session-workspace {
  display: block;
  height: auto;
}

html.easy-ui .session-play-column {
  height: auto;
  max-height: none;
  overflow: visible;
}

html.easy-ui .session-log-column {
  display: none;
}

html.easy-ui .session-play-column > .play-chat-composer,
html.easy-ui .chat-shell.is-novel-mode .session-play-column > .play-chat-composer {
  bottom: 0;
}

/* 入力欄：左に発言の種類（セリフ・行動／相談・質問）を縦に2つ、まん中に入力欄、右に送信。高さを低くして舞台を広く見せる。 */
html.easy-ui .chat-shell.is-novel-mode .play-chat-composer {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
}

html.easy-ui .play-chat-composer .play-input-controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

html.easy-ui .play-chat-composer .speech-mode-switch {
  grid-template-columns: minmax(0, 1fr);
}

html.easy-ui .play-chat-composer .speech-mode-button {
  min-height: 36px;
  padding-inline: 14px;
  white-space: nowrap;
}

html.easy-ui .chat-shell.is-novel-mode .play-chat-composer textarea {
  height: 84px;
  min-height: 84px;
}

/* 幅がせまい時は、発言の種類を上の段（横並び）に移す。入力欄の高さは今までの決まりのまま。 */
@media (max-width: 699px) {
  html.easy-ui .chat-shell.is-novel-mode .play-chat-composer {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  html.easy-ui .play-chat-composer .play-input-controls {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    grid-column: 1 / -1;
    gap: 6px 12px;
  }

  html.easy-ui .play-chat-composer .speech-mode-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  html.easy-ui .chat-shell.is-novel-mode .play-chat-composer textarea {
    height: 56px;
    min-height: 56px;
  }
}

@media (max-width: 480px) {
  html.easy-ui .chat-shell.is-novel-mode .play-chat-composer textarea {
    height: 78px;
    min-height: 78px;
  }
}

/* ダイスの段は、「技能とダイス」を開いた時だけ出す。 */
html.easy-ui:not(.easy-tools-open) #play-dice-bar {
  display: none;
}

.easy-stage-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 10px 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
}

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

.easy-stage-note p {
  flex: 1 1 240px;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.7;
}

/* --- 記録（これまでの会話）を画面いっぱいに重ねる --- */
html.easy-ui.easy-show-log body {
  overflow: hidden;
}

html.easy-ui.easy-show-log .easy-log-bar {
  position: fixed;
  z-index: 71;
  top: var(--easy-overlay-top, 0px);
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 8px max(16px, calc((100vw - 880px) / 2));
  color: var(--ink-text);
  background: var(--ink-bg);
}

.easy-log-bar strong {
  font-family: var(--display);
  font-weight: 500;
}

html.easy-ui.easy-show-log .session-log-column {
  position: fixed;
  z-index: 70;
  top: calc(var(--easy-overlay-top, 0px) + 56px);
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  height: auto;
  overflow: auto;
  padding: 8px max(8px, calc((100vw - 880px) / 2)) 40px;
  border: 0;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

html.easy-ui.easy-show-log .session-log-column .chat-messages {
  height: auto;
  max-height: none;
  min-height: 0;
  overflow: visible;
}

html.easy-ui.easy-show-log .log-rewind-row {
  width: 100%;
}

/* --- メニュー --- */
.easy-menu {
  width: min(92vw, 440px);
  max-height: min(86dvh, 720px);
  padding: 0;
  overflow: auto;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 24px 60px rgba(20, 14, 6, 0.4);
}

.easy-menu::backdrop {
  background: rgba(24, 18, 9, 0.55);
}

.easy-menu-head {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.easy-menu-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.1rem;
}

.easy-menu-head .easy-topbar-button,
.easy-menu .easy-toggle {
  color: var(--cream);
  border: 1px solid var(--border);
}

.easy-menu-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--bg-deep);
}

.easy-menu-section h3 {
  margin: 0 0 8px;
  color: var(--gold-soft);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

.easy-menu-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 52px;
}

.easy-menu-label {
  font-size: 0.95rem;
}

.easy-segment {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.easy-segment-button {
  min-width: 64px;
  min-height: 40px;
  padding: 6px 14px;
  color: var(--cream);
  border: 0;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 700;
}

.easy-menu .easy-toggle {
  min-width: 76px;
  border-radius: 999px;
}

.easy-segment-button.is-active {
  color: var(--ink-text);
  background: var(--ink-bg);
}

.easy-menu-details summary {
  padding: 10px 0;
  font-size: 0.95rem;
}

.easy-menu-details .easy-howto {
  margin: 8px 0 0;
}

.easy-scene-details {
  margin-bottom: 8px;
}

.easy-scene-list {
  max-height: 50vh;
  padding: 4px 4px 0 0;
  overflow-y: auto;
  scrollbar-color: rgba(168, 128, 47, 0.55) transparent;
}

.easy-scene-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.easy-scene-item.is-current {
  border-color: rgba(168, 128, 47, 0.62);
}

.easy-scene-current {
  flex: 0 0 auto;
  padding: 2px 7px;
  color: var(--gold-soft);
  border: 1px solid rgba(168, 128, 47, 0.35);
  border-radius: 999px;
  font-size: 0.68rem;
  white-space: nowrap;
}

.easy-menu-item {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0 0 8px;
  padding: 10px 14px;
  color: var(--cream);
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  font-size: 0.95rem;
  line-height: 1.5;
}

.easy-menu-item:last-child {
  margin-bottom: 0;
}

.easy-menu-item:hover:not(:disabled) {
  border-color: var(--gold);
}

.easy-menu-item:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.easy-menu-item.is-confirm {
  border-color: var(--gold);
  background: #fbf5e4;
  font-weight: 700;
}

.easy-menu-item.is-danger {
  color: var(--l3);
  border-color: var(--l3);
  background: #faf3ef;
  font-weight: 700;
}

.easy-menu-connection {
  margin: 0;
  padding: 12px 18px 16px;
  color: var(--cream-dim);
  font-size: 0.85rem;
}

.easy-menu-connection[data-tone="ok"] {
  color: var(--l0);
}

.easy-menu-connection[data-tone="ng"] {
  color: var(--l3);
}

/* --- キャラクター（顔・ステータス・過去）--- */
/* 顔アイコン。用意された探索者（is-tight）は、絵の幅・位置を easy_ui.js が決めて、顔のまわりだけを出す。 */
.easy-face {
  position: relative;
  display: inline-grid;
  flex: none;
  overflow: hidden;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fff;
  border: 2px solid var(--pc-color, var(--gold));
  border-radius: 50%;
  background: var(--pc-color, #8a7a62);
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

.easy-face.has-image {
  background: color-mix(in srgb, var(--pc-color, #8a7a62) 22%, #f6efe0);
}

.easy-face.has-image .easy-face-initial {
  visibility: hidden;
}

.easy-face img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
}

.easy-face.is-tight img {
  height: auto;
  object-fit: fill;
}

.easy-face.is-large {
  width: 104px;
  height: 104px;
  border-width: 3px;
  box-shadow: 0 6px 18px rgba(72, 53, 27, 0.18);
  font-size: 2.2rem;
}

/* 上の帯のボタン（顔アイコン＋「キャラクター」） */
.easy-topbar-button.is-cast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 14px 3px 4px;
}

.easy-topbar-face {
  display: inline-flex;
}

.easy-topbar-face .easy-face {
  width: 32px;
  height: 32px;
  border-width: 1.5px;
  border-color: var(--ink-gold);
  font-size: 0.85rem;
}

.easy-cast {
  width: min(94vw, 620px);
  max-height: min(88dvh, 900px);
}

.easy-cast-tabs {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 6px;
  padding: 12px 14px 0;
}

.easy-cast-tabs[hidden] {
  display: none;
}

.easy-cast-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 9px 4px 8px;
  color: var(--cream);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}

.easy-cast-tab:hover {
  border-color: var(--pc-color, var(--gold));
}

.easy-cast-tab.is-active {
  border-color: var(--pc-color, var(--gold));
  background: color-mix(in srgb, var(--pc-color, var(--gold)) 10%, var(--card));
  box-shadow: inset 0 0 0 1px var(--pc-color, var(--gold));
}

.easy-cast-tab:not(.is-active) .easy-face {
  opacity: 0.82;
}

.easy-cast-tab-text {
  display: grid;
  gap: 1px;
  min-width: 0;
  max-width: 100%;
  text-align: center;
}

.easy-cast-tab-text strong {
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.easy-cast-tab-text span {
  color: var(--cream-dim);
  font-size: 0.75rem;
}

.easy-cast-tab.is-active .easy-cast-tab-text span {
  color: color-mix(in srgb, var(--pc-color, var(--gold)) 62%, var(--cream));
  font-weight: 700;
}

.easy-cast-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 18px 14px;
}

.easy-cast-id {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.easy-cast-role {
  color: color-mix(in srgb, var(--pc-color, var(--gold)) 68%, var(--cream));
  font-size: 0.82rem;
  font-weight: 700;
}

.easy-cast-name {
  font-family: var(--display);
  font-size: 1.5rem;
  line-height: 1.3;
}

.easy-cast-reading {
  color: var(--cream-dim);
  font-size: 0.85rem;
}

.easy-cast-tag {
  justify-self: start;
  margin-top: 6px;
  padding: 2px 10px;
  color: color-mix(in srgb, var(--pc-color, var(--gold)) 62%, var(--cream));
  border: 1px solid color-mix(in srgb, var(--pc-color, var(--gold)) 55%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--pc-color, var(--gold)) 12%, var(--card));
  font-size: 0.78rem;
  font-weight: 700;
}

.easy-cast-vitals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 18px;
}

.easy-cast-vital,
.easy-cast-stat {
  display: grid;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.easy-cast-vital {
  gap: 1px;
  padding: 10px 4px 9px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--vital-color, var(--gold));
  border-radius: 12px;
  background: var(--card-soft);
}

.easy-cast-vital[data-key="HP"] {
  --vital-color: var(--l3);
}

.easy-cast-vital[data-key="MP"] {
  --vital-color: var(--l1);
}

.easy-cast-vital[data-key="SAN"] {
  --vital-color: #7a5a9c;
}

.easy-cast-key {
  color: var(--gold-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.easy-cast-vital .easy-cast-key {
  color: var(--vital-color, var(--gold-soft));
}

.easy-cast-vital strong {
  font-family: var(--display);
  font-size: 1.9rem;
  line-height: 1.15;
}

.easy-cast-label {
  color: var(--cream-dim);
  font-size: 0.75rem;
  line-height: 1.3;
  /* 言葉の途中では折り返さない（「マジック／ポイント」の切れ目でだけ折る）。 */
  word-break: keep-all;
}

.easy-cast-note {
  margin: 8px 18px 14px;
  color: var(--cream-dim);
  font-size: 0.8rem;
  line-height: 1.6;
}

.easy-cast-section {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--bg-deep);
}

.easy-cast-section h3 {
  margin: 0 0 8px;
  color: var(--gold-soft);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.easy-cast-section .easy-cast-note {
  margin: 0;
}

.easy-cast-text {
  margin: 0 0 8px;
  font-size: 0.95rem;
  line-height: 1.8;
}

.easy-cast-text:last-child {
  margin-bottom: 0;
}

.easy-cast-facts {
  display: grid;
  grid-template-columns: 4.5em minmax(0, 1fr);
  gap: 6px 10px;
  margin: 10px 0 0;
  font-size: 0.9rem;
  line-height: 1.7;
}

.easy-cast-facts dt {
  color: var(--gold-soft);
  font-weight: 700;
}

.easy-cast-facts dd {
  margin: 0;
}

/* 過去（あなただけの秘匿）。舞台の「だけの秘匿」の札と同じ紫で見分ける。 */
.easy-cast-section.is-secret {
  background: #f6f1f8;
}

.easy-cast-section.is-secret h3 {
  color: #6a4a86;
}

.easy-cast-section.is-secret .easy-cast-text {
  padding-left: 12px;
  border-left: 3px solid rgba(106, 74, 134, 0.3);
  font-family: var(--serif);
}

.easy-cast-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.easy-cast-stat {
  padding: 8px 2px 7px;
  border-radius: 10px;
  background: var(--card-soft);
}

.easy-cast-stat strong {
  font-size: 1.2rem;
  line-height: 1.25;
}

.easy-cast-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.easy-cast-stats + .easy-cast-pills {
  margin-top: 10px;
}

.easy-cast-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.85rem;
}

.easy-cast-pill strong {
  font-size: 0.95rem;
}

/* 幅のせまい画面：上の帯は顔アイコンだけ（「キャラクター」の文字はしまう）。 */
@media (max-width: 599px) {
  .easy-topbar-label {
    display: none;
  }

  .easy-topbar-button.is-cast {
    padding: 3px;
  }

  .easy-topbar-actions {
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .easy-topbar-chapter {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .easy-cast-hero {
    gap: 14px;
    padding: 16px 14px 12px;
  }

  .easy-face.is-large {
    width: 84px;
    height: 84px;
    font-size: 1.8rem;
  }

  .easy-cast-name {
    font-size: 1.3rem;
  }

  .easy-cast-tabs {
    padding: 10px 10px 0;
  }

  .easy-cast-vitals {
    padding: 0 14px;
  }

  .easy-cast-vital strong {
    font-size: 1.6rem;
  }

  .easy-cast-note {
    margin: 8px 14px 12px;
  }

  .easy-cast-section {
    padding: 12px 14px 14px;
  }
}

@media (max-width: 640px) {
  html.easy-ui.easy-playing .easy-topbar {
    position: static;
  }

  /* 左右 4px：スマホ幅では物語のパネルが左右に 4px はみ出す決まり（今までの画面と同じ）なので、その分を空ける。 */
  html.easy-ui.easy-playing .app-shell {
    padding: 8px 4px 24px;
  }
}

@media (max-width: 480px) {
  .easy-topbar-title strong {
    display: none;
  }
}

/* 一般公開版：APIキーの設定の小窓（メニューと同じ見た目の上に、キーの欄を入れる） */
.easy-key-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}

.easy-key-dialog .easy-byo-box {
  margin-top: 12px;
}

.easy-key-dialog .easy-byo-start-actions {
  margin-top: 14px;
}

