/* Dragonworld — same house style as the Time Machine Library, in Simbala green and gold */
@font-face { font-family: "Courgette"; src: url("fonts/Courgette.ttf") format("truetype"); font-display: swap; }

:root {
  --text-scale: 1;
  --accent: #1d5a45;
  --gold: #b8862b;
  --bg: #efe9d8;
  --bg-page: #fbf7ec;
  --ink: #2a2118;
  --muted: #6c5f4f;
  --line: #d6ccb2;
  --btn: #fffaf0;
  --chip: #f3ecd9;
  --shadow: 0 1px 2px rgb(60 40 10 / .12), 0 6px 18px rgb(60 40 10 / .10);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111a16; --bg-page: #18221d; --ink: #ece3d0; --muted: #b3a68f; --line: #33433a; --btn: #1f2b25; --chip: #24322b;
    --accent: #8fcfb4; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 18px rgb(0 0 0 / .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111a16; --bg-page: #18221d; --ink: #ece3d0; --muted: #b3a68f; --line: #33433a; --btn: #1f2b25; --chip: #24322b;
  --accent: #8fcfb4; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 18px rgb(0 0 0 / .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: calc(1.0625rem * var(--text-scale))/1.6 var(--serif);
  min-height: 100vh; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--btn); padding: 8px 12px; }
main:focus { outline: none; }
.muted { color: var(--muted); font-size: .9em; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: #14231d; color: #f1ead6;
}
[hidden] { display: none !important; }
.bar-title { flex: 1; font: 600 1rem/1.2 var(--sans); letter-spacing: .02em; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 10px;
  background: transparent; color: inherit; cursor: pointer; flex: none;
}
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn:hover { background: rgb(255 255 255 / .08); }
.icon-btn.pearl svg { fill: #e9e2f3; filter: drop-shadow(0 0 4px #b9a6e8); }
.icon-btn.pearl .shine { fill: #fff; opacity: .85; }
.badge {
  position: absolute; right: 2px; bottom: 4px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
  background: var(--gold); color: #1b1408; font: 700 11px/18px var(--sans); text-align: center;
}

/* page */
main { max-width: 44rem; margin: 0 auto; padding: 14px 14px 40px; }
main.enter { animation: enter .3s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { main.enter { animation: none; } * { scroll-behavior: auto !important; } }
.page {
  background: var(--bg-page); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: clamp(16px, 4.5vw, 34px);
}
.page p { margin: 0 0 .9em; hyphens: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
.fancy, .title-page h1 { font-family: "Courgette", var(--serif); font-weight: 400; color: var(--accent); }
.title-page { text-align: center; }
.title-page h1 { font-size: 2.6em; margin-top: .3em; }
.title-page .cover { width: min(70%, 300px); border-radius: 8px; box-shadow: var(--shadow); }
.title-page .credits { font-size: .95em; }
.intro p:first-of-type::first-letter, .room-text p:first-child::first-letter {
  float: left; font: 3.1em/.9 "Courgette", var(--serif); padding: .06em .14em 0 .02em; color: var(--accent);
}
figure.art { margin: 0 0 1em; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
figure.art img { display: block; margin: 0 auto; max-height: 46vh; width: auto; cursor: zoom-in; }
figure.art figcaption { font: .75rem/1.3 var(--sans); color: #6c5f4f; padding: 4px 10px 6px; text-align: right; background: #fff; }
.room-name:focus { outline: none; }
.room-name { font: 400 1.75em/1.15 "Courgette", var(--serif); color: var(--accent); margin-bottom: .4em; }

/* response */
.response { margin: 1em 0 .4em; padding: .8em 1em; border-left: 4px solid var(--gold); background: var(--chip); border-radius: 0 10px 10px 0; }
.response p { margin: 0 0 .5em; }
.response p:last-child { margin-bottom: 0; }
.response .echo { font: 600 .82rem/1.3 var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4em; }
.response.death { border-left-color: #8b2b2b; }
.history summary { cursor: pointer; font: 600 .85rem/1.4 var(--sans); color: var(--muted); padding: 6px 0; }
.history .response { opacity: .85; font-size: .95em; }

/* controls */
.controls { margin-top: 1em; display: grid; gap: 14px; }
.group h3 { font: 700 .78rem/1.2 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 600 calc(.95rem * var(--text-scale))/1.2 var(--sans); color: var(--ink); background: var(--btn);
  border: 1.5px solid var(--line); border-radius: 999px; padding: 10px 14px; min-height: 44px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"], .chip.on { background: var(--accent); border-color: var(--accent); color: var(--bg-page); }
.chip.verb { border-radius: 10px; }
.actions-for { border: 1.5px dashed var(--line); border-radius: 12px; padding: 10px; }
.actions-for p { margin: 0 0 8px; font: 600 .9rem/1.3 var(--sans); }
.compass { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 48px); gap: 6px; }
.compass-wrap { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.compass button, .updown button {
  font: 700 .9rem/1 var(--sans); border-radius: 10px; border: 1.5px solid var(--line); background: var(--btn); color: var(--ink); cursor: pointer;
}
.compass button:disabled, .updown button:disabled { opacity: .3; cursor: default; }
.compass button:not(:disabled):hover, .updown button:not(:disabled):hover { border-color: var(--accent); }
.compass .hub { display: grid; place-items: center; font: 400 1.3rem/1 "Courgette", var(--serif); color: var(--gold); }
.updown { display: grid; grid-template-columns: repeat(2, 64px); gap: 6px; }
.updown button { height: 48px; }
form.typed { display: flex; gap: 8px; }
form.typed input {
  flex: 1; min-width: 0; font: calc(1rem * var(--text-scale))/1.3 var(--sans); padding: 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--btn); color: var(--ink);
}
.btn {
  display: block; width: 100%; text-align: center; cursor: pointer; text-decoration: none;
  font: 600 calc(1rem * var(--text-scale))/1.35 var(--sans); color: var(--ink);
  background: var(--btn); border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 16px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg-page); }
.btn.inline { display: inline-block; width: auto; padding: 12px 16px; }
.stack { display: grid; gap: 10px; margin-top: 1.2em; }
.act-done { text-align: center; border-top: 2px solid var(--gold); margin-top: 1.4em; padding-top: 1em; }
.act-done h2 { font: 400 2em/1.2 "Courgette", var(--serif); color: var(--gold); }

/* sheet (menu) */
.sheet { border: 0; border-radius: 16px; padding: 0; width: min(560px, 94vw); max-height: 86vh; background: var(--bg-page); color: var(--ink); box-shadow: var(--shadow); }
.sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 0 18px; }
.sheet-head h2 { margin: 0; font: 400 1.5em "Courgette", var(--serif); color: var(--accent); }
.sheet-body { padding: 8px 18px 20px; overflow: auto; }
.sheet-body .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.sheet-body ul { padding-left: 1.2em; }
.zoom { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .85); display: grid; place-items: center; padding: 10px; cursor: zoom-out; border: 0; width: 100%; }
.zoom img { max-height: 96vh; background: #fff; border-radius: 6px; }

/* act list */
.acts-head { font: 400 1.5em/1.2 "Courgette", var(--serif); color: var(--accent); margin-top: 1.2em; }
.act-list { list-style: none; padding: 0; margin: .6em 0 0; display: grid; gap: 8px; text-align: left; }
.act-btn { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; }
.act-btn:disabled { opacity: .5; cursor: default; }
.act-status { font: 600 .78rem/1.2 var(--sans); color: var(--muted); white-space: nowrap; }

/* arcade */
.arcade { margin-top: 1em; border: 2px solid var(--gold); border-radius: 14px; padding: 12px; background: var(--chip); }
.arc-title { font: 400 1.6em/1.2 "Courgette", var(--serif); color: var(--gold); margin: 0 0 .3em; }
.arc-status { font: 600 .95rem/1.4 var(--sans); min-height: 2.8em; margin: 0 0 8px; }
.arc-result { font: 400 1.4em/1.2 "Courgette", var(--serif); text-align: center; color: var(--accent); }
.arc-field { position: relative; height: min(56vh, 420px); border-radius: 10px; overflow: hidden; touch-action: manipulation; }
.arc-field.bog { background: linear-gradient(#3b4a3a, #233024 60%, #4a3f22); }
.arc-field.stones { background: radial-gradient(circle at 50% 30%, #2b2440, #120f1d); }
.arc-field button { position: absolute; top: -70px; border: 0; background: none; padding: 6px; cursor: crosshair; transition-property: top, left; transition-timing-function: linear; color: #10100c; }
.arc-field .bat { color: #0b0b08; filter: drop-shadow(0 0 2px #c9d3a5); }
.arc-field .bat.fall { top: calc(100% - 20px); }
.arc-field .bat.giant { top: 10%; left: -40%; transition: left 4.5s linear; color: #2a1b12; filter: drop-shadow(0 0 6px #e9c46a); }
.arc-field .bat.giant.glide { left: 110%; }
.arc-field .stone { width: 52px; height: 52px; border-radius: 50%; box-shadow: inset -6px -8px 12px rgb(0 0 0 / .45), 0 0 10px rgb(255 255 255 / .25); }
.arc-field .stone.fall { top: calc(100% + 10px); }
.arc-maze { display: grid; gap: 3px; max-width: 360px; margin: 0 auto 10px; }
.arc-maze .mrow { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.arc-maze .mcell { aspect-ratio: 1; border-radius: 4px; display: grid; place-items: center; font: 700 1.1rem/1 var(--sans); background: #8fae73; color: #13240f; }
.arc-maze .cliff { background: #121212; }
.arc-maze .ladder { background: #b98b4e; }
.arc-maze .ladder.gone { background: #3a2f22; }
.arc-maze .gate { background: #e9c46a; }
.arc-maze .start { background: #a8c88a; }
.arc-pad { display: grid; grid-template-columns: repeat(3, 72px); grid-template-areas: ". u ." "l . r" ". d ."; gap: 6px; justify-content: center; }
.arc-btn { height: 52px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--btn); color: var(--ink); font: 700 .95rem var(--sans); cursor: pointer; }
.arc-btn.u { grid-area: u; } .arc-btn.l { grid-area: l; } .arc-btn.r { grid-area: r; } .arc-btn.d { grid-area: d; }
