/* ============ АУДИОКВЕСТ — тёмное фэнтези ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0b0910;
  --panel: #16121e;
  --panel2: #1e1828;
  --gold: #d4a94e;
  --gold-dim: #8a6f33;
  --text: #e8e0d0;
  --dim: #9a8fa8;
  --red: #c0392b;
  --green: #4e9a51;
  --border: #2c2438;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  /* вертикальные отступы малы намеренно: с 12px таверна ровно на них
     и вылезала за экран, давая лишнюю прокрутку */
  padding: 6px 12px;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(90, 60, 30, 0.15), transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(60, 30, 80, 0.15), transparent 60%);
}

.screen { display: flex; justify-content: center; align-items: flex-start; width: 100%; max-width: 1000px; }
.screen[style*="display: flex"] { display: flex; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 560px;
  margin-top: 6vh;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.panel.small { max-width: 420px; margin-top: 18vh; }

.title { font-size: 44px; letter-spacing: 4px; color: var(--text); text-shadow: 0 0 30px rgba(212,169,78,.25); }
.accent { color: var(--gold); }
.subtitle { color: var(--dim); margin: 8px 0 22px; font-size: 14px; }
.hint { background: rgba(192,57,43,.12); border: 1px solid rgba(192,57,43,.4); color: #e8a0a0; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

.lbl { display: block; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 6px; }
.inp {
  width: 100%; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); padding: 11px 14px; border-radius: 8px; font-size: 15px; outline: none;
}
.inp:focus { border-color: var(--gold-dim); }
.cr-desc { color: var(--dim); font-size: 13px; line-height: 1.5; margin: 10px 0 4px; min-height: 40px; }
.preload-hint { color: var(--gold-dim); font-size: 12px; min-height: auto; }

.btn {
  display: block; width: 100%; margin-top: 12px; padding: 13px;
  background: linear-gradient(180deg, #2a2138, #1c1626);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 15px; cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--gold-dim); transform: translateY(-1px); }
.btn.big { background: linear-gradient(180deg, #b8903c, #8a6f33); color: #14100a; font-weight: 700; border: none; }
.btn.big:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.small { display: inline-block; width: auto; margin: 4px 4px 4px 0; padding: 8px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; margin-top: 0; }

/* ---------- Таверна (хаб): визуальный бар ---------- */
.hub-wrap { width: 100%; max-width: 1100px; }
.hub-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hub-head h2 { color: var(--gold); letter-spacing: 1px; }
.hub-right { display: flex; gap: 14px; }
.hub-day { color: var(--dim); font-size: 14px; }
.bar-scene {
  /* высота в vh: таверна должна влезать в экран целиком, без прокрутки */
  position: relative; height: 30vh; min-height: 190px; max-height: 340px;
  border-radius: 16px; overflow: hidden;
  border: 1px solid var(--border); background: #1a140d;
}
.bar-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .55; transition: opacity .4s; }
.bar-bg.show { opacity: .75; }
.bar-warm {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 70% 110%, rgba(255,150,40,.32), rgba(10,6,2,.55) 60%, rgba(5,3,1,.85));
  pointer-events: none;
}
.bar-fire {
  position: absolute; right: 26px; bottom: 10px; font-size: 46px;
  animation: fire-flicker 1.2s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(255,140,40,.8));
}
@keyframes fire-flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  30% { transform: scale(1.12) rotate(2deg); }
  60% { transform: scale(.96) rotate(-1deg); }
}
.bar-counter {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: linear-gradient(180deg, transparent, rgba(10,6,2,.92) 40%);
}
.bar-bartender { font-weight: 700; color: var(--gold); font-size: 15px; margin-right: 8px; text-shadow: 0 2px 6px #000; }
.btn.tiny { width: auto; margin: 0; padding: 5px 10px; font-size: 12px; }
.bar-patrons { position: absolute; top: 18px; left: 0; right: 0; display: flex; gap: 12px; padding: 0 16px; flex-wrap: wrap; }
.patron-chip {
  background: rgba(24,17,8,.88); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text); transition: all .15s; max-width: 210px;
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
.patron-chip:hover { border-color: var(--gold); transform: translateY(-2px); }
.patron-chip .p-emoji { font-size: 24px; }
.patron-chip .p-name { font-weight: 700; }
.patron-chip .p-desc { color: var(--dim); font-size: 11px; }
.patron-chip.comp { border-color: #8a6ae0; box-shadow: 0 0 14px rgba(138,106,224,.35); }
.patron-chip.comp .p-emoji { filter: drop-shadow(0 0 6px rgba(138,106,224,.8)); }
.bar-sign {
  position: absolute; top: 8px; right: 14px; color: rgba(212,169,78,.55);
  font-size: 11px; font-style: italic; letter-spacing: 1px;
}
.patron-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-top: 10px;
}
.patron-panel .pp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.patron-panel .pp-head .p-emoji { font-size: 30px; }
.patron-panel .pp-name { font-size: 16px; font-weight: 700; }
.patron-panel .pp-mood { color: var(--dim); font-size: 12px; }
/* ---------- Пошаговое создание героя ---------- */
.panel.panel-wide { max-width: 760px; }
.cr-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.crs-dot {
  font-size: 11px; color: var(--dim); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; letter-spacing: .3px;
}
.crs-dot.now { color: var(--gold); border-color: var(--gold-dim); }
.crs-dot.done { color: var(--green); }
.cr-step { display: none; }
.cr-step.active { display: block; }
.cr-sub { color: var(--dim); font-size: 13px; margin: 6px 0 12px; }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick-card {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; transition: all .15s;
}
.pick-card:hover { border-color: var(--gold-dim); transform: translateY(-1px); }
.pick-card.chosen { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-dim); }
.pick-card .pc-name { font-weight: 700; color: var(--text); margin-bottom: 3px; }
.pick-card .pc-desc { color: var(--dim); font-size: 12px; line-height: 1.45; }
.pick-card .pc-desc i { color: var(--gold-dim); font-style: normal; }
.pts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.pts-row {
  display: flex; align-items: center; gap: 8px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.pts-row .pts-name { flex: 1; font-size: 13px; }
.pts-row .pts-val { min-width: 28px; text-align: center; color: var(--gold); font-weight: 700; }
.btn.tiny[disabled] { opacity: .35; cursor: not-allowed; }
.cr-sheet { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.cr-sheet .crs-line { font-size: 13px; margin-bottom: 6px; }
.cr-sheet .crs-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.cr-summary { margin-top: 12px; }
.cr-story {
  border-left: 2px solid var(--gold-dim); padding-left: 10px;
  color: var(--text); font-style: italic; font-size: 14px; line-height: 1.6; margin-bottom: 8px;
}
.btn.big[disabled] { opacity: .4; cursor: not-allowed; filter: none; }
/* пролог */
.pro-text { font-size: 15px; line-height: 1.75; margin: 10px 0 20px; }
.pro-text p { margin-bottom: 12px; }
.pro-text b { color: var(--gold); }
@media (max-width: 640px) {
  .pick-grid, .pts-grid { grid-template-columns: 1fr; }
}

/* Полоса параметров героя в таверне */
.hub-stats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.hub-stats .hs-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 3px 8px; font-size: 12px; color: var(--dim); white-space: nowrap;
}
.hub-stats .hs-item b { color: var(--text); font-weight: 700; }
.hub-stats .hs-item i { color: var(--gold-dim); font-style: normal; margin-left: 4px; }
.hub-stats .hs-hp b { color: #9fd49f; }
.hub-stats .hs-mp b { color: #8ab4e0; }
/* шанс успеха у кнопок подхода */
.dc.ch-good { color: #9fd49f; }
.dc.ch-mid { color: var(--gold-dim); }
.dc.ch-bad { color: #e08080; }
.btn.small[disabled] { opacity: .45; cursor: not-allowed; }

/* Вкладки таверны: разделов девять, экран один. Видна ровно одна панель,
   у неё же своя прокрутка — сама таверна больше не растёт в высоту. */
.hub-tabs { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.hub-tab {
  flex: 1 1 auto; min-width: 90px; cursor: pointer;
  background: var(--panel); color: var(--dim);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 10px 10px 0 0; padding: 7px 10px;
  font: inherit; font-size: 13px; letter-spacing: .3px;
}
.hub-tab:hover { color: var(--gold-dim); }
.hub-tab.active { color: var(--gold); background: var(--panel-hi, var(--panel)); box-shadow: inset 0 2px 0 var(--gold); }
.hub-pane { display: none; }
.hub-pane.active { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hub-bottom { margin-top: 0; max-height: 30vh; overflow-y: auto; }
/* на узком экране две колонки по 170px нечитаемы — разворачиваем в одну,
   высоту держит прокрутка самой панели */
@media (max-width: 640px) {
  .hub-pane.active { grid-template-columns: 1fr; }
  .hub-tab { min-width: 70px; font-size: 12px; padding: 6px 6px; }
  /* на телефоне заголовок, кнопки и подсказка занимают втрое больше рядов,
     поэтому сцене бара достаётся меньше */
  .bar-scene { height: 22vh; min-height: 140px; }
  .btn-row .btn { padding: 9px 6px; font-size: 13px; }
  #hub-log { max-height: 11vh; }
}
.hub-col { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.hub-cap { color: var(--gold-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 8px 0 6px; }
.hub-cap:first-child { margin-top: 0; }
#hub-log { margin-top: 10px; max-height: 13vh; min-height: 56px; }
.hire-card { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }
.hire-card .hc-info { flex: 1; }
.hire-card .hc-name { font-weight: 700; color: var(--text); }
.hire-card .hc-role { color: var(--dim); font-size: 12px; }
.hire-card.wounded { border-color: #8a3a3a; }
.hire-card.dead { opacity: .45; border-style: dashed; }
.hire-card .bad { color: #e08080; }
.hire-card button { font-size: 12px; padding: 5px 10px; }
.zone-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; margin-bottom: 6px; color: var(--text); font-size: 13px; cursor: pointer; }
.zone-btn:hover { border-color: var(--gold); }
.zone-btn .z-lock { color: var(--dim); font-size: 11px; }
.zone-btn.rare { border-color: #3a6ea5; }
.zone-btn.epic { border-color: #8a6ae0; }
.zone-btn.legendary { border-color: #d4a94e; box-shadow: 0 0 10px rgba(212,169,78,.25); }
.zone-btn.portal { border-color: #4ac0e0; box-shadow: 0 0 12px rgba(74,192,224,.3); }
.q-badge { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; font-size: 11px; color: var(--gold); }
.rep-row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; margin-bottom: 4px; background: var(--panel2); border-radius: 8px; font-size: 12px; }
.rep-row.ally { border-left: 3px solid var(--gold); }
.tutor-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0; padding: 8px 12px; background: var(--panel2); border-left: 3px solid var(--gold); border-radius: 8px; font-size: 13px; color: var(--dim); }
.st-row.locked { opacity: .45; }
.cw-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.gslot { display: flex; align-items: flex-start; gap: 8px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 12px; }
.gslot.empty { opacity: .5; }
.gslot.uniq { border-color: #ff7b3a; box-shadow: 0 0 10px rgba(255,123,58,.25); }
.gslot .gs-icon { font-size: 18px; }
.gslot .gs-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.gslot .gs-cap { color: var(--gold-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.gslot .gs-name { font-weight: 700; }
.gslot .gs-desc { color: var(--dim); font-size: 11px; line-height: 1.35; }
.gs-tot { grid-column: 1 / -1; color: var(--gold); font-size: 12px; padding: 6px 9px; background: var(--panel2); border-radius: 8px; }
.roll { color: var(--gold-dim); font-size: 11px; }
.ab-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.ab-row .ab { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; font-size: 11px; color: var(--dim); letter-spacing: .5px; }
.ab-row .ab b { color: var(--text); font-weight: 700; }
.ab-row .ab i { color: var(--gold-dim); font-style: normal; margin-left: 3px; }
.ab-row .ab.up { border-color: var(--gold-dim); }
.ab-row .ab.up b { color: var(--gold); }
.act-btn { white-space: normal; line-height: 1.35; }
.zone-btn.locked { opacity: .72; }
.zone-btn.unlocked { border-color: var(--gold); }
.rift-box { margin-top: 8px; padding: 9px 11px; background: linear-gradient(180deg, rgba(74,192,224,.10), var(--panel2)); border: 1px solid #2f5f70; border-radius: 8px; }
.rift-box .rift-head { font-size: 13px; margin-bottom: 6px; }
.rift-box .btn-row { margin-top: 0; }
.keyring { margin-top: 8px; padding: 7px 10px; background: var(--panel2); border-radius: 8px; font-size: 12px; color: var(--dim); }
.unique { color: #ff7b3a; }
.panel.ending { max-width: 640px; text-align: left; }
.panel.ending h2 { text-align: center; }
.ending-text { color: var(--text); line-height: 1.55; margin: 10px 0; }

/* ---------- Журнал квестов ---------- */
.jr-section { margin-bottom: 14px; }
.jr-section h3 { color: var(--gold-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.q-card { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--gold-dim); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; font-size: 13px; }
.q-card .q-title { font-weight: 700; color: var(--text); }
.q-card .q-desc { color: var(--dim); margin-top: 2px; line-height: 1.4; }
.q-card .q-twist { color: var(--gold); font-style: italic; margin-top: 2px; }

/* ---------- Слоты сохранений ---------- */
.save-slots { margin-top: 14px; }
.save-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-bottom: 5px; font-size: 12px; color: var(--dim); }
.save-item button { font-size: 12px; padding: 4px 9px; }
.save-item .si-info { flex: 1; }

/* ---------- Заклинания ---------- */
.spells-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.spell-btn { background: linear-gradient(180deg, #2a2140, #1c1630); border: 1px solid #4a3a70; border-radius: 10px; color: #c8b8f0; padding: 8px 12px; font-size: 13px; cursor: pointer; }
.spell-btn:hover { border-color: #8a6ae0; }
.spell-btn .mp { color: #6ab0e0; font-size: 11px; }
.foot { color: var(--dim); font-size: 12px; margin-top: 18px; text-align: center; }

/* ---------- HUD ---------- */
#scr-game { flex-direction: column; align-items: stretch; }
.hud { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0 8px; }
/* Шапка сцены: раньше одна строка «Пещеры Вой — Имя (Дварф Воин) · офлайн-Мастер»
   переносилась посреди слова и выглядела как отладочный вывод. */
.zone-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.zone-name .zn-place {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px; font-weight: 600; letter-spacing: .6px;
  color: var(--gold); line-height: 1.15;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zone-name .zn-hero {
  font-size: 12px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .zone-name .zn-place { font-size: 17px; }
  .zone-name .zn-hero { font-size: 11px; letter-spacing: .4px; }
}
.hpbar { width: 300px; max-width: 50vw; height: 12px; background: #0d0a12; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-top: 3px; }
.hpbar.hp { height: 14px; }
.hpbar.mp #mp-fill { height: 100%; background: linear-gradient(90deg, #3a6ea5, #6ab0e0); width: 100%; }
.hpbar.xp #xp-fill { height: 100%; background: linear-gradient(90deg, #8a6f33, #d4a94e); width: 0; }
#hp-fill { height: 100%; background: linear-gradient(90deg, #6ab04c, #badc58); width: 100%; transition: width .4s; border-radius: 6px; }
#mp-fill, #xp-fill { transition: width .4s; border-radius: 6px; }
.hp-label { font-size: 13px; color: var(--dim); margin-top: 3px; }
.hud-right { display: flex; gap: 16px; color: var(--dim); font-size: 13px; }
#goal-bar { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 14px; margin-bottom: 10px; color: var(--gold); }

/* ---------- Сцена ---------- */
.stage { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #0d0b12; min-height: 380px; }
#loc-fallback { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.loc-photo { position: absolute; inset: 0; z-index: 1; background-size: cover; background-position: center 40%; opacity: 0; transition: opacity .6s; }
.loc-photo.show { opacity: .55; }
.loc-photo.show::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,9,16,.35), rgba(11,9,16,.8)); }
.loc-bg { position: absolute; inset: 0; z-index: 2; background-size: contain; background-position: center 62%; background-repeat: no-repeat; opacity: .9; }
.loc-bg.has-img::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,9,16,.1), rgba(11,9,16,.7)); z-index: 1; pointer-events: none; }

.hero-wrap { position: absolute; right: 4%; bottom: 6%; z-index: 3; }
#hero-img { height: 250px; max-height: 38vh; filter: drop-shadow(0 8px 20px rgba(0,0,0,.7)); }

.narr-wrap { position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 22px 16px; background: linear-gradient(180deg, transparent, rgba(11,9,16,.96)); z-index: 4; }
.narr { font-size: 16px; line-height: 1.5; color: var(--text); max-width: 760px; }
.thinking { display: inline-block; color: var(--gold); font-size: 13px; font-style: italic; margin-bottom: 6px; animation: fxpulse 1.2s ease-in-out infinite; }

/* ---------- Действия ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.act-btn {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 12px; font-size: 14px; cursor: pointer; text-align: left; transition: all .12s;
}
.act-btn:hover { border-color: var(--gold); background: var(--panel2); transform: translateY(-1px); }
.dc { color: var(--dim); font-size: 12px; }
.enemy-bar { grid-column: span 2; background: rgba(192,57,43,.15); border: 1px solid rgba(192,57,43,.45); border-radius: 10px; padding: 10px 14px; font-size: 15px; }
.enemy-bar .ehp { color: #e88; margin-left: 8px; }

/* ---------- Низ: журнал + статус ---------- */
.bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.log { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.55; max-height: 13vh; min-height: 60px; overflow-y: auto; }
.log-line { padding: 2px 0; border-bottom: 1px solid rgba(44,36,56,.5); }
.log-line:last-child { border-bottom: none; }
.log-sys { color: var(--dim); font-style: italic; }
.log-ok { color: #9fd49f; }
.log-bad { color: #e88; }
.log-loot { color: var(--gold); }
.log-info { color: var(--text); }
.log-line .ok { color: #9fd49f; font-weight: 700; }
.log-line .bad { color: #e88; font-weight: 700; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.st-cell { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--dim); }
.st-cell.wide { grid-column: span 2; }
.st-cap { color: var(--gold-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }

/* ---------- Предметы (кликабельные чипы) ---------- */
#items-row { display: flex; flex-wrap: wrap; gap: 5px; }
.item-chip {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12px; padding: 4px 9px; cursor: pointer; transition: all .12s;
}
.item-chip:hover { border-color: var(--gold); background: #2a2238; transform: translateY(-1px); }

/* ---------- Окно персонажа ---------- */
.char-window { max-width: 520px; max-height: 88vh; overflow-y: auto; }
.cw-head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.cw-portrait { width: 92px; height: 92px; object-fit: contain; background: radial-gradient(circle, #2a2238, #16121e); border: 1px solid var(--border); border-radius: 12px; padding: 6px; }
.cw-title { flex: 1; }
.cw-title h2 { font-size: 22px; letter-spacing: 1px; }
.cw-sub { color: var(--dim); font-size: 13px; margin-bottom: 8px; }
.xpbar { height: 10px; background: #0d0a12; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
#cw-xp-fill { height: 100%; background: linear-gradient(90deg, #8a6f33, #d4a94e); width: 0; transition: width .4s; }
.cw-xp-text { color: var(--dim); font-size: 11px; margin-top: 3px; }

.cw-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.slot { display: flex; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.slot-icon { font-size: 26px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: #241d30; border-radius: 10px; }
.slot-name { color: var(--gold-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.slot-item { color: var(--text); font-size: 14px; font-weight: 600; }
.slot-state { color: var(--dim); font-size: 12px; }
.slot-state.bad { color: #e88; }
.slot-state.good { color: #9fd49f; }

.status-rows { margin-bottom: 12px; }
.status-rows .st-row { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.status-rows .st-k { color: var(--gold-dim); white-space: nowrap; }
.status-rows .st-v { color: var(--text); text-align: right; line-height: 1.4; }

.cw-inv { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.cw-cap { color: var(--gold-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.cw-hint { color: var(--dim); text-transform: none; letter-spacing: 0; font-size: 11px; }
.cw-items { display: flex; flex-wrap: wrap; gap: 6px; }
.cw-items .item-chip { font-size: 13px; padding: 6px 12px; }

/* ---------- Анимация кубика ---------- */
#dice-overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  z-index: 70; pointer-events: none;
  /* лёгкое затемнение: бросок должен читаться поверх любой сцены */
  background: radial-gradient(ellipse at center, rgba(11,9,16,.55), rgba(11,9,16,.82));
  animation: dice-fade .25s ease-out;
}
@keyframes dice-fade { from { opacity: 0; } to { opacity: 1; } }
.dice-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dice {
  width: 140px; height: 140px; position: relative; user-select: none;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 14px 26px rgba(0,0,0,.75));
}
.dice .d20 { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.dice #dice-num {
  position: relative; z-index: 2;
  font-size: 40px; font-weight: 800; color: #2a2018;
  /* число живёт на центральной грани, а она смещена вверх от центра */
  transform: translateY(-6px);
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
/* Бросок: кость крутится и «летит», а не дёргается на месте.
   Вращаем ТЕЛО кости, число держим ровно — иначе цифру не прочесть. */
.dice.rolling .d20-body { animation: d20-spin .62s cubic-bezier(.36,.05,.3,1) infinite; transform-origin: 50% 50%; }
.dice.rolling { animation: d20-hop .62s cubic-bezier(.36,.05,.3,1) infinite; }
.dice.rolling #dice-num { opacity: .55; }
.dice.settle { animation: d20-land .7s cubic-bezier(.16,1.05,.3,1) both; }
.dice.settle .d20-body { animation: d20-settle-spin .7s cubic-bezier(.16,1.05,.3,1) both; transform-origin: 50% 50%; }
.dice.settle #dice-num { animation: d20-num .5s cubic-bezier(.2,1.5,.4,1) both; }
.dice.settle .d20-top { animation: d20-flash .7s ease-out both; }
@keyframes d20-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(.94); }
  100% { transform: rotate(360deg) scale(1); }
}
@keyframes d20-hop {
  0%, 100% { transform: translateY(0) scale(1); }
  45%      { transform: translateY(-26px) scale(1.06); }
}
@keyframes d20-settle-spin {
  0%   { transform: rotate(190deg) scale(1.1); }
  70%  { transform: rotate(-6deg) scale(.99); }
  100% { transform: rotate(0deg) scale(1); }
}
@keyframes d20-land {
  0%   { transform: translateY(-64px) scale(1.14); opacity: .35; }
  60%  { transform: translateY(6px) scale(.97); opacity: 1; }
  80%  { transform: translateY(-3px) scale(1.01); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes d20-num {
  0%   { opacity: 0; transform: translateY(-6px) scale(.6); }
  60%  { opacity: 1; transform: translateY(-6px) scale(1.14); }
  100% { opacity: 1; transform: translateY(-6px) scale(1); }
}
@keyframes d20-flash {
  0%   { fill-opacity: 1; }
  35%  { fill-opacity: .55; }
  100% { fill-opacity: 1; }
}
/* 20 и 1 читаются мгновенно, без чтения текста под кубиком */
.dice.crit { filter: drop-shadow(0 0 34px rgba(212,169,78,.95)) drop-shadow(0 14px 26px rgba(0,0,0,.7)); }
.dice.fumble { filter: drop-shadow(0 0 34px rgba(192,57,43,.95)) drop-shadow(0 14px 26px rgba(0,0,0,.7)); }
.dice.crit #dice-num { color: #6b4c00; }
.dice.fumble #dice-num { color: #6b1410; }
@media (prefers-reduced-motion: reduce) {
  .dice.rolling, .dice.rolling .d20-body, .dice.settle,
  .dice.settle .d20-body, .dice.settle #dice-num, .dice.settle .d20-top { animation: none; }
  .dice.rolling #dice-num { opacity: 1; }
}
.dice-label { color: var(--gold); font-size: 15px; font-weight: 600; text-shadow: 0 2px 8px rgba(0,0,0,.8); max-width: 70vw; text-align: center; }
.dice-result { color: var(--text); font-size: 15px; background: rgba(11,9,16,.85); border: 1px solid var(--border); border-radius: 10px; padding: 8px 16px; max-width: 76vw; text-align: center; line-height: 1.4; }
.dice-result .ok { color: #9fd49f; font-weight: 700; }
.dice-result .bad { color: #e88; font-weight: 700; }
.dice-result .gold { color: var(--gold); font-weight: 700; }

/* ---------- Тост ---------- */
#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: linear-gradient(180deg, #b8903c, #8a6f33); color: #14100a; font-weight: 700; padding: 12px 22px; border-radius: 12px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .3s; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
#toast.show { opacity: 1; }

/* ---------- Оверлеи ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,4,8,.8); display: flex; justify-content: center; align-items: center; z-index: 50; }
/* ---------- Боевая обратная связь ----------
   Всё, что происходит в бою, раньше было только текстом в логе: игрок
   не понимал, прошёл удар, увернулся он или его закрыл спутник. */
/* числа всплывают относительно экрана боя, а не страницы */
#scr-game { position: relative; }
.cpop {
  position: absolute; z-index: 45; pointer-events: none;
  font-weight: 700; font-size: 26px; letter-spacing: .5px;
  text-shadow: 0 2px 8px #000, 0 0 20px rgba(0,0,0,.8);
  animation: cpop-rise 1.1s ease-out forwards;
  white-space: nowrap;
}
@keyframes cpop-rise {
  0%   { transform: translate(-50%, 0) scale(.7); opacity: 0; }
  18%  { transform: translate(-50%, -10px) scale(1.15); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translate(-50%, -60px) scale(1); opacity: 0; }
}
.cpop-hit       { color: #ff6b6b; }
.cpop-crit      { color: #ff3b30; font-size: 34px; }
.cpop-deal      { color: #ffd479; }
.cpop-deal-crit { color: var(--gold); font-size: 34px; }
.cpop-dodge     { color: #8ab4e0; font-size: 20px; }
.cpop-block     { color: #b9b4c8; font-size: 20px; }
.cpop-cover     { color: #c6a6ff; font-size: 19px; }
.cpop-shield    { color: #7fd4ff; font-size: 19px; }
.cpop-resist    { color: #9fd49f; font-size: 19px; }
.cpop-heal      { color: #6fdc8c; font-size: 22px; }
.cpop-dot       { color: #b7d96b; font-size: 19px; }
.cpop-down      { color: var(--gold); font-size: 24px; }
.cpop-mercy     { color: #9fd49f; font-size: 20px; }
/* тряска сцены: слабая на обычный удар, сильная на крит */
@keyframes shake-soft {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, 1px); }
}
@keyframes shake-hard {
  0%,100% { transform: translate(0,0) rotate(0); }
  15% { transform: translate(-9px, 4px) rotate(-.5deg); }
  35% { transform: translate(8px, -5px) rotate(.5deg); }
  55% { transform: translate(-6px, 3px) rotate(-.3deg); }
  80% { transform: translate(4px, -2px) rotate(.2deg); }
}
.shake-soft { animation: shake-soft .35s ease-out; }
.shake-hard { animation: shake-hard .5s ease-out; }
/* полосы HP/MP/XP меняются плавно, а не рывком */
.hpbar > div { transition: width .45s cubic-bezier(.22,.61,.36,1); }
@media (prefers-reduced-motion: reduce) {
  .cpop { animation-duration: .01s; }
  .shake-soft, .shake-hard { animation: none; }
  .hpbar > div { transition: none; }
}

#dmg-flash { position: fixed; inset: 0; background: rgba(192,57,43,.25); pointer-events: none; opacity: 0; z-index: 40; }
#dmg-flash.show { animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Живая сцена ----------
   Фон и кат-аут раньше стояли неподвижно, и сцена выглядела как слайд.
   Здесь: медленный наплыв фона (Ken Burns), дыхание кат-аута,
   мерцающее освещение факела и пылинки в воздухе. */
.loc-photo.show { animation: kenburns 38s ease-in-out infinite alternate; }
@keyframes kenburns {
  0%   { transform: scale(1.06) translate(0, 0); }
  50%  { transform: scale(1.13) translate(-1.5%, -1%); }
  100% { transform: scale(1.08) translate(1.5%, .8%); }
}
.loc-bg.has-img { animation: cutout-breathe 7s ease-in-out infinite alternate; }
@keyframes cutout-breathe {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-6px) scale(1.015); }
}
/* тёплый неровный свет факела поверх сцены */
.stage::after {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    radial-gradient(ellipse at 78% 88%, rgba(255,150,50,.22), transparent 55%),
    radial-gradient(ellipse at 20% 10%, rgba(120,90,200,.12), transparent 60%);
  animation: torch-light 3.6s ease-in-out infinite alternate;
  mix-blend-mode: screen;
}
@keyframes torch-light {
  0%   { opacity: .75; }
  40%  { opacity: 1; }
  70%  { opacity: .85; }
  100% { opacity: .95; }
}
/* виньетка: собирает кадр и прячет швы фотографий */
.stage::before {
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  box-shadow: inset 0 0 120px 30px rgba(6,4,10,.85);
}
/* пылинки: очень медленные, чтобы не отвлекали от текста */
.motes { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.mote {
  position: absolute; border-radius: 50%;
  background: rgba(255, 226, 170, .5);
  filter: blur(.4px);
  animation: mote-drift linear infinite;
}
@keyframes mote-drift {
  0%   { transform: translate(0, 110%) scale(.7); opacity: 0; }
  12%  { opacity: .8; }
  85%  { opacity: .55; }
  100% { transform: translate(18px, -18%) scale(1.05); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .loc-photo.show, .loc-bg.has-img, .stage::after, .mote { animation: none; }
}

/* ---------- Добыча: вспышка, искры, карточка ----------
   Лут приходил строчкой в логе и терялся среди прочего текста. */
.loot-burst {
  position: absolute; left: 50%; top: 46%; z-index: 12; pointer-events: none;
  width: 0; height: 0;
}
.loot-burst::before {
  content: ''; position: absolute; left: -90px; top: -90px; width: 180px; height: 180px;
  border-radius: 50%; background: radial-gradient(circle, rgba(255,225,150,.85), transparent 65%);
  animation: loot-flash .7s ease-out forwards;
}
.loot-burst i {
  position: absolute; width: 7px; height: 7px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 10px rgba(255,210,120,.9);
  animation: loot-spark 1.1s cubic-bezier(.15,.7,.3,1) forwards;
}
.loot-burst.loot-gold i { background: #ffd479; }
.loot-burst.loot-unique i { background: #c6a6ff; box-shadow: 0 0 12px rgba(198,166,255,.95); }
.loot-burst.loot-unique::before { background: radial-gradient(circle, rgba(198,166,255,.85), transparent 65%); }
.loot-burst.loot-boss i { background: #ff9d6b; box-shadow: 0 0 14px rgba(255,157,107,.95); }
@keyframes loot-flash {
  0%   { transform: scale(.3); opacity: 0; }
  25%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes loot-spark {
  0%   { transform: translate(0,0) scale(.5); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}
.loot-card {
  position: absolute; left: 50%; top: 34%; transform: translateX(-50%);
  z-index: 13; pointer-events: none; text-align: center;
  background: rgba(11,9,16,.9); border: 1px solid var(--gold-dim); border-radius: 12px;
  padding: 10px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.7);
  animation: loot-card-in 2.6s cubic-bezier(.2,1.3,.35,1) forwards;
}
.loot-card .lc-title { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.loot-card .lc-sub { color: var(--dim); font-size: 12px; margin-top: 3px; }
@keyframes loot-card-in {
  0%   { opacity: 0; transform: translateX(-50%) translateY(18px) scale(.85); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  80%  { opacity: 1; transform: translateX(-50%) translateY(-6px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-26px) scale(.97); }
}
/* сундук: короткий толчок сцены, как будто крышка отлетела */
@keyframes chest-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.stage.chest-open { animation: chest-pop .45s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .loot-burst, .loot-card, .stage.chest-open { animation: none; }
  .loot-burst i, .loot-burst::before { animation: none; opacity: 0; }
}

/* ---------- FX изображений ---------- */
.fx-shake { animation: fxshake .4s linear infinite; }
@keyframes fxshake { 0%,100% { transform: translate(0,0); } 25% { transform: translate(-5px,2px); } 50% { transform: translate(4px,-3px); } 75% { transform: translate(-3px,-2px); } }
.fx-bob { animation: fxbob .7s ease-in-out infinite alternate; }
@keyframes fxbob { from { transform: translateY(0); } to { transform: translateY(-10px); } }
.fx-flip { transform: scaleX(-1); }
.fx-pulse { animation: fxpulse 1s ease-in-out infinite; }
@keyframes fxpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.fx-wobble { animation: fxwobble .5s ease-in-out infinite; }
@keyframes fxwobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
.fx-fadein { animation: fxfadein .8s ease-out; }
@keyframes fxfadein { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 640px) {
  .actions { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
  .st-cell.wide { grid-column: span 1; }
  #hero-img { height: 180px; }
}
