/* Farwander: parchment, ink and lamplight. Tokens mirror THEME in js/ui.js. */
@font-face { font-family: "Cinzel"; src: url(fonts/cinzel-500.woff2) format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Cinzel Decorative"; src: url(fonts/cinzel-decorative-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url(fonts/eb-garamond-400.woff2) format("woff2"); font-style: normal; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url(fonts/eb-garamond-400-italic.woff2) format("woff2"); font-style: italic; font-display: swap; }

:root {
  --bg: #1c1712;
  --surface: #efe3c6;
  --surface-2: #e4d4ae;
  --edge: #8a6a40;
  --ink: #2e2418;
  --muted: #6f5c44;
  --accent: #b8862e;
  --reward: #a8781c;
  --danger: #9b2c22;
  --shadow: #3b2a52;
  --hope: #e8a030;
  --text-s: 14px;
  --text-m: 17px;
  --text-l: 22px;
  --text-xl: 34px;
  --space: 8px;
  --serif: "EB Garamond", Georgia, "Times New Roman", serif;
  --caps: "Cinzel", Georgia, serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--serif); font-size: var(--text-m); -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
canvas#map { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; cursor: crosshair; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
b, .num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ icons */
.ico { display: inline-block; width: 1.1em; height: 1.1em; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; vertical-align: -0.15em; }
.ico-food { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 13c0-4 4-7 8-7s8 3 8 7v4H4z M3 18h18v2H3z M8 10h1v2H8z M12 9h1v2h-1z M15 10h1v2h-1z'/%3E%3C/svg%3E"); }
.ico-silver { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Ccircle cx='12' cy='12' r='5.5' fill='white'/%3E%3Cpath d='M12 7l1.5 3.5 3.5.3-2.7 2.3.9 3.4-3.2-2-3.2 2 .9-3.4L7 10.8l3.5-.3z'/%3E%3C/svg%3E"); }
.ico-book { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 5c3-1 6-1 8.5 1v14C9 18 6 18 3 19zM21 5c-3-1-6-1-8.5 1v14c2.5-2 5.5-2 8.5-1z'/%3E%3C/svg%3E"); }
.ico-pause { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14' rx='1'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1'/%3E%3C/svg%3E"); }
.ico-target { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2 6h-4zM12 22l-2-6h4zM2 12l6-2v4zM22 12l-6 2v-4z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.ico-fire { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2c1 4 5 6 5 11a5 5 0 0 1-10 0c0-3 2-4 2-7 1 1 2 2 2 4 1-2 2-5 1-8z M4 20l16-3v2L4 22z M20 20L4 17v2l16 3z'/%3E%3C/svg%3E"); }
.ico-flame { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1c1 5 7 8 7 14a7 7 0 0 1-14 0c0-4 3-6 3-10 2 1 3 3 3 6 2-3 2-6 1-10z'/%3E%3C/svg%3E"); }
.ico-shade { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 3a9 9 0 1 0 6 15A8 8 0 0 1 15 3z'/%3E%3C/svg%3E"); }
.ico-lock { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 10V8a6 6 0 0 1 12 0v2h1v12H5V10zm3 0h6V8a3 3 0 0 0-6 0z'/%3E%3C/svg%3E"); }
.ico-check { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2L4.8 12 3.4 13.4 9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E"); }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space); padding: calc(var(--space) + var(--safe-t)) calc(var(--space) * 1.5 + var(--safe-r)) var(--space) calc(var(--space) * 1.5 + var(--safe-l)); pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.hud-left, .hud-right { display: flex; gap: var(--space); align-items: center; flex-wrap: wrap; }
.hud-left { flex-direction: column; align-items: flex-start; gap: 4px; }
.meter, .stock, .clock, .doom { background: rgba(239, 227, 198, 0.9); border: 1px solid var(--edge); border-radius: 10px; padding: 4px 10px; box-shadow: 0 2px 8px rgba(30, 20, 10, 0.35); display: flex; align-items: center; gap: 8px; }
.meter-label { font-family: var(--caps); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); width: 54px; }
.pips { display: flex; gap: 2px; }
.pip { width: 13px; height: 16px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
#hopePips .pip { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1c1 5 7 8 7 14a7 7 0 0 1-14 0c0-4 3-6 3-10 2 1 3 3 3 6 2-3 2-6 1-10z'/%3E%3C/svg%3E"); color: var(--hope); }
#hopePips .pip.off { color: rgba(110, 90, 60, 0.28); }
#shadowPips .pip { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 3a9 9 0 1 0 6 15A8 8 0 0 1 15 3z'/%3E%3C/svg%3E"); color: var(--shadow); }
#shadowPips .pip.off { color: rgba(110, 90, 60, 0.2); }
.pip.pop { animation: pop 0.45s ease-out; }
@keyframes pop { 0% { transform: scale(1.8); } 100% { transform: scale(1); } }
html.rm .pip.pop { animation: none; }
.badge { font-family: var(--caps); font-size: 11px; letter-spacing: 0.08em; padding: 2px 6px; border-radius: 6px; }
.badge.weary { background: var(--shadow); color: #efe3c6; }
.stock .stat { display: inline-flex; align-items: center; gap: 4px; min-width: 44px; }
.stock .stat b { min-width: 2ch; }
.stock .ico-food { color: #8a5a2a; }
.stock .ico-silver { color: #6a7078; }
.stat.low b { color: var(--danger); }
.clock { padding: 3px 10px 3px 4px; }
.clock-text { display: flex; flex-direction: column; line-height: 1.05; }
.clock-text b { font-family: var(--caps); font-size: 15px; }
.clock-text span { font-size: 13px; color: var(--muted); font-style: italic; }
.doom { font-size: 13px; color: var(--shadow); font-style: italic; max-width: 190px; line-height: 1.15; }
.doom.urgent { color: #fff; background: rgba(90, 40, 80, 0.92); border-color: #3b2a52; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--edge); background: rgba(239, 227, 198, 0.92); display: grid; place-items: center; font-size: 20px; color: var(--ink); cursor: pointer; box-shadow: 0 2px 8px rgba(30, 20, 10, 0.35); }
.icon-btn:hover { background: #fff5dc; }
.icon-btn.big { width: 48px; height: 48px; }

#bottom { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space); padding: var(--space) calc(var(--space) * 1.5 + var(--safe-r)) calc(var(--space) * 1.5 + var(--safe-b)) calc(var(--space) * 1.5 + var(--safe-l)); pointer-events: none; z-index: 10; }
#bottom > * { pointer-events: auto; }
#party { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; max-width: 60%; }
.member { position: relative; width: 58px; border-radius: 10px; background: rgba(239, 227, 198, 0.92); border: 1px solid var(--edge); box-shadow: 0 2px 8px rgba(30, 20, 10, 0.35); display: flex; flex-direction: column; align-items: center; padding: 2px 2px 3px; cursor: pointer; }
.member canvas { width: 48px; height: 48px; }
.member .mname { font-size: 11px; font-family: var(--caps); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 54px; }
.member.ready::after { content: ""; position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--hope); box-shadow: 0 0 6px var(--hope); }
.member.spent { opacity: 0.8; }
.member:hover { background: #fff5dc; }
#place { font-style: italic; color: #f4e8cc; text-shadow: 0 1px 3px #000, 0 0 8px #000; font-size: var(--text-s); text-align: center; flex: 1; padding-bottom: 12px; pointer-events: none; }
.bottom-right { display: flex; gap: var(--space); align-items: center; }
.camp-btn { height: 52px; min-width: 104px; border-radius: 26px; border: 1px solid #6b4a24; background: linear-gradient(#e2a64a, #b8742a); color: #2a1a08; font-family: var(--caps); font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px; cursor: pointer; box-shadow: 0 3px 10px rgba(30, 20, 10, 0.45); }
.camp-btn.armed { background: linear-gradient(#f6d27a, #d89a3a); }
.camp-btn:disabled { filter: grayscale(0.8); opacity: 0.6; }

/* ------------------------------------------------------------ toasts + banner */
#toasts { position: fixed; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 40; pointer-events: none; width: min(92vw, 520px); }
.toast { background: rgba(28, 23, 18, 0.88); color: #f2e6c8; border: 1px solid rgba(184, 134, 46, 0.6); padding: 7px 14px; border-radius: 10px; font-size: var(--text-s); text-align: center; animation: toastIn 0.3s ease-out; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4); }
.toast.reward { border-color: var(--hope); color: #ffe7b0; }
.toast.danger { border-color: #8a4ab0; color: #e4d0ff; }
.toast.out { opacity: 0; transition: opacity 0.5s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
#banner { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); text-align: center; z-index: 30; pointer-events: none; color: #fbf1d6; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85), 0 0 24px rgba(0, 0, 0, 0.6); width: 92vw; animation: bannerIn 0.9s ease-out; }
#banner.fade { opacity: 0; transition: opacity 1.2s; }
.banner-kind { font-family: var(--caps); letter-spacing: 0.3em; font-size: 13px; text-transform: uppercase; opacity: 0.85; }
.banner-title { font-family: "Cinzel Decorative", var(--caps); font-size: clamp(28px, 6vw, 54px); line-height: 1.1; margin: 4px 0; }
.banner-sub { font-style: italic; font-size: var(--text-m); }
@keyframes bannerIn { from { opacity: 0; letter-spacing: 0.08em; } }
html.rm #banner { animation: none; }

/* ------------------------------------------------------------ event card */
#cardWrap { touch-action: pan-y; position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; background: radial-gradient(ellipse at center, rgba(20, 14, 8, 0.25), rgba(20, 14, 8, 0.55)); padding: calc(var(--space) * 2); padding-top: calc(70px + var(--safe-t)); }
#card { position: relative; width: min(560px, 100%); max-height: min(86vh, 900px); overflow-y: auto; background: var(--surface); border-radius: 6px; padding: 20px 24px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), inset 0 0 60px rgba(160, 120, 60, 0.25); border: 1px solid var(--edge); outline: 4px double rgba(138, 106, 64, 0.5); outline-offset: -10px; animation: cardIn 0.35s ease-out; -webkit-user-select: text; user-select: text; touch-action: pan-y; }
#card.danger { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 0 70px rgba(120, 30, 20, 0.28); }
#card.wonder { box-shadow: 0 10px 50px rgba(255, 200, 100, 0.35), inset 0 0 70px rgba(200, 150, 60, 0.3); }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
html.rm #card { animation: none; }
.card-art { float: right; margin: 0 0 8px 14px; width: 112px; height: 112px; border-radius: 50%; background: #d9c498; border: 3px solid var(--edge); overflow: hidden; box-shadow: 0 2px 8px rgba(40, 24, 10, 0.35); }
.card-art canvas { width: 100%; height: 100%; display: block; }
#card h2 { font-family: var(--caps); font-weight: 500; font-size: var(--text-l); margin: 4px 0 10px; line-height: 1.2; }
.card-text { line-height: 1.45; font-size: var(--text-m); }
.card-text blockquote { margin: 10px 0 4px; padding: 8px 12px; border-left: 3px solid var(--accent); background: rgba(184, 134, 46, 0.1); font-style: italic; }
.card-text .tale { display: block; font-size: var(--text-s); color: var(--muted); font-family: var(--caps); letter-spacing: 0.03em; margin-bottom: 8px; }
.card-text .result { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(138, 106, 64, 0.4); }
.card-options { clear: both; display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.opt { text-align: left; min-height: 48px; padding: 9px 12px 9px 44px; border-radius: 8px; border: 1px solid var(--edge); background: linear-gradient(#f7eed8, #eadbb6); cursor: pointer; position: relative; line-height: 1.25; }
.opt:hover:not(:disabled) { background: #fff7e2; }
.opt .key { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--edge); display: grid; place-items: center; font-family: var(--caps); font-size: 13px; background: #fff8e6; }
.opt .hint { display: block; font-size: var(--text-s); color: var(--muted); font-style: italic; margin-top: 2px; }
.opt .req { display: inline-block; margin-left: 6px; font-size: 12px; font-family: var(--caps); padding: 1px 6px; border-radius: 5px; color: #fff; vertical-align: 1px; }
.opt .odds-mini { float: right; font-family: var(--caps); font-size: 13px; color: var(--muted); margin-left: 8px; }
.opt:disabled { opacity: 0.55; cursor: not-allowed; }
.opt:disabled .hint::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 4px; background: currentColor; vertical-align: -1px; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 10V8a6 6 0 0 1 12 0v2h1v12H5V10zm3 0h6V8a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 10V8a6 6 0 0 1 12 0v2h1v12H5V10zm3 0h6V8a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat; }
.opt.primary { background: linear-gradient(#e9b660, #c98a36); border-color: #7a5424; color: #2a1a08; font-family: var(--caps); }

/* dice test */
.test { clear: both; margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: rgba(120, 90, 50, 0.1); border: 1px dashed var(--edge); }
.test-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--caps); }
.odds { font-size: var(--text-l); color: var(--reward); font-variant-numeric: tabular-nums; }
.test-parts { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.part { font-size: 13px; padding: 2px 7px; border-radius: 10px; background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(138, 106, 64, 0.4); }
.part.neg { color: var(--shadow); border-color: var(--shadow); }
.dice { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 38px; }
.die { width: 36px; height: 36px; border-radius: 7px; background: #fbf5e6; border: 1.5px solid #7a5a34; display: grid; place-items: center; font-family: var(--caps); font-size: 18px; box-shadow: 0 2px 0 #7a5a34; }
.die.hit { background: linear-gradient(#ffe9a8, #e8b048); border-color: #8a5a10; box-shadow: 0 2px 0 #8a5a10, 0 0 10px rgba(255, 200, 80, 0.8); }
.die.auto { background: linear-gradient(#d8e8ff, #9ab8e8); }
.die.rolling { animation: jiggle 0.12s infinite alternate; }
@keyframes jiggle { from { transform: rotate(-12deg) translateY(-2px); } to { transform: rotate(12deg) translateY(2px); } }
html.rm .die.rolling { animation: none; }
.test-abilities { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { min-height: 40px; border-radius: 20px; border: 1px solid var(--edge); background: #fbf2dc; padding: 4px 12px; cursor: pointer; font-size: var(--text-s); }
.chip-btn:hover { background: #fff; }
.chip-btn b { font-family: var(--caps); font-weight: 500; }
.outcome { font-family: var(--caps); font-size: var(--text-l); margin: 8px 0 0; }
.outcome.ok { color: #3c6a2a; }
.outcome.bad { color: var(--danger); }

/* ------------------------------------------------------------ screens */
.screen { touch-action: pan-y; position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); }
#loading { background: radial-gradient(ellipse at center, #3a2c1c, #140f0a); color: #efe3c6; z-index: 60; }
.loading-inner { text-align: center; width: min(420px, 90vw); }
.quill { height: 4px; background: rgba(239, 227, 198, 0.2); border-radius: 2px; overflow: hidden; margin: 18px 0 10px; }
.quill-bar { height: 100%; width: 0; background: linear-gradient(90deg, #b8862e, #f0c870); transition: width 0.2s; }
.loading-text { font-style: italic; opacity: 0.85; }
#title { background: radial-gradient(ellipse at center, rgba(20, 14, 8, 0) 30%, rgba(20, 14, 8, 0.6)); }
.title-inner { text-align: center; color: #fbf1d6; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 0, 0, 0.6); }
.wordmark { font-family: "Cinzel Decorative", var(--caps); font-size: clamp(48px, 11vw, 112px); line-height: 1; letter-spacing: 0.02em; color: #fbe8b8; }
.wordmark.small { font-size: 40px; }
.subtitle { font-style: italic; font-size: clamp(17px, 2.6vw, 24px); margin: 10px 0 26px; }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: stretch; width: min(320px, 86vw); margin: 0 auto; }
.btn { min-height: 48px; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--edge); background: linear-gradient(#f7eed8, #e6d4aa); color: var(--ink); font-family: var(--caps); font-size: 16px; cursor: pointer; text-shadow: none; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.btn:hover { background: #fff7e2; }
.btn.primary { background: linear-gradient(#ecbd66, #c98a36); border-color: #7a5424; color: #2a1a08; }
.btn.primary:hover { background: linear-gradient(#f6cf80, #d99a46); }
.btn.big { font-size: 20px; min-height: 56px; padding: 10px 34px; }
.btn.small { min-height: 44px; font-size: 14px; padding: 6px 12px; }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.title-foot { margin-top: 22px; opacity: 0.85; }
.hint { font-style: italic; color: var(--muted); font-size: var(--text-s); }
.title-inner .hint { color: #f0e2c0; }
.hint.center { text-align: center; margin-top: 16px; }
a.back { position: fixed; left: calc(12px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); color: #f0e2c0; text-decoration: none; font-size: var(--text-s); text-shadow: 0 1px 4px #000; z-index: 55; padding: 10px 4px; }
a.back:hover { color: var(--hope); }
a.back.in-game { top: auto; bottom: auto; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); font-size: 12px; z-index: 11; opacity: 0.8; padding: 4px; }

.sheet-inner { position: relative; width: min(540px, 100%); background: var(--surface); border-radius: 6px; padding: 22px 26px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 0 60px rgba(160, 120, 60, 0.25); border: 1px solid var(--edge); outline: 4px double rgba(138, 106, 64, 0.5); outline-offset: -10px; margin: auto; -webkit-user-select: text; user-select: text; }
.sheet-inner.wide { width: min(820px, 100%); }
#prep, #hearth, #journal, #pause, #settings, #over { background: rgba(20, 14, 8, 0.72); align-items: flex-start; }
.sheet-inner h1 { font-family: var(--caps); font-weight: 500; font-size: 28px; text-align: center; margin: 4px 0 14px; }
.sheet-inner h3 { font-family: var(--caps); font-weight: 500; font-size: 16px; letter-spacing: 0.06em; margin: 16px 0 8px; color: var(--muted); }
.lede { font-style: italic; text-align: center; }
section { margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; font-size: var(--text-s); color: var(--muted); gap: 4px; }
.field input { font: inherit; font-size: 18px; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--edge); background: #fffaf0; color: var(--ink); min-height: 44px; width: 190px; }
.actions { display: flex; justify-content: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.companions { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.comp { display: grid; grid-template-columns: 52px 1fr; gap: 2px 10px; text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--edge); background: #f6ecd4; cursor: pointer; min-height: 44px; position: relative; }
.comp canvas { grid-row: span 3; width: 48px; height: 48px; }
.comp .cn { font-family: var(--caps); font-size: 15px; }
.comp .ct { font-size: 13px; color: var(--muted); font-style: italic; }
.comp .ca { font-size: 12px; }
.comp.sel { background: #fff3cf; border-color: var(--reward); box-shadow: 0 0 0 2px var(--reward); }
.comp.sel::after, .boon.owned.on::after { content: ""; position: absolute; top: 8px; right: 8px; width: 18px; height: 18px; background: var(--reward); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2L4.8 12 3.4 13.4 9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2L4.8 12 3.4 13.4 9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E") center / contain no-repeat; }
.comp.locked { opacity: 0.55; cursor: not-allowed; }
.aspects { display: flex; gap: 6px; flex-wrap: wrap; }
.asp { font-size: 11px; font-family: var(--caps); padding: 0 5px; border-radius: 4px; color: #fff; }
.segmented { display: inline-flex; border: 1px solid var(--edge); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.segmented button { min-height: 44px; padding: 6px 14px; border: 0; border-right: 1px solid var(--edge); background: #f6ecd4; cursor: pointer; font-family: var(--caps); font-size: 14px; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-checked="true"] { background: var(--reward); color: #fff; }
.segmented button:disabled { opacity: 0.45; cursor: not-allowed; }
.boons { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.boon { position: relative; text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--edge); background: #f6ecd4; min-height: 44px; cursor: pointer; }
.boon .bn { font-family: var(--caps); font-size: 15px; display: block; padding-right: 22px; }
.boon .bt { font-size: 13px; color: var(--muted); font-style: italic; }
.boon .price { display: block; margin-top: 4px; font-family: var(--caps); color: var(--reward); font-size: 14px; }
.boon.owned .price { color: #3c6a2a; }
.boon.owned.on { background: #fff3cf; border-color: var(--reward); }
.boon.locked, .boon:disabled { opacity: 0.55; cursor: not-allowed; }
.renown { text-align: center; font-family: var(--caps); font-size: 18px; margin-bottom: 8px; }
.renown b { color: var(--reward); }
.journeys { display: flex; flex-direction: column; gap: 4px; font-size: 14px; max-height: 220px; overflow-y: auto; }
.journey { display: flex; justify-content: space-between; gap: 8px; padding: 4px 8px; border-bottom: 1px dotted var(--edge); }
.journey .won { color: #3c6a2a; font-family: var(--caps); }
.journey .lost { color: var(--danger); font-family: var(--caps); }
.tabs { display: flex; gap: 4px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.tab { min-height: 44px; padding: 6px 16px; border: 1px solid var(--edge); border-radius: 8px 8px 0 0; background: #e8d9b4; cursor: pointer; font-family: var(--caps); font-size: 15px; }
.tab[aria-selected="true"] { background: #fff3cf; border-bottom-color: #fff3cf; }
.tab-body { min-height: 200px; }
.tale-block { margin-bottom: 14px; }
.tale-block h4 { font-family: var(--caps); font-weight: 500; margin: 0 0 4px; display: flex; justify-content: space-between; gap: 8px; }
.tale-block h4 span { font-size: 14px; color: var(--muted); }
.tale-block .done { color: #3c6a2a; }
.verse { margin: 3px 0; padding-left: 12px; border-left: 2px solid rgba(184, 134, 46, 0.5); font-style: italic; font-size: 15px; }
.verse.missing { color: rgba(110, 90, 60, 0.55); border-left-color: rgba(110, 90, 60, 0.25); letter-spacing: 0.3em; }
.unlock-note { font-size: 13px; color: var(--muted); }
.fellow { display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; padding: 8px 0; border-bottom: 1px dotted var(--edge); }
.fellow canvas { width: 52px; height: 52px; grid-row: span 3; }
.fellow .fn { font-family: var(--caps); }
.fellow .fp, .fellow .fa { font-size: 14px; }
.fellow .fa b { font-family: var(--caps); font-weight: 500; }
.relics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; margin-top: 8px; }
.relic { display: grid; grid-template-columns: 36px 1fr; gap: 0 8px; align-items: center; font-size: 13px; }
.relic canvas { width: 32px; height: 32px; grid-row: span 2; }
.relic .rn { font-family: var(--caps); font-size: 14px; }
.logline { font-size: 15px; padding: 3px 0; border-bottom: 1px dotted rgba(138, 106, 64, 0.35); }
.logline .d { font-family: var(--caps); color: var(--muted); font-size: 13px; margin-right: 8px; }
.settings { display: flex; flex-direction: column; gap: 14px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.set-row label { font-family: var(--caps); font-size: 15px; }
.slider { display: flex; align-items: center; gap: 10px; }
.slider input[type=range] { width: 170px; accent-color: var(--reward); height: 32px; }
.slider .val { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
.toggle { width: 60px; height: 34px; border-radius: 17px; border: 1px solid var(--edge); background: #d9c9a4; position: relative; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); transition: left 0.15s; }
.toggle[aria-checked="true"] { background: var(--reward); }
.toggle[aria-checked="true"]::after { left: 29px; }
.over-kind { text-align: center; font-family: var(--caps); letter-spacing: 0.3em; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.sum { text-align: center; padding: 8px; border-radius: 8px; background: rgba(184, 134, 46, 0.12); }
.sum b { display: block; font-family: var(--caps); font-size: 24px; color: var(--reward); }
.sum span { font-size: 13px; color: var(--muted); }
.unlocks { text-align: center; margin-bottom: 12px; }
.unlocks p { margin: 4px 0; font-family: var(--caps); color: #3c6a2a; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 640px) {
  :root { --text-m: 16px; --text-l: 20px; }
  .meter { padding: 2px 8px; }
  .meter-label { display: none; }
  .pip { width: 11px; height: 14px; }
  .doom { max-width: 120px; font-size: 12px; }
  .hud-right { justify-content: flex-end; max-width: 50%; }
  .clock-text span { font-size: 12px; }
  #cardWrap { align-items: flex-end; padding: 0; }
  #card { width: 100%; max-height: 78vh; border-radius: 14px 14px 0 0; padding: 16px 16px calc(14px + var(--safe-b)); outline-offset: -8px; }
  .card-art { width: 84px; height: 84px; }
  .member { width: 50px; }
  .member canvas { width: 40px; height: 40px; }
  #party { max-width: 64%; }
  .camp-btn { min-width: 60px; padding: 0 12px; }
  .camp-btn span { display: none; }
  #place { display: none; }
  .sheet-inner { padding: 18px 16px; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  a.back.in-game { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #card { max-height: 92vh; }
  #cardWrap { padding-top: 8px; }
}
