/* Fortune and Glory adventure workshop. 1930s expedition look: parchment, leather, brass and map ink. */
:root {
  --sys: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: Cinzel, Georgia, serif;
  --slab: "Alfa Slab One", Georgia, serif;
  --west: Rye, Georgia, serif;
  --bg: #e9dbb8;
  --bg2: #dccaa0;
  --panel: #f7eed6;
  --panel2: #efe2c1;
  --ink: #2a1a0a;
  --muted: #6b5538;
  --line: #b8955a;
  --accent: #8e1c12;
  --accent2: #b3261e;
  --gold: #c9a24a;
  --leather: #2b2116;
  --leather2: #3d2e1c;
  --ok: #3f6f2a;
  --shadow: 0 2px 0 rgba(60,35,10,.15), 0 8px 20px rgba(60,35,10,.15);
  --radius: 10px;
}
[data-theme="dark"] {
  --bg: #15110b;
  --bg2: #1d170f;
  --panel: #231b12;
  --panel2: #2c2216;
  --ink: #f0e3c4;
  --muted: #b9a37c;
  --line: #5e4a2c;
  --accent: #e0624c;
  --accent2: #f07a62;
  --gold: #d9b25a;
  --leather: #0d0a06;
  --leather2: #1a140c;
  --ok: #8fc26b;
  --shadow: 0 2px 0 rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.5 var(--sys); color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255,250,230,.35), transparent 60%),
    radial-gradient(ellipse at 90% 100%, rgba(120,80,30,.18), transparent 55%),
    repeating-linear-gradient(0deg, rgba(120,80,30,.035) 0 2px, transparent 2px 5px),
    var(--bg);
  min-height: 100vh; display: flex; flex-direction: column;
}
[data-theme="dark"] body { background: radial-gradient(ellipse at 20% 0%, rgba(201,162,74,.08), transparent 60%), var(--bg); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 900; line-height: 1.15; letter-spacing: .01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); }
h2 { font-size: clamp(1.2rem, 3.2vw, 1.55rem); color: var(--accent); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .9em; }
img, canvas { max-width: 100%; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* masthead */
.masthead {
  background: linear-gradient(180deg, var(--leather2), var(--leather)); color: #f3e2b4;
  border-bottom: 3px solid var(--gold); box-shadow: 0 4px 14px rgba(0,0,0,.35); position: sticky; top: 0; z-index: 20;
}
.mast-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px 4px; }
.brand { text-decoration: none; color: inherit; display: flex; flex-direction: column; line-height: 1; }
.brand-title { font-family: var(--west); font-size: clamp(1.35rem, 5vw, 2rem); color: #f6d77a; text-shadow: 2px 2px 0 #000, 0 0 12px rgba(246,215,122,.25); }
.brand-sub { font-family: var(--display); font-weight: 700; font-size: .8rem; letter-spacing: .28em; text-transform: uppercase; color: #e5cf9b; margin-top: 4px; }
.theme-btn { margin-left: auto; background: none; border: 1px solid rgba(246,215,122,.5); border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; }
.theme-btn svg { width: 20px; height: 20px; fill: #f6d77a; }
.tabs { max-width: 1200px; margin: 0 auto; display: flex; gap: 2px; padding: 0 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  color: #e9d7a8; text-decoration: none; padding: 9px 13px 8px; font-weight: 600; font-size: .95rem; white-space: nowrap;
  border-radius: 8px 8px 0 0; border: 1px solid transparent; border-bottom: 0;
}
.tabs a:hover { color: #fff; background: rgba(255,255,255,.06); }
.tabs a.on { background: var(--bg); color: var(--accent); border-color: var(--gold); }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }
main:focus { outline: none; }
.foot { text-align: center; font-size: .82rem; color: var(--muted); padding: 18px 16px 28px; border-top: 1px solid var(--line); }
.foot p { margin: .3em 0; }

/* panels and controls */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; position: relative; }
.panel.parch {
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.35), transparent 60%), radial-gradient(ellipse at 80% 90%, rgba(150,100,40,.18), transparent 60%), var(--panel);
}
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: 600 .95rem var(--sys); cursor: pointer; text-decoration: none;
  background: linear-gradient(180deg, #a7342a, #7a160e); color: #fff6e2; border: 1px solid #4a0c06; border-radius: 8px; padding: 9px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 0 rgba(0,0,0,.2); min-height: 40px;
}
.btn:hover { filter: brightness(1.08); }
.btn.alt { background: linear-gradient(180deg, #f3e3b5, #d6b878); color: #2a1a0a; border-color: #8a6a2e; }
[data-theme="dark"] .btn.alt { background: linear-gradient(180deg, #4a3a22, #2e2414); color: #f0e3c4; border-color: #6b5530; }
.btn.ghost { background: none; color: var(--accent); border-color: var(--line); box-shadow: none; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn.danger { background: none; color: var(--accent2); border-color: var(--accent2); box-shadow: none; }
.btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
label.f { display: block; margin: 0 0 12px; }
label.f > span, .f-label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; color: var(--muted); }
input[type=text], input[type=number], input[type=email], input[type=search], select, textarea {
  width: 100%; font: 16px/1.35 var(--sys); color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
}
textarea { min-height: 70px; resize: vertical; }
input[type=number] { max-width: 110px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: -3px; }
.check { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; font-weight: 600; font-size: .92rem; }
.hint { font-size: .82rem; color: var(--muted); margin: -6px 0 12px; }
.sec-head { font-family: var(--display); font-weight: 900; color: var(--accent); font-size: 1.05rem; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 18px 0 12px; }
.sec-head:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 12px; }
.chip { font-size: .75rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--gold); color: #2a1a0a; }
.badge.green { background: #4f7d3a; color: #fff; }
.badge.grey { background: var(--line); color: var(--ink); }

/* lists inside forms */
.list-item { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; background: rgba(255,255,255,.12); }
.list-item .row > * { min-width: 0; }
.test-row { display: grid; grid-template-columns: 1.4fr .8fr .8fr auto; gap: 6px; align-items: end; }
.test-row .note, .test-row .clabel { grid-column: 1 / -2; }
.mini { font-size: .75rem; color: var(--muted); display: block; margin-bottom: 2px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; max-height: 220px; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.icon-btn { aspect-ratio: 1; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; padding: 6px; color: var(--ink); }
.icon-btn svg { width: 100%; height: 100%; fill: currentColor; }
.icon-btn:hover { border-color: var(--line); }
.icon-btn.on { background: var(--accent); color: #fff; }
details.picker > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
details.picker > summary::-webkit-details-marker { display: none; }
details.picker > summary svg { width: 28px; height: 28px; fill: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
.art-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 12px; background: var(--panel2); }
.art-box .thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* home */
.hero-band {
  border-radius: 14px; padding: 28px 22px; margin-bottom: 18px; color: #f6e7c1; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 75% 20%, rgba(246,215,122,.25), transparent 55%), linear-gradient(135deg, #3b2a17, #1a120a 70%);
  border: 2px solid var(--gold); box-shadow: var(--shadow);
}
.hero-band::after { content: ""; position: absolute; inset: 0; background: repeating-conic-gradient(from 0deg at 80% 110%, rgba(246,215,122,.07) 0 6deg, transparent 6deg 14deg); pointer-events: none; }
.hero-band h1 { font-family: var(--west); font-weight: 400; color: #f6d77a; text-shadow: 2px 2px 0 #000; }
.hero-band p { max-width: 640px; font-size: 1.05rem; position: relative; z-index: 1; }
.hero-band .row { position: relative; z-index: 1; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { display: block; text-decoration: none; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); transition: transform .12s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile svg { width: 42px; height: 42px; fill: var(--accent); }
.tile h3 { margin: 8px 0 4px; }
.tile p { margin: 0; font-size: .92rem; color: var(--muted); }

/* card library */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 140px; flex: 1 1 140px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.ctile { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.ctile:hover { border-color: var(--accent); }
.ctile .img { width: 100%; aspect-ratio: 63.5/88.9; display: grid; place-items: center; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.ctile .img img { width: 100%; height: 100%; object-fit: contain; }
.ctile .nm { font-weight: 700; font-size: .9rem; line-height: 1.2; }
.ctile .tp { font-size: .75rem; color: var(--muted); }
.ctile .sel { position: absolute; top: 12px; left: 12px; z-index: 2; }
.ctile .sel input { width: 22px; height: 22px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.type-btn { text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; color: var(--ink); font: inherit; display: flex; gap: 10px; }
.type-btn:hover { border-color: var(--accent); }
.type-btn b { display: block; }
.type-btn small { color: var(--muted); font-size: .8rem; line-height: 1.3; display: block; }
.type-btn .sw { width: 14px; border-radius: 4px; flex: none; }

/* editors */
.editor { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 20px; align-items: start; }
.preview { position: sticky; top: 120px; }
.preview canvas { width: 100%; height: auto; display: block; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.35); background: #222; }
.preview.wide canvas { max-width: 100%; }
.side-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.side-tabs button { font: 600 .85rem var(--sys); border: 1px solid var(--line); background: var(--panel2); color: var(--ink); padding: 6px 10px; border-radius: 999px; cursor: pointer; }
.side-tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.editor.hero-ed { grid-template-columns: 1fr; }
.editor.hero-ed .preview { position: static; }
.editor.wide-ed { grid-template-columns: minmax(300px, 520px) 1fr; }
.crumbs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.crumbs h1 { margin: 0; font-size: clamp(1.2rem, 3.5vw, 1.7rem); }
.saved { font-size: .8rem; color: var(--ok); }

/* adventures */
.adv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.adv-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.adv-tile .cov { height: 130px; background: #3b2a17 center/cover no-repeat; display: grid; place-items: center; }
.adv-tile .cov svg { width: 70px; height: 70px; fill: rgba(246,215,122,.7); }
.adv-tile .bd { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.adv-tile h3 { margin: 0; }
.adv-tile p { margin: 0; font-size: .9rem; color: var(--muted); }
.adv-tile .row { margin-top: auto; padding-top: 6px; }
.pages { display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 12px; }
.pages canvas { height: 360px; width: auto; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.3); flex: none; }

/* reader */
.reader { max-width: 780px; margin: 0 auto; }
.reader .adv-head { text-align: center; border-bottom: 2px solid var(--gold); padding-bottom: 14px; margin-bottom: 16px; }
.reader .kicker { font-family: var(--display); font-weight: 700; letter-spacing: .2em; text-transform: uppercase; font-size: .75rem; color: var(--accent); margin: 0 0 4px; }
.reader .tagline { font-style: italic; font-size: 1.1rem; color: var(--muted); }
.reader .story { font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: 1.12rem; }
.reader dl.meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin: 10px 0 0; }
.reader dl.meta div { display: flex; gap: 6px; font-size: .9rem; }
.reader dt { font-weight: 700; color: var(--accent); }
.reader dd { margin: 0; }
.reader section { margin-bottom: 18px; }
.reader ol { padding-left: 1.4em; }
.reader li { margin-bottom: .4em; }
.dtable { width: 100%; border-collapse: collapse; }
.dtable th { width: 3.2em; font-family: var(--slab); font-weight: 400; color: var(--accent); vertical-align: top; padding: 8px 6px; text-align: center; }
.dtable td { padding: 8px 6px; }
.dtable tr:nth-child(odd) { background: rgba(120,80,30,.12); }
.sk { font-weight: 700; font-size: .85em; letter-spacing: .03em; }
.sk-combat { color: #b3261e; } .sk-agility { color: #a8740a; } .sk-cunning { color: #3f8a35; } .sk-lore { color: #2e68a8; }
.xmark { color: #24467e; font-weight: 900; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.gallery img { width: 100%; border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,.3); cursor: zoom-in; }

/* community */
.com-list { display: grid; gap: 12px; }
.com-item { display: grid; grid-template-columns: 88px 1fr; gap: 14px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.com-item .ic { width: 88px; height: 88px; border-radius: 8px; background: #3b2a17 center/cover; display: grid; place-items: center; }
.com-item .ic svg { width: 52px; height: 52px; fill: rgba(246,215,122,.75); }
.com-item h3 { margin: 0 0 2px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps > li { counter-increment: s; position: relative; padding: 0 0 14px 48px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; font: 400 1.05rem var(--slab); display: grid; place-items: center; box-shadow: 0 0 0 3px var(--gold); }
.checklist { list-style: none; padding: 0; }
.checklist li { padding-left: 28px; position: relative; margin-bottom: 6px; }
.checklist li::before { content: "\2713"; position: absolute; left: 4px; color: var(--ok); font-weight: 900; }

/* guide */
.guide-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.odds-out { font: 400 2rem var(--slab); color: var(--accent); }
table.odds { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.odds th, table.odds td { border: 1px solid var(--line); padding: 5px 6px; text-align: center; }
table.odds th { background: var(--panel2); }
.anat { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; margin-bottom: 18px; }
.anat canvas { width: 100%; border-radius: 8px; box-shadow: 0 3px 10px rgba(0,0,0,.3); }
.anat.w { grid-template-columns: 260px 1fr; }

/* quick reference */
.ref-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; box-shadow: var(--shadow); }
.ref-sheet svg { display: block; width: 100%; height: auto; }
.ref-sheet.land { min-width: 860px; }
@media (max-width: 480px) { .ref-sheet { min-width: 640px; } .ref-sheet.land { min-width: 900px; } }

/* modal and toast */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,6,2,.65); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); color: var(--ink); border: 2px solid var(--gold); border-radius: 12px; width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 20px; position: relative; box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.modal-box.big { width: min(980px, 100%); }
.modal-x { position: absolute; top: 6px; right: 10px; font-size: 1.8rem; line-height: 1; background: none; border: 0; color: var(--ink); cursor: pointer; }
.progress { height: 12px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; margin: 12px 0; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width .15s; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: var(--leather); color: #f6e7c1; border: 1px solid var(--gold); padding: 10px 16px; border-radius: 10px; z-index: 60; transition: transform .25s; max-width: 90vw; }
.toast.on { transform: translateX(-50%) translateY(0); visibility: visible; }
.toast:not(.on) { visibility: hidden; }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty svg { width: 70px; height: 70px; fill: var(--line); }

@media (max-width: 820px) {
  .editor, .editor.wide-ed { grid-template-columns: 1fr; }
  .preview { position: static; max-width: 360px; margin: 0 auto; width: 100%; }
  .preview.wide { max-width: 480px; }
  .anat, .anat.w { grid-template-columns: 1fr; }
  .anat canvas { max-width: 240px; }
  .pages canvas { height: 260px; }
}
@media (max-width: 480px) {
  main { padding: 14px 10px 30px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .test-row { grid-template-columns: 1fr 1fr 1fr auto; }
  .com-item { grid-template-columns: 60px 1fr; }
  .com-item .ic { width: 60px; height: 60px; }
}
@media print { .masthead, .foot, .toolbar { display: none; } }
