/* MiddleWay Game Manual: one shared stylesheet. Colours follow the game's palette (twilight navy, gold, the seven Rays).
   Works offline: system fonts only, no external file. Dark by default, light on request (the button) or by the system. */
:root {
  --bg: #0f1233; --bg2: #121641; --panel: #1b2462; --panel2: #151a4a; --text: #f3ecd9; --muted: #b9b6d6; --gold: #fcc323;
  --gold-soft: rgba(252, 195, 35, .14); --line: #3a4390; --link: #ffd96b; --shadow: 0 6px 22px rgba(0, 0, 0, .35);
  --red: #ff2a2a; --orange: #ff8a00; --yellow: #ffe60d; --green: #2cff60; --blue: #2a82ff; --indigo: #6a3cf5; --violet: #c04cff;
  --pink: #ff8fb8; --power: #5c9dff; --wisdom: #ffd866; --well: #9fe8ff; --debt: #c8742a;
  --svg-ink: #f3ecd9; --svg-dim: #8e8bb5; --svg-floor: #222b6e;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #faf6ea; --bg2: #f4eedc; --panel: #fff; --panel2: #f1ead4; --text: #231f3d; --muted: #5a567a; --gold: #a06b00;
    --gold-soft: rgba(160, 107, 0, .1); --line: #d9cfae; --link: #5b2bb0; --shadow: 0 4px 16px rgba(60, 40, 0, .12);
    --svg-ink: #231f3d; --svg-dim: #8a84a8; --svg-floor: #e9e2f7;
  }
}
:root[data-theme="light"] {
  --bg: #faf6ea; --bg2: #f4eedc; --panel: #fff; --panel2: #f1ead4; --text: #231f3d; --muted: #5a567a; --gold: #a06b00;
  --gold-soft: rgba(160, 107, 0, .1); --line: #d9cfae; --link: #5b2bb0; --shadow: 0 4px 16px rgba(60, 40, 0, .12);
  --svg-ink: #231f3d; --svg-dim: #8a84a8; --svg-floor: #e9e2f7;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 system-ui, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); }
img { max-width: 100%; }

/* ---------- layout and the table of contents ---------- */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
nav.toc { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; padding: 20px 14px 40px;
  background: var(--panel2); border-right: 1px solid var(--line); }
nav.toc .brand { font: 700 21px Georgia, "Cinzel", serif; color: var(--gold); letter-spacing: .05em; margin: 0 0 2px; }
nav.toc .sub { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
nav.toc .part { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 16px 8px 4px; opacity: .85; }
nav.toc ol { list-style: none; margin: 0; padding: 0; }
nav.toc a { display: flex; gap: 8px; padding: 4px 8px; border-radius: 6px; text-decoration: none; color: var(--text); font-size: 14.5px; line-height: 1.35; }
nav.toc a .n { color: var(--muted); min-width: 1.6em; text-align: right; font-variant-numeric: tabular-nums; }
nav.toc a:hover { background: var(--panel); }
nav.toc a.here { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); }
nav.toc a.sub2 { padding-left: 38px; font-size: 13.5px; color: var(--muted); }
nav.toc details > summary { display: none; }
main { min-width: 0; padding: 24px clamp(16px, 4vw, 56px) 80px; max-width: 1060px; }

/* ---------- headings and text ---------- */
h1 { font: 700 clamp(30px, 5vw, 46px)/1.12 Georgia, serif; color: var(--gold); margin: 0 0 8px; }
h2 { font: 700 28px/1.25 Georgia, serif; color: var(--gold); margin: 60px 0 10px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; }
h2 .n { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font: 700 17px system-ui, sans-serif;
  color: #1b1440; background: radial-gradient(circle at 35% 30%, #fff1b8, #fcc323 70%); box-shadow: 0 0 0 3px var(--gold-soft); }
h3 { font: 700 21px/1.3 Georgia, serif; margin: 30px 0 6px; }
h4 { margin: 18px 0 4px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 8px 0; } ul, ol { padding-left: 22px; } li { margin: 4px 0; }
.lead { color: var(--muted); font-size: 18px; }
.partline { margin: 70px 0 -46px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); opacity: .8; }
.intro { font-size: 18px; color: var(--muted); margin-top: 0; }

/* ---------- the banner ---------- */
.banner { position: relative; border-radius: 14px; overflow: hidden; margin: 0 0 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.banner img { display: block; width: 100%; aspect-ratio: 16 / 7; object-fit: cover; object-position: 50% 45%; }
.banner .over { position: absolute; inset: auto 0 0 0; padding: 60px clamp(14px, 3vw, 28px) 18px;
  background: linear-gradient(to top, rgba(10, 12, 40, .94), rgba(10, 12, 40, .6) 60%, transparent); color: #f3ecd9; }
.banner h1 { margin: 0; color: #fcc323; text-shadow: 0 2px 10px rgba(0, 0, 0, .6); }
.banner p { margin: 4px 0 0; color: #e7e2ff; font-size: 17px; max-width: 760px; }

/* ---------- boxes ---------- */
.tldr, .tip, .warn, .new, .why { background: var(--panel); padding: 10px 16px; border-radius: 8px; margin: 14px 0; border-left: 4px solid var(--gold); }
.tldr strong:first-child { color: var(--gold); }
.tip { border-left-color: var(--green); } .warn { border-left-color: var(--orange); } .new { border-left-color: var(--violet); } .why { border-left-color: var(--blue); }
.tip::before { content: "Tip. "; font-weight: 700; color: var(--green); }
.warn::before { content: "Careful. "; font-weight: 700; color: var(--orange); }
.why::before { content: "Why it works this way. "; font-weight: 700; color: var(--blue); }
.new h3 { margin: 4px 0 6px; font-size: 18px; color: var(--violet); }
.new ul { margin: 4px 0; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; margin: 12px 0; border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--panel); border-radius: 8px; overflow: hidden; }
th, td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--panel2); color: var(--gold); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.k { font-weight: 600; white-space: nowrap; }

/* ---------- chips, keys, marks ---------- */
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-weight: 700; font-size: 13px; color: #111; white-space: nowrap; line-height: 1.5; }
.c-red { background: var(--red); color: #fff; } .c-orange { background: var(--orange); } .c-yellow { background: var(--yellow); }
.c-green { background: var(--green); } .c-blue { background: var(--blue); color: #fff; } .c-indigo { background: var(--indigo); color: #fff; }
.c-violet { background: var(--violet); } .c-gold { background: var(--gold); color: #111; } .c-pink { background: var(--pink); }
.c-power { background: var(--power); color: #fff; } .c-debt { background: var(--debt); color: #fff; } .c-well { background: var(--well); }
.c-grey { background: #b9b6d6; }
kbd { background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font: 600 14px ui-monospace, monospace; }
code { background: var(--panel2); padding: 0 5px; border-radius: 4px; font-size: 15px; }
img.mark, .card img.mark { display: inline-block; height: 26px; width: 26px; margin: 0 2px 0 0; padding: 3px; background: #1b2462; border-radius: 6px; vertical-align: middle; }
img.icon { height: 30px; width: auto; vertical-align: middle; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 14px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card img { display: block; height: 96px; width: auto; max-width: 100%; margin: 0 auto 8px; object-fit: contain; }
.card img.wide { height: auto; width: 100%; border-radius: 6px; }
.card h3, .card h4 { margin: 4px 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 18px; }
.card p { font-size: 15px; margin: 4px 0; }
.card img.art { background: #1b2462; border-radius: 8px; padding: 6px; }

/* ---------- screenshots ---------- */
figure { margin: 16px 0; }
figure img { display: block; width: 100%; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow); cursor: zoom-in; }
figcaption { color: var(--muted); font-size: 14.5px; margin-top: 6px; }
figure.half { max-width: 560px; }
.shots2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 14px 0; }
.shots2 figure { margin: 0; }
.shot { position: relative; }
.shot .pin { position: absolute; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font: 800 14px system-ui, sans-serif; color: #1b1440;
  background: radial-gradient(circle at 35% 30%, #fff6cf, #fcc323 70%); border: 2px solid #1b1440;
  box-shadow: 0 0 0 2px #fcc323, 0 2px 8px rgba(0, 0, 0, .6); pointer-events: none; }
.shot .ring { position: absolute; border: 3px solid #fcc323; border-radius: 12px; box-shadow: 0 0 0 2px rgba(27, 20, 64, .8), 0 0 14px rgba(252, 195, 35, .55); pointer-events: none; }
ol.legend { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 6px 18px; counter-reset: lg; }
ol.legend li { counter-increment: lg; display: flex; gap: 10px; align-items: flex-start; margin: 0; font-size: 15.5px; }
ol.legend li::before { content: counter(lg); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font: 800 13px system-ui, sans-serif; color: #1b1440; background: #fcc323; margin-top: 1px; }

/* ---------- steps ---------- */
ol.steps { list-style: none; padding: 0; margin: 12px 0; counter-reset: st; }
ol.steps > li { counter-increment: st; position: relative; padding: 2px 0 10px 46px; margin: 0; }
ol.steps > li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font: 800 15px system-ui, sans-serif; color: var(--gold); border: 2px solid var(--gold); background: var(--panel2); }
ol.steps > li:not(:last-child)::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 0; width: 2px; background: var(--line); }

/* ---------- a place card (sanctuaries and finds) ---------- */
.place { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0; margin: 26px 0; overflow: hidden; box-shadow: var(--shadow); }
.place > header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 18px; background: var(--panel2); border-bottom: 1px solid var(--line); }
.place > header h3 { margin: 0; font-size: 24px; }
.place > header img.art { width: 64px; height: 64px; object-fit: contain; }
.place > header .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.place > header .tags .chip { font-weight: 600; }
.place .body { padding: 6px 18px 16px; }
.place .cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; align-items: start; }
.place .cols figure { margin: 10px 0 0; }
.place h4 { margin: 16px 0 6px; color: var(--gold); }
.place .cols > div > h4:first-child { margin-top: 10px; }
.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.glance div { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 14px; color: var(--muted); }
.glance b { display: block; color: var(--text); font-size: 15.5px; }
.ways { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.ways > div { border-radius: 8px; padding: 8px 12px; border: 1px solid var(--line); background: var(--panel2); font-size: 15px; }
.ways .hi { border-top: 3px solid var(--gold); } .ways .lo { border-top: 3px solid var(--orange); }
.ways b { display: block; margin-bottom: 2px; }

/* ---------- diagrams ---------- */
.diagram { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 14px 0; }
.diagram svg { display: block; width: 100%; height: auto; max-height: 440px; }
.diagram svg text { fill: var(--svg-ink); font: 600 13px system-ui, sans-serif; }
.diagram svg text.dim { fill: var(--svg-dim); font-weight: 500; }
.diagram svg text.big { font-size: 16px; font-weight: 700; }
.diagram .floor { fill: var(--svg-floor); }
.diagram .ink { stroke: var(--svg-ink); }
.diagram .dimline { stroke: var(--svg-dim); }
.diagram figcaption { margin: 6px 4px 0; }

/* ---------- the mirror, flows, rows ---------- */
.mirror { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.mirror div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.mirror img { height: 64px; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0; }
.flow span { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 15px; }
.flow i { color: var(--gold); font-style: normal; }
.row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.row > img { width: 180px; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.row > .grow { flex: 1; min-width: 240px; }

/* ---------- questions ---------- */
details.q { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 0 14px; }
details.q > summary { cursor: pointer; padding: 10px 0; font-weight: 700; list-style: none; display: flex; gap: 10px; align-items: baseline; }
details.q > summary::-webkit-details-marker { display: none; }
details.q > summary::before { content: "+"; color: var(--gold); font-weight: 800; width: 14px; flex: none; }
details.q[open] > summary::before { content: "\2212"; }
details.q > div { padding: 0 0 12px 24px; }
.qgroup { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin: 22px 0 4px; }

/* ---------- misc ---------- */
footer { margin-top: 60px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.theme { position: fixed; top: 10px; right: 12px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 14px; z-index: 5; }
.totop { position: fixed; right: 12px; bottom: 12px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 14px; text-decoration: none; z-index: 5; }
.lightbox { position: fixed; inset: 0; background: rgba(5, 6, 20, .94); display: none; place-items: center; z-index: 20; cursor: zoom-out; padding: 12px; }
.lightbox.on { display: grid; }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.lightbox p { color: #e7e2ff; text-align: center; margin: 8px auto 0; font-size: 15px; max-width: 900px; }

/* Inside the game (plan 29: the web shell's frame, the Android app's WebView mark the page .mw-framed): the game's round
   close button takes the top-right corner, so the Light / Dark button stands left of it. */
@media (min-width: 901px) { .mw-framed .theme { right: 72px; } }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  nav.toc { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; }
  nav.toc details > summary { display: block; cursor: pointer; font-weight: 700; color: var(--gold); padding: 6px 0; }
  nav.toc .inner { columns: 2; column-gap: 14px; }
  nav.toc .part { break-after: avoid; }
  nav.toc li { break-inside: avoid; }
  nav.toc a.sub2 { display: none; }
  .place .cols { grid-template-columns: minmax(0, 1fr); }
  .theme { top: auto; bottom: 12px; right: auto; left: 12px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  nav.toc .inner { columns: 1; }
  h2 { font-size: 23px; } h2 .n { width: 34px; height: 34px; font-size: 15px; }
  .ways { grid-template-columns: 1fr; }
  .shot .pin { width: 22px; height: 22px; font-size: 12px; }
  .banner img { aspect-ratio: 16 / 9; }
  .banner .over { position: static; background: var(--panel2); color: var(--text); padding: 12px 14px; }
  .banner h1 { color: var(--gold); text-shadow: none; }
  .banner p { color: var(--muted); }
  .place > header .tags { margin-left: 0; }
}
@media print { nav.toc, .theme, .totop, .lightbox { display: none !important; } .layout { display: block; } body { background: #fff; color: #000; }
  .place, figure img { box-shadow: none; } }

/* ---------- step diagrams and the island map ---------- */
.diagram .dtitle { margin: 2px 4px 8px; font-weight: 700; color: var(--gold); }
.diagram .dnote { margin: 8px 4px 0; color: var(--muted); font-size: 14.5px; text-align: center; }
.diagram p.dim { color: var(--muted); margin: 4px 0; font-size: 14.5px; }
.dsteps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dsteps figure { margin: 0; text-align: center; }
.dsteps svg { display: block; width: 100%; max-width: 190px; margin: 0 auto; }
.dsteps figcaption { margin-top: 2px; font-size: 14px; }
.dsteps figcaption b { display: block; color: var(--text); font-size: 15.5px; }
.maprow { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 8px 18px; align-items: center; }
.maprow > svg { max-height: 420px; }
.maprow > figcaption { grid-column: 1 / -1; }
.keys { list-style: none; padding: 0; margin: 8px 0; }
.keys li { display: flex; gap: 10px; align-items: center; margin: 7px 0; font-size: 15px; line-height: 1.35; }
.keys svg { width: 24px; height: 24px; flex: none; }
@media (max-width: 640px) {
  .dsteps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .maprow { grid-template-columns: minmax(0, 1fr); }
}
