/* Faewood Adventures: parchment panels over the painted scene.
 * Panel art lives in ui/. Each panel draws its frame with a 9-slice border-image on ::before,
 * so text padding stays independent of the art and the frames stretch to any screen. */
:root { --s: 0.30; }
@media (min-width: 900px) { :root { --s: 0.36; } }
@media (max-width: 560px) { :root { --s: 0.24; } }

body { background: #0b140f; }
#forest.painted { position: fixed; inset: 0; z-index: 0; }
.painted-canvas { width: 100%; height: 100%; display: block; }
#forest.painted::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(4,10,8,0.45) 100%);
}

/* every framed panel reads as light parchment, whatever the page theme is */
.panel-art {
  --ink: #2B2418; --ink-soft: #5A4B33; --ink-faint: #7A6A49;
  --gold: #8E6A22; --gold-strong: #6E5119; --ember: #8B3A2B; --sage: #4F6142;
  --bg-panel: #FBF6E9; --bg: #F1E8D3; --border: rgba(43,36,24,0.18); --border-strong: rgba(43,36,24,0.34);
  position: relative; isolation: isolate; color: var(--ink);
}
.panel-art::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border-style: solid; border-color: transparent;
  border-image-repeat: stretch;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.45));
}

/* ---------- top: banner ---------- */
.topbar {
  background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 0;
  gap: 6px 8px;
}
.brand {
  order: 2; flex: 1 0 100%; margin: 0 auto; max-width: min(820px, 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; text-align: center;
  padding: calc(260px * var(--s) * 0.34) calc(280px * var(--s)) calc(260px * var(--s) * 0.3);
  min-height: calc(270px * var(--s) * 1.1);
}
.brand::before {
  border-width: calc(110px * var(--s)) calc(270px * var(--s));
  border-image-source: url(ui/banner.webp);
  border-image-slice: 110 270 fill;
}
.brand h1 { font-size: clamp(18px, 3.6vw, 27px); line-height: 1.15; color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,0.4); white-space: normal; }
.brand .sub { font-size: 13px; color: var(--ink-soft); white-space: normal; line-height: 1.2; max-width: 46ch; }
.brand .sub:empty { display: none; }
.icon-btn {
  background: rgba(10,18,14,0.62); border: 1px solid rgba(214,180,106,0.55); color: #E8D5A0;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.icon-btn:hover { border-color: #F0D58C; color: #FFF1C2; }
#drawerToggle { order: 1; }
.top-actions { order: 1; margin-left: auto; }
@media (min-width: 900px) {
  .topbar { position: relative; }
  #drawerToggle { position: absolute; left: 14px; top: calc(14px + env(safe-area-inset-top, 0px)); z-index: 3; }
  .top-actions { position: absolute; right: 14px; top: calc(14px + env(safe-area-inset-top, 0px)); z-index: 3; }
}
.topbar:not(:has(#drawerToggle:not([hidden]))) .top-actions[hidden] { display: none; }

/* ---------- middle: story panel ---------- */
.layout { padding: 0; }
.main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 12px; }
.story-panel {
  flex: 1 1 auto; min-height: 0; display: flex; margin: calc(14px) 0 6px;
  padding: calc(190px * var(--s) * 0.78) calc(190px * var(--s) * 0.82);
}
.story-panel::before {
  border-width: calc(190px * var(--s));
  border-image-source: url(ui/main.webp);
  border-image-slice: 190 fill;
}
.scene-scroll { flex: 1 1 auto; min-width: 0; padding: 6px 10px 14px 4px; }
.scene-inner {
  max-width: 720px; margin: 0 auto; padding: 0; background: none; border: 0; border-radius: 0;
  backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none;
}
.scene-inner::before, .scene-inner::after { content: none; }
.scene-scroll::-webkit-scrollbar-thumb { background: rgba(110,81,25,0.35); }
.prose { font-size: 18px; line-height: 1.62; }
.divider::after { background: #F3E9D0; }
.gate, .setup { margin-top: 0; }
.setup textarea, .gate input { background: rgba(255,251,238,0.8); }
.btn-primary, .act-btn { background: #6E5119; color: #FBF1D4; }
.btn-primary:hover, .act-btn:hover { background: #8E6A22; }
.error-banner { background: rgba(139,58,43,0.12); }

/* ---------- bottom: choices ---------- */
.dock { background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0 0 calc(10px + env(safe-area-inset-bottom, 0px)); }
.dock-inner { max-width: none; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px calc(40px * var(--s)); margin: 0 0 8px; }
.choices:has(.choice-chip:nth-child(4)) { grid-template-columns: repeat(2, 1fr); }
.choices:has(.choice-chip:nth-child(2):last-child) { grid-template-columns: repeat(2, 1fr); }
.choices:empty { display: none; }
.choice-chip {
  --ink: #2B2418; --gold: #6E5119;
  position: relative; isolation: isolate; background: none; border: 0; border-radius: 0; color: var(--ink);
  min-height: calc(195px * var(--s) * 1.18);
  padding: calc(195px * var(--s) * 0.28) calc(150px * var(--s) * 0.95);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 15.5px; line-height: 1.22; font-weight: 500;
  transition: transform .15s ease, filter .15s ease;
}
.choice-chip::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border-style: solid; border-color: transparent;
  border-width: calc(80px * var(--s)) calc(150px * var(--s));
  border-image: url(ui/pill.webp) 80 150 fill stretch;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.45));
}
.choice-chip .num { color: #6E5119; font-weight: 700; margin-right: 7px; }
.choice-chip:hover:not(:disabled) { background: none; transform: translateY(-2px); filter: brightness(1.08); }
.choice-chip:disabled { opacity: 0.55; }
.input-row textarea { background: rgba(251,246,233,0.94); color: #2B2418; border-color: rgba(214,180,106,0.6); }
.input-row textarea::placeholder { color: #7A6A49; }
.dock-foot { color: #E8D5A0; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.drawer { background: rgba(14,22,17,0.9); }

@media (max-width: 700px) {
  .choices, .choices:has(.choice-chip:nth-child(4)), .choices:has(.choice-chip:nth-child(2):last-child) { grid-template-columns: 1fr; gap: 4px; }
  .choice-chip { min-height: calc(195px * var(--s) * 0.95); padding-top: 0; padding-bottom: 0; font-size: 15px; }
  .brand { padding-left: calc(190px * var(--s)); padding-right: calc(190px * var(--s)); }
  .brand::before { border-width: calc(110px * var(--s)) calc(190px * var(--s)); border-image-slice: 110 190 fill; }
  .main { padding: 0 6px; }
  .prose { font-size: 17px; }
}
@media (max-height: 640px) and (min-width: 700px) { .brand .sub { display: none; } }
