:root {
  --ink: #1b1612;
  --paper: #f4eee4;
  --wash: #c45c48;
  --gold: #c9a36a;
  --wood: #14110e;
  --panel: rgba(20, 16, 13, 0.72);
  --line: rgba(244, 238, 228, 0.14);
  --muted: rgba(244, 238, 228, 0.62);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--paper);
  background: var(--wood);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}

body.busy { cursor: progress; }

#app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 300px;
  grid-template-rows: auto 1fr auto;
}

header, footer, aside {
  position: relative;
  z-index: 2;
}

header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 22px 28px 10px;
  gap: 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand small {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand h1 {
  margin: 0;
  font-family: "Palatino Linotype", Palatino, "Iowan Old Style", serif;
  font-size: 42px;
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.brand h1 em {
  font-style: italic;
  color: #f7d7c8;
}

.lede {
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.status i {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #8a847c;
}
.status[data-kind="live"] i { background: #7dba6a; box-shadow: 0 0 12px #7dba6a; }
.status[data-kind="local"] i { background: #c9a36a; }
.status b { display: block; font-size: 12px; }
.status span { display: block; font-size: 11px; color: var(--muted); max-width: 28ch; }

aside {
  padding: 12px 18px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.stage-wrap {
  position: relative;
  min-height: 0;
}

canvas#stage {
  width: 100%;
  height: 100%;
  display: block;
}

.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 40%, transparent 40%, rgba(10,8,6,0.35) 100%),
    linear-gradient(90deg, rgba(20,17,14,0.55), transparent 18%, transparent 82%, rgba(20,17,14,0.55));
}

.narration {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 28px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(16,13,11,0.78);
  backdrop-filter: blur(18px);
  font-family: "Palatino Linotype", Palatino, "Iowan Old Style", serif;
  font-size: 20px;
  font-style: italic;
  line-height: 1.25;
}

aside.right { padding: 12px 28px 24px 12px; }

h2 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.hands, .recipe, button {
  font: inherit;
  color: inherit;
}

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

.hands button, .ghost, .recipe {
  border: 1px solid var(--line);
  background: rgba(244,238,228,0.04);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.hands button:hover, .ghost:hover, .recipe:hover, .landmarks button:hover {
  background: rgba(244,238,228,0.1);
}

.recipe {
  display: grid;
  gap: 4px;
  width: 100%;
  margin-bottom: 8px;
}
.recipe span { color: var(--muted); font-size: 12px; line-height: 1.35; }

.landmarks, .prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.landmarks button, .prompt-row button, .ghost {
  padding: 7px 9px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

#fold-list, #trace {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

#fold-list li, .trace-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  font-size: 13px;
}
#fold-list em { color: var(--gold); font-style: normal; }
#fold-list small, .empty { color: var(--muted); }
#fold-list strong { text-transform: capitalize; }

.trace-row {
  grid-template-columns: 1fr auto;
  font-size: 11px;
  color: var(--muted);
}
.trace-row code { color: var(--paper); }

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
  color: var(--paper);
  padding: 10px;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
}

footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 28px 18px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

a { color: #f0d2b4; }

@media (max-width: 980px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 62vh auto auto;
  }
  header, footer, aside { padding-left: 16px; padding-right: 16px; }
  .stage-wrap { grid-row: 2; }
  aside.left { grid-row: 3; }
  aside.right { grid-row: 4; }
  .brand h1 { font-size: 32px; }
  .narration { font-size: 16px; }
}
