:root {
  color-scheme: dark;
  --ink: #f2ede2;
  --ink-muted: #b9ad9b;
  --paper: #e7dac3;
  --paper-ink: #271d16;
  --night: #0a0908;
  --night-soft: #17120f;
  --ember: #d86f42;
  --ember-bright: #ffae76;
  --line: rgba(242, 237, 226, 0.22);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --hand: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --safe-top: max(1rem, env(safe-area-inset-top));
  --safe-right: max(1rem, env(safe-area-inset-right));
  --safe-bottom: max(1rem, env(safe-area-inset-bottom));
  --safe-left: max(1rem, env(safe-area-inset-left));
}

* { box-sizing: border-box; }

html { background: var(--night); scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--night);
  font-family: var(--sans);
  line-height: 1.6;
}

button, input, textarea { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 4px;
}

[hidden] { display: none !important; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-bar {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.5rem;
  padding: var(--safe-top) var(--safe-right) 0.75rem var(--safe-left);
  background: linear-gradient(180deg, rgba(5, 4, 3, 0.88), transparent);
  pointer-events: none;
}

.site-bar > * { pointer-events: auto; }

.wordmark {
  display: grid;
  gap: 0.05rem;
  color: var(--ink);
  text-decoration: none;
}

.wordmark span { font: 600 clamp(1.05rem, 2vw, 1.45rem)/1.1 var(--serif); letter-spacing: 0.12em; }
.wordmark small { color: var(--ink-muted); font-size: 0.56rem; letter-spacing: 0.18em; }

.site-actions { display: flex; align-items: center; gap: clamp(0.35rem, 1.4vw, 1.1rem); }

.text-button,
.icon-button,
.primary-button {
  min-height: 2.75rem;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.text-button { padding: 0.5rem 0.65rem; color: var(--ink-muted); }
.text-button:hover { color: var(--ink); }
.icon-button { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem; }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  border: 1px solid color-mix(in srgb, var(--ember-bright), transparent 35%);
  background: rgba(102, 34, 18, 0.36);
  box-shadow: inset 0 0 20px rgba(255, 102, 60, 0.08), 0 0 22px rgba(216, 79, 44, 0.08);
  letter-spacing: 0.14em;
}

.primary-button:hover { border-color: var(--ember-bright); background: rgba(126, 42, 21, 0.5); }

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--ember-bright);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.paper-dialog {
  width: min(42rem, calc(100% - 2rem));
  max-height: min(82dvh, 48rem);
  padding: 0;
  border: 1px solid rgba(91, 57, 32, 0.55);
  color: var(--paper-ink);
  background:
    linear-gradient(rgba(255,255,255,0.16), transparent),
    var(--paper);
  box-shadow: 0 2rem 6rem rgba(0,0,0,0.65);
}

.paper-dialog::backdrop { background: rgba(4, 3, 2, 0.82); backdrop-filter: blur(8px); }
.paper-dialog form { position: relative; padding: clamp(1.5rem, 5vw, 3.5rem); }
.paper-dialog h2 { max-width: 14em; margin: 0; font: 600 clamp(1.8rem, 5vw, 3rem)/1.25 var(--serif); }
.dialog-lede { max-width: 34rem; margin: 1rem 0 1.75rem; color: #5d4d40; }
.dialog-close { position: absolute; top: 0.75rem; right: 0.75rem; width: 2.75rem; height: 2.75rem; border: 0; background: transparent; color: var(--paper-ink); font-size: 1.8rem; cursor: pointer; }

.role-options { display: grid; gap: 0.75rem; }
.role-choice {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(65, 42, 26, 0.28);
  color: var(--paper-ink);
  background: rgba(255, 252, 243, 0.35);
  text-align: left;
  cursor: pointer;
}
.role-choice:hover { border-color: #8e4428; background: rgba(255, 250, 237, 0.78); }
.role-choice__index { color: #9b5438; font: 700 0.75rem var(--sans); }
.role-choice__label { font: 600 1.05rem var(--serif); }
.role-choice__label small { display: block; margin-top: 0.2rem; color: #6d5a48; font: 400 0.78rem/1.5 var(--sans); }

.experience {
  min-height: 100dvh;
  padding: 8rem var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: radial-gradient(circle at 20% 12%, #312017, #0b0907 62%);
}
.experience__placeholder { width: min(70rem, 100%); margin: 10vh auto; }
.experience__placeholder h1 { max-width: 12em; margin: 0; font: 600 clamp(2.4rem, 7vw, 6rem)/1.05 var(--serif); }
.experience__placeholder p:last-child { color: var(--ink-muted); }

.save-notice {
  position: fixed;
  z-index: 200;
  right: 1rem;
  bottom: 1rem;
  max-width: 25rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  background: #261a14;
  box-shadow: 0 1rem 3rem rgba(0,0,0,0.4);
}

.danger-button {
  min-height: 2.75rem;
  margin-top: 1rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid rgba(126, 51, 35, 0.45);
  color: #763823;
  background: transparent;
  cursor: pointer;
}
.danger-button:hover { color: #fff; background: #763823; }

.source-list { display: grid; gap: 0.65rem; max-height: 42dvh; margin: 1.4rem 0; padding: 0; overflow: auto; list-style: none; }
.source-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.12rem 1rem; padding: 0.75rem; border: 1px solid rgba(74,52,35,0.2); background: rgba(255,255,255,0.2); }
.source-list small { color: #705f50; }
.source-list a { grid-row: 1 / 3; grid-column: 2; align-self: center; color: #87432c; }
.source-note { padding: 0.8rem; border-left: 2px solid #9b5438; color: #5f4c3e; background: rgba(255,255,255,0.22); font-size: 0.82rem; }

@media (max-width: 650px) {
  .site-bar { min-height: 3.75rem; }
  .site-actions { gap: 0; }
  .text-button, .icon-button { font-size: 0.86rem; }
  .paper-dialog form { padding-top: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* 聲音圖示：開著是喇叭＋聲波，靜音是喇叭＋叉 */
.sound-icon { width: 1.25rem; height: 1.25rem; }
.sound-icon__body { fill: currentColor; }
.sound-icon__on,
.sound-icon__off { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sound-icon__off,
[data-mute][aria-pressed='true'] .sound-icon__on { display: none; }
[data-mute][aria-pressed='true'] .sound-icon__off { display: inline; }

/* 右上角：素材來源與聲音都是圓形圖示按鈕 */
.site-actions .icon-button { width: 2.75rem; height: 2.75rem; justify-content: center; padding: 0; border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 50%; color: rgba(255, 255, 255, 0.88); background: rgba(0, 0, 0, 0.35); transition: border-color 160ms ease, background 160ms ease; }
.site-actions .icon-button:hover { border-color: var(--ember-bright); background: rgba(0, 0, 0, 0.55); }
.site-actions { gap: 0.55rem; }
.info-icon { font: italic 700 1.05rem/1 var(--serif); }

/* 標準字（AI 生成，白字透明底） */
.wordmark__logo { display: block; width: clamp(8.5rem, 14vw, 11.5rem); height: auto; filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.6)); }
