/* Trophy: Zachodnie Marchie. Ink, bone and forest dark. */
:root {
  --bg: #0b0d0a;
  --bg2: #10130d;
  --panel: #151912;
  --panel2: #1b2017;
  --panel3: #232a1d;
  --line: rgba(220, 205, 165, 0.12);
  --line2: rgba(220, 205, 165, 0.22);
  --bone: #e9e0c7;
  --bone2: #cfc5a9;
  --dim: #9d957f;
  --muted: #7a7462;
  --gold: #c9a24a;
  --gold-hi: #e8c76f;
  --gold-lo: #7d6428;
  --olive: #969c6c;
  --blood: #962f22;
  --blood-hi: #cf5339;
  --sea: #6f8fa8;
  --ink: #060705;
  --r: 10px;
  --display: 'Pirata One', 'UnifrakturMaguntia', serif;
  --serif: 'EB Garamond', Garamond, Georgia, serif;
  --caps: 'Cormorant SC', 'EB Garamond', serif;
  --ds: 50px;
  font-size: 16px;
}
@media (min-width: 2300px) { :root { font-size: 17px; --ds: 56px; } }
@media (min-width: 3000px) { :root { font-size: 19px; --ds: 62px; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--bone); }
body {
  font-family: var(--serif); font-size: 1.02rem; line-height: 1.4;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
body::before { /* paper grain */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: url('/assets/grain.jpg') center / cover; mix-blend-mode: screen; opacity: 0.05;
}
body::after { /* vignette + canopy light */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% -10%, rgba(150, 156, 108, 0.13), transparent 70%),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55));
}
#app { position: relative; z-index: 1; height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: rgba(201, 162, 74, 0.35); }
h1, h2, h3, h4 { margin: 0; font-weight: 400; }
h2 { font-family: var(--display); font-size: 1.9rem; letter-spacing: 0.01em; color: var(--bone); }
h3 { font-family: var(--caps); font-weight: 700; font-size: 1.12rem; letter-spacing: 0.04em; color: var(--bone2); }
h4 { font-family: var(--caps); font-weight: 700; font-size: 1rem; letter-spacing: 0.06em; color: var(--gold); display: flex; gap: 0.5em; align-items: baseline; margin-bottom: 0.4rem; }
p { margin: 0.3rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.pad { padding: 1rem; }
.danger { color: var(--blood-hi) !important; }
.error { color: var(--blood-hi); }
.hint { color: var(--dim); font-size: 0.92rem; margin: 0.2rem 0 0.5rem; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3324; border-radius: 10px; border: 2px solid var(--bg2); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- controls ---------- */
.field {
  width: 100%; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 7px;
  padding: 0.38rem 0.6rem; color: var(--bone); transition: border-color 0.15s, background 0.15s;
}
.field::placeholder { color: #5f5a4c; font-style: italic; }
.field:hover:not(:disabled) { border-color: var(--line2); }
.field:focus { outline: none; border-color: var(--gold-lo); background: rgba(0, 0, 0, 0.42); }
.field:disabled { opacity: 0.85; background: transparent; border-color: transparent; color: var(--bone2); }
textarea.field { resize: vertical; min-height: 2.4rem; line-height: 1.35; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 1.8rem; }
select.field option { background: var(--panel2); }
.field.xs { padding: 0.15rem 0.4rem; font-size: 0.85rem; width: auto; }
.lbl { display: block; font-family: var(--caps); font-weight: 700; letter-spacing: 0.05em; font-size: 0.9rem; color: var(--dim); margin: 0.55rem 0 0.2rem; }
.lbl > .field { margin-top: 0.2rem; font-family: var(--serif); letter-spacing: 0; font-size: 1rem; font-weight: 400; }
.chk { display: flex; gap: 0.5rem; align-items: center; color: var(--bone2); font-size: 0.95rem; margin: 0.4rem 0; cursor: pointer; }
.chk input { accent-color: var(--gold); width: 16px; height: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  border-radius: 8px; padding: 0.5rem 0.9rem; border: 1px solid var(--line2); background: var(--panel2);
  color: var(--bone); font-family: var(--caps); font-weight: 700; letter-spacing: 0.04em; font-size: 0.98rem;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, box-shadow 0.15s; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--gold-lo); background: var(--panel3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.xs { padding: 0.22rem 0.55rem; font-size: 0.86rem; border-radius: 6px; }
.btn-gold { background: linear-gradient(180deg, #d7b25a, #a9842f); border-color: #e5c56f; color: #1a1406; box-shadow: 0 1px 0 rgba(255, 240, 200, 0.4) inset, 0 6px 18px -8px rgba(201, 162, 74, 0.6); }
.btn-gold:hover:not(:disabled) { background: linear-gradient(180deg, #e3c06a, #b38d36); border-color: #f1d483; }
.btn-dark { background: linear-gradient(180deg, #1a1a17, #0b0b09); border-color: #3a362c; }
.btn-dark:hover:not(:disabled) { border-color: var(--blood-hi); box-shadow: 0 0 0 1px rgba(207, 83, 57, 0.25), 0 8px 20px -10px rgba(207, 83, 57, 0.6); }
.btn-light { background: linear-gradient(180deg, #efe6cf, #cfc3a1); color: #1d1a12; border-color: #f4ecd6; }
.btn-light:hover:not(:disabled) { background: linear-gradient(180deg, #f7efda, #dccfad); }
.btn-blood { background: linear-gradient(180deg, #b23d2b, #7d2418); border-color: #d05a42; color: #fbe9e3; }
.btn-ghost { background: transparent; }
.btn-big { width: 100%; padding: 0.75rem 1rem; font-size: 1.12rem; margin-top: 0.8rem; }
.btn-roll { width: 100%; margin-top: 0.55rem; padding: 0.62rem; font-size: 1.08rem; background: linear-gradient(180deg, #2a301f, #1a1e14); border-color: var(--gold-lo); color: var(--gold-hi); }
.btn-roll:hover:not(:disabled) { background: linear-gradient(180deg, #343c27, #1f2418); border-color: var(--gold); box-shadow: 0 8px 22px -12px rgba(201, 162, 74, 0.7); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.5rem 0; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--dim); text-decoration: none; }
.icon-btn:hover:not(:disabled) { color: var(--bone); background: var(--panel3); border-color: var(--line); }
.icon-btn.xs { width: 26px; height: 26px; border-radius: 6px; font-size: 0.85rem; }
.icon-btn:disabled { opacity: 0.35; }
.link { background: none; border: none; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; padding: 0; font-size: 0.9rem; }
.link:hover { color: var(--gold-hi); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: rgba(0, 0, 0, 0.25); }
.step { width: 30px; height: 30px; border: none; background: transparent; color: var(--dim); font-size: 1.1rem; line-height: 1; }
.step:hover:not(:disabled) { background: var(--panel3); color: var(--bone); }
.step:disabled { opacity: 0.3; }
.step-val { min-width: 2.1rem; text-align: center; font-family: var(--caps); font-weight: 700; font-size: 1.15rem; color: var(--bone); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: transparent; color: var(--dim); padding: 0.28rem 0.7rem; font-family: var(--caps); font-weight: 700; letter-spacing: 0.04em; }
.seg button.on { background: var(--gold); color: #1a1406; }
.seg button:not(.on):hover { color: var(--bone); background: var(--panel3); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; border: 2px solid; background: #0d0f0b; font-family: var(--display); line-height: 1; object-fit: cover; flex: none; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin: 0.35rem 0; color: var(--bone2); }
.row-between span { display: inline-flex; gap: 0.4rem; align-items: center; }
.tiny-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.45rem; font-size: 0.9rem; }

/* pip glyphs */
.pip { flex: none; vertical-align: middle; }
.pip-light rect { fill: #ece3ca; stroke: #b7ab88; stroke-width: 3; }
.pip-light circle { fill: #15120c; }
.pip-dark rect { fill: #121210; stroke: #4a4537; stroke-width: 3; }
.pip-dark circle { fill: #e3d8bb; }
.pip-hi rect { stroke: var(--gold-hi); stroke-width: 7; }
.pip-hit rect { stroke: var(--blood-hi); stroke-width: 7; }
.pip-dark.pip-hit circle { fill: #ff8c70; }

/* ---------- login ---------- */
.login { position: relative; height: 100%; display: grid; place-items: center; overflow: hidden; }
.login-bg { position: absolute; inset: 0; background: url('/assets/map-kalduhr-small.jpg') center / cover; filter: brightness(0.32) saturate(0.85); }
.login-bg::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(11, 13, 10, 0.25), rgba(11, 13, 10, 0.95) 75%); }
.login-card { position: relative; width: min(440px, 92vw); padding: 2.4rem 2.4rem 2rem; background: linear-gradient(180deg, rgba(23, 27, 19, 0.92), rgba(12, 14, 10, 0.96)); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 40px 80px -30px #000, 0 0 0 1px rgba(0, 0, 0, 0.6); }
.login-card::before { content: ''; position: absolute; inset: 7px; border: 1px solid rgba(201, 162, 74, 0.18); border-radius: 9px; pointer-events: none; }
.kicker { font-family: var(--caps); font-weight: 700; letter-spacing: 0.2em; color: var(--gold); font-size: 0.85rem; text-transform: uppercase; margin: 0; }
.login-card h1 { font-family: var(--display); font-size: 3.2rem; line-height: 1; margin: 0.35rem 0 0.4rem; color: var(--bone); text-shadow: 0 2px 30px rgba(201, 162, 74, 0.25); }
.login-sub { color: var(--dim); font-style: italic; margin-bottom: 1rem; }
.loading { height: 100%; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--dim); font-style: italic; }

/* ---------- top bar ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { flex: none; height: 62px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: 0 1rem; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(20, 24, 17, 0.95), rgba(11, 13, 10, 0.9)); backdrop-filter: blur(6px); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; background: url('/assets/favicon.svg') center / contain no-repeat; }
.brand-kicker { font-family: var(--caps); font-weight: 700; letter-spacing: 0.32em; font-size: 0.72rem; color: var(--gold); display: block; line-height: 1; }
.brand h1 { font-family: var(--display); font-size: 1.6rem; line-height: 1.05; white-space: nowrap; }
.sys-badge { font-family: var(--caps); font-weight: 700; letter-spacing: 0.08em; font-size: 0.78rem; padding: 0.1rem 0.5rem; border-radius: 99px; border: 1px solid; }
.sys-badge.gold { color: var(--gold-hi); border-color: var(--gold-lo); }
.sys-badge.dark { color: #d8cfb6; border-color: #4c463a; background: #0a0a09; }
.mode-seg button { padding: 0.18rem 0.6rem; font-size: 0.85rem; }
.tabs { display: flex; gap: 0.25rem; }
.tab { border: 1px solid transparent; background: transparent; color: var(--dim); padding: 0.4rem 0.95rem; border-radius: 8px; font-family: var(--caps); font-weight: 700; letter-spacing: 0.05em; font-size: 1.04rem; position: relative; }
.tab:hover { color: var(--bone); }
.tab.on { color: var(--bone); background: var(--panel2); border-color: var(--line); }
.tab.on::after { content: ''; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; background: var(--gold); border-radius: 2px; }
.tab.alert { color: var(--blood-hi); }
.tab.alert::before { content: ''; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--blood-hi); box-shadow: 0 0 10px var(--blood-hi); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.top-right { display: flex; align-items: center; gap: 0.4rem; justify-content: flex-end; min-width: 0; }
.online { display: flex; gap: 0.3rem; margin-right: 0.4rem; overflow: hidden; }
.who-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.12rem 0.55rem 0.12rem 0.15rem; border-radius: 99px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); font-size: 0.88rem; white-space: nowrap; }
.who-chip.gm { border-color: var(--gold-lo); }
.safety-wrap { position: relative; }
.safety-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 0.6rem; display: grid; gap: 0.3rem; min-width: 190px; box-shadow: 0 20px 40px -10px #000; }
.safety-menu .btn { justify-content: flex-start; }

/* ---------- layout ---------- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 23vw) minmax(0, 1fr) minmax(370px, 23vw); gap: 0; }
.col { min-height: 0; overflow: auto; position: relative; }
.col-left { border-right: 1px solid var(--line); background: linear-gradient(90deg, rgba(0, 0, 0, 0.25), transparent); }
.col-right { border-left: 1px solid var(--line); background: linear-gradient(270deg, rgba(0, 0, 0, 0.25), transparent); display: flex; flex-direction: column; gap: 0.75rem; padding: 0.75rem; }
.col-center { padding: 1rem 1.25rem; display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.panel-head h3 { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.panel-head h3 span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combat-banner { position: sticky; bottom: 0; margin-top: auto; align-self: center; display: flex; gap: 0.5rem; align-items: center; background: linear-gradient(180deg, #2a110c, #170806); border: 1px solid var(--blood); color: #f3d7cd; padding: 0.45rem 1rem; border-radius: 99px; box-shadow: 0 10px 30px -10px rgba(207, 83, 57, 0.6); }

/* ---------- minimap ---------- */
.minimap { flex: none; }
.minimap-view { display: block; position: relative; width: 100%; padding: 0; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; background: #0a0b07; cursor: zoom-in; box-shadow: 0 10px 30px -16px #000; }
.minimap-view img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s ease, filter 0.3s; filter: saturate(0.95); }
.minimap-view:hover img { transform: scale(1.03); filter: saturate(1.1) brightness(1.05); }
.mini-tok { position: absolute; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%, -50%); border: 1.5px solid #0b0b08; background: var(--gold); box-shadow: 0 0 0 1.5px rgba(233, 224, 199, 0.75); }
.mini-tok.k-enemy { background: var(--blood-hi); }
.mini-tok.k-npc { background: var(--sea); }
.mini-tok.k-pin { background: var(--bone); width: 7px; height: 7px; }
.minimap-cta { position: absolute; right: 8px; bottom: 7px; font-size: 0.78rem; font-family: var(--caps); font-weight: 700; letter-spacing: 0.06em; color: var(--bone); background: rgba(6, 7, 5, 0.72); padding: 0.1rem 0.5rem; border-radius: 99px; opacity: 0; transition: opacity 0.2s; }
.minimap-view:hover .minimap-cta { opacity: 1; }

/* ---------- map modal ---------- */
.map-modal { position: fixed; inset: 0; z-index: 40; display: grid; grid-template-columns: 1fr 330px; background: rgba(4, 5, 3, 0.94); animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } }
.map-stage { position: relative; overflow: hidden; cursor: grab; touch-action: none; background: radial-gradient(ellipse at center, #141810, #060705); }
.map-stage:active { cursor: grabbing; }
.map-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 40px 120px -20px #000; }
.map-inner > img { width: 100%; height: 100%; display: block; user-select: none; pointer-events: none; }
.tok { position: absolute; transform-origin: center; display: flex; flex-direction: column; align-items: center; cursor: grab; z-index: 2; }
.tok-face { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-family: var(--caps); font-weight: 700; font-size: 1.05rem; color: #1a1406; background: var(--tc, var(--gold)); border: 2px solid #0c0d09; box-shadow: 0 0 0 2px rgba(233, 224, 199, 0.9), 0 6px 14px -4px rgba(0, 0, 0, 0.9); user-select: none; }
.tok.k-enemy .tok-face, .tok-chip.k-enemy .tok-face { background: radial-gradient(circle at 35% 30%, #d55b42, #7d2418); color: #fde9e2; }
.tok.k-npc .tok-face, .tok-chip.k-npc .tok-face { background: radial-gradient(circle at 35% 30%, #8fb0c8, #4b6a82); color: #0b1218; }
.tok.k-pin .tok-face, .tok-chip.k-pin .tok-face { background: #ece3ca; color: #1b170e; width: 30px; height: 30px; font-size: 0.95rem; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); }
.tok.k-pin .tok-face { transform: rotate(-45deg); }
.tok-name { margin-top: 4px; font-size: 0.82rem; background: rgba(6, 7, 5, 0.82); color: var(--bone); padding: 0 0.45rem; border-radius: 99px; white-space: nowrap; pointer-events: none; font-family: var(--caps); font-weight: 700; letter-spacing: 0.03em; }
.tok .tok-name { opacity: 0; transition: opacity 0.15s; }
.map-inner.names .tok .tok-name, .tok:hover .tok-name, .tok.sel .tok-name { opacity: 1; }
.tok:hover { z-index: 4; }
.map-tools .icon-btn.on { color: var(--gold-hi); border-color: var(--gold-lo); }
.tok.sel .tok-face { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 0 6px rgba(232, 199, 111, 0.3), 0 6px 14px -4px #000; }
.tok.is-hidden { opacity: 0.45; }
.tok.is-locked .tok-face::after { content: ''; position: absolute; }
.ping { position: absolute; z-index: 3; pointer-events: none; width: 0; height: 0; }
.ping span { position: absolute; left: -40px; top: -40px; width: 80px; height: 80px; border-radius: 50%; border: 3px solid var(--pc, var(--gold)); animation: ping 1.3s ease-out infinite; }
.ping span + span { animation-delay: 0.45s; }
.ping b { position: absolute; left: 12px; top: -36px; white-space: nowrap; font-family: var(--caps); background: rgba(6, 7, 5, 0.85); padding: 0 0.4rem; border-radius: 6px; color: var(--pc); }
@keyframes ping { from { transform: scale(0.2); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.map-tools { position: absolute; left: 14px; top: 14px; display: grid; gap: 6px; }
.map-tools .icon-btn { background: rgba(14, 16, 11, 0.85); border-color: var(--line2); color: var(--bone); font-size: 1.2rem; width: 38px; height: 38px; }
.map-help { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; background: rgba(6, 7, 5, 0.75); color: var(--dim); padding: 0.25rem 0.8rem; border-radius: 99px; font-size: 0.85rem; pointer-events: none; }
.map-side { background: var(--bg2); border-left: 1px solid var(--line); padding: 1rem; overflow: auto; }
.map-side-head { display: flex; justify-content: space-between; align-items: start; gap: 0.5rem; margin-bottom: 0.8rem; }
.map-side-head h2 { font-size: 1.55rem; line-height: 1.1; }
.legend-group { margin-bottom: 1rem; }
.legend-toks { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tok-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.6rem 0.15rem 0.2rem; border-radius: 99px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--bone2); font-size: 0.9rem; }
.tok-chip .tok-face { width: 26px; height: 26px; font-size: 0.8rem; box-shadow: none; border-width: 1px; }
.tok-chip.k-pin .tok-face { width: 22px; height: 22px; }
.tok-chip.sel { border-color: var(--gold); }
.tok-chip.ghost { border-style: dashed; color: var(--dim); padding-left: 0.5rem; }
.tok-add { width: 30px; height: 30px; border-radius: 50%; border: 1px dashed var(--line2); background: transparent; color: var(--dim); display: grid; place-items: center; }
.tok-add:hover { color: var(--gold-hi); border-color: var(--gold); }
.tok-edit { border: 1px solid var(--line2); border-radius: 10px; padding: 0.7rem; margin-bottom: 1rem; background: var(--panel); }
.maps-list .map-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem; border-radius: 8px; border: 1px solid transparent; }
.maps-list .map-row.on { border-color: var(--gold-lo); background: rgba(201, 162, 74, 0.06); }
.maps-list img { width: 52px; height: 38px; object-fit: cover; border-radius: 4px; }
.maps-list .map-row span { flex: 1; font-size: 0.92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-label { cursor: pointer; margin-top: 0.4rem; }

/* ---------- dice builder ---------- */
.builder { flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 0.6rem 0.7rem 0.75rem; }
.tabs.small { flex-wrap: wrap; gap: 0.15rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--line); padding-bottom: 0.45rem; }
.tabs.small .tab { font-size: 0.9rem; padding: 0.22rem 0.45rem; }
.tabs.small .tab.on::after { bottom: -0.5rem; }
.roller-as { font-size: 0.9rem; color: var(--dim); display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.35rem; }
.roller-as b { color: var(--bone); }
.ruin-chip { font-family: var(--caps); font-weight: 700; font-size: 0.8rem; color: #f0c7bb; background: rgba(150, 47, 34, 0.35); border: 1px solid rgba(207, 83, 57, 0.45); padding: 0 0.45rem; border-radius: 99px; white-space: nowrap; }
.label-field { font-style: italic; margin-bottom: 0.3rem; }
.toggle { display: flex; align-items: center; gap: 0.55rem; padding: 0.32rem 0.45rem; border-radius: 7px; cursor: pointer; color: var(--bone2); border: 1px solid transparent; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle:hover { background: rgba(255, 255, 255, 0.025); border-color: var(--line); }
.toggle .pip { opacity: 0.45; transition: opacity 0.15s, transform 0.15s; }
.toggle.on { color: var(--bone); background: rgba(201, 162, 74, 0.07); border-color: rgba(201, 162, 74, 0.25); }
.toggle.on .pip { opacity: 1; transform: rotate(-8deg); }
.toggle.small { font-size: 0.88rem; padding-top: 0.15rem; padding-bottom: 0.15rem; }
.toggle.disabled { opacity: 0.7; }
.toggle:has(input:focus-visible) { outline: 2px solid var(--gold); }
.pool-line { display: flex; gap: 5px; align-items: center; min-height: 28px; margin-top: 0.45rem; padding: 0.3rem 0.5rem; border-radius: 7px; background: rgba(0, 0, 0, 0.3); flex-wrap: wrap; }
.builder .seg { margin-bottom: 0.5rem; display: flex; }
.builder .seg button { flex: 1; }

/* ---------- tray & 3D dice ---------- */
.tray { flex: none; background: radial-gradient(ellipse at 50% 30%, #1d2617, #10140d 70%); border: 1px solid var(--line2); border-radius: var(--r); padding: 0.6rem 0.75rem 0.7rem; box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6); position: relative; }
.tray.empty { display: grid; place-items: center; min-height: 140px; }
.tray-hint { color: var(--muted); font-style: italic; text-align: center; }
.tray-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.92rem; color: var(--dim); }
.tray-head .who { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 0; }
.tray-head .who b { color: var(--bone); }
.roll-type { font-family: var(--caps); font-weight: 700; letter-spacing: 0.05em; color: var(--gold); white-space: nowrap; }
.tray-label { font-style: italic; color: var(--bone2); margin: 0.2rem 0 0; }
.felt { min-height: calc(var(--ds) * 1.9); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: calc(var(--ds) * 0.32); padding: 0.9rem 0.4rem 0.7rem; perspective: 700px; }
.felt.many { --ds: 40px; }
.die-wrap { position: relative; width: var(--ds); height: var(--ds); }
.die-wrap::after { content: ''; position: absolute; left: 8%; right: 8%; bottom: -12%; height: 18%; border-radius: 50%; background: rgba(0, 0, 0, 0.55); filter: blur(5px); z-index: -1; }
@keyframes toss {
  0% { transform: translate(var(--dx), var(--dy)) scale(1.25); opacity: 0; }
  12% { opacity: 1; }
  55% { transform: translate(calc(var(--dx) * -0.12), 6px) scale(1); }
  72% { transform: translate(calc(var(--dx) * 0.05), -10px); }
  86% { transform: translate(0, 2px); }
  100% { transform: translate(0, 0); }
}
.die { position: absolute; inset: 0; transform-style: preserve-3d; }
.face { position: absolute; inset: 0; border-radius: 18%; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 16%; backface-visibility: hidden; }
.face.front { transform: translateZ(calc(var(--ds) / 2)); }
.face.back { transform: rotateY(180deg) translateZ(calc(var(--ds) / 2)); }
.face.right { transform: rotateY(90deg) translateZ(calc(var(--ds) / 2)); }
.face.left { transform: rotateY(-90deg) translateZ(calc(var(--ds) / 2)); }
.face.top { transform: rotateX(90deg) translateZ(calc(var(--ds) / 2)); }
.face.bottom { transform: rotateX(-90deg) translateZ(calc(var(--ds) / 2)); }
/* die faces: see dice.css */
.die-tag { position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); font-size: 0.72rem; white-space: nowrap; color: var(--dim); font-family: var(--caps); font-weight: 700; }
.verdict { display: flex; gap: 0.75rem; align-items: center; padding: 0.55rem 0.7rem; border-radius: 8px; background: rgba(0, 0, 0, 0.35); border-left: 3px solid var(--line2); animation: rise 0.5s 0.95s both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.verdict-num { font-family: var(--display); font-size: 2.4rem; line-height: 1; min-width: 1.6ch; text-align: center; color: var(--bone); }
.verdict-text h3 { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; font-size: 1.4rem; color: var(--bone); }
.verdict-text p { margin: 0.1rem 0 0; color: var(--bone2); font-size: 0.93rem; }
.tier-success .verdict, .verdict.tier-success { border-left-color: var(--gold); }
.tier-success .verdict-num, .verdict.tier-success .verdict-num { color: var(--gold-hi); }
.tier-mixed .verdict { border-left-color: var(--olive); }
.tier-mixed .verdict-num { color: #c8cc98; }
.tier-fail .verdict, .verdict.tier-fail, .tier-doom .verdict { border-left-color: var(--blood-hi); }
.tier-fail .verdict-num, .verdict.tier-fail .verdict-num, .tier-doom .verdict-num { color: var(--blood-hi); }
.contest-counts { display: grid; grid-template-columns: repeat(3, auto); gap: 0.2rem 0.6rem; font-family: var(--caps); font-weight: 700; }
.cc { display: inline-flex; gap: 0.25rem; align-items: center; }
.effects { list-style: none; margin: 0.45rem 0 0; padding: 0; display: grid; gap: 0.2rem; }
.eff { font-size: 0.93rem; padding: 0.2rem 0.55rem; border-radius: 6px; background: rgba(0, 0, 0, 0.25); display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap; }
.eff-ruin.up { color: #f3c2b4; background: rgba(150, 47, 34, 0.28); }
.eff-huntTokens.up, .eff-gold.up { color: var(--gold-hi); background: rgba(201, 162, 74, 0.1); }
.eff-why { color: var(--muted); font-size: 0.82rem; }
.helpers-note, .undone-note { font-size: 0.88rem; color: var(--dim); margin: 0.35rem 0 0; }
.tray.undone .felt { opacity: 0.45; filter: grayscale(0.6); }
.tray-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.tray-actions .btn { flex: 1 1 auto; }

/* combat */
.combat-setup .btn-roll { color: #f3d7cd; border-color: var(--blood); background: linear-gradient(180deg, #2a130e, #170906); }
.combat-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.combat-head h3 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; letter-spacing: 0; color: var(--bone); }
.shield { position: relative; width: 64px; height: 70px; display: grid; place-items: center; color: #3a3328; flex: none; }
.shield svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: #0a0a08; stroke: #bfb08a; stroke-width: 1; }
.shield b { position: relative; font-family: var(--display); font-size: 1.9rem; color: var(--bone); margin-top: -4px; }
.shield-adj { position: absolute; bottom: -10px; display: flex; gap: 2px; }
.shield-adj button { width: 22px; height: 18px; border-radius: 5px; border: 1px solid var(--line2); background: var(--panel3); color: var(--bone2); font-size: 0.85rem; line-height: 1; padding: 0; }
.participants { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.3rem; }
.participants li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; padding: 0.3rem 0.5rem; border-radius: 7px; background: rgba(0, 0, 0, 0.25); }
.participants li.retreated { opacity: 0.5; }
.pname { font-weight: 600; }
.weak { display: inline-flex; gap: 3px; }
.hit-actions { display: inline-flex; gap: 0.3rem; margin-left: auto; }
.retreat { margin-left: auto; }
.join-row { display: grid; gap: 0.35rem; margin: 0.4rem 0; }
.combat-felt { min-height: calc(var(--ds) * 1.6); }
.combat-log { margin-top: 0.5rem; font-size: 0.88rem; color: var(--dim); }
.combat-log ol { margin: 0.3rem 0 0; padding-left: 1.2rem; }

/* history */
.history { flex: 1 0 260px; min-height: 260px; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.history-head { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); }
.history-list { list-style: none; margin: 0; padding: 0.3rem; overflow: auto; flex: 1; }
.h-item { display: flex; gap: 0.55rem; padding: 0.42rem 0.5rem; border-radius: 7px; cursor: pointer; border: 1px solid transparent; animation: slidein 0.35s ease; }
@keyframes slidein { from { opacity: 0; transform: translateX(10px); } }
.h-item:hover { background: rgba(255, 255, 255, 0.025); }
.h-item.viewing { border-color: var(--line2); background: rgba(201, 162, 74, 0.05); }
.h-item.undone { opacity: 0.5; }
.h-dot { width: 4px; border-radius: 4px; flex: none; }
.h-main { min-width: 0; flex: 1; }
.h-top { font-size: 0.9rem; display: flex; gap: 0.25rem; align-items: baseline; }
.h-time { margin-left: auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.h-mid { font-size: 0.9rem; }
.h-type { font-family: var(--caps); font-weight: 700; color: var(--dim); letter-spacing: 0.03em; }
.h-res { color: var(--bone); }
.h-item.tier-success .h-res { color: var(--gold-hi); }
.h-item.tier-fail .h-res, .h-item.tier-doom .h-res { color: #e7907b; }
.h-label { font-style: italic; color: var(--dim); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-dice { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; margin-top: 0.2rem; }
.h-eff { font-size: 0.76rem; font-family: var(--caps); font-weight: 700; padding: 0 0.4rem; border-radius: 99px; margin-left: 0.25rem; border: 1px solid var(--line2); color: var(--bone2); }
.h-eff.eff-ruin { color: #f0b6a6; border-color: rgba(207, 83, 57, 0.5); }
.h-eff.eff-huntTokens, .h-eff.eff-gold { color: var(--gold-hi); border-color: var(--gold-lo); }

/* ---------- sheet ---------- */
.sheet { padding: 0.8rem 0.9rem 1.5rem; }
.sheet.is-lost { filter: grayscale(0.55); }
.char-picker { display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.6rem; }
.char-picker select { flex: 1; }
.new-char { display: flex; gap: 0.25rem; }
.claim-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.9rem; padding: 0.4rem 0.6rem; border-radius: 8px; background: rgba(201, 162, 74, 0.08); border: 1px solid rgba(201, 162, 74, 0.25); margin-bottom: 0.6rem; }
.claim-bar.muted { background: rgba(0, 0, 0, 0.2); border-color: var(--line); }
.empty-sheet { padding: 2rem 0.5rem; text-align: center; }
.sheet-head { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.6rem; position: relative; }
.portrait { cursor: pointer; flex: none; }
.portrait img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold-lo); display: block; }
.sheet-id { flex: 1; min-width: 0; }
.name-field { font-family: var(--display); font-size: 2rem !important; line-height: 1.1; padding: 0.05rem 0.45rem !important; background: transparent !important; border-color: transparent !important; }
.name-field:hover:not(:disabled), .name-field:focus { border-color: var(--line2) !important; }
.id-row { display: flex; gap: 0.3rem; align-items: center; }
.id-row .field { font-size: 0.9rem; padding: 0.18rem 0.45rem; }
.color-pick { width: 28px; height: 26px; padding: 0; border: 1px solid var(--line2); border-radius: 6px; background: none; flex: none; cursor: pointer; }
.sheet-head .sys-badge { position: absolute; top: 0; right: 0; }
.block { border-top: 1px solid var(--line); padding: 0.7rem 0 0.5rem; }
.sheet-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.list-field { display: grid; gap: 0.25rem; }
.list-field .field { padding: 0.26rem 0.55rem; }
.list-row { display: flex; gap: 0.2rem; align-items: center; }
.list-row .row-del { opacity: 0; transition: opacity 0.15s; flex: none; }
.list-row:hover .row-del, .list-row .row-del:focus-visible { opacity: 1; }
.list-row .row-del:hover { color: var(--blood-hi); }
.add-line { justify-self: start; display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.85rem; text-decoration: none; }

.ruin-track { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.ruin-box { position: relative; aspect-ratio: 1 / 1.05; border: 1.5px solid #5a5444; background: rgba(0, 0, 0, 0.3); border-radius: 5px; display: grid; place-items: center; color: var(--dim); padding: 0; }
.ruin-box:hover:not(:disabled) { border-color: var(--bone2); }
.ruin-n { font-family: var(--display); font-size: 1.5rem; }
.ruin-box.marked { border-color: #8a3b2c; background: linear-gradient(180deg, rgba(150, 47, 34, 0.25), rgba(60, 15, 10, 0.4)); color: #e7c9bd; }
.ruin-box.start::before { content: ''; position: absolute; left: 3px; right: 3px; bottom: 3px; height: 2px; background: var(--gold-lo); border-radius: 2px; }
.slash { position: absolute; inset: 8%; width: 84%; height: 84%; }
.slash path { fill: none; stroke: #e9e0c7; stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.35s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.ruin-box:nth-child(6).marked { box-shadow: 0 0 18px rgba(207, 83, 57, 0.6); }
.lost-box { margin-top: 0.5rem; padding: 0.55rem 0.65rem; border-radius: 8px; background: rgba(150, 47, 34, 0.2); border: 1px solid rgba(207, 83, 57, 0.5); font-size: 0.92rem; display: grid; gap: 0.4rem; }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.counter { display: grid; justify-items: center; gap: 0.25rem; padding: 0.4rem 0.2rem; border-radius: 8px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); }
.c-lbl { font-family: var(--caps); font-weight: 700; letter-spacing: 0.04em; font-size: 0.86rem; color: var(--dim); text-align: center; }
.town-btn { grid-column: 1 / -1; }
.hoard-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-bottom: 0.3rem; }
.hoard-cell { aspect-ratio: 1; border: 1px solid #4a4536; background: rgba(0, 0, 0, 0.3); border-radius: 3px; padding: 0; }
.hoard-cell:hover:not(:disabled) { border-color: var(--gold); }
.hoard-cell.on { background: linear-gradient(135deg, #e2c26b, #9c7a2c); border-color: #e8c76f; }
.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.slots li { display: flex; gap: 0.25rem; align-items: center; }
.slots .field { padding: 0.24rem 0.5rem; }
.slots .uses { width: 68px; flex: none; text-align: center; }
.slots li.crossed .field:first-child { text-decoration: line-through; color: var(--muted); }
.slots li.marked .field { text-decoration: line-through; color: var(--muted); }
.combat-eq { display: grid; gap: 0.6rem; }
.eq-lbl { font-family: var(--caps); font-weight: 700; color: var(--dim); font-size: 0.86rem; letter-spacing: 0.05em; display: block; margin-bottom: 0.2rem; }
.check { position: relative; display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; cursor: pointer; }
.check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.check span { width: 16px; height: 16px; border: 1.5px solid #6a634f; border-radius: 3px; background: rgba(0, 0, 0, 0.3); }
.check input:checked + span { background: var(--blood); border-color: var(--blood-hi); box-shadow: inset 0 0 0 3px #1a0d09; }
.check input:focus-visible + span { outline: 2px solid var(--gold); }
.ammo { display: inline-flex; gap: 1px; }
.sheet-foot { display: flex; gap: 1rem; justify-content: flex-end; padding-top: 0.8rem; border-top: 1px solid var(--line); margin-top: 0.4rem; }

/* ---------- center: stage ---------- */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.stage-main { flex: 1; min-height: 0; display: flex; }
.stage-fig { margin: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; animation: reveal 0.7s ease; }
@keyframes reveal { from { opacity: 0; filter: blur(8px) brightness(0.3); transform: scale(0.985); } }
.stage-fig img { flex: 1; min-height: 0; width: 100%; object-fit: contain; cursor: zoom-in; border-radius: 6px; filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.8)); }
.stage-fig figcaption { flex: none; text-align: center; padding: 0.6rem 1rem 0; max-width: 900px; margin: 0 auto; width: 100%; }
.stage-fig h2 { font-size: 2.1rem; }
.cap-field { text-align: center; font-style: italic; background: transparent !important; border-color: transparent !important; color: var(--bone2); }
.cap-field:hover, .cap-field:focus { border-color: var(--line2) !important; }
.back-live { position: absolute; top: 0.5rem; right: 0.5rem; background: rgba(6, 7, 5, 0.8); }
.stage-empty { margin: auto; text-align: center; max-width: 520px; display: grid; justify-items: center; gap: 0.6rem; color: var(--dim); }
.stage-empty h2 { font-size: 2.6rem; color: var(--bone); }
.sigil { width: 110px; height: 110px; border-radius: 50%; background: url('/assets/favicon.svg') center / 70% no-repeat, radial-gradient(circle, rgba(201, 162, 74, 0.12), transparent 70%); opacity: 0.85; }
.sigil.spin { animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gallery { flex: none; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.gallery-head { display: flex; justify-content: space-between; align-items: center; }
.gallery-head .btn-row { margin: 0; }
.gallery-strip { display: flex; gap: 0.6rem; overflow-x: auto; padding: 0.3rem 0.1rem 0.5rem; }
.thumb { position: relative; flex: none; width: 150px; }
.thumb-img { display: block; width: 150px; height: 96px; padding: 0; border-radius: 7px; overflow: hidden; border: 1px solid var(--line2); background: #000; }
.thumb-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.thumb-img:hover img { transform: scale(1.06); }
.thumb.live .thumb-img { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 6px 20px -8px rgba(201, 162, 74, 0.6); }
.thumb.viewing:not(.live) .thumb-img { border-color: var(--bone2); }
.thumb.hidden-h .thumb-img img { opacity: 0.4; filter: grayscale(1); }
.thumb-title { display: block; font-size: 0.85rem; margin-top: 0.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bone2); }
.live-badge { position: absolute; top: 5px; left: 5px; font-family: var(--caps); font-weight: 700; font-size: 0.72rem; background: var(--gold); color: #1a1406; padding: 0 0.4rem; border-radius: 99px; }
.thumb-actions { display: flex; gap: 2px; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(3, 4, 2, 0.96); display: grid; place-items: center; overflow: auto; animation: fade 0.2s; }
.lightbox img { max-width: 96vw; max-height: 86vh; cursor: zoom-in; }
.lightbox img.zoomed { max-width: none; max-height: none; cursor: zoom-out; }
.lb-cap { position: fixed; bottom: 0; left: 0; right: 0; text-align: center; padding: 0.6rem; background: linear-gradient(0deg, rgba(3, 4, 2, 0.95), transparent); }
.upload-preview { max-height: 46vh; display: grid; place-items: center; background: #000; border-radius: 8px; overflow: hidden; margin-bottom: 0.5rem; }
.upload-preview img { max-width: 100%; max-height: 46vh; }
.drop-hint { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(6, 7, 5, 0.85); border: 3px dashed var(--gold); font-family: var(--display); font-size: 2.6rem; color: var(--gold-hi); pointer-events: none; }

/* ---------- center tabs ---------- */
.tab-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab-head h2 { font-size: 2.3rem; line-height: 1; }
.party-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 0.8rem; }
.pcard { text-align: left; display: grid; gap: 0.5rem; padding: 0.85rem; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(160deg, var(--panel2), var(--panel)); color: var(--bone); position: relative; overflow: hidden; transition: border-color 0.15s, transform 0.15s; }
.pcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cc); }
.pcard:hover { border-color: var(--line2); transform: translateY(-2px); }
.pcard.sel { border-color: var(--gold-lo); box-shadow: 0 0 0 1px var(--gold-lo); }
.pcard.is-lost { filter: grayscale(0.7); }
.pcard-top { display: flex; gap: 0.65rem; align-items: center; }
.pcard-id { display: grid; min-width: 0; }
.pcard-id b { font-family: var(--display); font-weight: 400; font-size: 1.6rem; line-height: 1; }
.pcard-id .muted { font-size: 0.9rem; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #444; margin-right: 0.3rem; vertical-align: middle; }
.dot.on { background: #8fcf6a; box-shadow: 0 0 8px #8fcf6a; }
.pcard-ruin { display: flex; gap: 3px; align-items: center; }
.rb { width: 18px; height: 22px; border: 1.5px solid #5a5444; border-radius: 3px; }
.rb.on { background: linear-gradient(180deg, #a3402f, #5c1a11); border-color: #c4523b; }
.rb.st { box-shadow: inset 0 -3px 0 var(--gold-lo); }
.pcard-ruin .muted { margin-left: 0.4rem; }
.pcard-stats { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-size: 0.9rem; color: var(--dim); }
.pcard-stats b { color: var(--bone); font-family: var(--caps); font-size: 1.05rem; }
.pcard-drive { font-style: italic; color: var(--bone2); font-size: 0.93rem; margin: 0; }
.pcard-cond { font-size: 0.88rem; color: #e6b9aa; margin: 0; }
.archived-card { display: flex; gap: 0.6rem; align-items: center; cursor: default; }
.archived-card:hover { transform: none; }
.archived { margin-top: 1.2rem; display: grid; gap: 0.6rem; }
.pool { display: grid; justify-items: end; text-align: right; }
.pool-n { font-family: var(--display); font-size: 2.6rem; line-height: 1; color: var(--gold-hi); }

/* bestiary: modeled on the printed monster block */
.beast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 1rem; }
.beast { background: #e9e3d2; color: #15130e; border-radius: 4px; overflow: hidden; box-shadow: 0 20px 40px -20px #000; position: relative; }
.beast.is-hidden { opacity: 0.6; outline: 2px dashed var(--gold-lo); }
.beast .field { color: #15130e; background: transparent; border-color: transparent; }
.beast .field:hover, .beast .field:focus { border-color: rgba(0, 0, 0, 0.2); background: rgba(255, 255, 255, 0.4); }
.beast .field::placeholder { color: #8b8574; }
.beast-head { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; background: #0a0a09; color: #f0eadb; padding: 0.4rem 4.6rem 0.4rem 0.6rem; position: relative; }
.beast-name { font-family: var(--display); font-size: 1.5rem !important; color: #f6f1e4 !important; padding: 0 0.2rem !important; }
.beast-name:hover, .beast-name:focus { background: rgba(255, 255, 255, 0.06) !important; border-color: rgba(255, 255, 255, 0.15) !important; }
.beast-weak { grid-column: 1 / -1; display: flex; gap: 0.4rem; align-items: center; font-family: var(--caps); font-weight: 700; font-size: 0.95rem; padding-left: 0.2rem; }
.beast-weak .field.inv { color: #f0eadb !important; font-family: var(--serif); font-weight: 400; padding: 0.05rem 0.3rem; }
.beast-weak i { color: #9a937f; font-family: var(--serif); font-weight: 400; }
.beast-shield { position: absolute; right: 10px; top: 4px; width: 58px; height: 66px; display: grid; place-items: center; }
.beast-shield svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: #0a0a09; stroke: #e9e3d2; stroke-width: 1.6; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
.beast-shield b { position: relative; font-family: var(--display); font-size: 1.8rem; color: #f6f1e4; margin-top: -4px; }
.beast-desc, .beast-def { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.4rem; padding: 0.45rem 0.6rem; background: #dcd5c2; align-items: start; }
.beast-def { background: transparent; border-top: 1px solid #c5bda8; }
.beast-desc p, .beast-def p { margin: 0.1rem 0; }
.lbl-i { font-style: italic; color: #4a4536; border-right: 2px solid #15130e; padding-right: 0.4rem; text-align: right; }
.habits { list-style: none; margin: 0; padding: 0.3rem 0.6rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.habits li { display: flex; gap: 0.4rem; align-items: center; border-bottom: 1px dashed #b5ad97; min-height: 30px; }
.habits .pip-dark rect { fill: #0a0a09; }
.beast-foot { background: #15130e; color: var(--bone2); padding: 0.5rem 0.7rem; display: grid; gap: 0.15rem; }
.beast-foot .chk { margin: 0.1rem 0; font-size: 0.88rem; }
.beast-foot .field { color: var(--bone); }

/* chronicle */
.chronicle { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sess-pick { display: flex; gap: 0.4rem; align-items: center; }
.sess-pick select { min-width: 260px; }
.chron-cols { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; min-height: 0; }
.chron-col { background: rgba(201, 162, 74, 0.045); border: 1px solid rgba(201, 162, 74, 0.16); border-radius: 12px; padding: 0.7rem; display: flex; flex-direction: column; min-height: 320px; }
.chron-col h3 { font-family: var(--display); font-weight: 400; font-size: 1.45rem; letter-spacing: 0; color: var(--gold-hi); text-align: center; margin-bottom: 0.5rem; }
.chron-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; align-content: start; flex: 1; overflow: auto; }
.note { background: #ece4cb; color: #1c1910; border-radius: 3px 3px 10px 3px; padding: 0.4rem 0.5rem 0.25rem; box-shadow: 0 6px 12px -8px #000; transform: rotate(-0.3deg); }
.note:nth-child(2n) { transform: rotate(0.35deg); background: #e8dfc2; }
.note .field { background: transparent; border-color: transparent; color: #1c1910; padding: 0.1rem 0.2rem; resize: none; font-size: 0.98rem; }
.note .field:focus { background: rgba(255, 255, 255, 0.5); border-color: rgba(0, 0, 0, 0.2); }
.note-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: #6d6650; font-family: var(--caps); font-weight: 700; }
.note-meta .icon-btn { color: #6d6650; width: 22px; height: 22px; }
.note-meta .icon-btn:hover { background: rgba(0, 0, 0, 0.08); color: #1c1910; border-color: transparent; }
.note-add { display: grid; gap: 0.3rem; margin-top: 0.5rem; }
.note-add .btn { justify-self: end; }

/* rules */
.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0.9rem; align-items: start; }
.rule { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem 1rem; }
.rule h3 { font-family: var(--display); font-weight: 400; font-size: 1.55rem; letter-spacing: 0; color: var(--gold-hi); margin-bottom: 0.3rem; }
.rule table { border-collapse: collapse; width: 100%; margin: 0.4rem 0; }
.rule td { padding: 0.22rem 0.4rem; border-bottom: 1px solid var(--line); }
.rule td:first-child { font-family: var(--display); font-size: 1.2rem; width: 3.2rem; color: var(--bone); }
.rule ul { margin: 0.3rem 0; padding-left: 1.1rem; }
.rule.big { background: linear-gradient(160deg, #1b1f15, #0d0f0b); border-color: var(--gold-lo); }
.rule.safety { border-color: rgba(111, 143, 168, 0.4); }
.legend-dice { display: flex; gap: 1rem; margin-top: 0.5rem; }
.legend-dice span { display: inline-flex; gap: 0.4rem; align-items: center; }

/* ---------- modal, toasts, overlays ---------- */
.modal-back { position: fixed; inset: 0; z-index: 45; background: rgba(4, 5, 3, 0.78); display: grid; place-items: center; animation: fade 0.15s; padding: 1rem; }
.modal { width: min(560px, 96vw); max-height: 92vh; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 40px 90px -20px #000; }
.modal.wide { width: min(900px, 96vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 0.8rem 1rem 0.4rem; }
.modal-body { padding: 0 1rem 1rem; }
.town-check { display: grid; grid-template-columns: auto auto auto; justify-content: center; align-items: center; gap: 0.5rem 1.4rem; padding: 0.8rem; border-radius: 10px; margin-bottom: 0.6rem; text-align: center; }
.town-check > div { display: grid; }
.town-check .big { font-family: var(--display); font-size: 2.6rem; line-height: 1; }
.town-check .vs { font-family: var(--display); font-size: 2rem; color: var(--dim); }
.town-check p { grid-column: 1 / -1; color: var(--bone2); margin: 0; }
.town-check.ok { background: rgba(201, 162, 74, 0.08); border: 1px solid rgba(201, 162, 74, 0.3); }
.town-check.bad { background: rgba(150, 47, 34, 0.15); border: 1px solid rgba(207, 83, 57, 0.4); }
.town-list { list-style: none; padding: 0; margin: 0.3rem 0; display: grid; gap: 0.3rem; }
.town-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; padding: 0.35rem 0.5rem; background: rgba(0, 0, 0, 0.2); border-radius: 7px; font-size: 0.95rem; }
.town-list li > .btn, .town-list .inline { margin-left: auto; display: inline-flex; gap: 0.3rem; align-items: center; }
.toasts { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); z-index: 70; display: grid; gap: 0.4rem; justify-items: center; pointer-events: none; }
.toast { background: rgba(21, 25, 18, 0.96); border: 1px solid var(--line2); color: var(--bone); padding: 0.5rem 1rem; border-radius: 99px; box-shadow: 0 14px 30px -10px #000; animation: drop 0.3s ease; font-size: 0.98rem; }
.toast.t-stage { border-color: var(--gold-lo); color: var(--gold-hi); }
.toast.t-error { border-color: var(--blood-hi); color: #f3c2b4; }
.toast.t-doom, .toast.t-combat { border-color: var(--blood-hi); background: rgba(40, 12, 8, 0.96); }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }
.safety-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(8, 14, 20, 0.82); backdrop-filter: blur(3px); animation: fade 0.2s; }
.safety-card { text-align: center; background: #101820; border: 1px solid rgba(143, 176, 200, 0.5); border-radius: 16px; padding: 2rem 2.6rem; max-width: 520px; }
.safety-card h2 { font-size: 3rem; color: #cfe0ec; }
.safety-card p { color: #b9c9d5; font-size: 1.15rem; margin: 0.5rem 0 1.2rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (max-width: 1500px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr) 350px; }
  .who-chip span:last-child { display: none; }
  .chron-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
