:root {
  color-scheme: light;
  --paper: #f5efe4;
  --panel: #f8f3ea;
  --ink: #203a33;
  --muted: #575951;
  --line: #bdb5a6;
  --accent: #98422e;
  --soft: #e8e4d6;
  --serif: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --sans: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 42% 16%, #faf6ee 0%, var(--paper) 80%);
  color: var(--ink);
  font: 15px/1.65 var(--sans);
  min-height: 100vh;
}
button, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid #7a8479;
  background: transparent;
  border-radius: 7px;
  min-height: 44px;
  padding: 7px 15px;
  font-weight: 600;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #ece7da; }
button:disabled { opacity: .58; cursor: default; }
:focus-visible { outline: 2px solid #a95538; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; }
.site-header { border-bottom: 1px solid #b8b0a0; }
.header-inner {
  margin: 0 auto;
  max-width: 1160px;
  min-height: 73px;
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 13px;
}
.wordmark, nav { display: flex; align-items: center; gap: 13px; }
.wordmark h1 { white-space: nowrap; font-size: 34px; line-height: 1.12; letter-spacing: .1em; }
.seal {
  display: grid;
  place-items: center;
  color: #fff0dd;
  background: var(--accent);
  width: 32px;
  height: 32px;
  border: 3px double #fff0dd;
  border-radius: 4px;
  font: bold 21px/1 var(--serif);
}
.layout {
  width: min(100%, 1160px);
  margin: 24px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 41fr) minmax(0, 59fr);
  gap: 14px;
}
.scene-panel, .play-panel { border: 1px solid var(--line); border-radius: 10px; background: #f8f3eab0; }
.scene-panel { padding: 10px; }
.scene-panel img { display: block; width: 100%; height: auto; aspect-ratio: 4/3; object-fit: cover; border-radius: 7px; }
.scene-copy { margin: 16px 12px 14px; }
.scene-copy h2 { font-size: 25px; line-height: 1.35; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.scene-copy p { margin-top: 12px; color: var(--muted); }
.scene-copy strong { color: var(--ink); }
.play-panel { padding: 19px 20px 15px; }
.heading { display: flex; align-items: center; gap: 15px; margin-bottom: 16px; }
.heading::after { content: ""; flex: 1; border-top: 1px solid #8b998c; }
.heading h2 { font-size: 31px; line-height: 1.12; }
.roles { display: grid; gap: 12px; }
.role-choice {
  text-align: left;
  padding: 15px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 12px;
  background: #fcf8ef;
}
.role-choice strong { font: bold 22px/1.35 var(--serif); }
.role-choice small { grid-column: 1; margin-top: 4px; font-weight: 400; color: var(--muted); }
.role-choice span { grid-column: 2; grid-row: 1 / 3; font-size: 20px; }
.intro { margin-top: 15px; color: var(--muted); }
.transcript {
  list-style: none;
  padding: 1px 4px 2px 1px;
  margin: 0 0 14px;
  min-height: 182px;
  max-height: clamp(210px, 39vh, 435px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #aba996 transparent;
}
.message { display: grid; grid-template-columns: 67px minmax(0, 1fr); gap: 8px; align-items: start; margin-bottom: 9px; }
.message:last-child { margin-bottom: 0; }
.speaker {
  justify-self: start;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 5px;
  background: #eee5d6;
  font: bold 14px/1.5 var(--serif);
  text-align: center;
}
.bubble {
  padding: 9px 12px;
  border: 1px solid #d0c6b5;
  border-radius: 8px;
  background: #fcf8f1;
  font: 18px/1.6 var(--serif);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.player .speaker, .message.player .bubble { background: var(--soft); }
.message.player .bubble { border-color: transparent; }
.message.transition { gap: 4px; }
.message.transition .speaker { background: #e5e9df; }
#composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 8px; }
.invite-field { display: flex; gap: 8px; margin-top: 6px; }
.invite-field input { flex: 1; min-width: 0; border: 1px solid #9f9c8f; border-radius: 7px; font: inherit; color: inherit; background: #fcf8f1; padding: 7px 10px; }
.reason-prompt { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.reason-prompt button { flex-shrink: 0; }
textarea {
  width: 100%;
  min-height: 55px;
  max-height: 220px;
  border: 1px solid #9f9c8f;
  background: #fcf8f1;
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 16px;
  line-height: 1.4;
  resize: vertical;
}
textarea::placeholder { color: #67675d; }
.primary { background: #233e38; color: #fffaf0; border-color: #233e38; min-width: 69px; }
.primary:hover:not(:disabled) { background: #34554a; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.actions button { flex: 1 0 auto; }
.actions button:last-child[data-advance] { border-color: var(--ink); }
.ledger { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 11px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.ledger > div { display: flex; gap: 6px 9px; flex-wrap: wrap; align-items: center; }
.ledger ul { display: contents; }
.ledger li { list-style: none; border: 1px solid #b8bba9; border-radius: 5px; padding: 1px 7px; }
.ledger button { font-size: 14px; }
#empty-events, .holder { color: var(--muted); }
.holder { font-size: 13px; margin-top: 3px; }
.feedback { margin-top: 8px; display: flex; gap: 9px; align-items: center; font-size: 14px; }
.feedback[data-error="true"] { color: #822f22; }
footer {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin: 18px auto;
  padding: 0 24px;
  max-width: 1160px;
}
footer::before, footer::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
footer span:first-child { color: var(--ink); font-family: var(--serif); font-size: 16px; font-weight: 700; }
dialog {
  width: min(94vw, 540px);
  max-height: min(82dvh, 690px);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 18px 20px 24px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 60px #29332e40;
}
dialog::backdrop { background: #16251d60; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { font-size: 24px; }
dialog h3 { font-size: 18px; margin: 15px 0 4px; }
dialog ul { padding-left: 22px; }
dialog li { margin-bottom: 6px; }
dialog a { color: #284f43; text-underline-offset: 3px; }
dialog .muted { color: var(--muted); font-size: 14px; }
.saves-list { display: grid; gap: 7px; margin: 13px 0; }
.save { display: grid; text-align: left; width: 100%; }
.save small { font-weight: 400; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 680px) {
  .header-inner { min-height: 58px; padding: 6px 12px; }
  .wordmark, nav { gap: 6px; }
  .wordmark h1 { font-size: 23px; letter-spacing: .06em; }
  .seal { width: 24px; height: 24px; font-size: 15px; }
  nav button { font-size: 13px; padding: 5px 9px; }
  .layout { display: block; margin-top: 10px; padding: 0 10px; }
  .scene-panel { padding: 6px; }
  .scene-panel img { aspect-ratio: 2.75; object-position: center 37%; }
  .scene-copy { margin: 7px 6px 4px; }
  .scene-copy h2 { font-size: 17px; padding: 0; border: 0; }
  .scene-copy p { margin-top: 3px; font-size: 13px; }
  .scene-copy:has(#identity:not([hidden])) #entry { display: none; }
  .play-panel { margin-top: 9px; padding: 12px 10px; }
  .heading { margin-bottom: 10px; }
  .heading h2 { font-size: 24px; }
  .transcript { min-height: 101px; max-height: clamp(125px, 29dvh, 260px); margin-bottom: 9px; }
  .message { grid-template-columns: 51px minmax(0, 1fr); gap: 6px; }
  .speaker { font-size: 12px; padding: 2px 4px; }
  .bubble { font-size: 17px; padding: 6px 8px; }
  .actions { gap: 5px; margin-top: 8px; }
  .actions button { padding-inline: 8px; font-size: 13px; }
  .ledger { margin-top: 9px; padding-top: 6px; }
  .ledger button { padding-inline: 9px; }
  footer { margin: 9px auto 13px; padding-inline: 12px; }
}
