:root {
  --paper: #f7f0e1;
  --paper2: #efe4cd;
  --ink: #3a3128;
  --soft: #7a6c5a;
  --line: #d9caa9;
  --green: #5f9a3e;
  --red: #c4473a;
  --gold: #d9a23a;
  --blue: #3f7ca8;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #a8dcf0; color: var(--ink);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { opacity: 0.45; cursor: default; }
svg { width: 18px; height: 18px; vertical-align: -4px; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-size: 18px; color: #2f4a3a; background: #a8dcf0; z-index: 50; padding: 24px; text-align: center; }

/* ---------- place names on the island */
.spot-label { position: absolute; left: 0; top: 0; pointer-events: auto; white-space: nowrap; padding: 5px 10px; border-radius: 14px;
  background: rgba(247, 240, 225, 0.92); border: 2px solid #8a7a5a; font-weight: 700; font-size: 13px; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.spot-label::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -5px; border: 5px solid transparent; border-top-color: #8a7a5a; border-bottom: 0; }
.spot-label.danger { border-color: var(--red); color: #8a2a20; }
.spot-label.danger::after { border-top-color: var(--red); }
.spot-label.here { background: #fff7d6; border-color: var(--gold); }
.spot-label.locked { opacity: 0.6; font-weight: 600; }

.pop { position: absolute; transform: translate(-50%, -100%); font-weight: 800; font-size: 15px; color: #fff; pointer-events: none;
  text-shadow: 0 1px 0 #000, 0 0 4px rgba(0,0,0,.6); animation: rise 1.4s ease-out forwards; white-space: nowrap; }
.pop.gain { color: #fff7c2; }
.pop.level { color: #ffd34a; font-size: 20px; }
.pop.heal { color: #9cf08a; }
.pop.dmg-foe { color: #ffffff; font-size: 18px; }
.pop.power { color: #ffb43a; font-size: 24px; }
.pop.dmg-me { color: #ff6a5a; font-size: 18px; margin-left: -26px; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -80%) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -100%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }

/* ---------- top bar */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px)); background: linear-gradient(rgba(47,74,58,.85), rgba(47,74,58,.55) 70%, transparent);
  color: #fff; font-weight: 700; z-index: 10; }
#hud .hp { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 90px; max-width: 200px; }
.hp-bar { position: relative; flex: 1; height: 16px; border-radius: 8px; background: rgba(0,0,0,.35); overflow: hidden; border: 1.5px solid rgba(255,255,255,.5); }
.hp-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ef7a6a, #c4473a); transition: width .2s; }
.hp-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; text-shadow: 0 1px 1px #000; }
#hud .stat { display: flex; align-items: center; gap: 3px; font-size: 14px; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
#hud .icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(247,240,225,.9); display: grid; place-items: center; }
#hud .icon svg { width: 22px; height: 22px; }

#toasts { position: fixed; top: calc(56px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); display: flex;
  flex-direction: column; align-items: center; gap: 5px; z-index: 12; pointer-events: none; width: 92%; }
.toast { background: rgba(58,49,40,.9); color: #fff; padding: 7px 14px; border-radius: 16px; font-size: 14px; font-weight: 600;
  transition: opacity .4s, transform .4s; text-align: center; }
.toast.gold { background: rgba(160,110,20,.95); }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---------- bottom card */
#sheet { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; z-index: 11; transition: transform .3s ease;
  background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.25);
  padding: 8px 10px calc(10px + var(--safe-bottom)); border-top: 3px solid #b89a6a; }
.sheet-top { display: flex; align-items: center; gap: 8px; }
#tabs { display: flex; flex: 1; gap: 2px; background: var(--paper2); border-radius: 12px; padding: 3px; }
#tabs button { flex: 1; padding: 8px 2px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--soft); position: relative; }
#tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.ping { position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(127,191,90,.35); } }
#sheet-body { max-height: min(27vh, 230px); overflow-y: auto; padding-top: 8px; touch-action: pan-y; overscroll-behavior: contain; }
body.mapview #sheet-body { max-height: 18vh; }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); font-weight: 600; margin-bottom: 6px; min-height: 26px; }
.status span { white-space: nowrap; }
.status .bar { flex: 1; }
.bar { height: 8px; border-radius: 4px; background: var(--paper2); overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; width: 0; background: linear-gradient(#8fd06a, #5f9a3e); }
.bar.foe .bar-fill { background: linear-gradient(#ef7a6a, #c4473a); }

.place-head { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.tag.safe { background: #dcefcf; color: #3f6a2a; }
.tag.wild { background: #f6d6d0; color: #8a2a20; }
.blurb { margin: 2px 0 8px; color: var(--soft); font-size: 13px; }
.jobs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.job { text-align: left; padding: 9px 10px; border-radius: 12px; background: #fff; border: 2px solid var(--line); display: flex; flex-direction: column; gap: 2px; min-height: 64px; }
.job b { font-size: 14px; display: flex; align-items: center; gap: 4px; }
.job.fight { border-color: #e2a59a; background: #fff6f3; }
.job.on { border-color: var(--green); background: #f1f9ea; }
.job .detail { font-size: 12px; color: var(--soft); }
.sub { font-size: 12px; color: var(--soft); }
.sub .short, .short { color: var(--red); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.25); }
.label-sm { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--soft); margin: 10px 0 5px; }
.label-sm svg { width: 14px; height: 14px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; touch-action: pan-x; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { white-space: nowrap; padding: 7px 11px; border-radius: 16px; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: 13px; }
.chip.danger { border-color: #e2a59a; color: #8a2a20; }
.chip.here { border-color: var(--gold); background: #fff7d6; }
.row2 { display: flex; gap: 7px; margin-top: 8px; }
.wide { flex: 1; padding: 10px; border-radius: 12px; background: #e9dfc8; border: 2px solid #c9b994; font-weight: 700; width: 100%; }
.wide.on { background: #fff7d6; border-color: var(--gold); }
.panel { margin-top: 7px; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 4px 10px; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--paper2); }
.line:last-child { border-bottom: 0; }
.mini { padding: 6px 12px; border-radius: 10px; background: var(--green); color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; }
.mini.ghost, .ghost { background: #e9dfc8; color: var(--ink); }
.mission { display: flex; gap: 8px; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 7px; }
.mission > div:first-child { flex: 1; }
.mission .bar { margin: 5px 0 3px; }
.mission.ready { border-color: var(--gold); background: #fffbea; }
.col { display: flex; flex-direction: column; gap: 5px; }
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.skill { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 7px 10px; font-size: 13px; }
.skill .lvl { float: right; font-weight: 800; color: var(--blue); }
.skill .bar { margin-top: 5px; }
.journal { display: flex; flex-direction: column; gap: 0; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 2px 10px; }
.journal .entry { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--paper2); font-size: 14px; }
.journal .entry:last-child { border-bottom: 0; }
.journal .when { flex: none; width: 70px; font-size: 12px; color: var(--soft); padding-top: 1px; }
.journal-btn { margin-top: 10px; }
.thought { position: absolute; left: 0; top: 0; pointer-events: none; max-width: 220px; padding: 5px 10px; border-radius: 14px; background: rgba(255,255,255,.93);
  border: 2px solid #b8d9a4; font-size: 13px; font-weight: 600; color: #3a3128; box-shadow: 0 2px 6px rgba(0,0,0,.15); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thought::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -5px; border: 5px solid transparent; border-top-color: #b8d9a4; border-bottom: 0; }

/* ---------- fights */
#sheet.fighting { border-top-color: var(--red); }
.fight-card { padding: 2px 0; }
.fight-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.fight-head .bar { flex: 1; height: 14px; border-radius: 7px; }
.fight-buttons { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; margin: 10px 0 6px; }
.big { position: relative; overflow: hidden; padding: 16px 6px; border-radius: 14px; font-weight: 800; font-size: 16px; color: #fff; }
.big span { position: relative; z-index: 1; }
.big.power { background: linear-gradient(#e8a03a, #c4721a); }
.big.eat { background: linear-gradient(#7fbf5a, #4f8a36); }
.big.flee { background: linear-gradient(#8a8a96, #5a5a66); }
.cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,.35); }
.odds { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 8px; color: #fff; }
.odds-easy { background: #5f9a3e; }
.odds-even { background: #c9a03a; }
.odds-risky { background: #d9772a; }
.odds-deadly { background: #b8322a; }

/* ---------- question cards */
#modal { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; background: rgba(20,30,25,.45); padding: 18px; }
#modal.open { display: flex; }
.card { background: var(--paper); border-radius: 18px; padding: 16px 16px 14px; width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
  border: 3px solid #b89a6a; max-height: 86vh; overflow-y: auto; animation: pop-in .18s ease-out; }
.card.fight { border-color: var(--red); }
.card h2 { margin: 0 0 6px; font-size: 20px; }
.card p { margin: 6px 0; }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choices button { padding: 13px; border-radius: 12px; background: #e9dfc8; border: 2px solid #c9b994; font-weight: 800; font-size: 16px; }
.choices button.primary { background: var(--green); border-color: #4f8a36; color: #fff; }
.card.fight .choices button.primary { background: var(--red); border-color: #9a2a20; }
.field { display: block; width: 100%; margin: 8px 0; padding: 12px; border-radius: 10px; border: 2px solid var(--line); font: inherit;
  background: #fff; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg.three { grid-template-columns: 1fr 1fr 1fr; }
.seg button { padding: 10px 4px; border-radius: 10px; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: 13px; }
.seg button.on { border-color: var(--green); background: #f1f9ea; }
@keyframes pop-in { from { transform: scale(.94); opacity: 0; } }

.auto-line { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--soft); margin-bottom: 6px; }
.auto-line { align-items: flex-start; }
.auto-line .dot-on { margin-top: 4px; }
.auto-line .txt { flex: 1; min-width: 0; line-height: 1.35; }
.auto-line b { color: #3f7a2a; }
.auto-line .left { display: block; font-size: 12px; color: var(--soft); margin-top: 2px; }
.rested { background: #eef4ff; border: 2px solid #a9c4ec; border-radius: 12px; padding: 6px 10px; margin-bottom: 7px; font-size: 13px; }
.rested b { color: #2f5f9e; margin-right: 4px; }
.dot-on { width: 9px; height: 9px; border-radius: 50%; background: #7fbf5a; box-shadow: 0 0 0 3px rgba(127,191,90,.3); flex: none; }

/* ---------- watch mode: the card slides away, a small Show button brings it back */
#sheet-handle { display: block; width: 100%; height: 16px; margin: -6px 0 2px; padding: 0; }
#sheet-handle i { display: block; width: 44px; height: 5px; border-radius: 3px; background: #cdbd99; margin: 0 auto; }
body.watching #sheet { transform: translateY(calc(100% + 10px)); }
#show-sheet { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 11; display: none;
  align-items: center; gap: 4px; padding: 8px 16px 8px 12px; border-radius: 20px; background: rgba(247,240,225,.94); border: 2px solid #b89a6a;
  font-weight: 800; box-shadow: 0 3px 10px rgba(0,0,0,.2); }
#show-sheet svg { width: 20px; height: 20px; }
body.watching #show-sheet { display: flex; }
.blurb { margin: 0 0 6px; }

/* ---------- on Auto, a question sits on the card instead of covering the island */
#autoask { display: none; background: #fff6f0; border: 2px solid #e2a59a; border-radius: 12px; padding: 7px 9px; margin-bottom: 7px; font-size: 14px; }
#autoask.open { display: block; }
#autoask .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mini.red { background: var(--red); }
.seg.four { grid-template-columns: 1fr 1fr; }
.seg.tight { display: flex; flex-wrap: wrap; gap: 4px; }
.seg.tight button { padding: 6px 8px; font-size: 12px; }
.prefs { display: flex; flex-direction: column; gap: 8px; }
.pref > span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 3px; }

/* ---------- the mission in front of you, and Auto saying what it does */
.goal { display: flex; align-items: center; gap: 7px; background: #fffbea; border: 2px solid #e6cf8a; border-radius: 12px; padding: 7px 9px; margin-bottom: 7px; }
.goal.ready { border-color: var(--gold); background: #fff3c4; }
.goal-text { flex: 1; min-width: 0; font-size: 14px; }
.goal-text .bar { margin: 4px 0 2px; }
.goal-text .sub { display: inline-block; }
.mini.gold { background: var(--gold); }
.auto-strip { display: flex; align-items: center; gap: 8px; background: #eaf6e2; border: 2px solid #7fbf5a; border-radius: 12px; padding: 7px 10px; margin-bottom: 7px; font-size: 14px; }
.auto-strip > div { flex: 1; }
.auto-strip b { color: #3f7a2a; }
.pinned { text-align: center; font-weight: 700; color: var(--gold); }
button.skill { text-align: left; width: 100%; display: block; }
.lvl-big { float: right; color: var(--blue); }
.spot-label.goal { background: #fff3c4; border-color: var(--gold); animation: beckon 1.2s ease-in-out infinite; }
.spot-label.goal::before { content: 'Mission'; display: block; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: #a0761a; }
@keyframes beckon { 50% { box-shadow: 0 0 0 5px rgba(217,162,58,.35); } }

@media (min-width: 900px) {
  #sheet { left: auto; right: 16px; bottom: 16px; border-radius: 18px; width: 420px; border: 3px solid #b89a6a; }
  #sheet-body { max-height: 60vh; }
}

/* monsters: the place card's list, the bestiary (his ask, 2026-10-22) */
.row-between { display: flex; align-items: center; justify-content: space-between; }
.mons { display: flex; flex-direction: column; gap: 4px; }
.mon { display: flex; align-items: center; gap: 8px; padding: 3px 6px 3px 3px; background: #fff; border-radius: 10px; border: 1px solid var(--paper2); }
.mon.boss { border-color: #d9a23a; background: #fff8e6; }
.mon img { width: 40px; height: 40px; flex: none; border-radius: 8px; background: #e6efd8; }
.mon-t { flex: 1; min-width: 0; line-height: 1.2; font-size: 13px; }
.mon-t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.beasts { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.beast { display: flex; flex-direction: column; align-items: center; padding: 4px 2px 5px; background: #fff; border-radius: 10px; border: 1px solid var(--paper2); color: var(--ink); }
.beast.boss { border-color: #d9a23a; background: #fff8e6; }
.beast img { width: 60px; height: 60px; border-radius: 8px; background: #e6efd8; }
.beast .nm { font-size: 11px; font-weight: 700; line-height: 1.15; text-align: center; margin-top: 2px; }
.beast .lv { font-size: 10px; color: var(--soft); }
.beast.unknown img, .beast-big.unknown img { filter: brightness(0) opacity(.3); background: transparent; }
.beast-big { display: flex; justify-content: center; }
.beast-big img { width: 140px; height: 140px; border-radius: 14px; background: #e6efd8; }
.fight-pic { width: 34px; height: 34px; border-radius: 8px; background: #e6efd8; flex: none; }

/* stories: the island's people and their steps (his ask, 2026-10-22) */
.job.story { border-color: #d9a23a; background: #fff8e6; }
.person .face { width: 40px; height: 40px; flex: none; border-radius: 50%; background: #e9dfc8; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: var(--ink); }
.steps { margin: 6px 0 4px; padding-left: 20px; font-size: 13px; line-height: 1.35; color: var(--soft); }
.steps li.done { text-decoration: line-through; opacity: .6; }
.steps li.now { color: var(--ink); font-weight: 700; }
.mission.story { border-color: #d9a23a; }
.card h3 { margin: 6px 0 2px; font-size: 16px; }
.person-mark { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--gold, #e9b949); color: #3a2a10; font-weight: 900; font-size: 18px;
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
