:root {
  color-scheme: light;
  --bg: #eef2ee;
  --surface: #ffffff;
  --surface-soft: #f7f9f7;
  --ink: #18211f;
  --muted: #62706b;
  --line: #d7dfdc;
  --brand: #17696f;
  --brand-dark: #0e464b;
  --accent: #b0523f;
  --gold: #a47c24;
  --green: #2e7a52;
  --danger: #a43a3a;
  --shadow: 0 22px 60px rgba(24, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  background:
    linear-gradient(180deg, rgba(23, 105, 111, 0.14), rgba(238, 242, 238, 0) 310px),
    radial-gradient(circle at 12% 0%, rgba(176, 82, 63, 0.09), transparent 340px),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.progress-active {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 16px;
  max-width: 1320px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.sync-status {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 6px 0 0;
}

.sync-status.access-locked {
  color: var(--danger);
  cursor: pointer;
  font-weight: 750;
}

h1,
h2,
h3,
h4,
p {
  margin-block-start: 0;
}

h1 {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  line-height: 1.05;
  margin: 0;
}

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

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 410px);
  margin: 0 auto;
  max-width: 1320px;
  min-width: 0;
}

.story-panel,
.play-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.story-panel {
  min-height: calc(100dvh - 112px);
  padding: clamp(24px, 4vw, 54px);
}

.play-panel {
  align-self: start;
  max-height: calc(100dvh - 112px);
  overflow: auto;
  overflow-x: hidden;
}

.scene-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.scene-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}

h2 {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 2.35rem;
  line-height: 1.13;
  margin: 0 0 22px;
  max-width: 800px;
}

.story-text {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 1.16rem;
  line-height: 1.72;
  max-width: 820px;
  min-width: 0;
  overflow-wrap: break-word;
}

.story-text p {
  margin: 0 0 1.08em;
}

.scene-image-box {
  margin: -4px 0 22px;
  max-width: 820px;
  min-width: 0;
  width: 100%;
}

.scene-image-frame {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, rgba(29, 45, 39, 0.08), rgba(143, 116, 62, 0.1));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.scene-image-frame img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.scene-image-box.loading .scene-image-frame {
  position: relative;
}

.scene-image-box.loading .scene-image-frame::after {
  animation: image-sheen 1.6s linear infinite;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.46), transparent);
  content: "";
  inset: 0;
  position: absolute;
  transform: translateX(-100%);
}

.scene-image-box figcaption {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding-top: 10px;
}

.scene-image-box span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.scene-image-box p {
  font-size: 0.9rem;
  line-height: 1.4;
  margin: 2px 0 0;
}

.scene-image-box.error p {
  color: var(--danger);
}

@keyframes image-sheen {
  to {
    transform: translateX(100%);
  }
}

.narration-box {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  margin: -4px 0 22px;
  max-width: 820px;
  min-width: 0;
  padding: 12px;
  width: 100%;
}

.narration-box span,
.sound-box span,
.ai-box span,
.field span,
.action-box span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.narration-box p,
.sound-box p,
.ai-box p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  margin: 4px 0 0;
}

.narration-box audio {
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

.tabs {
  background: #e4ebe8;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tab-button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 720;
  min-height: 44px;
  min-width: 0;
  padding: 0 8px;
}

.tab-button.active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: grid;
  gap: 14px;
}

.setup-form,
.turn-controls {
  display: grid;
  gap: 14px;
}

.setup-intro {
  background:
    linear-gradient(135deg, rgba(23, 105, 111, 0.08), rgba(176, 82, 63, 0.08)),
    var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 14px;
}

.setup-intro h3 {
  font-size: 1.05rem;
  margin: 0;
}

.setup-intro p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
  margin: 0;
}

.field {
  display: grid;
  gap: 6px;
}

input,
textarea,
select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 46px;
  padding: 9px 10px;
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: #87938f;
}

textarea {
  resize: vertical;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  margin: 0;
}

.action-box,
.ai-box,
.sound-box,
.result-box,
.bonus-status,
.memory-section,
.log-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.action-box {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.turn-guide {
  background:
    linear-gradient(135deg, rgba(23, 105, 111, 0.1), rgba(164, 124, 36, 0.12)),
    var(--surface-soft);
  border: 1px solid rgba(23, 105, 111, 0.24);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.guide-kicker {
  color: var(--brand-dark);
  display: block;
  font-size: 0.76rem;
  font-weight: 850;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.turn-guide strong {
  display: block;
  font-size: 1.08rem;
  line-height: 1.25;
}

.turn-guide p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.42;
  margin: 5px 0 0;
}

.step-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.step-strip li {
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  font-size: 0.82rem;
  font-weight: 820;
  gap: 6px;
  justify-items: center;
  min-height: 62px;
  min-width: 0;
  padding: 8px 4px;
}

.step-strip span {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.step-strip li.active {
  background: var(--surface);
  border-color: rgba(23, 105, 111, 0.55);
  color: var(--ink);
  box-shadow: 0 0 0 3px rgba(23, 105, 111, 0.1);
}

.step-strip li.active span {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.step-strip li.done {
  border-color: rgba(46, 122, 82, 0.42);
  color: var(--green);
}

.step-strip li.done span {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.action-options {
  display: grid;
  gap: 8px;
}

.action-option {
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 22px minmax(0, 1fr);
  min-height: 72px;
  padding: 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.action-option:has(input:checked) {
  background: #f0f8f7;
  border-color: rgba(23, 105, 111, 0.62);
  box-shadow: 0 0 0 3px rgba(23, 105, 111, 0.1);
}

.action-option:active {
  transform: translateY(1px);
}

.action-option input {
  accent-color: var(--brand);
  height: 20px;
  min-height: 20px;
  margin-top: 2px;
  width: 20px;
}

.action-option > span {
  min-width: 0;
}

.action-option strong {
  display: block;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.action-option small {
  color: var(--muted);
  display: block;
  line-height: 1.35;
  margin-top: 2px;
  overflow-wrap: break-word;
}

.bonus-status {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.38;
  padding: 10px 12px;
}

.bonus-status.ready {
  border-color: rgba(46, 122, 82, 0.35);
  color: var(--green);
}

.progress-overlay {
  align-items: center;
  background: rgba(24, 33, 31, 0.52);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  position: fixed;
  z-index: 1000;
}

.access-dialog {
  align-items: center;
  background: rgba(24, 33, 31, 0.52);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  position: fixed;
  z-index: 1001;
}

.access-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 12px;
  max-width: 420px;
  padding: 18px;
  width: min(420px, 100%);
}

.access-card h3 {
  margin: 0;
}

.access-card p {
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.access-actions {
  display: flex;
  gap: 8px;
  justify-content: end;
}

.progress-card {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(23, 105, 111, 0.08), rgba(164, 124, 36, 0.12)),
    var(--surface-soft);
  border: 1px solid rgba(23, 105, 111, 0.22);
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 14px;
  grid-template-columns: 58px minmax(0, 1fr);
  max-height: calc(100dvh - 36px);
  max-width: 440px;
  overflow: auto;
  padding: 12px;
  width: min(440px, 100%);
}

.progress-card > div:last-child {
  display: grid;
  gap: 5px;
}

.progress-card span {
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 850;
}

.progress-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 0;
}

.spark-ring {
  aspect-ratio: 1;
  border: 1px solid rgba(23, 105, 111, 0.18);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
}

.spark-ring::before {
  animation: spinGlow 1.5s linear infinite;
  border: 3px solid rgba(23, 105, 111, 0.18);
  border-top-color: var(--gold);
  border-radius: 50%;
  content: "";
  height: 42px;
  position: absolute;
  width: 42px;
}

.spark-ring span {
  animation: sparkle 1.4s ease-in-out infinite;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(164, 124, 36, 0.65);
  height: 5px;
  position: absolute;
  width: 5px;
}

.spark-ring span:nth-child(1) {
  transform: translate(-12px, -14px);
}

.spark-ring span:nth-child(2) {
  animation-delay: 0.28s;
  transform: translate(14px, -3px);
}

.spark-ring span:nth-child(3) {
  animation-delay: 0.52s;
  transform: translate(-2px, 15px);
}

.progress-steps {
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.progress-steps li {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
  padding-left: 18px;
  position: relative;
}

.progress-steps li::before {
  border: 1px solid var(--line);
  border-radius: 50%;
  content: "";
  height: 8px;
  left: 0;
  position: absolute;
  top: 0.32em;
  width: 8px;
}

.progress-steps li.active {
  color: var(--ink);
  font-weight: 760;
}

.progress-steps li.active::before {
  animation: pulseDot 1s ease-in-out infinite;
  background: var(--gold);
  border-color: var(--gold);
}

.progress-steps li.done::before {
  background: var(--brand);
  border-color: var(--brand);
}

.dice-stage {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(23, 105, 111, 0.09), rgba(255, 255, 255, 0.86)),
    var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 92px minmax(0, 1fr);
  min-height: 112px;
  padding: 12px;
}

.dice-stage span {
  color: var(--ink);
  display: block;
  font-size: 0.95rem;
  font-weight: 850;
}

.dice-stage p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 4px 0 0;
}

.dice-scene {
  height: 78px;
  perspective: 520px;
  width: 78px;
}

.die3d {
  --die-size: 64px;
  height: var(--die-size);
  margin: 7px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 620ms cubic-bezier(0.22, 0.88, 0.28, 1.18);
  width: var(--die-size);
}

.die3d[data-face="1"] {
  transform: rotateX(-10deg) rotateY(0deg);
}

.die3d[data-face="2"] {
  transform: rotateX(-10deg) rotateY(-90deg);
}

.die3d[data-face="3"] {
  transform: rotateX(-100deg) rotateY(0deg);
}

.die3d[data-face="4"] {
  transform: rotateX(80deg) rotateY(0deg);
}

.die3d[data-face="5"] {
  transform: rotateX(-10deg) rotateY(90deg);
}

.die3d[data-face="6"] {
  transform: rotateX(-10deg) rotateY(180deg);
}

.die3d.rolling {
  animation: tumbleDie 720ms cubic-bezier(0.18, 0.7, 0.32, 1);
}

.die-face {
  align-items: center;
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 24px),
    linear-gradient(145deg, #fcfbf5, #dfe9e4);
  border: 1px solid rgba(23, 105, 111, 0.22);
  border-radius: 10px;
  box-shadow: inset 0 -8px 14px rgba(24, 33, 31, 0.08), 0 8px 20px rgba(24, 33, 31, 0.13);
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  height: var(--die-size);
  padding: 11px;
  position: absolute;
  width: var(--die-size);
}

.die-face span {
  align-self: center;
  background: var(--brand-dark);
  border-radius: 50%;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  height: 9px;
  justify-self: center;
  width: 9px;
}

.die-face-1 {
  transform: rotateY(0deg) translateZ(32px);
}

.die-face-2 {
  transform: rotateY(90deg) translateZ(32px);
}

.die-face-3 {
  transform: rotateX(90deg) translateZ(32px);
}

.die-face-4 {
  transform: rotateX(-90deg) translateZ(32px);
}

.die-face-5 {
  transform: rotateY(-90deg) translateZ(32px);
}

.die-face-6 {
  transform: rotateY(180deg) translateZ(32px);
}

.die-face-1 span {
  grid-area: 2 / 2;
}

.die-face-2 span:nth-child(1) {
  grid-area: 1 / 1;
}

.die-face-2 span:nth-child(2) {
  grid-area: 3 / 3;
}

.die-face-3 span:nth-child(1) {
  grid-area: 1 / 1;
}

.die-face-3 span:nth-child(2) {
  grid-area: 2 / 2;
}

.die-face-3 span:nth-child(3) {
  grid-area: 3 / 3;
}

.die-face-4 span:nth-child(1) {
  grid-area: 1 / 1;
}

.die-face-4 span:nth-child(2) {
  grid-area: 1 / 3;
}

.die-face-4 span:nth-child(3) {
  grid-area: 3 / 1;
}

.die-face-4 span:nth-child(4) {
  grid-area: 3 / 3;
}

.die-face-5 span:nth-child(1) {
  grid-area: 1 / 1;
}

.die-face-5 span:nth-child(2) {
  grid-area: 1 / 3;
}

.die-face-5 span:nth-child(3) {
  grid-area: 2 / 2;
}

.die-face-5 span:nth-child(4) {
  grid-area: 3 / 1;
}

.die-face-5 span:nth-child(5) {
  grid-area: 3 / 3;
}

.die-face-6 span:nth-child(1) {
  grid-area: 1 / 1;
}

.die-face-6 span:nth-child(2) {
  grid-area: 1 / 3;
}

.die-face-6 span:nth-child(3) {
  grid-area: 2 / 1;
}

.die-face-6 span:nth-child(4) {
  grid-area: 2 / 3;
}

.die-face-6 span:nth-child(5) {
  grid-area: 3 / 1;
}

.die-face-6 span:nth-child(6) {
  grid-area: 3 / 3;
}

.roll-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 72px 72px;
}

.primary-button,
.secondary-button,
.icon-button,
.roll-grid button {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 46px;
}

.primary-button {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  font-weight: 850;
  padding: 0 14px;
}

.primary-button:active {
  background: var(--brand-dark);
}

.secondary-button {
  background: var(--surface);
  color: var(--ink);
  font-weight: 760;
  padding: 0 12px;
}

.primary-button,
.secondary-button {
  line-height: 1.18;
}

.icon-button {
  align-items: center;
  background: var(--surface);
  color: var(--ink);
  display: inline-grid;
  font-size: 1.2rem;
  height: 42px;
  justify-content: center;
  padding: 0;
  width: 42px;
}

.icon-button.small {
  font-size: 1rem;
  height: 34px;
  min-height: 34px;
  width: 34px;
}

.danger {
  color: var(--danger);
}

.wide {
  width: 100%;
}

.result-box {
  color: var(--muted);
  min-height: 54px;
  padding: 12px;
}

.result-box strong {
  color: var(--ink);
}

.ai-box {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.toggle-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.toggle-row input {
  accent-color: var(--brand);
  height: 20px;
  min-height: 20px;
  width: 20px;
}

.range-field {
  display: grid;
  gap: 8px;
}

.range-field span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.85rem;
  font-weight: 800;
  justify-content: space-between;
}

.range-field output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

input[type="range"] {
  accent-color: var(--brand);
  min-height: 28px;
  padding: 0;
}

@keyframes spinGlow {
  to {
    transform: rotate(360deg);
  }
}

@keyframes sparkle {
  0%,
  100% {
    opacity: 0.35;
    scale: 0.72;
  }

  50% {
    opacity: 1;
    scale: 1.25;
  }
}

@keyframes pulseDot {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(164, 124, 36, 0);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(164, 124, 36, 0.18);
  }
}

@keyframes tumbleDie {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  48% {
    transform: rotateX(290deg) rotateY(220deg) rotateZ(35deg);
  }

  100% {
    transform: rotateX(690deg) rotateY(520deg) rotateZ(90deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spark-ring::before,
  .spark-ring span,
  .progress-steps li.active::before,
  .die3d.rolling {
    animation: none;
  }

  .die3d {
    transition: none;
  }
}

.panel-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

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

.story-list,
.story-group {
  display: grid;
  gap: 10px;
}

.story-group + .story-group {
  margin-top: 16px;
}

.story-group h4 {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.story-card {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.story-card.active {
  border-color: rgba(23, 105, 111, 0.5);
  box-shadow: inset 4px 0 0 var(--brand);
}

.story-card strong,
.story-card p,
.story-card small {
  overflow-wrap: break-word;
}

.story-card strong {
  display: block;
  font-size: 0.96rem;
  line-height: 1.25;
}

.story-card p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.32;
  margin: 5px 0 0;
}

.story-card small {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  line-height: 1.32;
  margin-top: 5px;
}

.memory-list,
.log-list {
  display: grid;
  gap: 12px;
}

.memory-section {
  padding: 12px;
}

.memory-section header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.memory-section h4 {
  font-size: 0.95rem;
  margin: 0;
}

.memory-items {
  display: grid;
  gap: 8px;
}

.memory-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px;
  padding: 10px;
}

.memory-row.relationship {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr) 34px;
}

.memory-row.text-only {
  grid-template-columns: minmax(0, 1fr) 34px;
}

.memory-row input {
  min-height: 36px;
}

.memory-row textarea {
  min-height: 58px;
}

.log-card {
  padding: 12px;
}

.log-card h4 {
  font-size: 0.95rem;
  margin: 0 0 6px;
}

.log-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.38;
  margin: 0 0 6px;
}

.sound-box {
  padding: 12px;
}

.empty-state {
  color: var(--muted);
  padding: 12px 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    padding-inline: 10px;
  }

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

  .story-panel {
    min-height: auto;
    padding: 22px;
  }

  .play-panel {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.45rem;
  }

  h2 {
    font-size: 1.95rem;
  }

  .story-text {
    font-size: 1.08rem;
  }

  .scene-meta {
    font-size: 0.78rem;
  }

  .roll-grid {
    grid-template-columns: 1fr 64px 64px;
  }

  .ai-box,
  .narration-box,
  .scene-image-box figcaption {
    grid-template-columns: 1fr;
  }

  .step-strip {
    gap: 6px;
  }

  .step-strip li {
    font-size: 0.76rem;
    min-height: 58px;
  }

  .scene-image-box figcaption {
    align-items: flex-start;
    flex-direction: column;
  }

  .progress-card,
  .story-card {
    grid-template-columns: 1fr;
  }

  .story-card button {
    width: 100%;
  }

  .memory-row,
  .memory-row.relationship {
    grid-template-columns: minmax(0, 1fr) 34px;
  }

  .memory-row input,
  .memory-row textarea {
    grid-column: 1 / 2;
  }
}
