:root { --ink: #3e3226; --soft: #6e5f4f; --paper: rgba(252, 247, 237, 0.94); --line: rgba(110, 95, 79, 0.18); --accent: #6f8096; --gold: #b8873b; --shadow: 0 8px 30px rgba(40, 28, 18, 0.22); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2f3b32; font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; }
#app canvas { display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.serif { font-family: Georgia, 'Times New Roman', serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.btn { background: var(--paper); border-radius: 999px; padding: 10px 18px; box-shadow: 0 3px 12px rgba(40, 28, 18, 0.18); font-size: 15px; transition: transform 0.12s; }
.btn:active { transform: scale(0.96); }
.btn.primary { background: #6f8096; color: #fff; }
.btn.gold { background: var(--gold); color: #fff; }
.btn.ghost { background: rgba(255,255,255,0.25); color: #fff; box-shadow: none; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); box-shadow: 0 3px 12px rgba(40, 28, 18, 0.18); font-size: 18px; }

/* screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 24px; }
.title-screen { background: radial-gradient(ellipse at 50% 35%, rgba(255, 244, 222, 0.35), rgba(30, 24, 18, 0.55)); color: #fff; }
.title-screen h1 { font-family: Georgia, serif; font-weight: 500; font-size: clamp(44px, 9vw, 86px); margin: 0; letter-spacing: 2px; text-shadow: 0 2px 20px rgba(0,0,0,0.35); }
.title-screen .verse { font-family: Georgia, serif; font-style: italic; font-size: 18px; opacity: 0.92; margin: 8px 0 26px; }
.title-screen p { max-width: 460px; line-height: 1.55; opacity: 0.95; margin: 0 0 26px; text-shadow: 0 1px 8px rgba(0,0,0,0.35); }
.title-screen .row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.foot { position: fixed; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255,255,255,0.8); }
.foot a { color: inherit; }

/* panels / modals */
.panel { background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); padding: 20px; max-width: min(560px, 94vw); max-height: 86vh; overflow: auto; text-align: left; }
.panel h2 { font-family: Georgia, serif; font-weight: 500; margin: 0 0 4px; font-size: 26px; }
.panel h3 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--soft); }
.panel .sub { color: var(--soft); margin: 0 0 14px; line-height: 1.5; }
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(30, 22, 15, 0.35); z-index: 20; padding: 12px; }
.close { float: right; background: none; font-size: 22px; color: var(--soft); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1); }
.sw.on { border-color: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 14px; border-radius: 999px; background: rgba(110, 95, 79, 0.1); font-size: 14px; }
.chip.on { background: var(--accent); color: #fff; }
input[type=text] { font: inherit; width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.card { background: #fff; border-radius: 16px; padding: 14px; border: 2px solid transparent; text-align: left; box-shadow: 0 2px 8px rgba(40,28,18,0.08); }
.card.on { border-color: var(--accent); }
.card .r { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.card .r.rare { color: #5b74b8; } .card .r.legendary { color: var(--gold); } .card .r.common { color: var(--soft); }
.card b { display: block; font-family: Georgia, serif; font-size: 17px; font-weight: 500; margin: 4px 0; }
.card small { color: var(--soft); line-height: 1.4; display: block; }
.card .ref { font-style: italic; margin-top: 6px; font-size: 12px; color: var(--soft); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.cell { background: #fff; border-radius: 12px; padding: 10px; font-size: 13px; text-align: left; border: 2px solid transparent; min-height: 64px; }
.cell.on { border-color: var(--accent); background: #eef2f7; }
.cell.locked { opacity: 0.38; }
.cell .s { font-size: 11px; color: var(--soft); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* HUD */
.hud-top { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.status { min-width: min(320px, 60vw); background: var(--paper); border-radius: 18px; padding: 10px 14px; box-shadow: 0 3px 14px rgba(40,28,18,0.16); max-width: min(520px, 70vw); }
.status .t1 { font-family: Georgia, serif; font-size: 17px; }
.status .t2 { font-size: 13px; color: var(--soft); margin-top: 2px; }
.bar { position: relative; height: 6px; background: rgba(110,95,79,0.15); border-radius: 3px; margin-top: 8px; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; }
.bar b { position: absolute; top: -2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.bar b.done { background: var(--accent); }
.tools { display: flex; gap: 8px; align-items: flex-start; flex-shrink: 0; }
.hud-top .status { flex: 0 1 auto; min-width: 0; }
.hud-bottom { position: fixed; left: 0; right: 0; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 0 10px; }
.caption { max-width: min(760px, 92vw); text-align: center; background: rgba(28, 22, 16, 0.62); color: #fff; border-radius: 14px; padding: 10px 16px; font-family: Georgia, serif; font-size: clamp(16px, 2.3vw, 21px); line-height: 1.45; pointer-events: none; transition: opacity 0.4s; }
.caption .who { display: block; font-family: -apple-system, 'Segoe UI', sans-serif; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.75; margin-bottom: 4px; }
.caption .ref { font-size: 13px; opacity: 0.75; font-style: italic; }
.caption.jesus { background: rgba(60, 40, 18, 0.7); }
.caption.jesus .text { color: #ffe9c2; }
.scene-action { background: var(--gold); color: #fff; padding: 12px 22px; font-size: 16px; }
.toasts { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 15; }
.toast { background: var(--paper); border-radius: 999px; padding: 8px 16px; font-size: 14px; box-shadow: 0 3px 12px rgba(40,28,18,0.18); animation: tin 0.3s ease; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }
.flash { position: fixed; inset: 0; background: radial-gradient(circle, #fffaf0, #fff3d6); opacity: 0; pointer-events: none; transition: opacity 0.9s; z-index: 30; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.flash.on { opacity: 1; pointer-events: auto; }
.flash .msg { font-family: Georgia, serif; font-size: clamp(20px, 3vw, 28px); color: #6b5232; max-width: 640px; line-height: 1.5; }
.flash .msg small { display: block; font-size: 15px; margin-top: 10px; font-style: italic; opacity: 0.75; }
.names { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.name { position: absolute; left: 0; top: 0; will-change: transform; transform: translate(-50%, -100%); font-size: 11px; background: rgba(255,255,255,0.75); padding: 2px 8px; border-radius: 999px; white-space: nowrap; color: var(--ink); }
.name.me { background: rgba(111,128,150,0.9); color: #fff; }
.followhint { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--paper); padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow); pointer-events: none; }
.list { display: flex; flex-direction: column; gap: 6px; }
.note { background: #fff; border-radius: 12px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.note a { color: var(--accent); text-decoration: none; font-weight: 600; }
.note small { color: var(--soft); }
.tiny { font-size: 12px; color: var(--soft); }
.linkbtn { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
@media (max-width: 600px) { .status { max-width: 62vw; } .status .t1 { font-size: 15px; } .btn { padding: 9px 14px; font-size: 14px; } }

a.btn { text-decoration: none; color: inherit; display: inline-block; }

#ui > .names, #ui > .hud-top, #ui > .hud-bottom { pointer-events: none; }
#ui > .hud-top > *, #ui > .hud-bottom > * { pointer-events: auto; }
.hud-bottom .caption { pointer-events: none !important; }

/* create screen: side panel on wide screens, bottom sheet on phones (the preview stays visible above it) */
.create-screen { justify-content: flex-end; align-items: flex-end; }
.create-panel { max-width: 380px; }
.narrow-only { display: none; }

@media (max-width: 700px) {
  .wide-only { display: none !important; }
  .narrow-only { display: inline-block; }
}
@media (max-width: 600px) {
  .hud-top { left: 8px; right: 8px; gap: 6px; }
  .status { min-width: 0; max-width: none; padding: 8px 12px; }
  .status .t2 { font-size: 12px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .tools { gap: 6px; }
  .icon { width: 38px; height: 38px; font-size: 16px; }
  .actions { gap: 6px; }
  .actions .btn { padding: 8px 12px; font-size: 13px; }
  .caption { font-size: 16px; padding: 8px 12px; }
  .create-screen { padding: 0; align-items: stretch; }
  .create-panel { max-width: none; width: 100%; max-height: 50vh; border-radius: 22px 22px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .create-panel h2 { font-size: 21px; }
  .create-panel .sub { display: none; }
  .create-panel h3 { margin: 10px 0 6px; }
  .sw { width: 30px; height: 30px; }
  .sheet { width: 100%; }
}
.list a.btn { text-align: center; }

/* optional support (lamp stands) */
/* lamp-stand buttons: 44 px hit area around a small quiet chip */
#ui > .stand-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#ui > .stand-layer > .stand-btn { position: absolute; left: 0; top: 0; pointer-events: auto; min-width: 44px; min-height: 44px; padding: 0 2px; background: transparent; display: flex; align-items: center; justify-content: center; will-change: transform; }
.stand-btn[hidden] { display: none !important; }
.stand-btn .chipface { background: rgba(255, 241, 214, 0.95); color: #6b4f2a; font-size: 12px; padding: 4px 11px; border-radius: 999px; white-space: nowrap; box-shadow: 0 2px 8px rgba(60, 40, 18, 0.2); }
.stand-btn.edge .chipface { opacity: 0.88; font-size: 11px; }
.stand-btn:focus-visible { outline: none; }
.stand-btn:focus-visible .chipface { outline: 3px solid #6f8096; outline-offset: 2px; }
.support { max-width: min(460px, 94vw); }
.preview-banner { background: #fff4d9; border: 1px dashed #c9a24e; color: #6b4f2a; border-radius: 12px; padding: 8px 12px; font-size: 13px; margin: 0 28px 12px 0; }
.chip.amount { font-size: 16px; padding: 10px 18px; min-width: 84px; }
.btn.primary[disabled] { background: #b9c2cd; }

/* free walk: thumb joystick (appears where the thumb lands, lower-left half) and the "walk with the group" pill */
.joy { position: fixed; left: 0; top: 0; width: 104px; height: 104px; border-radius: 50%; pointer-events: none; z-index: 12; opacity: 0; transition: opacity 0.15s; background: radial-gradient(circle, rgba(255, 250, 240, 0.10) 55%, rgba(255, 250, 240, 0.32) 56%, rgba(255, 250, 240, 0.18) 70%, rgba(255, 250, 240, 0) 71%); }
.joy.on { opacity: 1; }
.joy-knob { position: absolute; left: 30px; top: 30px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 250, 240, 0.78); box-shadow: 0 2px 10px rgba(40, 28, 18, 0.25); }
.joy.run .joy-knob { background: rgba(255, 236, 196, 0.95); }
.btn.rejoin { background: #fff3d2; color: #4a3626; font-size: 15px; font-weight: 600; padding: 9px 20px; border: 2px solid #c9a24e; box-shadow: 0 3px 14px rgba(40,28,18,0.22); }
.btn.rejoin:focus-visible { outline: 3px solid #8a6a2e; outline-offset: 2px; }
/* the road map (minimap.js), under the round buttons on the right */
.minimap-box { position: fixed; right: 10px; top: calc(max(10px, env(safe-area-inset-top)) + 64px); z-index: 2; pointer-events: none; }
.minimap-box .fm-minimap { pointer-events: auto; }

/* the cut into a teaching (journey.js CUT): the 3D view fades out and in; toasts, modals and flashes stay above */
.cut { position: fixed; inset: 0; background: #140f0b; opacity: 0; pointer-events: none; z-index: 10; }

/* the jump button (phones; Space on a keyboard): lower right, above the bottom buttons (main.js syncJumpBtn sets bottom) */
.jump-btn { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: 96px; z-index: 3; width: 52px; height: 52px; border-radius: 50%; border: 0; padding: 0; background: var(--paper); color: var(--ink, #3b2f25); box-shadow: 0 3px 14px rgba(40,28,18,0.2); font-size: 26px; line-height: 52px; text-align: center; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.jump-btn:active { transform: scale(0.92); }
.jump-btn:focus-visible { outline: 3px solid #c58a3a; outline-offset: 2px; }

/* the large map of the land (worldmap.js): click / tap the little map or press M */
.fm-minimap[role="button"] { cursor: zoom-in; }
.fm-minimap[role="button"]:focus-visible { outline: 3px solid #c58a3a; outline-offset: 2px; }
.wm-modal .wm-panel { width: min(1100px, 96vw); max-width: none; height: min(820px, 90vh); max-height: none; display: flex; flex-direction: column; padding: 14px 16px 12px; overflow: hidden; }
.wm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wm-head h2 { margin: 0; }
.wm-head .close { float: none; width: 44px; height: 44px; border-radius: 50%; }
.wm-where { margin: 2px 0 8px; color: var(--soft); font-size: 14px; line-height: 1.35; }
.wm-body { flex: 1; min-height: 0; display: flex; gap: 12px; }
.wm-stage { position: relative; flex: 1; min-width: 0; min-height: 0; border-radius: 14px; overflow: hidden; box-shadow: inset 0 0 0 1.5px rgba(120,90,55,.55); background: #e7d6ae; }
.wm-map { position: absolute; inset: 0; touch-action: none; cursor: grab; outline: none; }
.wm-map:active { cursor: grabbing; }
.wm-map:focus-visible { box-shadow: inset 0 0 0 3px #c58a3a; }
.wm-svg { width: 100%; height: 100%; display: block; user-select: none; }
.wm-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.wm-zbtn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--paper); box-shadow: 0 2px 8px rgba(60,40,20,.25); font-size: 20px; color: var(--ink); cursor: pointer; }
.wm-inset { position: absolute; right: 8px; bottom: 8px; width: 150px; height: 110px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 10px rgba(60,40,20,.35), inset 0 0 0 1.5px rgba(120,90,55,.6); background: #efe2c2; cursor: zoom-in; }
.wm-inset-svg { width: 100%; height: 100%; display: block; }
.wm-zbtn:focus-visible, .wm-inset:focus-visible, .wm-place:focus-visible { outline: 3px solid #c58a3a; outline-offset: 2px; }
.wm-side { width: 280px; display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
.wm-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--soft); }
.wm-legend span { display: inline-flex; align-items: center; gap: 5px; }
.wm-k { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #6b4a2f; }
.wm-k.me { background: #c0392b; border-color: #fff; box-shadow: 0 0 0 1px #c0392b; }
.wm-k.jesus { background: #f6d27a; border-color: #9a6b2a; box-shadow: 0 0 0 3px rgba(255,214,120,.45); }
.wm-k.grp { background: #8a7a68; border-color: #fffaf0; width: 8px; height: 8px; }
.wm-k.seen { background: #c99a5b; }
.wm-k.unseen { background: #fffaf0; }
.wm-places summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 4px 0; }
.wm-list { margin: 4px 0 0; padding-left: 26px; font-size: 13px; line-height: 1.35; }
.wm-list li { margin: 2px 0; }
.wm-place { background: none; border: 0; padding: 2px 0; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.wm-place span { color: var(--soft); }
.wm-state { color: #9a6b2a; font-style: normal; }
.wm-list li.seen .wm-place b { color: #8a5a22; }
@media (max-width: 720px), (orientation: portrait) {
  .wm-modal { padding: 6px; }
  .wm-modal .wm-panel { width: 100%; height: calc(100vh - 12px); height: calc(100dvh - 12px); padding: 10px 10px 8px; border-radius: 16px; }
  .wm-body { flex-direction: column; gap: 8px; }
  .wm-side { width: auto; max-height: 30%; flex: 0 0 auto; }
  .wm-inset { width: 118px; height: 88px; }
  .wm-legend { font-size: 12px; }
}
