:root {
  color-scheme: dark;
  --ink: #080a0b;
  --ink-soft: #0d1011;
  --ink-raised: #131718;
  --gold: #c4a879;
  --gold-dim: #806c4d;
  --gold-line: #6e5532;
  --blood: #9f271b;
  --blood-bright: #d33a26;
  --paper: #ded2bb;
  --muted: #938775;
  --green: #55b890;
  --shadow: rgba(0, 0, 0, 0.72);
  font-family: Georgia, "Times New Roman", serif;
}

/* v0.8 — бой, торговцы и финальная подготовка героя */
.combat-tracker {
  position: fixed;
  z-index: 44;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: min(850px, calc(100vw - 210px));
  min-height: 76px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 58px minmax(260px, 1fr) minmax(130px, auto) auto;
  align-items: center;
  gap: 10px;
  color: #efe3ca;
  background: linear-gradient(180deg, rgba(22, 17, 17, .97), rgba(7, 9, 10, .97));
  box-shadow: 0 12px 38px rgba(0, 0, 0, .62), inset 0 0 0 1px rgba(151, 42, 34, .5);
}

.combat-round { text-align: center; border-right: 1px solid rgba(196, 165, 119, .2); }
.combat-round small, .current-turn-copy small { display: block; color: #a99980; text-transform: uppercase; letter-spacing: .1em; font-size: .62rem; }
.combat-round strong { display: block; color: #d85343; font-size: 1.65rem; line-height: 1; }
.turn-order { display: flex; align-items: flex-start; gap: 6px; overflow-x: auto; padding: 4px 6px 12px; }
.turn-portrait { position: relative; flex: 0 0 48px; width: 48px; height: 48px; border-radius: 50%; border: 2px solid #55473c; background: #17191a; box-shadow: 0 3px 9px #000; transition: .18s ease; }
.turn-portrait img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; filter: grayscale(.45) contrast(1.08); }
.turn-portrait > span { display: grid; width: 100%; height: 100%; place-items: center; font: 700 1.2rem Georgia, serif; }
.turn-portrait b { position: absolute; right: -3px; top: -4px; display: grid; place-items: center; min-width: 18px; height: 18px; border-radius: 50%; color: #f3e5ca; background: #5f201c; font-size: .66rem; }
.turn-portrait small { position: absolute; top: 50px; left: 50%; width: 72px; transform: translateX(-50%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: .58rem; color: #baa98e; }
.turn-portrait.current { border-color: #d34c3d; transform: translateY(-3px) scale(1.08); box-shadow: 0 0 0 3px rgba(176, 43, 34, .22), 0 4px 16px #000; }
.turn-portrait.dead { opacity: .48; filter: grayscale(1); }
.turn-portrait.dead i { position: absolute; inset: 0; display: grid; place-items: center; color: #eee5d2; font-size: 1.35rem; text-shadow: 0 2px 3px #000; }
.current-turn-copy strong { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #f0e1c4; }
.end-turn-button, .end-turn-wide { border: 1px solid #93362e; background: linear-gradient(#7e2a24, #441511); color: #f4e7d0; padding: 9px 12px; font-weight: 700; }

.quickbar-panel {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(820px, calc(100vw - 190px));
  padding: 8px 12px 7px;
  color: #eadcc1;
  background: linear-gradient(180deg, rgba(25, 20, 19, .98), rgba(7, 8, 9, .98));
  box-shadow: 0 15px 45px rgba(0,0,0,.72), inset 0 0 0 1px rgba(145, 42, 34, .5);
}
.quickbar-panel > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.quickbar-panel > header small { display: block; color: #d05042; font-size: .67rem; text-transform: uppercase; letter-spacing: .11em; }
.quickbar-panel > header strong { font-size: .8rem; }
.quickbar-panel > header button { border: 1px solid #6d4934; color: #f0dec2; background: #241a17; padding: 6px 12px; }
.quickbar-slots { display: grid; grid-template-columns: repeat(8, minmax(66px, 1fr)); gap: 5px; }
.quickbar-slot { position: relative; min-width: 0; height: 66px; display: grid; grid-template-columns: 26px 1fr; grid-template-rows: 1fr auto; align-items: center; gap: 0 5px; padding: 5px; border: 1px solid #5e4a37; background: radial-gradient(circle at 50% 35%, #30251f, #111313 72%); cursor: pointer; box-shadow: inset 0 0 12px rgba(0,0,0,.65); }
.quickbar-slot:hover, .quickbar-slot.dragover { border-color: #bd483b; transform: translateY(-2px); }
.quickbar-slot.disabled { opacity: .55; cursor: not-allowed; }
.quickbar-slot > small { position: absolute; top: 2px; left: 4px; color: #9c8b73; font-size: .58rem; }
.quickbar-slot > span { grid-row: 1 / 3; color: #c24a3c; font-size: 1.35rem; text-align: center; }
.quickbar-slot > strong { align-self: end; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .65rem; }
.quickbar-slot > i { position: absolute; top: -5px; right: -4px; display: none; width: 17px; height: 17px; border-radius: 50%; background: #1a1918; color: #d8c6a7; text-align: center; line-height: 16px; font-style: normal; }
.quickbar-slot:hover > i { display: block; }
.quickbar-panel > p { margin: 5px 0 0; text-align: center; color: #8f816d; font-size: .62rem; }

.token.targeted { outline: 5px solid rgba(201, 48, 36, .85); outline-offset: 4px; box-shadow: 0 0 0 10px rgba(161, 35, 28, .2), 0 0 28px #e34839 !important; }
.token.dead img, .token.dead .token-initial { filter: grayscale(1) brightness(.38); }
.token-death { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; color: #f2eadb; font-size: 2rem; text-shadow: 0 3px 4px #000; pointer-events: none; }
.token-risk { position: absolute; z-index: 4; top: -15px; left: 50%; transform: translateX(-50%); min-width: 44px; padding: 2px 6px; border: 1px solid #8e3028; border-radius: 9px; background: rgba(10,10,11,.95); color: #f1d7c0; font-size: .64rem; white-space: nowrap; pointer-events: none; }

.combat-master-panel { display: grid; gap: 18px; }
.combat-master-panel section > h3 { margin: 0 0 8px; color: #e5d4b8; font-family: Georgia, serif; }
.combat-state-card { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 13px; border: 1px solid rgba(153,52,43,.5); background: rgba(38,22,20,.45); }
.combat-state-card h3 { margin: 2px 0; }
.danger-button { border: 1px solid #7d332d !important; background: #2a1312 !important; color: #e9bdb5 !important; }
.gm-current-action { padding: 14px; border-left: 3px solid #a43930; background: linear-gradient(90deg, rgba(111,31,26,.22), transparent); }
.combat-order-list, .combat-monster-list { display: grid; gap: 6px; }
.combat-order-row { display: grid; grid-template-columns: 25px 1fr auto 26px 26px; align-items: center; gap: 5px; padding: 7px; border: 1px solid #393631; background: #141617; }
.combat-order-row.current { border-color: #92362e; background: rgba(83,29,25,.35); }
.combat-order-row > span { color: #b84a3d; font-weight: 800; }
.combat-order-row small { color: #948571; }
.combat-order-row button { min-height: 25px; border: 1px solid #51473d; background: #211f1d; color: #d6c4a8; }
.end-turn-wide { width: 100%; margin-top: 8px; }
.combat-help { color: #9d8d77; font-size: .76rem; }
.combat-monster-row { display: grid; grid-template-columns: 48px 1fr; gap: 9px; padding: 8px; border: 1px solid #3d3833; background: #121415; }
.combat-monster-row.dead { opacity: .58; }
.combat-monster-row img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; filter: grayscale(.55) contrast(1.2); }
.combat-monster-row div:nth-child(2) { min-width: 0; }
.combat-monster-row strong, .combat-monster-row small { display: block; }
.combat-monster-row small { color: #bc9f7d; }
.combat-monster-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto auto; gap: 5px; }
.combat-monster-actions button { min-height: 30px; border: 1px solid #55483b; background: #211e1b; color: #d9c7a9; }

.knowledge-merchant-list { display: grid; gap: 14px; }
.knowledge-merchant-card { padding: 13px; border: 1px solid #413a33; background: #111314; }
.knowledge-merchant-card.active { border-color: #9f392f; box-shadow: inset 0 0 22px rgba(110,31,26,.22); }
.knowledge-merchant-card > header { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; }
.knowledge-merchant-card > header > span { font-size: 2rem; color: #b34438; }
.knowledge-merchant-card input { width: 100%; border: 0; border-bottom: 1px solid #5a4a3e; background: transparent; color: #ecdec5; font: 700 1.1rem Georgia,serif; }
.knowledge-merchant-card > header i { color: #b66b5e; font-size: .67rem; }
.knowledge-merchant-card ol { columns: 2; margin: 12px 0; padding: 10px 10px 10px 28px; background: #181a1a; }
.knowledge-merchant-card li { break-inside: avoid; padding: 3px; color: #bdae98; font-size: .73rem; }
.knowledge-merchant-card li b { float: right; color: #d3b98f; }
.knowledge-merchant-card footer { display: flex; flex-wrap: wrap; gap: 6px; }
.knowledge-merchant-card footer button { min-height: 34px; border: 1px solid #58493b; background: #211e1a; color: #ded0b8; padding: 6px 9px; }

.merchant-overlay { position: fixed; z-index: 76; inset: 0; display: grid; place-items: center; }
.merchant-window { position: relative; z-index: 2; width: min(1050px, calc(100vw - 48px)); max-height: calc(100vh - 64px); overflow: auto; color: #e8d9bd; background: linear-gradient(145deg, #16191a, #090b0c 65%); box-shadow: 0 24px 80px #000; }
.merchant-window > header { position: sticky; z-index: 2; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid #653029; background: rgba(13,15,16,.97); }
.merchant-window h2 { margin: 2px 0; font-family: Georgia,serif; font-size: 1.65rem; }
#merchant-content { padding: 16px 20px 22px; }
.merchant-balance { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; margin-bottom: 14px; padding: 10px 14px; border: 1px solid #4c4034; background: #171819; }
.merchant-balance strong { color: #ddc080; font-size: 1.2rem; }
.merchant-stock { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.merchant-item { position: relative; border: 1px solid #423a33; background: #121414; }
.merchant-item.selected { border-color: #ad4035; box-shadow: inset 0 0 18px rgba(140,42,34,.2); }
.merchant-item.forbidden { opacity: .62; }
.merchant-item > button { width: 100%; display: grid; grid-template-columns: 48px 1fr 55px; gap: 10px; align-items: start; padding: 11px 11px 28px; border: 0; background: transparent; color: inherit; text-align: left; }
.merchant-item-icon { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #5f4a39; color: #b9483c; font-size: 1.4rem; }
.merchant-item h3, .merchant-item p { margin: 0 0 5px; }
.merchant-item p { color: #a99b87; font-size: .78rem; line-height: 1.42; }
.merchant-item div small { display: inline-block; margin-right: 6px; color: #d2b58a; }
.merchant-item > button > strong { text-align: right; color: #dfbd7a; font-size: 1.1rem; }
.merchant-item > button > strong small { display: block; font-size: .58rem; }
.merchant-item > i { position: absolute; left: 69px; bottom: 8px; color: #bb665b; font-size: .68rem; font-style: normal; }
.merchant-checkout { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #40362f; }
.merchant-checkout p { color: #91826f; font-size: .75rem; }

.gold-transfer { display: grid; grid-template-columns: 1fr minmax(120px,1fr) 70px auto; gap: 6px; align-items: center; margin-top: 7px; padding: 7px; border: 1px solid rgba(105,74,52,.4); }
.gold-transfer select, .gold-transfer input, .gold-transfer button { min-width: 0; height: 32px; border: 1px solid #5d4a3b; background: #171818; color: #e0d0b7; }
.modifier-output { display: grid !important; place-items: center; min-height: 40px; font-size: 1.15rem; }
.scene-editor > header { align-items: flex-start; gap: 10px; }
.scene-image-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.scene-image-actions button { border: 1px solid #55473c; background: #1c1b19; color: #d9c7a9; padding: 6px 8px; }

.combat-chat-card { display: grid; grid-template-columns: 42px 1fr; gap: 9px; padding: 10px; border: 1px solid #4b3931; background: linear-gradient(135deg,#191715,#101212); }
.combat-action-sigil { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #7f3029; border-radius: 50%; color: #c94a3c; font-size: 1.15rem; }
.combat-chat-card p { margin: 0 0 4px !important; }
.combat-chat-card strong { color: #dcc5a3; }
.combat-chat-card small { display: block; color: #bca082; margin-top: 4px; }
.combat-roll { display: flex; gap: 8px; align-items: center; margin: 5px 0; color: #c9b89e; }
.combat-roll b { color: #e05343; }
.combat-chat-message.hit .combat-chat-card { border-color: #76372e; }
.combat-chat-message.miss { opacity: .82; }
.xp-chat-message { border-left: 3px solid #b58a45 !important; background: rgba(90,63,28,.18) !important; }

.money-dice-result { display: flex; justify-content: center; gap: 8px; margin: 10px; }
.money-dice-result i { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #6a5037; background: #1a1a19; color: #e6d2ad; font-style: normal; }
.money-dice-result i.dropped { opacity: .35; text-decoration: line-through; }
.starter-shop-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 10px; padding: 10px 13px; border: 1px solid #4a3f35; background: #151717; }
.starter-shop-head small { display: block; color: #9e8c74; }
.starter-shop-head strong { color: #ddbf7e; font-size: 1.35rem; }
.starter-recommendation { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 11px; padding: 10px 13px; border-left: 3px solid #9e3a30; background: rgba(97,34,28,.22); }
.starter-recommendation small { display: block; margin-top: 3px; color: #a9967e; }
.starter-recommendation button { border: 1px solid #75503a; background: #241c18; color: #e2ceb0; padding: 7px 10px; }
.starter-shop-layout { display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 12px; }
.starter-catalog { max-height: 48vh; overflow: auto; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; padding-right: 4px; }
.starter-item { position: relative; border: 1px solid #3f3933; background: #121414; }
.starter-item.selected { border-color: #a13c32; }
.starter-item.forbidden { opacity: .55; }
.starter-item > button { width: 100%; min-height: 96px; display: grid; grid-template-columns: 34px 1fr 48px; gap: 7px; padding: 8px 8px 24px; border: 0; color: #ded0b8; background: transparent; text-align: left; }
.starter-item > button > span { color: #b44338; font-size: 1.2rem; }
.starter-item strong, .starter-item p { display: block; margin: 0 0 3px; }
.starter-item p { color: #9c8e7b; font-size: .7rem; line-height: 1.35; }
.starter-item b { color: #d8ba7f; text-align: right; }
.starter-item b small { display: block; }
.starter-item > i { position: absolute; left: 48px; bottom: 6px; color: #bb6257; font-size: .64rem; font-style: normal; }
.starter-shop-layout > aside { position: sticky; top: 0; align-self: start; max-height: 48vh; overflow: auto; padding: 10px; border: 1px solid #4b4035; background: #171818; }
.starter-shop-layout > aside h3 { margin: 5px 0 8px; font-family: Georgia,serif; }
.starter-shop-layout > aside > div, .starter-purchased-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 5px 0; border-bottom: 1px solid #302d29; color: #b9aa94; font-size: .72rem; }
.starter-purchased-row { grid-template-columns: 1fr auto auto !important; }
.starter-purchased-row button { border: 0; color: #c26b60; background: none; font-size: .63rem; }
.starter-total { display: block; padding: 10px 0; color: #e0c188; }
.starter-shop-layout > aside > .primary-button { width: 100%; }
.hero-review { max-width: 760px; margin: auto; }
.hero-review > header { display: flex; gap: 14px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid #4d4035; }
.review-avatar { display: grid; place-items: center; width: 76px; height: 76px; overflow: hidden; border: 2px solid #8c342d; border-radius: 50%; background: #171818; font-size: 1.8rem; }
.review-avatar img { width: 100%; height: 100%; object-fit: cover; }
.hero-review h3 { margin: 2px 0; font: 700 1.7rem Georgia,serif; }
.review-vitals { display: grid; grid-template-columns: repeat(5,1fr); gap: 7px; margin: 13px 0; }
.review-vitals span { padding: 9px; border: 1px solid #4a3c33; text-align: center; color: #9f8e76; }
.review-vitals b { display: block; margin-top: 3px; color: #e0c8a5; font-size: 1.2rem; }
.review-stats { display: grid; grid-template-columns: repeat(5,1fr); gap: 6px; }
.review-stats > div { position: relative; padding: 8px; border: 1px solid #3e3832; text-align: center; }
.review-stats span, .review-stats small { display: block; color: #9c8b75; }
.review-stats strong { color: #dfc8a5; font-size: 1.15rem; }
.forpost-note { margin-top: 14px; padding: 10px; border-left: 3px solid #9e3a31; background: rgba(88,28,24,.2); color: #bca98d; }
.hero-ready-button { min-width: 190px; }

@media (max-width: 900px) {
  .combat-tracker { width: calc(100vw - 96px); grid-template-columns: 48px 1fr auto; }
  .current-turn-copy { display: none; }
  .quickbar-panel { width: calc(100vw - 96px); }
  .quickbar-slots { grid-template-columns: repeat(4,1fr); }
  .quickbar-panel > p { display: none; }
  .merchant-stock, .starter-catalog { grid-template-columns: 1fr; }
  .starter-shop-layout { grid-template-columns: 1fr 220px; }
}

/* v0.11 — управляемые окна, вместимость и инструменты сюжетной кампании */
.combat-tracker {
  top: 64px !important;
  bottom: auto !important;
}

.side-drawer {
  min-width: 320px;
  min-height: 300px;
  resize: both;
}
.side-drawer > header { cursor: move; user-select: none; }
.side-drawer > .drawer-content { max-height: calc(100% - 70px); }
.window-header-actions { display: flex; gap: 5px; }

.chat-panel {
  bottom: auto;
  height: calc(100vh - 90px);
  min-width: 320px;
  min-height: 390px;
  max-width: calc(100vw - 72px);
  max-height: calc(100vh - 64px);
  resize: both;
}
.chat-header { cursor: move; user-select: none; }
.app-dialog > form > header, .app-dialog > article > header { cursor: move; user-select: none; }
.sheet-header-actions > .icon-button { flex: 0 0 auto; }
.sheet-resize-hint::after { content: "перетащите угол для произвольного размера"; position: absolute; right: 18px; bottom: 3px; color: #755f48; font-size: 9px; pointer-events: none; }

.capacity-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
  color: #a79374;
  font-size: 11px;
}
.capacity-breakdown span { padding: 4px 7px; border: 1px solid #493a2d; background: #111313; }
.capacity-breakdown b { color: #ddc49b; }
.master-settings-stack { display: grid; gap: 6px; }
.capacity-level-setting { justify-content: space-between; }
.capacity-level-setting input { width: 92px; min-height: 32px; border: 1px solid #5a4636; background: #0b0d0d; color: #dbc8a9; text-align: center; }

.side-drawer.campaign-drawer {
  width: min(920px, calc(100vw - 110px));
  height: min(780px, calc(100vh - 86px));
}
.campaign-tabs { display: flex; gap: 3px; overflow-x: auto; margin: -5px -2px 14px; padding-bottom: 7px; border-bottom: 1px solid #49362a; }
.campaign-tabs button { flex: 0 0 auto; min-height: 34px; padding: 6px 10px; border: 1px solid #46392f; background: #121414; color: #aa987e; font-size: 11px; }
.campaign-tabs button.active { border-color: #96392f; color: #e4cda7; background: #2a1613; }
.campaign-panel-body { min-height: 0; }

.campaign-location-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; }
.campaign-location-layout > nav { display: grid; align-content: start; gap: 4px; max-height: calc(100vh - 225px); overflow: auto; padding-right: 4px; }
.campaign-location-layout > nav button { display: grid; grid-template-columns: 26px 1fr 16px; gap: 7px; align-items: center; min-height: 44px; padding: 5px 7px; border: 1px solid #3e3731; background: #111313; color: #ab9d89; text-align: left; }
.campaign-location-layout > nav button b { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid #69352e; border-radius: 50%; color: #c84a3d; }
.campaign-location-layout > nav button.active { border-color: #9a392f; background: rgba(104, 33, 27, .28); color: #e0ccb0; }
.campaign-location-layout > nav button.completed { opacity: .76; }
.campaign-location-detail { min-width: 0; }
.campaign-location-detail > header { display: flex; justify-content: space-between; gap: 14px; align-items: start; border-bottom: 1px solid #4c382d; padding-bottom: 10px; }
.campaign-location-detail h3 { margin: 2px 0 5px; color: #e2ccaa; font: 700 24px Georgia, serif; }
.campaign-location-detail header small { color: #9e8c75; line-height: 1.45; }
.campaign-location-detail select, .campaign-location-detail textarea { border: 1px solid #594538; background: #0d0f0f; color: #d5c3a7; }
.campaign-read-aloud { margin: 13px 0; padding: 15px; border-left: 3px solid #a13d32; background: linear-gradient(90deg, rgba(104, 31, 25, .25), transparent); }
.campaign-read-aloud small { color: #c15245; text-transform: uppercase; letter-spacing: .08em; }
.campaign-read-aloud p { color: #e4d4ba; font-size: 16px; line-height: 1.62; white-space: pre-wrap; }
.campaign-read-aloud button { border: 1px solid #69493a; background: #1d1916; color: #ceb995; padding: 6px 9px; }
.campaign-location-detail dl { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.campaign-location-detail dl div { padding: 9px; border: 1px solid #39342f; background: #111313; }
.campaign-location-detail dt { color: #ba4a3d; font-size: 10px; text-transform: uppercase; }
.campaign-location-detail dd { margin: 4px 0 0; color: #bdae98; font-size: 13px; line-height: 1.5; }
.campaign-location-detail blockquote { margin: 7px 0; padding: 8px 10px; border-left: 2px solid #6e4c37; color: #c8b394; }
.campaign-location-detail > label { display: grid; gap: 5px; margin-top: 10px; color: #b29f82; }

.campaign-board-settings { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 10px; padding: 10px; border: 1px solid #5a3d30; background: #171413; }
.campaign-board-settings p { margin: 0; color: #9d8970; font-size: 11px; }
.clue-link-builder { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 6px; margin-bottom: 8px; }
.clue-link-builder select, .clue-link-builder button { min-width: 0; border: 1px solid #554337; background: #111313; color: #d2c0a3; }
.clue-link-list { display: flex; flex-wrap: wrap; gap: 5px; padding: 0; list-style: none; }
.clue-link-list li { display: flex; gap: 5px; align-items: center; padding: 5px 7px; border: 1px solid #483a30; color: #ad9c85; font-size: 10px; }
.clue-link-list button { border: 0; background: none; color: #bd5145; }
.gm-clue-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.gm-clue-card { padding: 10px; border: 1px solid #3e3934; background: #111313; }
.gm-clue-card.connected, .gm-clue-card.resolved { border-color: #7e3b32; }
.gm-clue-card > header { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.gm-clue-card h3 { margin: 2px 0; color: #dbc6a5; font-size: 16px; }
.gm-clue-card p { color: #a99b86; font-size: 12px; line-height: 1.48; }
.clue-secret-type { display: inline-block; padding: 2px 5px; background: #67231d; color: #f1c9bb; text-transform: uppercase; font-size: 8px; letter-spacing: .08em; }
.clue-controls { display: grid; gap: 5px; }
.clue-controls select, .clue-controls textarea { width: 100%; border: 1px solid #4d4035; background: #0b0d0d; color: #cab99d; }

.campaign-npc-grid, .campaign-quest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.campaign-npc-card, .campaign-quest-card { padding: 11px; border: 1px solid #403a34; background: #111313; }
.campaign-npc-card > header { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center; }
.campaign-npc-card > header > span, .campaign-quest-card > span { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid #7d382f; border-radius: 50%; color: #ce4d40; }
.campaign-npc-card h3, .campaign-quest-card h3 { margin: 0; color: #dfcaa8; }
.campaign-npc-card label, .campaign-quest-card label { display: grid; gap: 4px; margin-top: 7px; color: #9e8b72; font-size: 11px; }
.campaign-npc-card input, .campaign-npc-card select, .campaign-npc-card textarea, .campaign-quest-card select { width: 100%; border: 1px solid #504136; background: #0b0d0d; color: #d1bfa2; }
.npc-stage-copy { margin: 8px 0; padding: 8px; border-left: 2px solid #7e352d; background: #171514; }
.npc-stage-copy p { margin: 4px 0; color: #b6a48b; font-size: 12px; line-height: 1.45; }
.campaign-quest-card { display: grid; grid-template-columns: 38px 1fr; gap: 9px; opacity: .82; }
.campaign-quest-card.discovered { border-color: #8e3c31; opacity: 1; }
.campaign-quest-card header { display: flex; justify-content: space-between; gap: 8px; }
.campaign-quest-card p { color: #b3a48d; line-height: 1.5; }
.quest-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 5px; }
.quest-actions button { border: 1px solid #594336; background: #1a1715; color: #d4bea0; }

.campaign-clock-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.campaign-clock-grid article { padding: 13px; border: 1px solid #443a32; background: #111313; }
.campaign-clock-grid header { display: flex; justify-content: space-between; gap: 12px; }
.campaign-clock-grid h3 { margin: 0; color: #ddc7a6; }
.campaign-clock-grid p { color: #a39179; font-size: 11px; }
.campaign-clock-grid output { color: #d04e40; font-size: 20px; }
.campaign-clock-grid input { width: 100%; accent-color: #9e352c; }
.clock-segments { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.clock-segments i { height: 8px; background: #292725; }
.clock-segments i.filled { background: #a43b31; }

.campaign-subtitle { color: #dec8a6; border-bottom: 1px solid #4a392e; padding-bottom: 7px; }
.campaign-preset-list, .campaign-cue-list { display: grid; gap: 6px; }
.campaign-preset-list article, .campaign-cue-list article { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 9px; border: 1px solid #3f3933; background: #111313; }
.campaign-cue-list article { grid-template-columns: 32px 1fr auto; }
.campaign-preset-list h3, .campaign-cue-list h3 { margin: 0 0 3px; color: #d7c2a2; font-size: 14px; }
.campaign-preset-list small, .campaign-cue-list p { margin: 0; color: #9e8d76; font-size: 11px; }
.campaign-preset-list button, .campaign-cue-list button { border: 1px solid #694739; background: #211815; color: #ddc5a2; padding: 7px 9px; }
.campaign-cue-list > article > span { color: #c64b3e; font-size: 20px; text-align: center; }

.campaign-recap-form, .decision-master form { display: grid; gap: 8px; margin-bottom: 14px; padding: 12px; border: 1px solid #4b3b31; background: #111313; }
.campaign-recap-form label, .decision-master form label { display: grid; gap: 4px; color: #aa9679; }
.campaign-recap-form input, .campaign-recap-form textarea, .decision-master input, .decision-master textarea { border: 1px solid #554337; background: #0a0c0c; color: #d8c5a5; }
.campaign-recap-list { display: grid; gap: 7px; }
.campaign-recap-card { padding: 11px; border-left: 3px solid #84342c; background: #121414; }
.campaign-recap-card h3 { margin: 4px 0; color: #d8c2a0; }
.campaign-recap-card p { color: #ad9d85; line-height: 1.55; white-space: pre-wrap; }
.campaign-recap-card small { color: #7f725f; }
.finale-mechanics, .decision-master { margin-bottom: 14px; padding: 12px; border: 1px solid #493a31; background: #111313; }
.finale-mechanics h3, .decision-master h3 { color: #dec7a3; }
.finale-flags { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.finale-flags label { padding: 7px; border: 1px solid #3f3731; color: #b6a48b; }
.finale-outcomes article { margin-top: 9px; padding: 10px; border-left: 3px solid #a33b31; background: #1a1514; }
.finale-outcomes h4 { margin: 0; color: #e1c8a3; }
.active-decision ul { padding-left: 20px; color: #baa78a; }
.active-decision li b { float: right; color: #d05043; }

.player-investigation > header { margin-bottom: 14px; padding: 12px; border-left: 3px solid #a23b31; background: rgba(95, 31, 25, .2); }
.player-investigation h3, .player-investigation h4 { color: #dfc9a5; }
.player-investigation > header p { color: #a9967c; }
.player-clue-grid, .campaign-public-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.player-clue-card, .campaign-public-card { display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 10px; border: 1px solid #423a33; background: #111313; }
.player-clue-card > span, .campaign-public-card > span { color: #c64b3e; font-size: 23px; text-align: center; }
.player-clue-card h3, .campaign-public-card h3 { margin: 0; color: #d8c4a4; }
.player-clue-card p, .campaign-public-card p { color: #ab9b84; line-height: 1.5; }

.decision-overlay { position: fixed; z-index: 92; inset: 0; display: grid; place-items: center; }
.decision-card { position: relative; z-index: 2; width: min(680px, calc(100vw - 80px)); max-height: calc(100vh - 100px); overflow: auto; padding: 18px; background: radial-gradient(circle at 50% 0, rgba(131, 39, 30, .3), transparent 45%), #0b0d0d; }
.decision-card > div > header { display: flex; justify-content: space-between; align-items: start; border-bottom: 1px solid #54382d; padding-bottom: 10px; }
.decision-card h2 { margin: 2px 0; color: #e2cba6; font-size: 28px; }
.decision-question { color: #d0bea0; font-size: 17px; line-height: 1.55; }
.decision-options { display: grid; gap: 8px; }
.decision-option, .decision-result { display: flex; justify-content: space-between; gap: 10px; padding: 13px; border: 1px solid #514238; background: #141616; color: #d7c4a5; text-align: left; }
.decision-option.selected, .decision-result.own { border-color: #ad4135; background: #2b1714; }
.decision-card footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; color: #92826d; }
.decision-card footer button { border: 1px solid #594436; background: #191715; color: #ccb594; }

@media (max-width: 900px) {
  .side-drawer.campaign-drawer { width: calc(100vw - 74px); height: calc(100vh - 74px); }
  .campaign-location-layout { grid-template-columns: 1fr; }
  .campaign-location-layout > nav { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 170px; }
  .gm-clue-grid, .campaign-npc-grid, .campaign-quest-grid, .campaign-clock-grid, .player-clue-grid, .campaign-public-grid { grid-template-columns: 1fr; }
  .campaign-location-detail dl { grid-template-columns: 1fr; }
  .chat-panel { resize: none; }
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050607;
  color: var(--paper);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blood-bright);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.blood-frame {
  position: relative;
  border: 1px solid #684b2d;
  box-shadow:
    0 0 0 4px #090a0a,
    0 0 0 5px #35291e,
    0 22px 70px var(--shadow),
    inset 0 0 36px rgba(0, 0, 0, 0.82);
  background:
    radial-gradient(circle at 82% 0, rgba(125, 34, 24, 0.13), transparent 32%),
    linear-gradient(135deg, #111516, #060809 60%, #0c0d0d);
}

.blood-frame::before,
.blood-frame::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 5;
  width: 18px;
  height: 18px;
  border-color: var(--blood);
}

.blood-frame::before {
  left: 5px;
  top: 5px;
  border-left: 1px solid;
  border-top: 1px solid;
}

.blood-frame::after {
  right: 5px;
  bottom: 5px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-dim);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  padding: 0 18px;
  border-radius: 3px;
  cursor: pointer;
}

.primary-button {
  border: 1px solid #a33323;
  background: linear-gradient(#3a1612, #180d0b);
  color: #e1c69a;
  box-shadow: inset 0 0 0 2px #100a09, 0 0 18px rgba(164, 42, 27, 0.18);
}

.primary-button:hover {
  border-color: var(--blood-bright);
  background: linear-gradient(#4c1a14, #1e0d0a);
}

.ghost-button {
  border: 1px solid #56462f;
  background: #101313;
  color: var(--gold);
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #54432d;
  border-radius: 50%;
  background: #0c0f10;
  color: var(--gold);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(3, 5, 5, 0.74), rgba(3, 5, 5, 0.9)),
    url("/assets/battlemap.jpg") center / cover;
}

.login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 18%, rgba(0, 0, 0, 0.72) 78%);
}

.login-card {
  z-index: 1;
  width: min(520px, 100%);
  padding: 42px;
  text-align: center;
}

.sigil {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--blood);
  border-radius: 50%;
  color: var(--blood-bright);
  font-size: 38px;
  box-shadow: inset 0 0 20px rgba(158, 37, 25, 0.3), 0 0 30px rgba(158, 37, 25, 0.18);
}

.login-card h1 {
  margin: 0;
  color: #d4b886;
  font-size: clamp(30px, 6vw, 47px);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.login-copy {
  max-width: 390px;
  margin: 16px auto 28px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  text-align: left;
}

.login-form label,
.app-dialog label {
  display: grid;
  gap: 7px;
  color: var(--gold);
  font-size: 13px;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #58472e;
  border-radius: 3px;
  background: #080a0a;
  color: #e0d5c0;
}

input {
  height: 38px;
  padding: 0 11px;
}

select {
  height: 38px;
  padding: 0 9px;
}

textarea {
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.45;
}

.form-error {
  min-height: 18px;
  margin: 8px 0 0;
  color: #d87569;
  font-size: 12px;
}

.prototype-codes {
  margin-top: 20px;
  border-top: 1px solid #382e22;
  padding-top: 14px;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
}

.prototype-codes summary {
  cursor: pointer;
}

.prototype-codes div {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.prototype-codes button {
  border: 1px solid #59462f;
  border-radius: 3px;
  background: #0c1010;
  color: var(--gold);
  cursor: pointer;
}

.game-app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 72px 1fr;
  grid-template-rows: 58px 1fr;
  background: #060808;
}

.topbar {
  z-index: 30;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 14px;
  border-bottom: 1px solid #4a3927;
  background: rgba(7, 9, 9, 0.96);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65);
}

.brand-lockup,
.topbar-status {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 10px;
}

.brand-lockup strong {
  display: block;
  color: var(--gold);
  font-size: 17px;
  font-weight: 500;
}

.brand-lockup small {
  color: var(--muted);
  font-size: 11px;
}

.brand-mark {
  color: var(--blood-bright);
  font-size: 25px;
}

.topbar-status {
  gap: 14px;
  font-size: 11px;
}

.connection-status {
  color: #a8b1ab;
}

.connection-status i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(85, 184, 144, 0.7);
}

.connection-status.offline i {
  background: #b23a2b;
}

.save-status {
  color: var(--gold-dim);
}

.role-badge {
  padding: 5px 9px;
  border: 1px solid #5b472e;
  border-radius: 999px;
  color: var(--gold);
}

.tool-rail {
  z-index: 25;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  border-right: 1px solid #4a3825;
  background: linear-gradient(90deg, #0a0d0e, #080a0a);
}

.rail-button {
  position: relative;
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 58px;
  padding: 6px 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #7f7463;
  cursor: pointer;
}

.rail-button:hover,
.rail-button.active {
  border-color: #533c28;
  background: #111313;
  color: var(--gold);
}

.rail-button.active::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  background: var(--blood-bright);
  box-shadow: 0 0 10px var(--blood);
}

.rail-button span {
  font-size: 23px;
}

.rail-button small {
  font-size: 10px;
}

.rail-button b {
  position: absolute;
  right: 4px;
  top: 4px;
  min-width: 17px;
  padding: 2px 4px;
  border-radius: 99px;
  background: var(--blood);
  color: white;
  font: 10px Arial, sans-serif;
}

.rail-button-bottom {
  margin-top: auto;
}

.map-viewport {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  overflow: hidden;
  cursor: grab;
  background: #050707;
  user-select: none;
}

.map-viewport.panning {
  cursor: grabbing;
}

.map-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1600px;
  height: 1024px;
  transform-origin: 0 0;
  will-change: transform;
  background: #0b1110;
  box-shadow: 0 0 120px #000;
}

.battlemap,
.grid-overlay,
.scene-geometry-layer,
.fog-layer,
.token-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.battlemap { z-index: 0; }
.grid-overlay { z-index: 1; }
.scene-geometry-layer { z-index: 2; }
.token-layer { z-index: 3; }
.fog-layer { z-index: 4; }

.scene-geometry-layer {
  overflow: visible;
  pointer-events: none;
}

.scene-wall {
  stroke: #050505;
  stroke-linecap: round;
  pointer-events: stroke;
  cursor: pointer;
  filter: drop-shadow(0 1px 1px rgba(218, 197, 157, 0.26));
}

.scene-door {
  pointer-events: stroke;
  cursor: pointer;
}

.scene-door .door-halo {
  stroke: rgba(5, 5, 5, 0.88);
  stroke-width: 15;
  stroke-linecap: square;
}

.scene-door .door-leaf {
  stroke: #c08945;
  stroke-width: 8;
  stroke-linecap: square;
}

.scene-door circle {
  fill: #17100c;
  stroke: #dec08a;
  stroke-width: 2;
}

.scene-door.door-open .door-leaf {
  stroke: #5fbd8d;
  stroke-dasharray: 12 10;
}

.scene-door.door-locked .door-leaf {
  stroke: #b22f26;
}

.scene-trap {
  pointer-events: all;
  cursor: pointer;
}

.scene-trap circle {
  fill: rgba(12, 7, 6, 0.84);
  stroke: #d34a35;
  stroke-width: 3;
}

.scene-trap text {
  fill: #ebc78b;
  font-size: 25px;
  font-family: Georgia, serif;
}

.scene-trap.hidden-trap {
  opacity: 0.55;
}

.scene-trap.hidden-trap circle {
  stroke-dasharray: 4 4;
}

.scene-drawing-preview {
  pointer-events: none;
  stroke-linecap: round;
  stroke-dasharray: 13 8;
}

.scene-drawing-preview.wall-preview { stroke: #050505; }
.scene-drawing-preview.door-preview { stroke: #d0a05c; }

.fog-layer {
  pointer-events: none;
}

.fog-fill {
  fill: rgba(0, 0, 0, 0.965);
}

.fog-memory rect {
  fill: rgba(23, 27, 28, var(--fog-memory-opacity, 0.58));
}

.scene-light {
  pointer-events: all;
  cursor: pointer;
}

.scene-light-radius {
  fill: rgba(232, 183, 91, 0.08);
  stroke: rgba(225, 157, 58, 0.86);
  stroke-width: 3;
  stroke-dasharray: 14 9;
}

.scene-light-core {
  fill: #1b1009;
  stroke: #f0b24c;
  stroke-width: 3;
}

.scene-light text,
.scene-light-preview text {
  fill: #ffd782;
  font: 20px Georgia, serif;
  pointer-events: none;
}

.scene-light.disabled { opacity: 0.38; }
.scene-light.disabled .scene-light-radius { fill: transparent; stroke: #746757; }

.scene-light-preview { pointer-events: none; }
.scene-light-preview circle {
  fill: rgba(255, 203, 104, 0.1);
  stroke: #ffd074;
  stroke-width: 3;
  stroke-dasharray: 13 8;
}

.battlemap {
  object-fit: cover;
  filter: saturate(0.78) brightness(0.66) contrast(1.1);
  pointer-events: none;
}

.grid-overlay {
  pointer-events: none;
  background-image:
    linear-gradient(rgba(183, 158, 105, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(183, 158, 105, 0.28) 1px, transparent 1px);
  background-size: 64px 64px;
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.75);
}

.token-layer {
  pointer-events: none;
}

.token {
  position: absolute;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 3px solid var(--token-color, #a93425);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, #3c3b36, #0c0e0e 68%);
  color: #e4d6bd;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.68), 0 0 0 2px #090a0a, 0 0 16px color-mix(in srgb, var(--token-color) 52%, transparent);
  cursor: not-allowed;
  pointer-events: auto;
  touch-action: none;
}

.token.owned {
  cursor: grab;
}

.token.monster-token:not(.owned) {
  cursor: zoom-in;
}

.token.monster-token img {
  filter: contrast(1.06) saturate(0.84);
}

.token.dragging {
  z-index: 20;
  cursor: grabbing;
  filter: brightness(1.18);
}

.token img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}

.token-initial {
  font-size: 23px;
  text-transform: uppercase;
}

.token-name {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: max-content;
  padding: 3px 8px;
  border: 1px solid #5b472f;
  border-radius: 3px;
  background: rgba(7, 9, 9, 0.9);
  color: #d1c5ae;
  font-size: 12px;
  pointer-events: none;
}

.scene-ribbon {
  position: absolute;
  left: 20px;
  top: 18px;
  z-index: 3;
  padding: 8px 18px 8px 12px;
  border-left: 3px solid var(--blood);
  background: rgba(8, 10, 10, 0.84);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.scene-ribbon span {
  display: block;
  color: var(--gold-dim);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.scene-ribbon strong {
  color: #d2c3a6;
  font-size: 14px;
  font-weight: 500;
}

.zoom-controls {
  position: absolute;
  left: 20px;
  bottom: 20px;
  z-index: 6;
  display: flex;
  align-items: center;
  border: 1px solid #59452d;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(8, 10, 10, 0.92);
}

.zoom-controls button,
.zoom-controls output {
  height: 34px;
  min-width: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-right: 1px solid #392f23;
  background: transparent;
  color: var(--gold);
}

.zoom-controls button {
  cursor: pointer;
}

.zoom-controls output {
  min-width: 52px;
  color: var(--muted);
  font-size: 11px;
}

.map-hint {
  position: absolute;
  right: 18px;
  bottom: 13px;
  z-index: 3;
  margin: 0;
  color: rgba(199, 187, 162, 0.58);
  font-size: 10px;
  pointer-events: none;
}

.map-viewport.monster-drop-ready::after {
  content: "Отпустите — появится круглый токен";
  position: absolute;
  z-index: 18;
  inset: 16px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(205, 64, 43, 0.84);
  background: rgba(45, 10, 8, 0.24);
  color: #e1c69a;
  font-size: 18px;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 7px #000;
  pointer-events: none;
}

.side-drawer {
  position: fixed;
  z-index: 40;
  left: 84px;
  top: 70px;
  width: min(350px, calc(100vw - 110px));
  max-height: calc(100vh - 90px);
  border: 1px solid #674d30;
  background: rgba(9, 11, 11, 0.97);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}

.side-drawer.knowledge-drawer {
  width: min(520px, calc(100vw - 110px));
}

.side-drawer > header,
.app-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  border-bottom: 1px solid #3f3021;
}

.side-drawer h2,
.app-dialog h2 {
  margin: 0;
  color: var(--gold);
  font-size: 22px;
  font-weight: 500;
}

.drawer-content {
  max-height: calc(100vh - 170px);
  padding: 14px;
  overflow: auto;
}

.knowledge-tabs {
  display: flex;
  margin: -3px 0 13px;
  border-bottom: 1px solid #443224;
}

.knowledge-tabs button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #817461;
  cursor: pointer;
}

.knowledge-tabs button:hover,
.knowledge-tabs button.active {
  border-bottom-color: var(--blood-bright);
  background: rgba(121, 31, 22, 0.12);
  color: #d1ba90;
}

.knowledge-tabs b {
  min-width: 23px;
  padding: 2px 6px;
  border-radius: 99px;
  background: #2a1512;
  color: #c75642;
  font: 10px Arial, sans-serif;
}

.magic-level-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 13px;
}

.magic-level-tabs button {
  position: relative;
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 5px;
  padding: 6px 7px;
  border: 1px solid #3d3025;
  border-radius: 3px;
  background: #0b0d0d;
  color: #7c705f;
  text-align: left;
  cursor: pointer;
}

.magic-level-tabs button:hover,
.magic-level-tabs button.active {
  border-color: #863326;
  background: radial-gradient(circle at 78% 50%, rgba(137, 37, 26, 0.32), transparent 54%), #100d0c;
  color: #cfb98f;
}

.magic-level-tabs span {
  grid-column: 1 / -1;
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.magic-level-tabs b {
  color: #bd4a38;
  font-size: 16px;
  font-weight: 500;
}

.magic-level-tabs small {
  color: #655b4d;
  font: 9px Arial, sans-serif;
}

.magic-results-heading {
  display: flex;
  justify-content: space-between;
  margin: 5px 0 8px;
  color: #a38e6d;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.magic-results-heading b {
  color: #a64334;
  font-weight: 500;
}

.magic-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.magic-library-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  min-height: 132px;
  overflow: hidden;
  border: 1px solid #4c3828;
  border-radius: 3px;
  background: #0b0d0d;
  cursor: grab;
}

.magic-library-card:hover,
.magic-library-card:focus-visible {
  border-color: #853226;
  outline: none;
  box-shadow: inset 0 0 24px rgba(104, 28, 21, 0.15);
}

.magic-library-card.dragging {
  opacity: 0.45;
}

.magic-card-image {
  position: relative;
  min-height: 132px;
  border-right: 1px solid #4c3828;
  background: #070909;
}

.magic-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.15) contrast(1.06);
}

.magic-card-image span {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 3px 5px;
  border: 1px solid #59432e;
  background: rgba(5, 7, 7, 0.9);
  color: #af9265;
  font-size: 7px;
  text-transform: uppercase;
}

.magic-card-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
}

.magic-card-copy > div {
  display: flex;
  justify-content: space-between;
  gap: 5px;
}

.magic-card-copy h3 {
  margin: 1px 0 7px;
  color: #d0bc98;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.15;
}

.magic-card-copy i {
  color: #a44234;
  font-style: normal;
}

.magic-card-copy > p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #8e8372;
  font-size: 8px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  white-space: pre-line;
}

.magic-source {
  display: inline-block;
  margin-top: 12px;
}

.item-category-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 13px;
}

.item-category-tabs button {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #3d3025;
  border-radius: 3px;
  background: #0b0d0d;
  color: #7c705f;
  text-align: left;
  cursor: pointer;
}

.item-category-tabs button:hover,
.item-category-tabs button.active {
  border-color: #863326;
  background: radial-gradient(circle at 13% 50%, rgba(137, 37, 26, 0.3), transparent 40%), #100d0c;
  color: #cfb98f;
}

.item-category-tabs button > span {
  color: #a73c2d;
  font-size: 18px;
  text-align: center;
}

.item-category-tabs strong {
  overflow: hidden;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.15;
  text-overflow: ellipsis;
}

.item-category-tabs b {
  min-width: 20px;
  padding: 2px 4px;
  border-radius: 99px;
  background: #241512;
  color: #9b4a3c;
  font: 9px Arial, sans-serif;
  text-align: center;
}

.item-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.item-library-grid > .empty-state {
  grid-column: 1 / -1;
}

.item-library-card {
  min-width: 0;
  min-height: 134px;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #4c3828;
  border-radius: 3px;
  background: #0b0d0d;
  cursor: grab;
}

.item-library-card:hover,
.item-library-card:focus-visible {
  border-color: #853226;
  outline: none;
  box-shadow: inset 0 0 24px rgba(104, 28, 21, 0.15);
}

.item-library-card.dragging {
  opacity: 0.45;
}

.item-card-emblem {
  min-height: 134px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  border-right: 1px solid #4c3828;
  background:
    repeating-radial-gradient(circle at 50% 43%, transparent 0 11px, rgba(126, 45, 32, 0.13) 12px 13px),
    radial-gradient(circle at 50% 42%, #252421, #070909 72%);
}

.item-library-card.magical .item-card-emblem {
  background:
    repeating-radial-gradient(circle at 50% 43%, transparent 0 10px, rgba(158, 43, 30, 0.2) 11px 12px),
    radial-gradient(circle at 50% 42%, #34201c, #070909 72%);
}

.item-card-emblem > span {
  color: #b14a38;
  font-size: 34px;
  line-height: 1;
  text-shadow: 0 0 16px rgba(157, 50, 36, 0.42);
}

.item-card-emblem small {
  padding: 3px 5px;
  border: 1px solid #56412e;
  color: #917b5d;
  font-size: 7px;
  text-transform: uppercase;
}

.item-card-copy {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.item-card-copy h3 {
  margin: 1px 15px 0 0;
  color: #d0bc98;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.15;
}

.item-card-copy > i {
  position: absolute;
  right: 7px;
  top: 7px;
  color: #a44234;
  font-style: normal;
}

.item-card-copy > p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #8e8372;
  font-size: 8px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  white-space: pre-line;
}

.item-stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.item-stat-chips span {
  padding: 2px 4px;
  border: 1px solid #493827;
  border-radius: 2px;
  color: #a8906b;
  font: 7px Arial, sans-serif;
}

.item-stat-chips .item-price {
  border-color: #67482d;
  color: #c19a5a;
}

.knowledge-warning {
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid #67432a;
  border-left: 3px solid #b16931;
  background: #17110d;
  color: #c3a67f;
  font-size: 10px;
  line-height: 1.4;
}

.monster-search {
  display: grid;
  gap: 5px;
  color: var(--gold-dim);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.monster-drag-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 9px 0 12px;
  color: #817663;
  font-size: 10px;
  line-height: 1.4;
}

.monster-drag-hint span {
  color: var(--blood-bright);
  font-size: 18px;
}

.monster-detail {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #67462d;
  background:
    radial-gradient(circle at 12% 12%, rgba(117, 31, 23, 0.18), transparent 32%),
    #0d0f0f;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.42);
}

.monster-detail.dragging,
.monster-list-card.dragging {
  opacity: 0.45;
}

.monster-detail-heading {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.monster-detail-heading h3 {
  margin: 0 0 5px;
  color: #dcc59c;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.05;
  text-transform: uppercase;
}

.monster-detail-heading small {
  color: #766b5b;
  font-size: 9px;
}

.monster-detail-image {
  position: relative;
  width: 116px;
  height: 150px;
  overflow: hidden;
  border: 1px solid #86613b;
  background: #090b0b;
  cursor: grab;
}

.monster-detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.monster-detail-image span {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 5px;
  padding: 4px;
  background: rgba(5, 7, 7, 0.9);
  color: #c7a872;
  font-size: 8px;
  text-align: center;
}

.monster-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.monster-stat {
  min-width: 0;
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 5px 3px;
  border: 1px solid #4b3827;
  border-radius: 3px;
  background: #090b0b;
  color: #d8c6a5;
  cursor: pointer;
}

.monster-stat:hover {
  border-color: #8b3022;
  background: #15100e;
}

.monster-stat small {
  color: #887862;
  font-size: 8px;
  text-transform: uppercase;
}

.monster-stat strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  white-space: pre-line;
}

.monster-description {
  display: grid;
  gap: 7px;
  padding-top: 2px;
  border-top: 1px solid #352a20;
}

.monster-description p {
  margin: 0;
  color: #b9ad9b;
  font-size: 11px;
  line-height: 1.48;
  white-space: pre-line;
}

.monster-description strong {
  color: #b99f71;
  font-weight: 500;
}

.monster-source {
  justify-self: start;
  color: #796b57;
  font-size: 9px;
  text-decoration: none;
}

.monster-source:hover {
  color: var(--gold);
  text-decoration: underline;
}

.monster-results-heading {
  display: flex;
  justify-content: space-between;
  margin: 16px 0 8px;
  color: #9c8a70;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.monster-results-heading b {
  color: #655b4d;
  font-weight: 400;
}

.monster-library-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.monster-list-card {
  min-width: 0;
  border: 1px solid #3f3327;
  border-radius: 3px;
  background: #0c0e0e;
}

.monster-list-card.selected,
.monster-list-card:hover {
  border-color: #7e2e22;
  background: #15100e;
}

.monster-list-card > button {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 7px;
  padding: 5px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.monster-list-card img {
  width: 46px;
  height: 56px;
  border: 1px solid #4a3929;
  object-fit: cover;
}

.monster-list-card strong,
.monster-list-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monster-list-card strong {
  color: #c9b89c;
  font-size: 11px;
  font-weight: 500;
}

.monster-list-card small {
  margin-top: 5px;
  color: #746958;
  font-size: 8px;
}

.monster-list-card i {
  color: #8c3b2d;
  font-style: normal;
  cursor: grab;
}

.character-list,
.handout-list {
  display: grid;
  gap: 10px;
}

.add-character-button {
  min-height: 42px;
  border: 1px dashed #6d432e;
  border-radius: 4px;
  background: rgba(22, 13, 11, 0.72);
  color: #b79669;
  cursor: pointer;
  font-size: 11px;
}

.add-character-button:hover {
  border-color: #a23a2b;
  background: #1b0f0d;
  color: #dfbd86;
}

.character-card,
.handout-card {
  border: 1px solid #443728;
  border-radius: 4px;
  background: #0d1010;
}

.character-card {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  cursor: pointer;
}

.character-card:hover,
.character-card.active {
  border-color: #7f2d20;
  background: #15110f;
}

.mini-avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid #725537;
  border-radius: 50%;
  background: #090b0b;
  color: var(--gold);
  overflow: hidden;
}

.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-card strong {
  display: block;
  color: #d3c5ac;
  font-size: 14px;
}

.character-card small {
  color: var(--muted);
  font-size: 11px;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #544f45;
}

.presence-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(85, 184, 144, 0.65);
}

.drawer-action {
  width: 100%;
  margin-bottom: 12px;
}

.handout-card {
  padding: 13px;
}

.handout-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.handout-card h3 {
  margin: 0;
  color: #d0b889;
  font-size: 15px;
  font-weight: 500;
}

.handout-card time {
  color: #6e6557;
  font-size: 9px;
}

.handout-card p {
  margin: 10px 0 0;
  color: #bcb2a1;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.delete-button {
  border: 0;
  background: transparent;
  color: #8c4b43;
  cursor: pointer;
}

.empty-state {
  padding: 28px 14px;
  border: 1px dashed #433628;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.character-sheet {
  position: fixed;
  z-index: 35;
  top: 74px;
  right: 18px;
  width: clamp(440px, 33vw, 560px);
  height: calc(100vh - 94px);
  min-width: 420px;
  min-height: 560px;
  max-width: 72vw;
  max-height: calc(100vh - 70px);
  resize: both;
  overflow: hidden;
}

.sheet-header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid #5b432c;
  background: linear-gradient(90deg, #0b0e0e, #100b0a);
  cursor: move;
  user-select: none;
}

.sheet-header strong {
  color: var(--gold);
  font-size: 15px;
  font-weight: 500;
}

.sheet-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gm-sheet-actions {
  display: flex;
  gap: 5px;
}

.gm-sheet-actions button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #5b402b;
  border-radius: 3px;
  background: #0b0e0e;
  color: #aa9169;
  cursor: pointer;
  font-size: 8px;
  white-space: nowrap;
}

.gm-sheet-actions button:hover,
.gm-sheet-actions button.active {
  border-color: #983325;
  color: #ddb981;
}

#reset-character {
  color: #a8685e;
}

.drag-label {
  color: #695d4e;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sheet-body {
  height: calc(100% - 54px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
}

.sheet-content {
  min-width: 0;
  padding: 14px 12px 22px 14px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #5a3927 #0a0c0c;
}

.sheet-tabs {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  border-left: 1px solid #4d3927;
  background: #090b0b;
}

.sheet-tabs button {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid #392c20;
  background: transparent;
  color: #81735f;
  cursor: pointer;
  font-size: 10px;
  writing-mode: vertical-rl;
}

.sheet-tabs button span {
  font-size: 21px;
  writing-mode: horizontal-tb;
}

.sheet-tabs button.active {
  background: radial-gradient(circle, rgba(132, 33, 23, 0.34), transparent 65%), #130d0c;
  color: var(--blood-bright);
  box-shadow: inset 4px 0 0 #8e2c20;
}

.sheet-resize-hint {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 12px;
  height: 12px;
  border-right: 2px solid #765539;
  border-bottom: 2px solid #765539;
  pointer-events: none;
}

.generation-overlay {
  position: fixed;
  z-index: 90;
  inset: 58px 0 0 72px;
  display: grid;
  place-items: center;
  padding: 24px;
}

.generation-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(88, 22, 16, 0.28), transparent 42%),
    rgba(2, 4, 4, 0.82);
  backdrop-filter: blur(5px) saturate(0.65);
}

.generation-card {
  position: relative;
  width: min(860px, 100%);
  max-height: calc(100vh - 106px);
  overflow: hidden;
}

.generation-content {
  max-height: calc(100vh - 106px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #6b3928 #080a0a;
}

.generation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 16px;
  border-bottom: 1px solid #483224;
  background: linear-gradient(90deg, rgba(12, 15, 15, 0.98), rgba(29, 11, 9, 0.96));
}

.generation-heading h2 {
  margin: 0;
  color: #d6b77f;
  font-size: clamp(22px, 3vw, 31px);
  font-weight: 500;
}

.generation-seal {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid #8e3023;
  border-radius: 50%;
  color: #c04431;
  font-size: 24px;
  box-shadow: inset 0 0 18px rgba(131, 33, 23, 0.34), 0 0 22px rgba(112, 25, 18, 0.22);
}

.generation-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 10px 26px 0;
}

.generation-progress i {
  height: 3px;
  border-radius: 99px;
  background: #2f2922;
}

.generation-progress i.done {
  background: #6e5533;
}

.generation-progress i.active {
  background: #b83a2a;
  box-shadow: 0 0 9px rgba(190, 55, 39, 0.5);
}

.generation-copy {
  max-width: 690px;
  margin: 14px 26px 0;
  color: #958875;
  font-size: 12px;
  line-height: 1.55;
}

.generation-body {
  display: grid;
  gap: 14px;
  padding: 18px 26px 24px;
}

.generation-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 26px 20px;
  border-top: 1px solid #483224;
  background: rgba(7, 9, 9, 0.94);
}

.generation-footer button:disabled,
.generation-content button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.55);
}

.generated-stats-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.generated-stat {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #3c3026;
  border-radius: 3px;
  background: #0a0d0d;
}

.generated-stat > span {
  color: #917e61;
  font-size: 9px;
  text-transform: uppercase;
}

.generated-stat > div {
  display: flex;
  gap: 3px;
}

.generated-stat i {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid #4f3c2b;
  border-radius: 3px;
  color: #bca985;
  font: normal 9px Arial, sans-serif;
}

.generated-stat i.dropped {
  color: #725650;
  text-decoration: line-through;
  opacity: 0.55;
}

.generated-stat > strong {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #d1b47e;
  font-size: 21px;
  font-weight: 500;
}

.generated-stat > strong small {
  min-width: 24px;
  padding: 2px 4px;
  border: 1px solid #673126;
  border-radius: 99px;
  color: #c45948;
  font: 9px Arial, sans-serif;
  text-align: center;
}

.stat-roll-stage {
  min-height: 285px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  border: 1px solid #4b3727;
  background:
    radial-gradient(circle, rgba(112, 30, 22, 0.22), transparent 50%),
    #080b0b;
  text-align: center;
}

.stat-roll-stage > small {
  color: #725f48;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-roll-stage h3 {
  margin: 9px 0 6px;
  color: #ddc18e;
  font-size: 28px;
  font-weight: 500;
}

.stat-roll-stage p {
  max-width: 480px;
  margin: 0 0 22px;
  color: #998c78;
  font-size: 13px;
  line-height: 1.55;
}

.generation-dice-button {
  min-width: 210px;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 13px 20px;
  border: 1px solid #8e3527;
  border-radius: 4px;
  background: linear-gradient(#381511, #120b09);
  color: #d8bc87;
  cursor: pointer;
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.54), 0 0 24px rgba(119, 30, 21, 0.18);
}

.generation-dice-button strong {
  font-size: 14px;
  font-weight: 500;
}

.generation-dice-button small {
  color: #786b59;
  font-size: 8px;
}

.four-dice {
  display: flex;
  margin-bottom: 5px;
  padding-left: 9px;
}

.four-dice i {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin-left: -9px;
  border: 1px solid #9a5a3a;
  border-radius: 5px;
  background: linear-gradient(145deg, #5b1c15, #111515 70%);
  color: #e6c995;
  font: normal 11px Arial, sans-serif;
  transform: rotate(var(--dice-tilt, -7deg));
  box-shadow: 0 4px 7px rgba(0, 0, 0, 0.5);
}

.four-dice i:nth-child(2) { --dice-tilt: 6deg; }
.four-dice i:nth-child(3) { --dice-tilt: -3deg; }
.four-dice i:nth-child(4) { --dice-tilt: 9deg; }

.generation-class-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.generation-class-button {
  position: relative;
  min-height: 124px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 10px 7px;
  border: 1px solid #443428;
  border-radius: 3px;
  background: #0a0d0d;
  color: #857762;
  cursor: pointer;
  text-align: center;
}

.generation-class-button > span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #5c432e;
  border-radius: 50%;
  color: #a84a38;
  font-size: 21px;
}

.generation-class-button strong {
  color: #bca77e;
  font-size: 14px;
  font-weight: 500;
}

.generation-class-button small {
  min-height: 22px;
  font-size: 8px;
  line-height: 1.35;
}

.generation-class-button > i {
  color: #6f4a43;
  font-size: 7px;
  font-style: normal;
  text-transform: uppercase;
}

.generation-class-button.selected:not(:disabled),
.generation-class-button:hover:not(:disabled) {
  border-color: #9f3527;
  background: radial-gradient(circle, rgba(126, 34, 25, 0.26), transparent 64%), #100d0c;
  color: #d2ba8e;
  box-shadow: inset 0 -3px 0 #8e2c20;
}

.generation-class-preview,
.chosen-class-summary,
.generation-choice-section {
  border: 1px solid #49372a;
  background: rgba(10, 13, 13, 0.94);
}

.generation-class-preview {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.generation-class-preview > header,
.chosen-class-summary > header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.generation-class-preview > header > span,
.chosen-class-summary > header > span {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  display: grid;
  place-items: center;
  border: 1px solid #753326;
  border-radius: 50%;
  color: #c14c38;
  font-size: 23px;
}

.generation-class-preview h3,
.chosen-class-summary h3,
.generation-choice-section h3 {
  margin: 0;
  color: #d0b47f;
  font-size: 18px;
  font-weight: 500;
}

.generation-class-preview header small {
  color: #786d5d;
  font-size: 8px;
}

.generation-class-rules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.generation-class-rules p,
.generation-class-rules div {
  margin: 0;
  color: #9a8e7b;
  font-size: 9px;
  line-height: 1.45;
}

.generation-class-rules span {
  display: block;
  margin-bottom: 3px;
  color: #a95040;
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.generation-class-rules ul {
  margin: 0;
  padding-left: 14px;
}

.generation-blocked {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 28px;
  border: 1px dashed #684038;
  color: #8d7f6b;
  text-align: center;
}

.generation-blocked > span {
  color: #b54131;
  font-size: 28px;
}

.generation-blocked p {
  max-width: 420px;
  margin: 0;
  font-size: 10px;
}

.chosen-class-summary {
  padding: 16px;
}

.chosen-class-summary > header {
  margin-bottom: 14px;
}

.generation-choice-section {
  padding: 16px;
}

.generation-choice-section > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.generation-choice-section > header > strong {
  color: #d74c37;
  font-size: 34px;
  font-weight: 500;
}

.generation-choice-section > p {
  margin: 7px 0 12px;
  color: #8d8270;
  font-size: 10px;
  line-height: 1.5;
}

.generation-action-button,
.improvement-row button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #713429;
  border-radius: 3px;
  background: #160d0b;
  color: #c69d70;
  cursor: pointer;
  font-size: 9px;
}

.improvement-list {
  display: grid;
  gap: 5px;
}

.improvement-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 11px;
  border: 1px solid #352d25;
  background: #080a0a;
}

.improvement-row > span {
  color: #b5a27f;
  font-size: 11px;
}

.improvement-row > span small {
  display: block;
  margin-top: 2px;
  color: #6f6658;
  font-size: 8px;
}

.generation-spell-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 330px;
  overflow: auto;
}

.generation-spell {
  min-width: 0;
  display: grid;
  grid-template-columns: 55px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid #3e3228;
  border-radius: 3px;
  background: #090b0b;
  color: #9c8d76;
  cursor: pointer;
  text-align: left;
}

.generation-spell img {
  width: 55px;
  height: 68px;
  object-fit: cover;
  filter: grayscale(1) contrast(1.1);
}

.generation-spell > span {
  min-width: 0;
}

.generation-spell strong,
.generation-spell small {
  display: block;
}

.generation-spell strong {
  color: #bca57a;
  font-size: 11px;
}

.generation-spell small {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: #6f675a;
  font-size: 8px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.generation-spell > i {
  color: #806b4e;
  font-size: 7px;
  font-style: normal;
}

.generation-spell.selected {
  border-color: #a33a2a;
  background: rgba(48, 17, 13, 0.84);
  box-shadow: inset 3px 0 0 #a33a2a;
}

.generation-identity-form {
  display: grid;
  gap: 20px;
  padding: 8px 0 0;
}

.generation-identity-form fieldset {
  margin: 0;
  padding: 13px;
  border: 1px solid #49372a;
}

.generation-identity-form legend,
.hero-name-field {
  color: #b69b70;
  font-size: 11px;
}

.gender-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.gender-choice input {
  position: absolute;
  opacity: 0;
}

.gender-choice span {
  min-height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid #46372a;
  border-radius: 3px;
  background: #090c0c;
  color: #8c806e;
  cursor: pointer;
}

.gender-choice input:checked + span {
  border-color: #a23729;
  background: radial-gradient(circle, rgba(129, 33, 23, 0.25), transparent 65%), #110d0c;
  color: #d3b681;
  box-shadow: inset 0 -3px 0 #942f22;
}

.hero-name-field {
  display: grid;
  gap: 7px;
}

.hero-name-field input {
  height: 50px;
  font-size: 18px;
  text-align: center;
}

.generation-identity-form .generation-footer {
  margin: 0 -26px -24px;
}

.money-generation {
  min-height: 330px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 30px;
  border: 1px solid #49372a;
  background: radial-gradient(circle, rgba(137, 92, 39, 0.15), transparent 52%), #080a0a;
  text-align: center;
}

.coin-sigil {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 2px solid #9e7c42;
  border-radius: 50%;
  color: #c7a65c;
  font-size: 31px;
  box-shadow: inset 0 0 20px rgba(160, 114, 47, 0.22), 0 0 25px rgba(123, 85, 32, 0.18);
}

.money-generation > p {
  max-width: 450px;
  margin: 0;
  color: #918674;
  font-size: 12px;
}

.money-die {
  min-width: 180px;
  grid-template-columns: auto auto;
  align-items: center;
}

.money-die .tray-die {
  width: 45px;
  height: 45px;
}

.money-result {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #89775b;
}

.money-result > span {
  font-size: 16px;
}

.money-result > strong {
  color: #d2ad60;
  font-size: 38px;
  font-weight: 500;
}

.money-result small {
  display: block;
  color: #776a57;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 500;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #6a251b, transparent);
}

.main-sheet {
  display: grid;
  gap: 15px;
}

.identity-grid {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(122px, 0.84fr);
  gap: 12px;
}

.field-label {
  display: grid;
  gap: 5px;
  color: var(--gold-dim);
  font-size: 10px;
}

.character-name-input {
  color: #d8c7a8;
  font-size: 15px;
}

.portrait-box {
  position: relative;
  aspect-ratio: 0.82;
  margin-top: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #725435;
  background:
    radial-gradient(circle at 50% 35%, #292c2c, #0a0c0c 66%),
    #0a0c0c;
}

.portrait-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-placeholder {
  width: 52%;
  height: 66%;
  border-radius: 48% 48% 22% 22%;
  background: #202323;
  clip-path: polygon(31% 0, 69% 0, 78% 23%, 70% 39%, 95% 55%, 100% 100%, 0 100%, 5% 55%, 30% 39%, 22% 23%);
}

.portrait-upload {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  min-height: 31px;
  border: 1px solid #6a5033;
  border-radius: 3px;
  background: rgba(6, 8, 8, 0.9);
  color: var(--gold);
  cursor: pointer;
  font-size: 10px;
}

.portrait-upload input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.level-block {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 7px;
}

.level-seal {
  width: 126px;
  height: 126px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px solid var(--blood);
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 9px, rgba(143, 43, 30, 0.13) 10px 11px);
  box-shadow: inset 0 0 0 6px #090b0b, inset 0 0 0 7px #692419;
}

.level-seal small {
  color: var(--gold-dim);
  font-size: 9px;
  text-transform: uppercase;
}

.level-seal input {
  width: 76px;
  height: 65px;
  border: 0;
  background: transparent;
  color: #e1d4bd;
  font-size: 50px;
  text-align: center;
  appearance: textfield;
}

.experience {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.experience label {
  display: grid;
  gap: 3px;
  color: var(--gold-dim);
  font-size: 8px;
  text-align: center;
}

.experience input {
  height: 27px;
  padding: 0 4px;
  text-align: center;
}

.xp-track {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  border: 1px solid #493522;
  background: #050606;
}

.xp-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7f2218, #c1462f);
}

.class-field {
  width: 100%;
  text-align: center;
}

.class-field input {
  text-align: center;
}

.vitals {
  display: grid;
  grid-template-columns: 1fr 1.28fr 1fr;
  gap: 8px;
  align-items: center;
}

.vital {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 78px;
  padding: 5px;
  color: var(--gold-dim);
  text-align: center;
  font-size: 9px;
}

.vital-shape {
  position: relative;
  width: 55px;
  height: 55px;
  display: grid;
  place-items: center;
  border: 1px solid #86291d;
  color: #e2cdb0;
  background: #0b0d0d;
}

.vital-heart .vital-shape {
  width: 78px;
  height: 68px;
  border-radius: 48% 48% 50% 50%;
  clip-path: polygon(50% 100%, 5% 48%, 5% 25%, 18% 8%, 35% 8%, 50% 24%, 65% 8%, 82% 8%, 95% 25%, 95% 48%);
}

.vital-shield .vital-shape {
  clip-path: polygon(50% 0, 92% 16%, 84% 75%, 50% 100%, 16% 75%, 8% 16%);
}

.vital-clover .vital-shape {
  border-radius: 44%;
  transform: rotate(45deg);
}

.vital-clover input {
  transform: rotate(-45deg);
}

.vital-shape input {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 25px;
  text-align: center;
}

.auto-derived {
  cursor: default;
}

.auto-derived::-webkit-inner-spin-button,
.auto-derived::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.vital strong {
  margin-top: 5px;
  font-weight: 400;
}

.hit-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hit-value {
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--gold-dim);
  font-size: 9px;
  text-align: center;
}

.hit-value input {
  width: 74px;
  height: 74px;
  border: 1px solid #8d2b1e;
  border-radius: 50%;
  color: #e1d3bb;
  font-size: 31px;
  text-align: center;
  box-shadow: inset 0 0 0 5px #080a0a, inset 0 0 0 6px #5f231a;
}

.skills-table {
  display: grid;
  gap: 5px;
}

.skills-heading,
.skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 98px;
  gap: 8px;
  align-items: center;
}

.skills-heading {
  color: var(--gold-dim);
  font-size: 9px;
  text-transform: uppercase;
}

.skill-row {
  min-height: 48px;
  border-bottom: 1px solid #2c271f;
}

.skill-name {
  color: #c7baa4;
  font-size: 12px;
}

.stat-control {
  position: relative;
  width: 48px;
  height: 48px;
  margin: 0 auto;
}

.stat-control > input:first-of-type {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #7a2a20;
  border-radius: 50%;
  color: #e2d4bc;
  font-size: 20px;
  text-align: center;
}

.stat-control .modifier-input {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 19px;
  height: 19px;
  padding: 0;
  border: 1px solid #9a6240;
  border-radius: 5px;
  background: #15100e;
  color: #ebd7b7;
  font-size: 9px;
  text-align: center;
}

.bonus-control {
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  gap: 5px;
  color: #9e8c71;
  font-size: 9px;
}

.bonus-control input {
  height: 27px;
  padding: 0 3px;
  text-align: center;
}

.items-sheet {
  display: grid;
  gap: 14px;
}

.finance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.finance-grid label {
  display: grid;
  grid-template-columns: 1fr 70px;
  align-items: center;
  gap: 5px;
  color: var(--gold-dim);
  font-size: 11px;
}

.finance-grid input {
  text-align: center;
}

.gear-and-drop {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(132px, 0.9fr);
  gap: 10px;
}

.equipment-board {
  position: relative;
  min-height: 390px;
  border-right: 1px solid #30261e;
}

.mannequin {
  position: absolute;
  left: 50%;
  top: 56px;
  width: 82px;
  height: 292px;
  transform: translateX(-50%);
  opacity: 0.56;
}

.mannequin-head {
  position: absolute;
  left: 28px;
  top: 0;
  width: 27px;
  height: 33px;
  border-radius: 48%;
  background: #303434;
}

.mannequin-body {
  position: absolute;
  left: 20px;
  top: 31px;
  width: 42px;
  height: 128px;
  border-radius: 42% 42% 22% 22%;
  background: #303434;
}

.mannequin-body::before,
.mannequin-body::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 15px;
  height: 150px;
  border-radius: 10px;
  background: #303434;
}

.mannequin-body::before {
  left: -12px;
  transform: rotate(5deg);
}

.mannequin-body::after {
  right: -12px;
  transform: rotate(-5deg);
}

.mannequin-legs::before,
.mannequin-legs::after {
  content: "";
  position: absolute;
  top: 150px;
  width: 19px;
  height: 137px;
  border-radius: 0 0 10px 10px;
  background: #303434;
}

.mannequin-legs::before {
  left: 20px;
}

.mannequin-legs::after {
  right: 20px;
}

.equipment-slot {
  position: absolute;
  z-index: 2;
  width: 42px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 3px;
  overflow: hidden;
  border: 1px solid #8a6238;
  border-radius: 4px;
  background: rgba(7, 9, 9, 0.94);
  color: #ceb789;
  box-shadow: inset 0 0 0 2px #10100e;
  text-align: center;
  font-size: 8px;
  cursor: default;
}

.equipment-slot::before,
.equipment-slot::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-color: var(--blood-bright);
}

.equipment-slot::before {
  left: 2px;
  top: 2px;
  border-left: 1px solid;
  border-top: 1px solid;
}

.equipment-slot::after {
  right: 2px;
  bottom: 2px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.equipment-slot.dragover {
  border-color: var(--blood-bright);
  box-shadow: 0 0 14px rgba(187, 51, 35, 0.45);
}

.equipment-slot.filled {
  background: #1b100d;
  cursor: pointer;
}

.slot-center-head { left: calc(50% - 21px); top: 8px; }
.slot-center-chest { left: calc(50% - 21px); top: 91px; }
.slot-center-belt { left: calc(50% - 21px); top: 178px; }
.slot-center-legs { left: calc(50% - 21px); top: 330px; }
.slot-left-arm { left: 2px; top: 126px; }
.slot-left-belt { left: 2px; top: 179px; }
.slot-right-shoulder { right: 5px; top: 72px; }
.slot-right-arm { right: 5px; top: 126px; }
.slot-right-lower { right: 5px; top: 306px; }

.drop-column {
  display: grid;
  align-content: start;
  gap: 10px;
}

.add-item-button {
  width: 100%;
  padding-inline: 6px;
  font-size: 10px;
}

.item-dropzone {
  min-height: 174px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--blood-bright);
  border-radius: 4px;
  background: rgba(8, 10, 10, 0.78);
  color: var(--gold-dim);
  text-align: center;
  font-size: 10px;
}

.item-dropzone.dragover {
  background: rgba(68, 21, 16, 0.42);
  color: #dbc094;
}

.drop-arrow {
  color: #936138;
  font-size: 33px;
}

.inventory-list {
  display: grid;
  gap: 7px;
}

.inventory-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 9px;
  border: 1px solid #44372a;
  border-radius: 3px;
  background: #0d1010;
  cursor: grab;
}

.inventory-item:active {
  cursor: grabbing;
}

.inventory-item strong {
  color: #cfbd9d;
  font-size: 12px;
  font-weight: 500;
}

.inventory-item p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.inventory-item small {
  color: var(--gold-dim);
}

.inventory-item.catalog-item {
  border-left-color: #8a3427;
}

.inventory-item.magical {
  background: radial-gradient(circle at 0 50%, rgba(130, 34, 24, 0.2), transparent 44%), #0d1010;
}

.inventory-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 9px;
}

.inventory-meta span {
  color: #a44535;
  font-size: 8px;
  text-transform: uppercase;
}

.inventory-meta small {
  color: #86765f;
  font-size: 8px;
}

.inventory-actions {
  display: flex;
  gap: 5px;
}

.inventory-actions button {
  width: 25px;
  height: 25px;
  border: 1px solid #4f3d2a;
  border-radius: 3px;
  background: #090b0b;
  color: #a78e6a;
  cursor: pointer;
}

.spells-sheet {
  display: grid;
  gap: 12px;
}

.spells-sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #483628;
}

.spells-sheet-heading .section-title {
  margin-top: 2px;
  font-size: 16px;
}

.spells-sheet-heading > b {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #6a4330;
  border-radius: 50%;
  color: #bd4b3b;
  font-weight: 500;
}

.spell-dropzone {
  min-height: 92px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 10px;
  border: 1px dashed #8f3729;
  border-radius: 4px;
  background: radial-gradient(circle, rgba(109, 28, 21, 0.17), transparent 64%), #090b0b;
  color: #ad9877;
  text-align: center;
}

.spell-dropzone > span {
  color: #b74031;
  font-size: 24px;
}

.spell-dropzone strong {
  color: #cbb792;
  font-size: 11px;
  font-weight: 500;
}

.spell-dropzone small {
  color: #756a59;
  font-size: 9px;
}

.spell-dropzone.dragover {
  border-style: solid;
  background: radial-gradient(circle, rgba(150, 44, 31, 0.38), transparent 68%), #110d0c;
  box-shadow: inset 0 0 28px rgba(133, 37, 27, 0.25);
}

.character-spell-list {
  display: grid;
  gap: 8px;
}

.character-spell-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  min-height: 126px;
  overflow: hidden;
  border: 1px solid #4c3829;
  border-radius: 3px;
  background:
    linear-gradient(100deg, rgba(121, 32, 23, 0.1), transparent 45%),
    #0b0e0e;
  cursor: pointer;
}

.character-spell-card:hover,
.character-spell-card:focus-visible {
  border-color: #853426;
  outline: none;
  box-shadow: inset 0 0 28px rgba(107, 28, 21, 0.18);
}

.character-spell-art {
  position: relative;
  min-height: 126px;
  border-right: 1px solid #4b3728;
  background: #070909;
}

.character-spell-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-spell-art span {
  position: absolute;
  left: 7px;
  bottom: 7px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid #8a5f3c;
  border-radius: 50%;
  background: rgba(8, 10, 10, 0.92);
  color: #c14d3d;
  font-size: 12px;
}

.character-spell-card > div:nth-child(2) {
  min-width: 0;
  padding: 10px 30px 10px 11px;
}

.character-spell-card h3 {
  margin: 2px 0 6px;
  color: #d1bd98;
  font-size: 14px;
  font-weight: 500;
}

.character-spell-card p:not(.eyebrow) {
  display: -webkit-box;
  margin: 0 0 7px;
  overflow: hidden;
  color: #968a78;
  font-size: 9px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  white-space: pre-line;
}

.character-spell-card small {
  color: #665d50;
  font-size: 8px;
}

.spell-remove {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 23px;
  height: 23px;
  border: 1px solid #4c382b;
  border-radius: 3px;
  background: #090b0b;
  color: #a74a3e;
  cursor: pointer;
}

.chat-future-note {
  display: flex;
  gap: 7px;
  margin: 0;
  padding: 9px;
  border-top: 1px solid #3d3025;
  color: #716758;
  font-size: 9px;
  line-height: 1.45;
}

.chat-future-note span {
  color: #9a3d31;
  font-size: 16px;
}

.placeholder-tab {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  border: 1px dashed #403429;
  color: var(--muted);
  text-align: center;
}

.placeholder-tab span {
  color: var(--blood);
  font-size: 48px;
}

.placeholder-tab h3 {
  margin: 0;
  color: var(--gold);
  font-weight: 500;
}

.placeholder-tab p {
  max-width: 260px;
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
}

.feature-editor {
  min-height: 320px;
}

.app-dialog {
  width: min(520px, calc(100vw - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  color: var(--paper);
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(2px);
}

.app-dialog form {
  display: grid;
  gap: 14px;
  padding-bottom: 18px;
}

.character-dialog {
  width: min(460px, calc(100vw - 30px));
}

.dialog-intro {
  margin: 0 18px;
  color: #8f8371;
  font-size: 11px;
  line-height: 1.5;
}

.field-help {
  color: #746a5b;
  font-size: 8px;
  line-height: 1.45;
}

.app-dialog form > label,
.app-dialog fieldset {
  margin-inline: 18px;
}

.app-dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 18px 0;
}

.app-dialog fieldset {
  display: grid;
  gap: 8px;
  border: 1px solid #493827;
  color: var(--gold-dim);
}

.app-dialog fieldset label {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: #b2a58f;
}

.app-dialog fieldset input {
  width: auto;
  height: auto;
}

.monster-dialog {
  width: min(540px, calc(100vw - 30px));
}

.monster-preview {
  display: grid;
}

.monster-preview > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #493625;
}

.monster-preview h2 {
  margin: 0;
  color: #d7bd8d;
  font-size: 24px;
  font-weight: 500;
  text-transform: uppercase;
}

.monster-preview figure {
  min-height: 300px;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle, rgba(111, 31, 22, 0.18), transparent 55%),
    #070909;
}

.monster-preview img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 68vh;
  border: 1px solid #745335;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.72);
}

.spell-dialog {
  width: min(590px, calc(100vw - 30px));
}

.spell-preview {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  background:
    radial-gradient(circle at 20% 20%, rgba(120, 31, 23, 0.2), transparent 40%),
    #090b0b;
}

.spell-preview > header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #493625;
}

.spell-preview h2 {
  margin: 0;
  color: #d7bd8d;
  font-size: 22px;
  font-weight: 500;
}

.spell-preview figure {
  min-height: 280px;
  margin: 0;
  padding: 14px;
  border-right: 1px solid #493625;
  background: #070909;
}

.spell-preview img {
  width: 100%;
  height: 100%;
  max-height: 390px;
  border: 1px solid #745335;
  object-fit: cover;
}

.spell-dialog-description {
  align-self: center;
  margin: 0;
  padding: 20px;
  color: #b9ad9a;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-line;
}

.spell-preview > footer {
  grid-column: 1 / -1;
  justify-content: flex-start;
  padding: 12px 18px;
  border-top: 1px solid #493625;
  color: #746958;
  font-size: 9px;
}

.spell-preview > footer span {
  color: #a23f32;
  font-size: 15px;
}

.chat-panel {
  position: fixed;
  z-index: 34;
  top: 72px;
  right: 18px;
  bottom: 18px;
  width: min(370px, calc(100vw - 110px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 100%, rgba(111, 27, 20, 0.2), transparent 36%),
    linear-gradient(150deg, rgba(17, 21, 21, 0.98), rgba(5, 7, 7, 0.99));
}

.chat-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid #4c3826;
  background: linear-gradient(90deg, #0b0e0e, #110b0a);
}

.chat-header h2 {
  margin: 0;
  color: var(--gold);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.chat-messages {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 13px 12px 16px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #5a3927 #080a0a;
}

.chat-empty {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5px;
  padding: 24px;
  color: #776c5c;
  text-align: center;
}

.chat-empty span {
  color: #8f3025;
  font-size: 28px;
}

.chat-empty strong {
  color: #a8916c;
  font-size: 13px;
  font-weight: 500;
}

.chat-empty small {
  max-width: 210px;
  line-height: 1.45;
}

.chat-message {
  position: relative;
  width: 91%;
  align-self: flex-start;
  padding: 9px 10px 10px;
  border: 1px solid #3e3429;
  border-left: 2px solid #685033;
  border-radius: 3px 9px 9px 9px;
  background: rgba(13, 16, 16, 0.94);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.3);
}

.chat-message.own {
  align-self: flex-end;
  border-color: #523329;
  border-left-width: 1px;
  border-right: 2px solid #9a3023;
  border-radius: 9px 3px 9px 9px;
  background: linear-gradient(135deg, rgba(43, 17, 14, 0.94), rgba(14, 13, 12, 0.96));
}

.chat-message > header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}

.chat-message > header strong {
  min-width: 0;
  overflow: hidden;
  color: #c5aa7c;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message > header span {
  color: #766a59;
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chat-message > header time {
  margin-left: auto;
  color: #615a50;
  font: 8px Arial, sans-serif;
  white-space: nowrap;
}

.chat-message > p {
  margin: 0;
  color: #c5b9a4;
  font-size: 12px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.roll-chat-message {
  width: 100%;
  border-color: #683427;
  background:
    radial-gradient(circle at 90% 20%, rgba(139, 40, 28, 0.2), transparent 38%),
    #0d1010;
}

.chat-roll-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.chat-roll-sigil {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 94% 22%, 100% 72%, 69% 100%, 23% 92%, 0 48%, 15% 13%);
  background: conic-gradient(from 30deg, #2d0e0b, #8d3024, #151818, #5d2019, #2d0e0b);
  color: #ecd1a1;
  font-size: 12px;
  text-shadow: 0 2px 3px #000;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.55));
}

.chat-roll-card p {
  margin: 0 0 5px;
  color: #8c7e69;
  font-size: 10px;
}

.chat-roll-card p b {
  color: #ccb17f;
  font-weight: 500;
}

.chat-roll-results {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.chat-roll-results i {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid #62442d;
  border-radius: 2px;
  background: #090b0b;
  color: #cfc0a5;
  font: normal 10px Arial, sans-serif;
}

.chat-roll-total {
  min-width: 42px;
  color: #d64a35;
  font: 26px/1 Georgia, serif;
  text-align: center;
  text-shadow: 0 0 12px rgba(188, 47, 31, 0.34);
}

.chat-roll-total small {
  display: block;
  margin-top: 3px;
  color: #6f6353;
  font: 7px Arial, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 7px;
  padding: 10px 11px;
  border-top: 1px solid #443225;
  background: #090b0b;
}

.chat-form input {
  height: 38px;
  padding: 0 11px;
  border-color: #493929;
  background: #070909;
  font-size: 12px;
}

.chat-form button {
  border: 1px solid #8b3024;
  border-radius: 3px;
  background: linear-gradient(#3c1712, #180c0a);
  color: #d9b77f;
  cursor: pointer;
  font-size: 17px;
}

.chat-form button:hover {
  border-color: #c24431;
  color: #f0d39d;
}

.dice-tray {
  padding: 9px 10px 11px;
  border-top: 1px solid #5a3c29;
  background:
    linear-gradient(rgba(112, 34, 25, 0.06), transparent),
    #070909;
}

.dice-tray > header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
  color: #a78d65;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dice-tray > header small {
  color: #645c50;
  font-size: 7px;
  letter-spacing: 0.04em;
}

.dice-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.dice-tool {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr 24px;
  border: 1px solid #453426;
  border-radius: 3px;
  overflow: hidden;
  background: #0b0e0e;
}

.dice-cast-button {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 4px;
  border: 0;
  background:
    radial-gradient(circle at 25% 35%, rgba(126, 37, 28, 0.2), transparent 45%),
    transparent;
  color: #bca77f;
  cursor: pointer;
}

.dice-cast-button:hover {
  background: radial-gradient(circle, rgba(139, 40, 28, 0.28), transparent 68%), #100c0b;
  color: #e0c494;
}

.dice-cast-button > span:last-child {
  min-width: 0;
  display: grid;
  text-align: left;
}

.dice-cast-button strong {
  font-size: 12px;
  font-weight: 500;
}

.dice-cast-button small {
  color: #695f50;
  font-size: 7px;
  text-transform: uppercase;
}

.tray-die {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #5e1e17, #121515 66%);
  color: #e1c79a;
  font: 11px Arial, sans-serif;
  text-shadow: 0 1px 2px #000;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.55));
}

.tray-d6 {
  border: 1px solid #8c5636;
  border-radius: 5px;
  box-shadow: inset -6px -6px 8px rgba(0, 0, 0, 0.45), inset 4px 4px 7px rgba(190, 100, 64, 0.12);
  transform: rotate(-7deg) skewY(2deg);
}

.tray-d3 {
  clip-path: polygon(50% 0, 100% 92%, 0 92%);
  padding-top: 8px;
}

.tray-d18 {
  clip-path: polygon(50% 0, 86% 13%, 100% 48%, 82% 88%, 45% 100%, 9% 78%, 0 39%, 20% 8%);
  font-size: 9px;
}

.dice-stepper {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  border-top: 1px solid #382d23;
}

.dice-stepper button,
.dice-stepper output,
.fixed-dice-count {
  min-width: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: #080a0a;
  color: #8e7e65;
  font: 10px Arial, sans-serif;
}

.dice-stepper button {
  cursor: pointer;
}

.dice-stepper button:hover:not(:disabled) {
  background: #21100d;
  color: #cf9c6c;
}

.dice-stepper button:disabled {
  color: #39352f;
  cursor: default;
}

.dice-stepper output {
  border-inline: 1px solid #32291f;
  color: #d0b888;
}

.fixed-dice-count {
  border-top: 1px solid #382d23;
  color: #5f574b;
}

.dice-flight-layer {
  position: fixed;
  z-index: 120;
  inset: 0;
  pointer-events: none;
  perspective: 1100px;
  overflow: hidden;
}

.dice-flight-group {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.thrown-die {
  --land-x: 0px;
  --land-y: 0px;
  --delay: 0ms;
  --turn: 720deg;
  position: absolute;
  left: calc(50% - 34px);
  top: calc(46% - 34px);
  width: 68px;
  height: 68px;
  opacity: 0;
  transform-style: preserve-3d;
  filter: drop-shadow(0 16px 12px rgba(0, 0, 0, 0.78));
  animation: dice-flight 1.7s cubic-bezier(0.18, 0.72, 0.18, 1) var(--delay) forwards;
}

.thrown-die.discarded {
  filter: grayscale(0.9) drop-shadow(0 16px 12px rgba(0, 0, 0, 0.78));
  animation-name: dice-flight-discarded;
}

.thrown-die.discarded::after {
  content: "не считается";
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  padding: 3px 7px;
  border: 1px solid #65433b;
  border-radius: 99px;
  background: rgba(8, 10, 10, 0.94);
  color: #8f6c65;
  font: 7px Arial, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
}

.die-model {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 2px;
  transform-style: preserve-3d;
}

.cube-model {
  transform: rotateX(-16deg) rotateY(24deg);
}

.cube-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px solid #9b6540;
  border-radius: 7px;
  background:
    radial-gradient(circle at 28% 22%, rgba(183, 85, 54, 0.24), transparent 34%),
    linear-gradient(145deg, #4d1813, #101313 70%);
  color: #edd2a0;
  font: 700 29px Georgia, serif;
  text-shadow: 0 3px 4px #000;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.58);
  backface-visibility: hidden;
}

.cube-front { transform: translateZ(32px); }
.cube-back { transform: rotateY(180deg) translateZ(32px); }
.cube-right { transform: rotateY(90deg) translateZ(32px); }
.cube-left { transform: rotateY(-90deg) translateZ(32px); }
.cube-top { transform: rotateX(90deg) translateZ(32px); }
.cube-bottom { transform: rotateX(-90deg) translateZ(32px); }

.poly-model {
  display: grid;
  place-items: center;
  transform: rotateX(-14deg) rotateY(12deg) rotateZ(-3deg);
  color: #f0d5a3;
  font: 700 25px Georgia, serif;
  text-shadow: 0 3px 4px #000;
  filter: drop-shadow(0 7px 5px rgba(0, 0, 0, 0.72));
}

.poly-model span {
  position: relative;
  z-index: 3;
}

.poly-model i,
.poly-model b {
  position: absolute;
  z-index: 1;
  display: block;
  background: rgba(219, 139, 91, 0.18);
  pointer-events: none;
}

.poly-d3 {
  clip-path: polygon(50% 0, 100% 91%, 0 91%);
  padding-top: 14px;
  background: conic-gradient(from 30deg at 50% 64%, #111515, #6d231a 27%, #25100d 51%, #94402d 74%, #111515);
}

.poly-d3 i {
  left: 49%;
  top: 0;
  width: 1px;
  height: 92%;
  transform: rotate(31deg);
  transform-origin: top;
}

.poly-d3 b {
  left: 12%;
  right: 12%;
  bottom: 9%;
  height: 1px;
}

.poly-d18 {
  clip-path: polygon(50% 0, 82% 10%, 100% 38%, 93% 72%, 68% 96%, 35% 100%, 8% 78%, 0 44%, 17% 13%);
  background: conic-gradient(from 8deg, #121515, #74261c, #21100d, #9e4631, #131616, #5e1d17, #121515);
}

.poly-d18 i {
  inset: 9px 13px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  border: 1px solid rgba(222, 155, 104, 0.34);
  background: rgba(27, 10, 8, 0.22);
}

.poly-d18 b {
  left: 4%;
  top: 49%;
  width: 92%;
  height: 1px;
  transform: rotate(-23deg);
}

.dice-flight-summary {
  position: absolute;
  left: 50%;
  top: calc(46% + 105px);
  min-width: 190px;
  padding: 8px 18px;
  border: 1px solid #765033;
  border-radius: 999px;
  background: rgba(7, 9, 9, 0.94);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7), inset 0 0 18px rgba(111, 31, 23, 0.22);
  opacity: 0;
  transform: translateX(-50%);
  text-align: center;
  animation: dice-summary 1.15s ease 1.22s forwards;
}

.dice-flight-summary span,
.dice-flight-summary strong {
  display: block;
}

.dice-flight-summary span {
  color: #756958;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dice-flight-summary strong {
  margin-top: 2px;
  color: #e0c28e;
  font-size: 15px;
  font-weight: 500;
}

@keyframes dice-flight {
  0% {
    opacity: 0;
    transform: translate3d(46vw, 43vh, -260px) rotateX(0) rotateY(0) rotateZ(0) scale(0.32);
  }
  12% { opacity: 1; }
  55% {
    transform: translate3d(var(--land-x), calc(var(--land-y) - 105px), 210px) rotateX(var(--turn)) rotateY(var(--turn)) rotateZ(260deg) scale(1.13);
  }
  78% {
    opacity: 1;
    transform: translate3d(var(--land-x), var(--land-y), 0) rotateX(720deg) rotateY(720deg) rotateZ(356deg) scale(1);
  }
  88% {
    transform: translate3d(var(--land-x), calc(var(--land-y) - 17px), 16px) rotateX(720deg) rotateY(720deg) rotateZ(362deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate3d(var(--land-x), var(--land-y), 0) rotateX(720deg) rotateY(720deg) rotateZ(360deg) scale(1);
  }
}

@keyframes dice-flight-discarded {
  0% {
    opacity: 0;
    transform: translate3d(46vw, 43vh, -260px) rotateX(0) rotateY(0) rotateZ(0) scale(0.32);
  }
  12% { opacity: 1; }
  55% {
    transform: translate3d(var(--land-x), calc(var(--land-y) - 105px), 210px) rotateX(var(--turn)) rotateY(var(--turn)) rotateZ(260deg) scale(1.13);
  }
  78% {
    opacity: 1;
    transform: translate3d(var(--land-x), var(--land-y), 0) rotateX(720deg) rotateY(720deg) rotateZ(356deg) scale(0.92);
  }
  100% {
    opacity: 0.48;
    transform: translate3d(var(--land-x), calc(var(--land-y) + 18px), 0) rotateX(720deg) rotateY(720deg) rotateZ(360deg) scale(0.82);
  }
}

@keyframes dice-summary {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.94); }
  25%, 74% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -5px) scale(0.98); }
}

.toast-region {
  position: fixed;
  z-index: 150;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  width: min(330px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid #74512f;
  border-left: 3px solid var(--blood-bright);
  background: #0d1010;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
  color: #d1c4ad;
  font-size: 12px;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
}

@media (max-width: 820px) {
  .game-app {
    grid-template-columns: 58px 1fr;
  }

  .topbar {
    padding-right: 8px;
  }

  .save-status,
  .map-hint,
  .drag-label {
    display: none;
  }

  .topbar-status {
    gap: 7px;
  }

  .connection-status {
    font-size: 0;
  }

  .role-badge {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tool-rail {
    padding-inline: 4px;
  }

  .rail-button small {
    font-size: 8px;
  }

  .character-sheet {
    left: 66px !important;
    right: 8px !important;
    top: 66px !important;
    width: calc(100vw - 74px) !important;
    min-width: 0;
    max-width: none;
    height: calc(100vh - 74px) !important;
    max-height: none;
    resize: none;
  }

  .sheet-body {
    grid-template-columns: minmax(0, 1fr) 58px;
  }

  .sheet-tabs button {
    font-size: 0;
    writing-mode: horizontal-tb;
  }

  .side-drawer {
    left: 66px;
    top: 66px;
    width: calc(100vw - 74px);
  }

  .side-drawer.knowledge-drawer {
    width: calc(100vw - 74px);
  }

  .chat-panel {
    right: 8px;
    width: min(370px, calc(100vw - 74px));
  }

  .generation-overlay {
    inset: 58px 0 0 58px;
    padding: 8px;
  }

  .generation-card,
  .generation-content {
    max-height: calc(100vh - 74px);
  }

  .generation-class-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .generated-stats-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .generation-class-preview {
    grid-template-columns: 1fr;
  }

  .generation-class-rules {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 30px 20px;
  }

  .code-row {
    grid-template-columns: 1fr;
  }

  .brand-lockup small {
    display: none;
  }

  .brand-lockup strong {
    font-size: 14px;
  }

  .chat-panel {
    left: 66px;
    right: 8px;
    top: 66px;
    bottom: 8px;
    width: auto;
  }

  .chat-message {
    width: 96%;
  }

  .roll-chat-message {
    width: 100%;
  }

  .dice-cast-button {
    gap: 3px;
  }

  .tray-die {
    width: 27px;
    height: 27px;
    flex-basis: 27px;
  }

  .identity-grid,
  .gear-and-drop,
  .finance-grid {
    grid-template-columns: 1fr;
  }

  .equipment-board {
    border-right: 0;
  }

  .skills-heading,
  .skill-row {
    grid-template-columns: minmax(0, 1fr) 62px 86px;
  }

  .monster-library-list {
    grid-template-columns: 1fr;
  }

  .magic-library-grid {
    grid-template-columns: 1fr;
  }

  .item-library-grid {
    grid-template-columns: 1fr;
  }

  .item-category-tabs {
    grid-template-columns: 1fr;
  }

  .magic-level-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .spell-preview {
    grid-template-columns: 1fr;
  }

  .spell-preview figure {
    min-height: 220px;
    border-right: 0;
    border-bottom: 1px solid #493625;
  }

  .spell-preview img {
    max-height: 48vh;
    object-fit: contain;
  }

  .monster-detail-heading {
    grid-template-columns: 94px minmax(0, 1fr);
  }

  .monster-detail-image {
    width: 94px;
    height: 124px;
  }

  .monster-stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .generation-overlay {
    inset: 58px 0 0 58px;
    padding: 6px;
  }

  .generation-heading {
    padding: 15px 14px 12px;
  }

  .generation-seal {
    width: 38px;
    height: 38px;
    font-size: 19px;
  }

  .generation-progress {
    padding: 8px 14px 0;
  }

  .generation-copy {
    margin: 10px 14px 0;
  }

  .generation-body {
    padding: 14px;
  }

  .generation-footer {
    padding: 12px 14px 15px;
  }

  .generation-class-grid,
  .generated-stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .generation-class-rules,
  .generation-spell-list {
    grid-template-columns: 1fr;
  }

  .improvement-row {
    grid-template-columns: 1fr;
  }

  .generation-identity-form .generation-footer {
    margin: 0 -14px -14px;
  }

  .stat-roll-stage,
  .money-generation {
    min-height: 260px;
    padding: 20px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thrown-die {
    animation-duration: 0.35s;
    animation-timing-function: ease-out;
  }

  .dice-flight-summary {
    animation-delay: 0.2s;
  }
}

/* Scene construction and GM controls */
.side-drawer.scene-drawer {
  width: min(430px, calc(100vw - 110px));
}

.scene-list {
  display: grid;
  gap: 8px;
}

.scene-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid #443526;
  border-radius: 4px;
  background: #0b0e0e;
}

.scene-card.active {
  border-color: #923426;
  background: radial-gradient(circle at 10% 50%, rgba(143, 38, 27, 0.22), transparent 45%), #100e0d;
}

.scene-card img {
  width: 70px;
  height: 48px;
  border: 1px solid #65492f;
  object-fit: cover;
  filter: saturate(0.8) brightness(0.78);
}

.scene-card strong,
.scene-card small {
  display: block;
}

.scene-card strong {
  color: #ccb995;
  font-size: 13px;
  font-weight: 500;
}

.scene-card small {
  margin-top: 4px;
  color: #796d5b;
  font-size: 10px;
}

.scene-card button,
.scene-object-row button,
.scene-object-row select,
.scene-character-row button {
  min-height: 30px;
  border: 1px solid #58432e;
  border-radius: 3px;
  background: #0a0c0c;
  color: #ad946d;
  cursor: pointer;
  font-size: 10px;
}

.scene-card button:disabled,
.scene-character-row button:disabled {
  cursor: default;
  opacity: 0.48;
}

.scene-editor {
  display: grid;
  gap: 12px;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid #4a3525;
}

.scene-editor > header h3 {
  margin: 0;
  color: #d0b98d;
  font-size: 18px;
  font-weight: 500;
}

.scene-tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.scene-tool-grid button {
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 1px solid #493728;
  border-radius: 3px;
  background: #090b0b;
  color: #8f8069;
  cursor: pointer;
}

.scene-tool-grid button:hover,
.scene-tool-grid button.active {
  border-color: #a23d2d;
  background: #1a0f0d;
  color: #e0bc84;
}

.scene-tool-grid span {
  color: #b94a38;
  font-size: 22px;
}

.scene-tool-grid small {
  font-size: 9px;
}

.scene-tool-help {
  margin: 0;
  color: #968a77;
  font-size: 16px;
  line-height: 1.5;
}

.scene-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scene-settings-grid.compact label {
  display: grid;
  gap: 5px;
  color: #9e896a;
  font-size: 12px;
}

.scene-editor details {
  border-top: 1px solid #33291f;
  padding-top: 9px;
}

.scene-editor summary {
  color: #b79c73;
  cursor: pointer;
  font-size: 13px;
}

.scene-editor summary b {
  float: right;
  color: #a23d30;
  font-weight: 500;
}

.scene-object-list,
.scene-character-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.scene-object-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 112px 30px;
  align-items: center;
  gap: 5px;
}

.scene-object-row > span {
  color: #b54a38;
  text-align: center;
}

.scene-object-row > strong {
  color: #b7aa94;
  font-size: 12px;
  font-weight: 400;
}

.scene-object-row.light-row {
  grid-template-columns: 24px minmax(60px, 1fr) minmax(125px, 1.2fr) minmax(88px, auto) 30px;
  padding: 6px;
  border: 1px solid #443628;
  background: #0d1010;
}

.scene-object-row.light-row > label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #a89577;
  font-size: 11px;
}

.scene-object-row.light-row input[type="number"] {
  min-width: 0;
  width: 82px;
}

.scene-object-row.light-row input[type="checkbox"] { width: auto; }
.scene-object-row.light-row.disabled { opacity: 0.55; }

.fog-memory-settings,
.scene-map-scale {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #4b392a;
  background: linear-gradient(135deg, rgba(20, 19, 18, 0.96), rgba(8, 11, 11, 0.96));
}

.fog-memory-settings > label:not(.master-setting-row) {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(90px, 1fr) 44px;
  align-items: center;
  gap: 7px;
  color: #b9a481;
  font-size: 12px;
}

.fog-memory-settings output,
.player-token-scale-setting output,
.monster-token-scale-control output { color: #e0bc84; font-variant-numeric: tabular-nums; }

.fog-memory-settings > button,
.scene-map-scale > button {
  min-height: 34px;
  border: 1px solid #674932;
  background: #181312;
  color: #c7ae86;
  cursor: pointer;
}

.scene-map-scale {
  grid-template-columns: minmax(0, 1fr) 94px 94px;
  align-items: end;
}

.scene-map-scale strong,
.scene-map-scale small { display: block; }
.scene-map-scale strong { color: #d0b88e; }
.scene-map-scale small { margin-top: 3px; color: #8f816c; }
.scene-map-scale label { display: flex; align-items: center; gap: 4px; color: #b9a581; }
.scene-map-scale input { min-width: 0; width: 65px; }
.scene-map-scale p { grid-column: 1 / -1; margin: 0; color: #8f826f; font-size: 12px; line-height: 1.4; }

.player-token-scale-setting {
  display: grid !important;
  grid-template-columns: minmax(150px, 1fr) minmax(100px, 1fr) 48px;
}

.player-token-scale-setting input { width: 100%; }

.monster-token-scale-control {
  display: grid !important;
  grid-template-columns: auto minmax(90px, 1fr) 42px;
  align-items: center;
  gap: 5px;
}

.monster-token-scale-control input { width: 100%; }

.door-state-mark.door-open { color: #5fbd8d; }
.door-state-mark.door-locked { color: #d34b3c; }

.scene-list-empty {
  margin: 5px 0;
  color: #756a5b;
  font-size: 14px;
}

.scene-character-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
}

.scene-character-row .mini-avatar {
  width: 38px;
  height: 38px;
}

.scene-character-row strong,
.scene-character-row small {
  display: block;
}

.scene-character-row strong { color: #c9b899; font-size: 12px; }
.scene-character-row small { color: #746959; font-size: 10px; }

.map-viewport[data-scene-tool="wall"],
.map-viewport[data-scene-tool="door"],
.map-viewport[data-scene-tool="spikes"],
.map-viewport[data-scene-tool="arrows"],
.map-viewport[data-scene-tool="acid"],
.map-viewport[data-scene-tool="eraser"] {
  cursor: crosshair;
}

/* Editable knowledge cards */
.side-drawer.knowledge-drawer {
  width: min(760px, calc(100vw - 110px));
}

.knowledge-card-actions {
  display: flex !important;
  gap: 5px;
  margin-top: auto;
  padding-top: 6px;
}

.knowledge-card-actions button {
  min-height: 28px;
  padding: 3px 7px;
  border: 1px solid #5d402b;
  border-radius: 3px;
  background: #100d0c;
  color: #c39c6a;
  cursor: pointer;
  font-size: 11px;
}

.item-effect-chips,
.inventory-effects,
.active-equipment-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.item-effect-chips span,
.inventory-effects span,
.active-equipment-effects span {
  padding: 3px 5px;
  border: 1px solid #63392e;
  border-radius: 2px;
  background: rgba(92, 28, 21, 0.15);
  color: #d0a780;
  font-size: 14px;
  line-height: 1.25;
}

.inventory-effects {
  grid-column: 1 / -1;
}

.active-equipment-effects {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #4b3527;
}

.active-equipment-effects strong {
  width: 100%;
  color: #aa936f;
  font-size: 12px;
  font-weight: 500;
}

/* Handout media and visibility */
.handout-card-image {
  width: 100%;
  max-height: 360px;
  margin-top: 10px;
  border: 1px solid #6b4a31;
  object-fit: contain;
  background: #060808;
}

.handout-card.is-hidden {
  border-style: dashed;
  opacity: 0.78;
}

.handout-card-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.handout-card-actions .ghost-button {
  min-height: 26px;
  padding: 0 7px;
  font-size: 10px;
}

.handout-card footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #33291f;
}

.handout-visibility {
  color: #70a98d;
  font-size: 12px;
}

.handout-visibility.hidden {
  color: #b8685d;
}

.handout-image-preview,
.scene-image-preview {
  display: grid;
  gap: 8px;
  margin: 0 18px;
}

.handout-image-preview img,
.scene-image-preview img {
  width: 100%;
  max-height: 280px;
  border: 1px solid #6c4b31;
  object-fit: contain;
  background: #060808;
}

.handout-hidden-choice {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.handout-hidden-choice input {
  width: auto;
  height: auto;
}

.scene-dialog { width: min(650px, calc(100vw - 30px)); }
.knowledge-edit-dialog { width: min(640px, calc(100vw - 30px)); }

/* Body copy is intentionally twice the former prototype size; headings stay unchanged. */
.magic-card-copy > p,
.item-card-copy > p { font-size: 16px; }
.monster-description p { font-size: 22px; }
.handout-card p { font-size: 24px; }
.inventory-item p { font-size: 20px; }
.character-spell-card p:not(.eyebrow) { font-size: 18px; }
.spell-dialog-description { font-size: 24px; }
.skill-name { font-size: 24px; }
.bonus-control { font-size: 18px; }
.placeholder-tab p { font-size: 22px; }
.feature-editor { font-size: 20px; }
.dialog-intro { font-size: 22px; }
.field-help { font-size: 16px; }
.monster-drag-hint { font-size: 20px; }
.item-dropzone { font-size: 20px; }
.chat-future-note { font-size: 18px; }

.magic-library-card,
.item-library-card,
.item-card-emblem,
.magic-card-image {
  min-height: 220px;
}

.skills-heading,
.skill-row {
  grid-template-columns: minmax(0, 1fr) 72px 128px;
}

.skill-row {
  min-height: 66px;
}

.bonus-control output {
  min-width: 34px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #58422d;
  border-radius: 3px;
  background: #080a0a;
  color: #e0d5c0;
  font-size: 15px;
}

/* v0.9 — movable combat tools, initiative and live rule compendium */
.floating-tool-window {
  position: fixed;
  z-index: 72;
  top: 98px;
  left: 92px;
  width: min(590px, calc(100vw - 130px));
  max-height: calc(100vh - 145px);
  color: #dfd0b5;
  background:
    radial-gradient(circle at 12% 0, rgba(137, 38, 28, .2), transparent 32%),
    linear-gradient(155deg, rgba(20, 21, 21, .99), rgba(7, 9, 9, .99));
  box-shadow: 0 24px 75px rgba(0, 0, 0, .82), inset 0 0 0 1px rgba(138, 48, 38, .48);
}

.floating-tool-window > header {
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 16px;
  border-bottom: 1px solid #533125;
  cursor: move;
  user-select: none;
}

.floating-tool-window > header h2 { margin: 1px 0 0; color: #e1cba5; font-size: 21px; }
.floating-tool-content { max-height: calc(100vh - 215px); overflow: auto; padding: 14px; }
.monster-inspector { top: 128px; left: auto; right: 360px; width: min(430px, calc(100vw - 130px)); z-index: 74; }
.monster-inspector .monster-detail { margin: 0; }

/* The turn order deliberately reads as an MMORPG raid frame: rectangular,
   named portraits with a visibly enlarged active participant. */
.turn-order { align-items: center; min-height: 68px; padding-bottom: 13px; }
.turn-portrait {
  flex-basis: 68px;
  width: 68px;
  height: 48px;
  border-radius: 4px;
}
.turn-portrait img { border-radius: 2px; }
.turn-portrait small { top: 50px; width: 82px; color: #d8c7aa; font-size: .64rem; }
.turn-portrait.current { flex-basis: 84px; width: 84px; height: 60px; transform: translateY(-2px); }
.turn-portrait.current small { top: 62px; font-weight: 700; color: #f1dec0; }
.turn-portrait.fled { opacity: .42; filter: grayscale(1); }
.turn-portrait.fled::after { content: "сбежал"; position: absolute; inset: auto 2px 2px; padding: 1px 2px; background: #171515d9; color: #bba887; font-size: 8px; text-align: center; }

.quickbar-statuses {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  transform: translateX(-50%);
  width: min(720px, 92vw);
  pointer-events: none;
}
.quickbar-statuses > span { padding: 5px 8px; border: 1px solid #884136; border-radius: 3px; background: rgba(12, 12, 13, .95); color: #e3c8a0; box-shadow: 0 6px 16px #0009; font-size: 12px; }
.quickbar-statuses small { display: block; margin-top: 1px; color: #9f8c72; font-size: 9px; }
.quickbar-slot em { position: absolute; right: 3px; bottom: 3px; min-width: 26px; padding: 2px 3px; border-radius: 8px; background: #711f19; color: #f3dfc2; font-size: 9px; font-style: normal; text-align: center; }

.monster-row-identity {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.monster-row-identity:hover strong { color: #df9a82; }
.monster-risk-editor { display: flex; align-items: center; gap: 3px; }
.monster-risk-editor input { width: 60px; min-height: 30px; border: 1px solid #564638; background: #080a0a; color: #e4d4ba; text-align: center; }
.monster-risk-editor button { min-width: 30px; }
.combat-monster-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.combat-monster-actions label { display: flex; align-items: center; gap: 5px; color: #bca98b; font-size: 11px; }
.combat-monster-actions label input { width: auto; }
.hidden-token-row { border-style: dashed; opacity: .68; }
.monster-action-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.monster-action-buttons button { min-height: 34px; border: 1px solid #6c4631; background: #211712; color: #e0c7a4; cursor: pointer; }
.combat-order-row { grid-template-columns: 25px minmax(90px, 1fr) auto 28px 28px auto; }
.combat-order-row.fled { opacity: .48; text-decoration: line-through; }

.knowledge-merchant-card > header { grid-template-columns: 72px minmax(0, 1fr) auto; }
.knowledge-merchant-card > header > img { width: 72px; height: 92px; border: 1px solid #5f4633; object-fit: cover; filter: grayscale(1) contrast(1.15); }
.merchant-portrait-strip { display: flex; align-items: center; gap: 14px; margin: -5px 0 13px; padding: 8px; border: 1px solid #46382c; background: #0d0e0e; }
.merchant-portrait-strip img { width: 76px; height: 96px; border: 1px solid #76533a; object-fit: cover; filter: grayscale(1) contrast(1.12); }
.merchant-portrait-strip label { display: flex; align-items: center; gap: 6px; color: #d4c09c; }
.merchant-portrait-strip label input { width: auto; }
.merchant-portrait-strip small { margin-left: auto; color: #bd8c67; }
.merchant-item-icon img { width: 48px; height: 48px; object-fit: contain; filter: grayscale(1) contrast(1.18); }

.knowledge-heading-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; }
.knowledge-heading-actions .monster-drag-hint { margin: 0; }
.knowledge-editor-fields { display: grid; gap: 9px; padding: 10px; border: 1px solid #453428; background: rgba(13, 15, 15, .72); }
.knowledge-editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 8px; }
.toggle-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 7px; }
.toggle-row input { width: auto !important; }
.item-library-card img.item-card-art { width: 100%; min-height: 170px; max-height: 220px; object-fit: contain; background: #eee9de; filter: grayscale(1) contrast(1.1); }

.resource-library-grid,
.rule-character-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.resource-library-card,
.rule-character-card { min-width: 0; display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 10px; padding: 9px; border: 1px solid #46372a; background: #101212; }
.resource-library-card { cursor: grab; }
.resource-library-card img { width: 105px; height: 132px; border: 1px solid #5b4432; object-fit: contain; background: #ebe7de; filter: grayscale(1) contrast(1.12); }
.resource-library-card h3,
.rule-character-card h3 { margin: 2px 0 6px; color: #d9c5a2; }
.resource-library-card p,
.rule-character-card p { margin: 0 0 8px; color: #b2a28a; font-size: 17px; line-height: 1.45; }
.resource-library-card label { display: grid; gap: 4px; color: #8f806c; font-size: 11px; }
.resource-library-card select { min-width: 0; width: 100%; }
.rule-character-card > span { display: grid; place-items: center; height: 105px; border: 1px solid #5c4130; color: #a84334; font-size: 44px; background: radial-gradient(circle, #2b1a16, #0a0c0c); }
.resource-token img { border-radius: 5px !important; object-fit: contain !important; background: #eee9dd; }
.gm-hidden-token { opacity: .42; outline: 2px dashed #d06552; outline-offset: 3px; }

.castle-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-bottom: 14px; }
.castle-tabs button { min-width: 0; display: grid; grid-template-columns: 27px minmax(0, 1fr); align-items: center; gap: 5px; min-height: 44px; padding: 4px; border: 1px solid #43372c; background: #0d0f0f; color: #a99a83; text-align: left; cursor: pointer; }
.castle-tabs button b { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; color: #bd5545; background: #211311; }
.castle-tabs button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.castle-tabs button.active { border-color: #a04032; color: #ead7b8; background: #201210; }
.castle-detail > h3 { margin: 2px 0 14px; color: #e1caa3; font-size: 24px; }
.castle-detail > div { display: grid; gap: 6px; }
.castle-detail article { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 9px; padding: 9px; border-left: 2px solid #693428; background: #111313; }
.castle-detail article > b { color: #bd5748; }
.castle-detail article p { margin: 0; color: #c3b39a; font-size: 18px; line-height: 1.55; white-space: pre-line; }

.event-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 13px; padding: 10px; border: 1px solid #49392c; background: #101212; }
.event-controls > div { flex: 1 1 220px; }
.event-controls h3 { margin: 2px 0; color: #ddc7a3; }
.event-controls button { min-height: 34px; border: 1px solid #604330; background: #181513; color: #d5c09e; }
.event-draw-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 15px; }
.event-draw-card { position: relative; display: grid; align-content: space-between; min-height: 170px; padding: 12px; border: 1px solid #8d392e; background: radial-gradient(circle at 50% 0, #2b1612, #0d0f0f 65%); }
.event-draw-card > b { color: #c75343; font-size: 24px; }
.event-draw-card p,
.event-list-row p { margin: 7px 0; color: #c4b49a; font-size: 17px; line-height: 1.45; }
.event-draw-card button { border: 1px solid #654332; background: #201613; color: #d5bd97; }
.event-list { display: grid; gap: 4px; }
.event-list-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 85px; align-items: center; gap: 6px; padding: 7px; border: 1px solid #302c27; background: #0e1010; }
.event-list-row > b { color: #9e4336; }
.event-list-row > span { color: #7da88f; font-size: 10px; text-align: right; }
.event-list-row.used { opacity: .42; text-decoration: line-through; }

.hazard-master-panel,
.audio-master-panel,
.audio-player-panel { display: grid; gap: 13px; }
.hazard-master-panel > h3,
.audio-master-panel h3,
.audio-player-panel h3 { margin: 0; color: #ddc7a3; }
.hazard-master-panel > p,
.audio-master-panel > p { color: #b2a38c; font-size: 18px; line-height: 1.5; }
.hazard-master-panel label,
.audio-master-panel > label,
.audio-player-panel label { display: grid; gap: 6px; color: #a79373; }
.hazard-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.hazard-actions button { min-height: 58px; padding: 8px; border: 1px solid #624232; background: #181513; color: #dec8a6; cursor: pointer; }
.audio-now { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; align-items: center; padding: 12px; border: 1px solid #5d3c2e; background: #121414; }
.audio-now > span { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; color: #d14d3a; background: radial-gradient(circle, #3a1b16, #090b0b); font-size: 30px; }
.audio-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.audio-controls button { min-height: 34px; border: 1px solid #564334; background: #151514; color: #cdb899; }
.audio-controls button.active { border-color: #a53b2f; background: #2a1512; color: #f0d8b3; }
.audio-player-panel label { grid-template-columns: 75px minmax(0, 1fr) 45px; align-items: center; }

.journal-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; margin-bottom: 10px; }
.journal-tabs button { min-height: 38px; border: 1px solid #473a2e; background: #101212; color: #aa9b84; }
.journal-tabs button.active { border-color: #9a392e; color: #ead5b4; background: #251411; }
#journal-form { display: grid; gap: 8px; margin-bottom: 13px; padding: 10px; border: 1px solid #44362b; background: #0d0f0f; }
#journal-form label { display: grid; gap: 4px; color: #94846d; }
.journal-list { display: grid; gap: 8px; }
.journal-entry { padding: 10px 12px; border: 1px solid #3d332a; background: linear-gradient(135deg, #111313, #0b0d0d); }
.journal-entry header { display: flex; justify-content: space-between; gap: 8px; }
.journal-entry h3 { margin: 0; color: #d7c3a1; }
.journal-entry small { color: #897b69; }
.journal-entry p { color: #c2b197; font-size: 19px; line-height: 1.55; white-space: pre-wrap; }

.initiative-overlay { z-index: 83; }
.initiative-card { display: grid; place-items: center; gap: 15px; min-height: 310px; padding: 28px; text-align: center; }
.initiative-card > span { display: grid; place-items: center; width: 92px; height: 92px; border: 2px solid #8d3d32; clip-path: polygon(50% 0, 92% 24%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 8% 24%); background: radial-gradient(circle, #351914, #090b0b 70%); color: #e1b97b; font-size: 32px; }
.initiative-card h2 { margin: 0; color: #e4ceaa; }
.initiative-card p { max-width: 520px; color: #b8a78f; font-size: 20px; line-height: 1.5; }
.initiative-card button { min-width: 210px; min-height: 52px; }
.spell-offer-card { width: min(850px, calc(100vw - 140px)); }
.spell-offer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; max-height: 58vh; overflow: auto; padding: 12px 18px; }
.spell-offer-choice { min-width: 0; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 9px; padding: 7px; border: 1px solid #44362b; background: #0c0e0e; color: #c6b59b; text-align: left; cursor: pointer; }
.spell-offer-choice img { width: 72px; height: 96px; object-fit: cover; filter: grayscale(1) contrast(1.12); }
.spell-offer-choice strong,
.spell-offer-choice small { display: block; }
.spell-offer-choice p { margin: 5px 0 0; font-size: 16px; line-height: 1.4; }
.spell-offer-choice.selected { border-color: #b14335; box-shadow: inset 0 0 18px rgba(130, 35, 26, .3); }
.spell-offer-master { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 9px 0; padding: 8px; border: 1px solid #50372a; background: #121313; }
.spell-offer-master strong { flex: 1 1 220px; }
.spell-offer-master label { display: flex; align-items: center; gap: 4px; }
.spell-offer-master input { width: 62px; }

.inventory-item { grid-template-columns: auto minmax(0, 1fr) auto; }
.inventory-item-image { grid-row: 1 / 5; width: 72px; height: 88px; object-fit: contain; border: 1px solid #5a4230; background: #eee9dd; filter: grayscale(1) contrast(1.12); }
.item-transfer-controls { display: flex; gap: 5px; align-items: center; }
.item-transfer-controls select { min-width: 120px; }
.rest-button { min-height: 40px; padding: 7px 12px; border: 1px solid #705039; background: #211713; color: #e2caa5; cursor: pointer; }
.rest-button:disabled { opacity: .42; cursor: not-allowed; }
.skill-name { border: 0; background: transparent; color: #dfcfb5; cursor: pointer; text-align: left; font-family: inherit; }
.skill-name:hover { color: #d75a48; text-decoration: underline; }
.temp-bonus { margin-left: 4px; padding: 1px 4px; border-radius: 8px; background: #6d281f; color: #f0d7b2; font-size: 10px; }

.chat-shared-card { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; margin-top: 6px; padding: 7px; border: 1px solid #573b2d; background: #121313; cursor: pointer; }
.chat-shared-card img { width: 58px; height: 72px; object-fit: contain; background: #e9e5dc; filter: grayscale(1) contrast(1.12); }
.chat-shared-card strong { display: block; color: #d9c19a; }
.chat-shared-card p { margin: 3px 0 0; color: #ab9a83; font-size: 14px; line-height: 1.35; }
.card-dialog { width: min(720px, calc(100vw - 40px)); }
.card-dialog article > header { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid #53392b; }
.card-dialog article > img { width: 100%; max-height: 48vh; object-fit: contain; background: #e8e4da; filter: grayscale(1) contrast(1.1); }
#card-dialog-content { padding: 15px; color: #cdbb9d; font-size: 20px; line-height: 1.55; }
.card-preview-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 5px; margin-bottom: 12px; }
.card-preview-stats span { padding: 7px; border: 1px solid #4d3a2d; background: #111313; }
.image-viewer-dialog { width: min(96vw, 1500px); height: min(94vh, 1000px); padding: 40px 10px 10px; border: 1px solid #704c35; background: rgba(4, 6, 6, .97); }
.image-viewer-dialog::backdrop { background: rgba(0, 0, 0, .9); }
.image-viewer-dialog > button { position: absolute; top: 6px; right: 8px; }
.image-viewer-dialog img { width: 100%; height: 100%; object-fit: contain; }

.scene-wall.transparent-wall,
.scene-drawing-preview.transparent-wall { stroke: #c2e2db; stroke-dasharray: 14 8; filter: drop-shadow(0 0 3px #061a17); }
.scene-wall.opaque-wall { stroke: #040505; }
.publish-scene-button { width: 100%; min-height: 42px; }
.scene-image-actions { display: flex; gap: 5px; }
.scene-image-actions button { min-height: 31px; border: 1px solid #58402f; background: #141313; color: #cbb390; }

@media (max-width: 900px) {
  .floating-tool-window { left: 62px; top: 66px; width: calc(100vw - 72px); max-height: calc(100vh - 76px); }
  .floating-tool-content { max-height: calc(100vh - 145px); }
  .monster-inspector { right: auto; }
  .combat-tracker { top: 58px; width: calc(100vw - 80px); grid-template-columns: 44px minmax(140px, 1fr) auto; }
  .combat-tracker .current-turn-copy { display: none; }
  .turn-portrait { flex-basis: 54px; width: 54px; }
  .turn-portrait.current { flex-basis: 66px; width: 66px; }
  .event-draw-grid,
  .castle-tabs { grid-template-columns: 1fr; }
  .combat-monster-actions,
  .hazard-actions { grid-template-columns: 1fr; }
  .resource-library-grid,
  .rule-character-grid { grid-template-columns: 1fr; }
}

.merchant-master-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 9px 0; padding: 9px; border: 1px solid #3e332a; background: #0d0f0f; }
.merchant-master-options > label { display: flex; align-items: center; gap: 6px; color: #b8a58a; }
.merchant-master-options input { width: auto; }
.merchant-master-options fieldset { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px 12px; padding: 8px; border: 1px solid #4d3c30; }
.merchant-master-options fieldset label { display: flex; align-items: center; gap: 4px; color: #a99881; font-size: 12px; }
.item-card-emblem img { width: 100%; height: 100%; object-fit: contain; background: #eee9de; filter: grayscale(1) contrast(1.12); }
.character-card-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; align-items: stretch; }
.character-card-wrap > div { display: grid; gap: 3px; }
.character-card-wrap > div button { padding: 4px 7px; border: 1px solid #503b2d; background: #141313; color: #c0aa88; font-size: 10px; }
.master-setting-row { display: flex !important; align-items: center; gap: 8px; margin: 9px 0; padding: 10px; border: 1px solid #4a382a; background: #101212; color: #c4b093; }
.master-setting-row input { width: auto; }
.handout-image-button { position: relative; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.handout-image-button > span { position: absolute; right: 8px; bottom: 8px; padding: 4px 7px; border: 1px solid #78513a; background: #080a0ae8; color: #e1c9a4; font-size: 11px; }
.temporary-stat-bonus { position: absolute; right: -8px; bottom: -5px; padding: 2px 5px; border-radius: 9px; background: #6b251d; color: #f1d4ae; font-size: 10px; font-style: normal; }
.spell-charge-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; padding: 7px; border: 1px solid #55392c; background: #111313; }
.spell-charge-row span { color: #bba78a; }
.spell-charge-row b { color: #df6a54; }
.spell-charge-row button { min-height: 32px; border: 1px solid #87362c; background: #2b1512; color: #ead2ae; }
.monster-inspector .floating-tool-content > img { width: 100%; max-height: 360px; object-fit: contain; background: #eee9df; filter: grayscale(1) contrast(1.15); }
.monster-inspector .floating-tool-content > p { color: #c7b69c; font-size: 19px; line-height: 1.55; }
.monster-inspector-actions { display: flex; justify-content: flex-end; }
.monster-inspector-actions button { min-height: 34px; border: 1px solid #624330; background: #211613; color: #d9c19c; }
.inventory-actions select { min-width: 115px; max-width: 180px; }

@media (max-width: 900px) {
  .merchant-master-options { grid-template-columns: 1fr; }
  .merchant-master-options fieldset { grid-column: 1; }
  .character-card-wrap { grid-template-columns: 1fr; }
  .character-card-wrap > div { grid-template-columns: repeat(2, 1fr); }
}

/* v0.10 — читаемость генератора и надёжное viewport-позиционирование боевого HUD */
.quickbar-panel {
  position: fixed !important;
  inset: auto auto 18px 50vw !important;
  width: min(860px, calc(100vw - 120px));
  margin: 0 !important;
  transform: translateX(-50%) !important;
}

.quickbar-panel[hidden],
.combat-tracker[hidden] { display: none !important; }
.combat-tracker:not([hidden]) { display: grid !important; }

.combat-tracker {
  z-index: 68;
  top: 64px;
  left: 50vw;
  width: min(920px, calc(100vw - 140px));
  transform: translateX(-50%);
}

.turn-portrait {
  flex-basis: 72px;
  width: 72px;
  height: 50px;
  border-radius: 4px;
}
.turn-portrait.current {
  flex-basis: 92px;
  width: 92px;
  height: 64px;
}

.side-drawer.castle-drawer,
.side-drawer.event-drawer {
  width: min(490px, calc(100vw - 110px));
}

.generation-copy,
.generation-body,
.generation-body p,
.generation-body li,
.generation-body label,
.generation-class-rules p,
.generation-class-rules div,
.generation-choice-section > p,
.generation-blocked p,
.generation-spell small,
.generation-class-preview header small {
  font-size: 14px;
  line-height: 1.5;
}
.generation-class-rules span,
.generation-class-button > i { font-size: 12px; }
.generation-class-button small { min-height: 36px; font-size: 12px; line-height: 1.35; }
.generation-dice-button small,
.generated-stat > span,
.generated-stat > strong small,
.stat-roll-stage > small,
.improvement-row > span small,
.generation-spell > i,
.generation-identity-form legend,
.hero-name-field { font-size: 12px; line-height: 1.4; }
.improvement-row > span,
.generation-spell strong,
.starter-item p,
.starter-item > i,
.starter-shop-layout > aside > div,
.starter-purchased-row { font-size: 13px; line-height: 1.45; }
.generation-action-button,
.improvement-row button { font-size: 12px; }

.inventory-use-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 7px;
  border-top: 1px solid rgba(91, 67, 48, .45);
}
.inventory-equip-controls { display: flex; flex: 1 1 230px; gap: 5px; }
.inventory-equip-controls select { min-width: 0; flex: 1; }
.inventory-equip-controls button,
.use-consumable-button {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid #6b4934;
  background: #171513;
  color: #dbc5a3;
  cursor: pointer;
}
.use-consumable-button { border-color: #91392f; background: #2b1512; }
.inventory-item { scroll-margin-block: 90px; }

.gm-derived-control {
  width: 100%;
  display: grid;
  gap: 3px;
  margin-top: 5px;
  padding: 5px;
  border: 1px solid rgba(113, 73, 49, .5);
  background: rgba(18, 18, 17, .82);
  font-size: 10px;
  font-weight: 400;
}
.gm-derived-control > small { color: #a7957c; font-size: 10px; }
.gm-derived-control > small b { color: #dfc8a5; }
.gm-derived-control > span { display: grid; grid-template-columns: minmax(0, 1fr) 26px; gap: 3px; }
.gm-derived-control input { width: 100%; min-width: 0; height: 27px; padding: 2px 4px; text-align: center; }
.gm-derived-control button { border: 1px solid #604536; background: #191716; color: #cdb48f; }
.gm-derived-control button:disabled { opacity: .35; }

.item-search { margin: 8px 0 12px; }

@media (max-width: 900px) {
  .quickbar-panel { inset: auto auto 12px 50vw !important; width: calc(100vw - 80px); }
  .combat-tracker { left: 50vw; width: calc(100vw - 80px); }
  .side-drawer.castle-drawer,
  .side-drawer.event-drawer { width: calc(100vw - 82px); }
}

/* v0.11 final viewport overrides */
.combat-tracker { top: 64px !important; bottom: auto !important; }
.side-drawer { min-width: 320px; min-height: 300px; resize: both; }
.side-drawer > header { cursor: move; user-select: none; }
.side-drawer > .drawer-content { max-height: calc(100% - 70px); }
.side-drawer.campaign-drawer { width: min(920px, calc(100vw - 110px)); height: min(780px, calc(100vh - 86px)); }
.chat-panel { bottom: auto; height: calc(100vh - 90px); min-width: 320px; min-height: 390px; max-width: calc(100vw - 72px); max-height: calc(100vh - 64px); resize: both; }
.chat-header { cursor: move; user-select: none; }

@media (max-width: 900px) {
  .side-drawer, .chat-panel { resize: none; }
  .side-drawer.campaign-drawer { width: calc(100vw - 74px); height: calc(100vh - 74px); }
}

/* 1.0 — финальный визуальный слой «Кровавое клеймо» */
:root {
  --ink: #07090a;
  --ink-soft: #0d1011;
  --ink-raised: #151718;
  --gold: #d0b47f;
  --gold-dim: #927a55;
  --gold-line: #755534;
  --blood: #9d281f;
  --blood-bright: #dc4b37;
  --paper: #e4d7bd;
  --muted: #aa9b83;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

body {
  background:
    radial-gradient(circle at 78% 16%, rgba(104, 29, 20, .14), transparent 28%),
    repeating-linear-gradient(112deg, rgba(255,255,255,.012) 0 1px, transparent 1px 8px),
    #050707;
}

button,
input,
textarea,
select { transition: border-color .16s ease, background-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .46; }

* { scrollbar-width: thin; scrollbar-color: #70402e #090b0b; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: #090b0b; }
*::-webkit-scrollbar-thumb { border: 2px solid #090b0b; border-radius: 8px; background: #70402e; }

.blood-frame {
  border-color: #755234;
  background:
    linear-gradient(140deg, rgba(255,255,255,.025), transparent 22%),
    radial-gradient(circle at 84% 0, rgba(137, 35, 25, .16), transparent 34%),
    repeating-linear-gradient(104deg, rgba(255,255,255,.012) 0 1px, transparent 1px 7px),
    linear-gradient(135deg, #121617, #060809 62%, #100d0c);
  box-shadow: 0 0 0 4px #080a0a, 0 0 0 5px #3c2c20, 0 26px 78px rgba(0,0,0,.78), inset 0 0 42px rgba(0,0,0,.76);
}

.login-screen {
  isolation: isolate;
  background:
    linear-gradient(90deg, rgba(2,3,3,.5), rgba(2,3,3,.13) 50%, rgba(2,3,3,.5)),
    linear-gradient(rgba(2,3,3,.08), rgba(2,3,3,.42)),
    url("/assets/login-enchanted-country.webp") center / cover no-repeat;
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.015) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
}
.login-screen::after { background: radial-gradient(circle at center, transparent 10%, rgba(0,0,0,.76) 92%); }
.login-card {
  width: min(570px, 100%);
  padding: 44px 48px 38px;
  background:
    linear-gradient(145deg, rgba(19,22,22,.97), rgba(4,6,6,.985) 65%),
    #080a0a;
  backdrop-filter: blur(9px);
}
.login-card h1 { color: #e0c590; text-shadow: 0 3px 20px #000, 0 0 28px rgba(147,50,34,.18); }
.login-copy { color: #b3a58e; font-size: 15px; }
.login-form > label { font-size: 14px; letter-spacing: .035em; }
.code-row input { height: 44px; font-size: 16px; }
.code-row .primary-button { min-height: 44px; }
.prototype-codes { display: none !important; }

.login-code-picker {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #563e2a;
  background: rgba(8,10,10,.96);
  box-shadow: 0 12px 32px rgba(0,0,0,.55);
}
.login-code-picker > div:first-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: #c9b48f; font-size: 12px; }
.login-code-picker > div:first-child button { border: 0; background: transparent; color: #bc6657; cursor: pointer; font-size: 11px; }
.login-code-picker > small { display: block; margin-top: 8px; color: #847664; font-size: 10px; line-height: 1.4; }
.login-code-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 5px; max-height: 170px; margin-top: 8px; overflow: auto; }
.login-code-options button { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; padding: 8px; border: 1px solid #47382c; background: #101313; color: #c4b397; text-align: left; cursor: pointer; }
.login-code-options button:hover { border-color: #9b3b30; background: #211311; }
.login-code-options button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-code-options button b { color: #d66b57; font-size: 11px; }
.login-code-options p { grid-column: 1/-1; margin: 4px; color: #8f826f; font-size: 12px; }

.game-app { grid-template-columns: 78px 1fr; grid-template-rows: 62px 1fr; }
.topbar {
  min-height: 62px;
  border-bottom-color: #63462d;
  background:
    linear-gradient(90deg, rgba(101,29,21,.12), transparent 28%),
    rgba(6,8,8,.97);
}
.brand-mark { filter: drop-shadow(0 0 8px rgba(214,59,41,.45)); }
.brand-lockup strong { font-size: 18px; letter-spacing: .025em; }
.tool-rail {
  gap: 5px;
  padding: 9px 7px 12px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right-color: #5a4029;
  background: linear-gradient(90deg, #0c0f10, #070909);
}
.rail-button { flex: 0 0 53px; min-height: 53px; border-radius: 2px; }
.rail-button span { font-size: 21px; }
.rail-button small { font-size: 9px; }
.rail-button:hover { transform: translateX(2px); }

.side-drawer,
.floating-tool-window,
.chat-panel,
.character-sheet { border-color: #765238; }
.side-drawer > header,
.floating-tool-window > header,
.chat-header,
.sheet-header,
.app-dialog header {
  background: linear-gradient(90deg, rgba(48,20,16,.92), rgba(10,12,12,.97) 42%, rgba(10,12,12,.97));
  border-bottom-color: #60412d;
}
.side-drawer h2,
.floating-tool-window h2,
.app-dialog h2 { color: #e1c795; letter-spacing: .018em; }
.drawer-content { padding: 16px; }

.character-sheet {
  width: clamp(500px, 36.5vw, 640px);
  min-width: 470px;
  max-width: 78vw;
}
.sheet-body { grid-template-columns: minmax(0,1fr) 82px; }
.sheet-tabs { border-left-color: #5d412d; background: #080a0a; }
.sheet-tabs button { font-size: 11px; }
.sheet-content { padding: 17px 15px 28px 17px; }
.section-title { color: #dfc79d; }
.inventory-item p,
.character-spell-card p,
.handout-card p,
.item-card-copy > p,
.monster-description,
.spell-dialog-description { font-size: 16px; line-height: 1.55; }
.skills-table { border-color: #49372b; }
.skill-row { min-height: 58px; }
.skill-name { font-size: 15px; }
.finance-grid { align-items: start; }
.finance-grid > label { min-width: 0; }
.capacity-breakdown { font-size: 12px; }

.combat-tracker {
  top: 70px !important;
  border-color: #7d5136;
  backdrop-filter: blur(8px);
}
.quickbar-panel { bottom: 16px !important; border-color: #775035; backdrop-filter: blur(8px); }
.quickbar-slot { border-color: #674a35; }

.app-dialog { border-color: #785438; }
.app-dialog::backdrop { background: rgba(2,3,3,.82); backdrop-filter: blur(4px); }
.app-dialog form { background: linear-gradient(145deg,#111515,#070909 68%); }
.app-dialog input,
.app-dialog textarea,
.app-dialog select { background: #090b0b; border-color: #654a34; }
.app-dialog fieldset { border-color: #4f3a2c; }
.handout-show-choice,
.handout-hidden-choice { display: flex !important; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 8px; padding: 9px; border: 1px solid #4d392c; background: #0d1010; }
.handout-show-choice input,
.handout-hidden-choice input { width: auto; flex: 0 0 auto; }
.handout-show-choice span { color: #d0b98f; }
.app-dialog fieldset:disabled { opacity: .42; }
.handout-card-actions { flex-wrap: wrap; justify-content: flex-end; }

.spell-preview > footer { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.spell-preview > footer > span { margin-right: auto; color: #b74636; font-size: 22px; }

.resource-library-card label + label { margin-top: 7px; }
.resource-library-card .knowledge-card-actions { flex-wrap: wrap; }

@media (max-width: 900px) {
  .game-app { grid-template-columns: 60px 1fr; grid-template-rows: 58px 1fr; }
  .character-sheet { min-width: 0; }
  .login-card { padding: 34px 25px; }
  .login-code-options { grid-template-columns: 1fr; }
  .combat-tracker { top: 62px !important; }
}

/* 1.0.1 — исправление HUD и восстановленный лист «Кровавое клеймо» */
#combat-tracker.combat-tracker {
  position: fixed !important;
  z-index: 120 !important;
  inset: 70px auto auto calc(50vw + 39px) !important;
  width: min(960px, calc(100vw - 118px)) !important;
  max-height: 118px;
  margin: 0 !important;
  transform: translateX(-50%) !important;
  overflow: visible;
  isolation: isolate;
}

#quickbar-panel.quickbar-panel {
  position: fixed !important;
  inset: auto auto 16px 50vw !important;
  transform: translateX(-50%) !important;
}

.character-sheet {
  width: clamp(590px, 36.5vw, 700px);
  min-width: 590px;
  border: 2px solid #746145;
  outline: 1px solid #17140f;
  background:
    repeating-linear-gradient(103deg, rgba(255,255,255,.012) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 83% 4%, rgba(107,27,20,.13), transparent 30%),
    linear-gradient(145deg, #111516, #060909 66%, #0c0d0d);
  box-shadow:
    0 0 0 3px #080a0a,
    0 0 0 4px #4e412f,
    0 24px 74px rgba(0,0,0,.84),
    inset 0 0 0 6px #090b0b,
    inset 0 0 0 7px rgba(126,105,72,.46),
    inset 0 0 55px rgba(0,0,0,.82);
}

.character-sheet::before,
.character-sheet::after {
  width: 29px;
  height: 29px;
  border-color: #9b3829;
}

.sheet-header {
  position: relative;
  height: 46px;
  padding: 6px 11px 6px 17px;
  border-bottom: 1px solid #554731;
  background:
    linear-gradient(90deg, rgba(110,32,23,.16), transparent 36%),
    #080b0b;
}

.sheet-header::before {
  content: "•  •  •  •  •  •";
  position: absolute;
  left: 50%;
  top: 2px;
  transform: translateX(-50%);
  color: #514631;
  font-size: 7px;
  letter-spacing: 3px;
}

.sheet-header .eyebrow { display: none; }
.sheet-header strong { color: #bba887; font-size: 12px; letter-spacing: .08em; }
.sheet-header-actions { gap: 5px; }
.gm-sheet-actions button { min-height: 26px; padding-inline: 7px; font-size: 9px; }
.drag-label { font-size: 8px; }

.sheet-body {
  height: calc(100% - 46px);
  grid-template-columns: minmax(0,1fr) 84px;
}

.sheet-content {
  position: relative;
  padding: 19px 18px 34px;
  border-right: 1px solid #52442f;
  background:
    linear-gradient(90deg, transparent 0 97%, rgba(145,43,31,.08)),
    repeating-linear-gradient(108deg, rgba(255,255,255,.009) 0 1px, transparent 1px 8px);
  box-shadow: inset 0 0 0 7px #080a0a, inset 0 0 0 8px rgba(105,88,60,.22);
}

.sheet-tabs {
  position: relative;
  border-left: 1px solid #746145;
  background:
    linear-gradient(90deg, rgba(255,255,255,.018), transparent 35%),
    #080a0a;
  box-shadow: inset 5px 0 0 #050707, inset 6px 0 0 #342d22;
}

.sheet-tabs::before,
.sheet-tabs::after {
  content: "✦";
  position: absolute;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
  color: #5c4f38;
  font-size: 10px;
  pointer-events: none;
}
.sheet-tabs::before { top: 8px; }
.sheet-tabs::after { bottom: 8px; }

.sheet-tabs button {
  gap: 10px;
  margin: 4px 5px;
  padding: 10px 6px;
  border: 1px solid transparent;
  border-bottom-color: #332c22;
  color: #8f8169;
  font-size: 14px;
  letter-spacing: .025em;
}

.sheet-tabs button.active {
  border-color: #604331;
  background:
    radial-gradient(ellipse at center, rgba(132,35,25,.34), transparent 72%),
    linear-gradient(90deg, #1b0f0d, #0b0c0c);
  color: #db503c;
  box-shadow: inset 3px 0 0 #a33426, inset 0 0 18px rgba(107,25,19,.27);
}

.sheet-tabs button span.sheet-tab-icon {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  writing-mode: horizontal-tb;
}

.sheet-tab-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(146,47,34,.22));
}

.blood-character-main { min-width: 0; }

.identity-grid {
  grid-template-columns: minmax(178px,.88fr) minmax(238px,1.12fr);
  gap: 20px;
  align-items: start;
  padding: 10px 11px 0;
}

.portrait-column { min-width: 0; }
.field-label { color: #c3ae88; font-size: 13px; }
.field-label > span { display: block; }

.character-name-input,
.class-field input,
.gender-field select {
  border: 1px solid #68543a;
  border-radius: 2px;
  background: rgba(5,8,8,.78);
  box-shadow: inset 0 0 12px rgba(0,0,0,.62);
  color: #dfcfb4;
}
.character-name-input { height: 34px; font-size: 15px; }

.portrait-box {
  margin-top: 12px;
  aspect-ratio: .82;
  border: 1px solid #7f6948;
  background:
    radial-gradient(circle at 50% 31%, #313333, #111414 52%, #070909 72%);
  box-shadow: 0 0 0 4px #080a0a, 0 0 0 5px #3f3527, inset 0 0 0 5px #080a0a, inset 0 0 0 6px rgba(142,116,78,.42);
}
.portrait-box img { padding: 6px 6px 48px; filter: grayscale(.78) contrast(1.14) sepia(.08); }
.portrait-placeholder { margin-bottom: 42px; background: linear-gradient(#242829,#111414); }
.portrait-upload {
  left: 9px;
  right: 9px;
  bottom: 9px;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 9px;
  min-height: 38px;
  border-color: #725b3d;
  border-radius: 2px;
  background: rgba(7,9,9,.96);
  color: #cbb38d;
  font-size: 14px;
}
.portrait-upload > span { color: #cf5a43; font-size: 20px; line-height: 1; }

.level-block { gap: 10px; }
.level-seal {
  position: relative;
  isolation: isolate;
  width: 228px;
  height: 228px;
  border: 0;
  border-radius: 50%;
  background:
    linear-gradient(transparent 49.65%, rgba(159,48,34,.62) 49.8% 50.2%, transparent 50.35%),
    linear-gradient(90deg, transparent 49.65%, rgba(159,48,34,.62) 49.8% 50.2%, transparent 50.35%),
    repeating-conic-gradient(from 0deg, rgba(153,44,31,.52) 0 .5deg, transparent .7deg 12deg),
    repeating-radial-gradient(circle, transparent 0 22px, rgba(140,39,28,.38) 23px 24px, transparent 25px 35px),
    radial-gradient(circle, #0c0f0f 0 63%, #070909 64%);
  box-shadow: inset 0 0 0 13px #090b0b, inset 0 0 0 14px #8f2f23, inset 0 0 0 19px #090b0b, inset 0 0 0 20px rgba(149,45,32,.72);
}

.level-seal::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 30px;
  border: 1px solid rgba(157,47,34,.68);
  border-radius: 50%;
  box-shadow: 0 0 0 5px #090b0b, 0 0 0 6px rgba(146,43,31,.42);
}
.level-seal::after {
  content: "✦       ✦       ✦       ✦";
  position: absolute;
  inset: 5px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(129,37,27,.55);
  border-radius: 50%;
  color: #9f3528;
  font-size: 9px;
  letter-spacing: 34px;
  overflow: hidden;
  transform: rotate(45deg);
  pointer-events: none;
}
.level-rune { position: absolute; z-index: 2; top: 25px; color: #b84230; font-size: 27px; font-style: normal; }
.level-seal small { position: relative; z-index: 2; margin-top: 42px; color: #c8b28c; font-size: 15px; text-transform: none; }
.level-seal > input {
  position: relative;
  z-index: 2;
  width: 118px;
  height: 80px;
  color: #e4dac6;
  font-size: 70px;
  font-family: Georgia, serif;
  text-shadow: 0 2px 0 #000;
}

.experience {
  position: absolute;
  z-index: 3;
  left: 19px;
  right: 19px;
  bottom: 22px;
  height: 33px;
  display: grid;
  grid-template-columns: 1fr 12px 1fr;
  align-items: center;
  gap: 2px;
  padding: 2px 11px 5px;
  border: 1px solid #8b7047;
  border-radius: 18px;
  background: #0a0c0c;
  box-shadow: inset 0 0 13px #000;
}
.experience label { display: block; min-width: 0; }
.experience label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.experience b { color: #665945; font-size: 10px; font-weight: 400; }
.experience input { width: 100%; height: 23px; padding: 0; border: 0; background: transparent; color: #d7c5a5; font-size: 17px; }
.experience .xp-track { position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px; border: 0; }

.class-field { position: relative; width: 224px; text-align: center; }
.class-field > span {
  position: relative;
  width: 196px;
  margin: 0 auto 6px;
  padding: 7px 19px 8px;
  color: #c9b18a;
  font-size: 18px;
  background:
    linear-gradient(90deg, transparent, rgba(99,37,27,.14) 20% 80%, transparent),
    linear-gradient(#745837,#745837) top center/72% 1px no-repeat,
    linear-gradient(#745837,#745837) bottom center/72% 1px no-repeat;
  clip-path: polygon(0 0,15% 12%,18% 0,82% 0,85% 12%,100% 0,93% 50%,100% 100%,84% 88%,80% 100%,20% 100%,16% 88%,0 100%,7% 50%);
}
.class-field input { width: 100%; height: 39px; text-align: center; }
.gender-field { width: 190px; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; font-size: 10px; }
.gender-field select { height: 30px; font-size: 11px; }

.sheet-core-grid {
  display: grid;
  grid-template-columns: minmax(205px,.95fr) minmax(225px,1.05fr);
  gap: 16px;
  margin: 22px 11px 0;
}

.combat-summary-column { min-width: 0; }
.vitals { grid-template-columns: 1fr 1.42fr 1fr; gap: 2px; align-items: start; }
.vital { min-width: 0; min-height: 126px; padding: 2px; color: #b9a47f; font-size: 12px; }
.vital-shape,
.vital-heart .vital-shape,
.vital-shield .vital-shape,
.vital-clover .vital-shape {
  position: relative;
  width: 64px;
  height: 70px;
  border: 0;
  border-radius: 0;
  clip-path: none;
  transform: none;
  background: transparent;
}
.vital-heart .vital-shape { width: 94px; height: 88px; }
.vital-clover .vital-shape { width: 64px; height: 70px; }
.vital-shape-svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: #a83929; stroke-width: 1.35; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 3px rgba(139,40,29,.26)); }
.vital-shape input,
.vital-clover input {
  position: relative;
  z-index: 1;
  width: 54%;
  height: 54%;
  padding: 0;
  border: 0;
  transform: none;
  background: transparent;
  color: #e2d6c0;
  font: 31px Georgia,serif;
  text-align: center;
}
.vital-heart .vital-shape input { font-size: 40px; }
.vital strong { margin-top: 4px; color: #bda985; font-size: 13px; line-height: 1.25; }
.vitals .gm-derived-control { width: 100%; margin-top: 4px; }
.vitals .gm-derived-control > small { font-size: 7px; line-height: 1.25; }

.blood-divider { position: relative; height: 24px; margin: 5px 0 10px; color: #983025; text-align: center; }
.blood-divider::before,
.blood-divider::after { content: ""; position: absolute; top: 50%; width: calc(50% - 17px); height: 1px; background: linear-gradient(90deg, transparent, #6e2a22); }
.blood-divider::before { left: 0; }
.blood-divider::after { right: 0; transform: scaleX(-1); }
.blood-divider span { position: relative; top: 4px; font-size: 14px; }

.hit-values { gap: 16px; }
.hit-value { position: relative; gap: 8px; color: #c0aa84; font-size: 13px; line-height: 1.35; }
.hit-value > .modifier-output {
  position: relative;
  width: 88px;
  height: 88px;
  min-height: 88px;
  border: 1px solid #a13628;
  border-radius: 50%;
  background:
    linear-gradient(transparent 49.5%, rgba(149,43,31,.52) 49.8% 50.2%, transparent 50.5%),
    linear-gradient(90deg, transparent 49.5%, rgba(149,43,31,.52) 49.8% 50.2%, transparent 50.5%),
    repeating-radial-gradient(circle, #090b0b 0 29px, rgba(137,39,29,.48) 30px 31px, #090b0b 32px 38px, rgba(137,39,29,.64) 39px 40px);
  color: #e4d7c0;
  font: 38px Georgia,serif;
  box-shadow: 0 0 0 5px #090b0b, 0 0 0 6px rgba(142,42,31,.52);
}
.hit-value .gm-derived-control { width: 100%; }

.skills-section {
  position: relative;
  min-width: 0;
  padding: 0 2px 0 15px;
  border-left: 1px solid rgba(151,44,32,.54);
}
.skills-section::before,
.skills-section::after { content: "✣"; position: absolute; left: -6px; color: #963025; font-size: 11px; }
.skills-section::before { top: -5px; }
.skills-section::after { bottom: -5px; }
.skills-heading { grid-template-columns: minmax(130px,1.45fr) minmax(86px,1fr); gap: 8px; margin-bottom: 7px; color: #c7ae83; font-size: 15px; text-align: center; text-transform: none; }
.skill-row {
  grid-template-columns: 56px minmax(64px,.76fr) minmax(92px,1.24fr);
  gap: 7px;
  min-height: 59px;
  border-bottom: 0;
}
.stat-control { width: 54px; height: 54px; margin: 0; }
.stat-control > input:first-of-type {
  width: 54px;
  height: 54px;
  border: 1px solid #9e3528;
  border-radius: 50%;
  background: repeating-radial-gradient(circle,#090b0b 0 17px,rgba(141,41,30,.55) 18px 19px,#090b0b 20px 24px);
  color: #e1d2b8;
  font: 25px Georgia,serif;
  box-shadow: 0 0 0 3px #090b0b, 0 0 0 4px rgba(131,39,29,.45);
}
.stat-control .modifier-input {
  z-index: 2;
  left: 50%;
  right: auto;
  top: -7px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  border: 1px solid #a16c47;
  border-radius: 4px;
  background: #0b0d0d;
  color: #e8d7ba;
  font-size: 10px;
  box-shadow: 0 2px 4px #000;
}
.skill-name { padding: 0; border: 0; background: transparent; color: #c9b99f; font-size: 13px; text-align: left; }
.skill-name:hover { color: #e2b59e; background: transparent; }
.bonus-control { grid-template-columns: minmax(0,1fr) 29px; gap: 3px; color: #b7a487; font-size: 11px; line-height: 1.2; }
.bonus-control output { min-width: 29px; min-height: 28px; border: 0; background: transparent; color: #d8c6a7; font-size: 13px; }
.temporary-stat-bonus { right: -6px; bottom: -5px; }

.sheet-rest-row { margin: 22px 11px 0; padding-top: 12px; border-top: 1px solid #4c2b24; }
.sheet-rest-row .rest-button { width: 100%; }

@media (max-width: 1100px) {
  #combat-tracker.combat-tracker { left: calc(50vw + 30px) !important; width: calc(100vw - 88px) !important; }
  .character-sheet { width: min(660px, calc(100vw - 88px)); min-width: 590px; }
}

@media (max-width: 820px) {
  #combat-tracker.combat-tracker {
    inset: 62px auto auto calc(50vw + 30px) !important;
    width: calc(100vw - 72px) !important;
    max-height: 108px;
  }
  .character-sheet { min-width: 0; width: calc(100vw - 74px) !important; }
  .sheet-body { grid-template-columns: minmax(0,1fr) 58px; }
  .sheet-tabs button { margin-inline: 3px; font-size: 0; writing-mode: horizontal-tb; }
  .sheet-tabs button span.sheet-tab-icon { width: 30px; height: 30px; }
  .identity-grid { grid-template-columns: minmax(165px,.85fr) minmax(220px,1.15fr); gap: 13px; }
  .sheet-core-grid { grid-template-columns: minmax(195px,.95fr) minmax(215px,1.05fr); gap: 11px; }
}

@media (max-width: 600px) {
  .sheet-content { padding-inline: 13px; }
  .identity-grid,
  .sheet-core-grid { grid-template-columns: 1fr; }
  .portrait-column { max-width: 240px; margin: auto; }
  .skills-section { padding-top: 15px; border-top: 1px solid rgba(151,44,32,.54); border-left: 0; }
  .skills-section::before,
  .skills-section::after { display: none; }
}

/* 1.1 — независимые окна ведущего, надёжный resize листа и действия существ */
.master-drawer-window {
  position: fixed;
  z-index: 86;
  inset: 74px auto auto 92px;
  width: min(540px, calc(100vw - 118px));
  height: min(730px, calc(100vh - 96px));
  min-width: 360px;
  min-height: 320px;
  resize: both;
  overflow: hidden;
}

.master-drawer-window.knowledge-drawer { width: min(1120px, calc(100vw - 118px)); }
.master-drawer-window.campaign-drawer { width: min(980px, calc(100vw - 118px)); }
.master-drawer-window.castle-drawer,
.master-drawer-window.event-drawer { width: min(860px, calc(100vw - 118px)); }
.master-drawer-window > header { cursor: move; user-select: none; }
.master-drawer-window > .drawer-content { height: calc(100% - 70px); max-height: none; overflow: auto; }

.character-sheet {
  min-width: 470px;
  max-width: calc(100vw - 84px);
}

button.sheet-resize-hint {
  z-index: 40;
  right: 2px;
  bottom: 2px;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  border-right: 3px solid #a76440;
  border-bottom: 3px solid #a76440;
  border-radius: 0 0 2px 0;
  background:
    linear-gradient(135deg, transparent 0 44%, #523b2a 45% 49%, transparent 50% 61%, #8d5638 62% 67%, transparent 68%);
  box-shadow: none;
  cursor: nwse-resize;
  pointer-events: auto;
  touch-action: none;
}
button.sheet-resize-hint::before,
button.sheet-resize-hint::after { content: none; }
button.sheet-resize-hint:hover { border-color: #d04a35; background-color: rgba(104,31,23,.22); }
button.sheet-resize-hint:focus-visible { outline: 2px solid #d04a35; outline-offset: -4px; }

.monster-action-library {
  grid-column: 1 / -1;
  margin-top: 9px;
  border-top: 1px solid #4d3829;
  padding-top: 8px;
}
.monster-action-library > summary { display: flex; align-items: center; gap: 8px; color: #d0b786; cursor: pointer; font-size: 13px; }
.monster-action-library > summary b { min-width: 20px; padding: 2px 6px; border: 1px solid #6f4831; border-radius: 999px; color: #c34a39; font-size: 10px; text-align: center; }
.monster-action-library-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.monster-action-library-head small { color: #948570; font-size: 11px; }
.monster-action-library-head button { flex: 0 0 auto; }
.monster-action-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(154px,1fr)); gap: 7px; }
.monster-combat-action { position: relative; min-width: 0; }
.monster-combat-action > button:first-child {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 24px minmax(0,1fr);
  grid-template-rows: auto auto auto;
  gap: 2px 7px;
  padding: 8px 9px;
  border: 1px solid #65432e;
  background: radial-gradient(circle at 12% 18%, rgba(148,42,30,.2), transparent 38%), #0b0e0e;
  color: #c9b89b;
  text-align: left;
}
.monster-combat-action > button:first-child > span { grid-row: 1 / 4; align-self: center; color: #cb4c38; font-size: 23px; text-align: center; }
.monster-combat-action > button:first-child > small { color: #8f7b62; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.monster-combat-action > button:first-child > strong { overflow: hidden; color: #dbc59e; font-size: 12px; text-overflow: ellipsis; }
.monster-combat-action > button:first-child > em { color: #b85a47; font-size: 10px; font-style: normal; }
.monster-combat-action.spell > button:first-child { border-color: #753729; }
.monster-combat-action.skill > button:first-child { border-color: #595037; }
.monster-combat-action > i { position: absolute; top: 3px; right: 3px; display: flex; gap: 2px; }
.monster-combat-action > i button { width: 20px; height: 20px; padding: 0; border: 1px solid #5c3e2d; background: #0a0c0c; color: #b48769; font-size: 11px; }
.combat-monster-row.current-actor { box-shadow: inset 3px 0 0 #b03a2b; }
.monster-action-buttons button { display: inline-flex; align-items: center; gap: 6px; }
.monster-action-buttons button small { color: #9a8468; font-size: 8px; letter-spacing: .06em; text-transform: uppercase; }
.monster-action-dialog { width: min(590px, calc(100vw - 36px)); }

@media (max-width: 820px) {
  .master-drawer-window { left: 66px !important; top: 66px !important; width: calc(100vw - 74px) !important; height: calc(100vh - 74px) !important; resize: none; }
  button.sheet-resize-hint { display: none; }
}

/* 1.2 — полный сюжет, два вида ресурсов и масштабируемый показ изображений */
.master-drawer-window.story-drawer { width: min(1120px, calc(100vw - 118px)); }

.story-tabs {
  position: sticky;
  z-index: 5;
  top: -18px;
  display: flex;
  gap: 4px;
  margin: -18px -18px 16px;
  padding: 12px 18px 9px;
  overflow-x: auto;
  border-bottom: 1px solid #53372a;
  background: rgba(8,10,10,.97);
}
.story-tabs button { flex: 0 0 auto; min-height: 36px; padding: 7px 13px; border: 1px solid #49382e; background: #111313; color: #ad9a7f; cursor: pointer; }
.story-tabs button.active { border-color: #9c392e; background: #261512; color: #ead5b2; box-shadow: inset 0 -2px 0 #b14032; }
.story-panel-body { min-height: 0; color: #b9aa93; }
.story-panel-body p,
.story-panel-body li { font-size: 15px; line-height: 1.58; }
.story-panel-body h3,
.story-panel-body h4 { color: #dec7a3; font-family: Georgia, serif; }

.story-hero { padding: 22px; border: 1px solid #5d3f31; background: radial-gradient(circle at 92% 8%, rgba(128,34,25,.3), transparent 32%), linear-gradient(135deg,#151414,#0a0d0d); }
.story-hero h3 { margin: 3px 0 9px; color: #e9d2ab; font-size: 34px; }
.story-hero .story-logline { max-width: 900px; color: #d0bfa3; font-size: 18px; }
.story-hero blockquote { margin: 18px 0; padding: 13px 17px; border-left: 4px solid #b23e30; background: rgba(75,24,19,.34); color: #f0d5ae; font: 20px/1.5 Georgia,serif; }
.story-route > h3 { margin: 22px 0 10px; }
.story-route > div { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 7px; }
.story-route-card { min-width: 0; display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 8px; padding: 11px; border: 1px solid #44382f; background: #101212; color: #b4a58f; text-align: left; cursor: pointer; }
.story-route-card:hover,
.story-route-card.completed { border-color: #96392e; background: #1e1412; }
.story-route-card > b { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #7f382e; border-radius: 50%; color: #d14e3e; }
.story-route-card small,
.story-route-card strong,
.story-route-card em { display: block; }
.story-route-card small { color: #bd4b3d; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.story-route-card strong { margin: 2px 0; color: #ddc5a2; font-family: Georgia,serif; font-size: 15px; }
.story-route-card em { color: #9d8c75; font-size: 11px; font-style: normal; }
.story-route-card p { margin: 7px 0 0; color: #a89882; font-size: 12px; line-height: 1.45; }
.story-overview-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 12px; margin-top: 15px; }
.story-overview-grid > article { padding: 15px; border: 1px solid #42372f; background: #101212; }
.story-overview-grid h3 { margin-top: 0; }
.story-overview-grid ul { padding-left: 21px; }
.story-reveal-path { display: grid; gap: 5px; }
.story-reveal-path > article { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 8px; padding: 7px; border-left: 2px solid #683328; background: #0b0e0e; }
.story-reveal-path > article > b { color: #c94a3b; font-size: 18px; }
.story-reveal-path h4 { margin: 1px 0 3px; }
.story-reveal-path p { margin: 0; font-size: 12px; }
.story-reveal-path small { color: #806f5b; }

.story-world-intro { padding: 18px; border-left: 4px solid #a13b30; background: linear-gradient(90deg,rgba(94,29,23,.27),transparent); }
.story-world-intro p { margin: 0; color: #dfccb0; font-size: 18px; }
.story-world-grid,
.story-faction-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.story-world-grid article,
.story-faction-grid article { padding: 13px; border: 1px solid #42372f; background: #101212; }
.story-world-grid h3,
.story-faction-grid h3 { margin: 0 0 7px; }
.story-world-grid p,
.story-faction-grid p { margin: 0; }
.story-faction-grid details { margin-top: 9px; padding: 8px; border: 1px solid #4c3429; background: #0a0c0c; }

.story-prologue > header { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 13px; border-bottom: 1px solid #4a372e; }
.story-prologue > header h3 { margin: 2px 0 5px; font-size: 30px; }
.story-prologue > header p { margin: 0; max-width: 700px; }
.story-prologue-actions { display: flex; flex-direction: column; gap: 6px; }
.story-prologue-actions button,
.story-read-aloud button,
.story-narration-chapter button,
.story-location-detail > header button { min-height: 34px; padding: 6px 10px; border: 1px solid #704838; background: #201613; color: #ddc29e; cursor: pointer; }
.story-prologue-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 13px 0; }
.story-prologue-grid > article { padding: 14px; border: 1px solid #413831; background: #101212; }
.story-prologue-grid h4 { margin: 0 0 5px; }
.story-prologue-grid ul { margin-top: 4px; padding-left: 21px; }
.story-prologue-grid blockquote { margin: 8px 0; padding-left: 10px; border-left: 2px solid #6c3f31; color: #c7b498; }
.story-secret { border-color: #73362d !important; background: linear-gradient(135deg,#1b1211,#0d1010) !important; }
.story-read-aloud { margin: 12px 0; padding: 17px; border: 1px solid #694537; border-left: 4px solid #b33f31; background: radial-gradient(circle at 100% 0,rgba(119,35,27,.21),transparent 40%),#121313; }
.story-read-aloud > small { color: #cd4e3f; letter-spacing: .08em; text-transform: uppercase; }
.story-read-aloud > p { color: #e1ceb0; font-size: 17px; line-height: 1.72; white-space: pre-wrap; }

.story-act-buttons { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.story-act-buttons button { display: grid; gap: 2px; padding: 11px; border: 1px solid #45382f; background: #101212; color: #a8957a; text-align: left; cursor: pointer; }
.story-act-buttons button.active { border-color: #9e3b30; background: #211412; }
.story-act-buttons small { color: #bf4a3c; }
.story-act-buttons strong { color: #dec6a1; font: 17px Georgia,serif; }
.story-act-buttons span { color: #82725e; font-size: 10px; }
.story-act-summary { margin-bottom: 12px; padding: 15px; border: 1px solid #543b30; background: linear-gradient(135deg,#171414,#0c0f0f); }
.story-act-summary > header { display: flex; justify-content: space-between; gap: 15px; }
.story-act-summary > header h3 { margin: 1px 0 5px; font-size: 27px; }
.story-act-summary > header p { margin: 0; color: #c7b69a; }
.story-act-summary > header > span { align-self: start; padding: 5px 9px; border: 1px solid #6c4133; color: #c54b3c; white-space: nowrap; }
.story-act-summary > div { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 12px 0; }
.story-act-summary > div article { padding: 10px; border: 1px solid #3e3630; background: #0e1010; }
.story-act-summary h4 { margin: 0 0 5px; }
.story-act-summary p { margin: 0; }
.story-act-summary details { padding: 10px; border-top: 1px solid #49382f; }
.story-act-summary summary { color: #d4ba96; cursor: pointer; }
.story-act-plan { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.story-act-layout { display: grid; grid-template-columns: 245px minmax(0,1fr); gap: 12px; }
.story-act-layout > nav { display: grid; align-content: start; gap: 5px; }
.story-act-layout > nav button { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 2px 7px; min-height: 48px; padding: 7px; border: 1px solid #423831; background: #101212; color: #aa9a84; text-align: left; cursor: pointer; }
.story-act-layout > nav button b { grid-row: 1/3; display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #71382e; border-radius: 50%; color: #c4493b; }
.story-act-layout > nav button small { color: #766a59; font-size: 9px; }
.story-act-layout > nav button.active { border-color: #9a3b30; background: #201412; color: #e2ccb0; }
.story-location-detail { min-width: 0; padding: 15px; border: 1px solid #483a31; background: #101212; }
.story-location-detail > header { display: flex; justify-content: space-between; gap: 15px; }
.story-location-detail > header h3 { margin: 2px 0 4px; font-size: 25px; }
.story-location-detail > header p { margin: 0; }
.story-location-facts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin-top: 12px; }
.story-location-facts section { padding: 9px; border: 1px solid #38332e; background: #0b0e0e; }
.story-location-facts small { color: #c34a3c; text-transform: uppercase; }
.story-location-facts p { margin: 4px 0 0; font-size: 13px; }
.story-location-clues { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.story-location-clues article { padding: 9px; border: 1px solid #50382f; background: #0b0e0e; }
.story-location-clues b,
.story-location-clues strong { display: block; }
.story-location-clues b { color: #bf493b; font-size: 9px; text-transform: uppercase; }
.story-location-clues p { margin-bottom: 0; font-size: 12px; }
.story-act-clues { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.story-act-clues article { display: grid; grid-template-columns: 24px minmax(0,1fr); gap: 7px; padding: 9px; border: 1px solid #3f3730; background: #101212; opacity: .65; }
.story-act-clues article.found,
.story-act-clues article.connected,
.story-act-clues article.resolved { opacity: 1; border-color: #714036; }
.story-act-clues article > span { color: #c4493b; font-size: 19px; }
.story-act-clues h4 { margin: 0; }
.story-act-clues p { margin: 3px 0; font-size: 12px; }
.story-act-clues small { color: #8f7d66; }

.story-narration-layout { display: grid; grid-template-columns: 190px minmax(0,1fr); gap: 13px; }
.story-narration-layout > nav { display: grid; align-content: start; gap: 5px; position: sticky; top: 48px; }
.story-narration-layout > nav button { min-height: 40px; padding: 7px; border: 1px solid #443831; background: #101212; color: #aa987e; text-align: left; cursor: pointer; }
.story-narration-layout > nav button.active { border-color: #9a3b30; background: #211412; color: #e1c7a2; }
.story-narration-chapter > h3 { margin: 2px 0 12px; font-size: 29px; }
.story-act-readings { display: grid; gap: 9px; }
.story-act-readings > section { padding: 15px; border-left: 3px solid #9f3a2f; background: #111313; }
.story-act-readings small { color: #c94a3b; text-transform: uppercase; }
.story-act-readings p { color: #dec9aa; font-size: 17px; line-height: 1.7; }
.story-location-readings { display: grid; gap: 6px; }
.story-location-readings details { padding: 10px; border: 1px solid #40372f; background: #101212; }
.story-location-readings summary { color: #d2b995; cursor: pointer; }
.story-location-readings summary b { color: #c94a3b; margin-right: 5px; }
.story-location-readings p { color: #d8c5a7; font-size: 16px; line-height: 1.7; white-space: pre-wrap; }
.story-finale-texts { display: grid; gap: 10px; }
.story-finale-texts section { padding: 15px; border: 1px solid #553a30; background: #101212; }
.story-finale-texts h4 { margin: 0 0 3px; font-size: 19px; }
.story-finale-texts small { color: #9b886e; }
.story-finale-texts blockquote { padding: 12px; border-left: 3px solid #a33d31; background: #171111; color: #e1cbaa; font-size: 16px; line-height: 1.65; }

.campaign-road-beats { display: grid; gap: 6px; margin-bottom: 17px; }
.campaign-road-beats article { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 9px; align-items: start; padding: 10px; border: 1px solid #3f3831; background: #101212; opacity: .58; }
.campaign-road-beats article.ready { border-color: #704036; opacity: 1; }
.campaign-road-beats article > b { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #73392f; border-radius: 50%; color: #c94a3b; }
.campaign-road-beats h3 { margin: 0 0 2px; }
.campaign-road-beats p { margin: 4px 0 0; color: #ad9e87; font-size: 13px; }
.campaign-road-beats small { color: #82715e; }
.campaign-road-beats article > span { padding: 3px 6px; border: 1px solid #4d3c32; color: #887967; font-size: 9px; text-transform: uppercase; }
.campaign-road-beats article.ready > span { border-color: #834034; color: #cf5848; }

.resource-placement-choice { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.resource-placement-choice legend { color: #b8a385; }
.resource-placement-choice label { display: grid !important; grid-template-columns: auto minmax(0,1fr); gap: 8px; align-items: center; padding: 9px; border: 1px solid #4c3b30; background: #101212; cursor: pointer; }
.resource-placement-choice input { width: auto !important; accent-color: #ae3e31; }
.resource-placement-choice b,
.resource-placement-choice small { display: block; }
.resource-placement-choice b { color: #d4bd98; }
.resource-placement-choice small { margin-top: 2px; color: #887966; font-size: 10px; }
.resource-library-art { position: relative; }
.resource-library-art > span { position: absolute; left: 4px; right: 4px; bottom: 4px; padding: 3px 4px; border: 1px solid #6a4937; background: rgba(7,9,9,.9); color: #d5ba93; font-size: 9px; text-align: center; }
.resource-library-card.token .resource-library-art img { border-radius: 50%; object-fit: cover; }

.token.resource-round-token { border-radius: 50%; }
.token.resource-round-token img { border-radius: 50% !important; object-fit: cover !important; background: #151717; }
.token.resource-image { border-width: 1px; border-radius: 4px; background: rgba(8,10,10,.32); box-shadow: 0 6px 18px rgba(0,0,0,.72),0 0 0 2px #090a0a; }
.token.resource-image img { border-radius: 3px !important; object-fit: contain !important; background: transparent; }
.token.resource-image .token-name { top: calc(100% + 4px); }
.token.resource-image.resizing { z-index: 24; outline: 2px solid #c64b3b; outline-offset: 3px; }
.resource-resize-handle { position: absolute; z-index: 9; right: -9px; bottom: -9px; width: 20px; height: 20px; border: 2px solid #d05a43; background: linear-gradient(135deg,#0b0d0d 0 45%,#c24b38 46% 55%,#0b0d0d 56%); box-shadow: 0 2px 5px #000; cursor: nwse-resize; pointer-events: auto; touch-action: none; }
.map-viewport.monster-drop-ready::after { content: "Отпустите — элемент появится на сцене"; }

.image-viewer-dialog { width: 70vw; max-width: 70vw; height: 70vh; max-height: 70vh; padding: 0; overflow: hidden; border: 1px solid #704c35; background: rgba(4,6,6,.98); color: #cdbb9d; }
.image-viewer-dialog::backdrop { background: rgba(0,0,0,.88); }
.image-viewer-dialog > article { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; width: 100%; height: 100%; }
.image-viewer-dialog header { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid #50372c; }
.image-viewer-dialog h2 { margin: 0; color: #dec6a1; font: 22px Georgia,serif; }
.image-viewer-toolbar { display: grid; grid-template-columns: 34px minmax(120px,1fr) 34px auto 52px; gap: 6px; align-items: center; padding: 7px 11px; border-bottom: 1px solid #3e322a; background: #0d1010; }
.image-viewer-toolbar button { min-height: 31px; border: 1px solid #594233; background: #181513; color: #d4bd99; cursor: pointer; }
.image-viewer-toolbar input { width: 100%; accent-color: #a73a2e; }
.image-viewer-toolbar output { color: #d45a48; text-align: right; }
.image-viewer-viewport { min-width: 0; min-height: 0; overflow: auto; padding: 12px; background: repeating-conic-gradient(#0d0f0f 0 25%,#111414 0 50%) 0/24px 24px; }
.image-viewer-dialog .image-viewer-viewport img { display: block; width: 100%; height: auto; max-width: none; max-height: none; margin: 0 auto; object-fit: contain; filter: none; }
.image-viewer-description { max-height: 92px; margin: 0; padding: 9px 13px; overflow: auto; border-top: 1px solid #4b392f; color: #bca98d; font-size: 14px; line-height: 1.45; }

@media (max-width: 900px) {
  .story-route > div { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .story-overview-grid,
  .story-act-layout,
  .story-narration-layout { grid-template-columns: 1fr; }
  .story-narration-layout > nav { position: static; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .story-act-layout > nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .story-act-clues { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .image-viewer-dialog { width: 92vw; max-width: 92vw; height: 85vh; max-height: 85vh; }
}

@media (max-width: 620px) {
  .story-world-grid,
  .story-faction-grid,
  .story-prologue-grid,
  .story-act-summary > div,
  .story-act-plan,
  .story-location-facts,
  .story-location-clues,
  .story-act-clues { grid-template-columns: 1fr; }
  .story-act-buttons { grid-template-columns: 1fr; }
  .story-prologue > header { display: block; }
  .story-prologue-actions { margin-top: 9px; }
  .resource-placement-choice { grid-template-columns: 1fr; }
  .image-viewer-toolbar { grid-template-columns: 34px minmax(80px,1fr) 34px 45px; }
  .image-viewer-toolbar #image-viewer-zoom-reset { display: none; }
}
