/* ============================================================
   «Кости и Хроники» — тёмное фэнтези: чернильный фон, античное
   золото, арканный фиолет. Mobile-first под Telegram Mini App.
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0f0d16;
  --bg-2: #14111f;
  --card: #1c1830;
  --card-2: #252040;
  --border: #322a52;
  --border-soft: #2a2445;
  --text: #efeaff;
  --muted: #9b93b8;
  --gold: #d9ac52;
  --gold-soft: #f0cf8d;
  --arcane: #8e6cf0;
  --danger: #e35d6a;
  --ok: #58c98b;
  --radius: 16px;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --font-head: 'Cormorant', Georgia, serif;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(142,108,240,.14), transparent 60%),
    radial-gradient(700px 420px at -10% 10%, rgba(217,172,82,.08), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
}
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(15,13,22,.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon {
  font-size: 22px; width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2c2450, #1b1730);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.brand h1 {
  font-family: var(--font-head); font-weight: 700; font-size: 20px; line-height: 1.05;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.room-chip {
  flex: none; padding: 7px 12px; border-radius: 999px;
  background: linear-gradient(145deg, rgba(142,108,240,.25), rgba(142,108,240,.1));
  border: 1px solid rgba(142,108,240,.5);
  color: var(--text); font-weight: 700; font-size: 12px; letter-spacing: .08em;
}
.room-chip::before { content: '🏰 '; }

/* ---------- каркас экранов ---------- */
#screens { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.screen { display: none; animation: screen-in .22s ease; }
.screen.active { display: block; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.screen-head h2 { font-family: var(--font-head); font-size: 26px; font-weight: 700; }
.screen-head-actions { display: flex; gap: 8px; }
h3 { font-family: var(--font-head); font-size: 19px; font-weight: 700; color: var(--gold-soft); }

/* ---------- таббар ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(17,14,26,.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-soft);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em;
  padding: 5px 18px; border-radius: 14px; transition: color .15s, background .15s;
}
.tab-ico { font-size: 20px; filter: grayscale(.55) opacity(.8); transition: filter .15s, transform .15s; }
.tab.active { color: var(--gold-soft); background: rgba(217,172,82,.09); }
.tab.active .tab-ico { filter: none; transform: translateY(-1px); }

/* ---------- базовые элементы ---------- */
.card {
  background: linear-gradient(160deg, var(--card), var(--bg-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 3px 14px rgba(0,0,0,.25);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); font-weight: 700; font-size: 14px;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(145deg, #e6bd66, #b8862f);
  border-color: #a67c2e; color: #241a05;
  box-shadow: 0 4px 16px rgba(217,172,82,.28);
}
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger { background: rgba(227,93,106,.14); border-color: rgba(227,93,106,.55); color: #f299a3; }
.btn-ok { background: rgba(88,201,139,.14); border-color: rgba(88,201,139,.5); color: #8fe0b4; }
.btn-big { width: 100%; padding: 15px; font-size: 17px; border-radius: 14px; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 10px; }
.icon-btn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 11px; background: var(--card-2); border: 1px solid var(--border); font-size: 17px;
}
.inp, input.inp, select.inp, textarea.inp {
  width: 100%; padding: 11px 13px;
  background: rgba(10,8,18,.55); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); outline: none; font-size: 15px;
  transition: border-color .15s;
}
.inp:focus { border-color: var(--gold); }
.inp::placeholder { color: #6d6590; }
textarea.inp { resize: vertical; min-height: 84px; line-height: 1.45; }
label.fld { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
label.fld .inp { margin-top: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.divider {
  display: flex; align-items: center; gap: 12px; color: var(--muted);
  font-size: 12px; margin: 14px 0; text-transform: uppercase; letter-spacing: .12em;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- аватар ---------- */
.avatar {
  flex: none; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 30% 25%, #34295e, #1b1730);
  border: 2px solid var(--gold); border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(217,172,82,.15), 0 4px 12px rgba(0,0,0,.4);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 52px; height: 52px; font-size: 26px; }
.avatar-lg { width: 84px; height: 84px; font-size: 44px; }

/* ---------- список героев ---------- */
.campaign-group { margin-bottom: 18px; }
.campaign-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-head); font-size: 17px; font-weight: 700; color: var(--arcane);
  margin: 0 2px 8px;
}
.campaign-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.hero-card {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  margin-bottom: 10px; transition: transform .1s, border-color .15s;
}
.hero-card:active { transform: scale(.985); }
.hero-name { font-family: var(--font-head); font-size: 19px; font-weight: 700; }
.hero-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.hero-info { flex: 1; min-width: 0; }
.hero-hp {
  flex: none; text-align: center; font-size: 11px; color: var(--muted);
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: rgba(10,8,18,.4);
}
.hero-hp b { display: block; font-size: 14px; color: var(--danger); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .big { font-size: 52px; margin-bottom: 12px; filter: drop-shadow(0 4px 14px rgba(217,172,82,.3)); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- лист персонажа ---------- */
.sheet-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.btn-back { color: var(--gold-soft); font-weight: 700; font-size: 15px; padding: 8px 4px; }
.sheet-actions { display: flex; gap: 8px; }
.sheet-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.sheet-head-fields { flex: 1; min-width: 0; display: grid; gap: 8px; }
.inp-name { font-family: var(--font-head); font-size: 21px; font-weight: 700; }
.lvl-field { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.lvl-field .inp { width: 64px; text-align: center; }

.prof-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 12px 0; padding: 10px 14px;
  border: 1px dashed var(--border); border-radius: 12px; font-size: 13.5px; color: var(--muted);
}
.prof-line b { color: var(--gold-soft); font-size: 16px; }
.insp-toggle { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--muted); }
.insp-toggle.on { color: var(--gold-soft); text-shadow: 0 0 12px rgba(217,172,82,.6); }

.abilities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.ability {
  text-align: center; padding: 10px 6px 8px;
  background: linear-gradient(170deg, var(--card-2), var(--card));
  border: 1px solid var(--border); border-radius: 14px;
}
.ab-name { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--muted); }
.ab-score {
  width: 56px; margin: 6px auto 4px; padding: 4px; text-align: center;
  font-size: 20px; font-weight: 800;
  background: rgba(10,8,18,.5); border: 1px solid var(--border); border-radius: 10px; color: var(--text); outline: none;
}
.ab-mod {
  display: block; margin: 0 auto; min-width: 52px; padding: 4px 10px;
  font-family: var(--font-head); font-size: 17px; font-weight: 700;
  color: var(--gold-soft); background: rgba(217,172,82,.1);
  border: 1px solid rgba(217,172,82,.35); border-radius: 999px;
}
.ab-mod:active { transform: scale(.93); }

.combat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.combat-cell { text-align: center; padding: 8px 4px; background: rgba(10,8,18,.4); border: 1px solid var(--border); border-radius: 12px; }
.combat-cell .cap { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.combat-cell input {
  width: 100%; text-align: center; background: none; border: none; outline: none;
  font-size: 19px; font-weight: 800; color: var(--text); margin-top: 2px;
}
.combat-cell.tappable { border-color: rgba(142,108,240,.5); }
.combat-cell.tappable .val { font-size: 19px; font-weight: 800; color: var(--arcane); margin-top: 2px; }

.hp-box { display: flex; align-items: center; gap: 10px; }
.hp-btn {
  width: 46px; height: 46px; flex: none; font-size: 24px; font-weight: 800;
  border-radius: 13px; border: 1px solid var(--border); background: var(--card-2); color: var(--text);
}
.hp-btn:active { transform: scale(.92); }
.hp-mid { flex: 1; text-align: center; }
.hp-nums { font-size: 24px; font-weight: 800; }
.hp-nums .cur { color: var(--danger); }
.hp-nums input {
  width: 58px; text-align: center; background: none; border: none; border-bottom: 1px dashed var(--border);
  outline: none; font-size: 24px; font-weight: 800; color: var(--text);
}
.hp-sub { display: flex; justify-content: center; gap: 14px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.hp-sub input {
  width: 44px; text-align: center; background: rgba(10,8,18,.5); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); outline: none; padding: 2px; font-size: 12px;
}

details.card { margin-bottom: 10px; }
details.card summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--gold-soft); cursor: pointer;
}
details.card summary::after { content: '▾'; color: var(--muted); transition: transform .2s; }
details.card[open] summary::after { transform: rotate(180deg); }
details.card summary::-webkit-details-marker { display: none; }
.check-list { margin-top: 10px; display: grid; gap: 2px; }
.check-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 6px;
  border-radius: 10px; transition: background .12s; cursor: pointer;
}
.check-row:active { background: rgba(142,108,240,.1); }
.prof-toggle {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 50%; color: var(--border); font-size: 13px;
  transition: all .15s;
}
.check-row.prof .prof-toggle { color: #120d02; background: var(--gold); border-color: var(--gold); box-shadow: 0 0 10px rgba(217,172,82,.4); }
.check-name { flex: 1; font-size: 14.5px; }
.check-sub { font-size: 11px; color: var(--muted); margin-left: 4px; }
.check-val { font-weight: 800; font-size: 15px; color: var(--gold-soft); min-width: 34px; text-align: right; }
.passive-line { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-soft); font-size: 12.5px; color: var(--muted); }
.passive-line b { color: var(--arcane); }

.fields-list { margin-top: 10px; display: grid; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr 34px; gap: 6px; align-items: center; }
.field-row .del { color: var(--danger); font-size: 17px; text-align: center; }
.section-card { margin-bottom: 10px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.section-title {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--gold-soft);
}
.sheet-footer { display: grid; gap: 8px; margin-top: 16px; }

/* ---------- кубики ---------- */
.dice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.die-btn { aspect-ratio: 1; display: grid; place-items: center; }
.die-shape {
  width: 88%; height: 88%; display: grid; place-items: center;
  background: linear-gradient(155deg, #362a63, #201a3c 60%, #191430);
  border: 1px solid var(--border);
  transition: transform .12s, filter .15s;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.4));
}
.die-btn:active .die-shape { transform: scale(.88) rotate(-8deg); filter: drop-shadow(0 0 14px rgba(217,172,82,.5)); }
.die-shape b { font-size: 15px; font-weight: 800; color: var(--gold-soft); }
.shape-d4 { clip-path: polygon(50% 4%, 98% 96%, 2% 96%); border: none; }
.shape-d4 b { transform: translateY(6px); }
.shape-d6 { border-radius: 16px; }
.shape-d8 { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); border: none; }
.shape-d10 { clip-path: polygon(50% 0%, 100% 42%, 81% 100%, 19% 100%, 0% 42%); border: none; }
.shape-d12 { clip-path: polygon(50% 0%, 98% 35%, 79% 93%, 21% 93%, 2% 35%); border: none; }
.shape-d20 { clip-path: polygon(50% 0%, 94% 25%, 94% 75%, 50% 100%, 6% 75%, 6% 25%); border: none; }
.shape-d100 { border-radius: 50%; }

.mod-stepper {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 4px;
}
.mod-stepper button { width: 34px; height: 100%; min-height: 44px; font-size: 20px; font-weight: 800; color: var(--muted); }
.mod-stepper span { font-size: 17px; font-weight: 800; color: var(--gold-soft); }

.dice-pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 38px; margin-bottom: 12px; align-items: center; }
.pool-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: rgba(142,108,240,.16); border: 1px solid rgba(142,108,240,.5);
  border-radius: 999px; font-weight: 800; font-size: 14px; color: #cabcf7;
}
.pool-chip small { font-weight: 600; opacity: .7; }
.pool-hint { color: #6d6590; font-size: 13px; }
.dice-actions { display: grid; gap: 8px; margin-bottom: 12px; }
.advdis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.formula-row { display: flex; gap: 8px; margin-bottom: 14px; }
.formula-row .inp { flex: 1; }

.roll-result {
  text-align: center; padding: 18px 14px 20px; margin-bottom: 16px;
  background:
    radial-gradient(320px 140px at 50% 0%, rgba(142,108,240,.18), transparent 70%),
    linear-gradient(160deg, var(--card), var(--bg-2));
  border: 1px solid var(--border); border-radius: 18px;
  animation: result-pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes result-pop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
.roll-result .rr-label { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .05em; }
.roll-result .rr-total {
  font-family: var(--font-head); font-size: 64px; font-weight: 700; line-height: 1.1;
  color: var(--gold-soft); text-shadow: 0 0 24px rgba(217,172,82,.35);
}
.roll-result .rr-detail { font-size: 13px; color: var(--muted); }
.roll-result.crit-hit .rr-total { color: #ffd76e; text-shadow: 0 0 34px rgba(255,205,90,.75); }
.roll-result.crit-hit::after { content: 'Критический успех!'; display: block; margin-top: 6px; color: var(--gold); font-weight: 800; font-size: 13px; letter-spacing: .06em; }
.roll-result.crit-fail .rr-total { color: var(--danger); text-shadow: 0 0 30px rgba(227,93,106,.55); }
.roll-result.crit-fail::after { content: 'Критический провал…'; display: block; margin-top: 6px; color: var(--danger); font-weight: 800; font-size: 13px; letter-spacing: .06em; }

.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.roll-history { display: grid; gap: 6px; }
.hist-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: rgba(28,24,48,.55); border: 1px solid var(--border-soft); border-radius: 12px;
}
.hist-info { flex: 1; min-width: 0; }
.hist-label { font-size: 13.5px; font-weight: 700; }
.hist-detail { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-total { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--gold-soft); }
.hist-time { font-size: 10px; color: #6d6590; }

/* ---------- комната ---------- */
.room-lobby { display: grid; gap: 12px; }
.room-lobby h2 { font-family: var(--font-head); font-size: 24px; }
.join-row { display: flex; gap: 8px; }
.join-row .inp { flex: 1; text-transform: uppercase; letter-spacing: .2em; font-weight: 800; }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.room-code {
  font-family: var(--font-head); font-size: 34px; font-weight: 700; letter-spacing: .18em;
  color: var(--gold-soft); text-shadow: 0 0 18px rgba(217,172,82,.3); padding: 2px 0;
}
.room-code::after { content: ' ⧉'; font-size: 16px; color: var(--muted); }
.playing-card { display: grid; gap: 8px; margin-bottom: 10px; }
.members-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.member-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px; font-size: 13px; font-weight: 700;
}
.member-chip .mc-char { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.member-chip.you { border-color: rgba(217,172,82,.55); }

.feed { display: grid; gap: 8px; margin-bottom: 12px; }
.feed-sys { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; font-style: italic; }
.feed-item { padding: 10px 13px; background: var(--card); border: 1px solid var(--border-soft); border-radius: 14px; }
.feed-item.mine { border-color: rgba(217,172,82,.4); background: linear-gradient(160deg, rgba(217,172,82,.07), var(--card)); }
.feed-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.feed-meta .fm-nick { font-weight: 800; color: var(--arcane); }
.feed-roll { display: flex; align-items: center; gap: 10px; }
.feed-roll-info { flex: 1; min-width: 0; }
.feed-roll-label { font-weight: 700; font-size: 14px; }
.feed-roll-detail { font-size: 12px; color: var(--muted); }
.feed-roll-total { font-family: var(--font-head); font-size: 30px; font-weight: 700; color: var(--gold-soft); flex: none; }
.feed-item.crit-hit .feed-roll-total { color: #ffd76e; text-shadow: 0 0 16px rgba(255,205,90,.6); }
.feed-item.crit-fail .feed-roll-total { color: var(--danger); }
.feed-note { font-size: 14px; line-height: 1.4; }
.feed-char { display: flex; align-items: center; gap: 10px; }
.feed-char-name { font-family: var(--font-head); font-size: 17px; font-weight: 700; }
.note-row { display: flex; gap: 8px; }
.note-row .inp { flex: 1; }

/* ---------- модалки ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8,6,14,.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in .18s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 640px; max-height: 86dvh; overflow-y: auto;
  background: linear-gradient(170deg, #221c3c, var(--bg-2));
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  animation: sheet-up .25s cubic-bezier(.2, 1, .3, 1);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head h3 { font-size: 21px; }
.modal-body { display: grid; gap: 10px; }
.share-code-big {
  text-align: center; font-family: var(--font-head); font-size: 44px; font-weight: 700; letter-spacing: .22em;
  color: var(--gold-soft); text-shadow: 0 0 22px rgba(217,172,82,.35);
  padding: 12px; border: 1px dashed rgba(217,172,82,.5); border-radius: 14px;
}
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.emoji-grid button { font-size: 26px; padding: 8px 0; border-radius: 12px; transition: background .12s, transform .1s; }
.emoji-grid button:active { background: rgba(142,108,240,.2); transform: scale(.9); }

/* ---------- плавающий результат броска ---------- */
.roll-float {
  position: fixed; z-index: 150;
  left: 50%; bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 210px; max-width: 86%;
  text-align: center; padding: 12px 22px 14px;
  background: linear-gradient(165deg, #2a2350, #171226);
  border: 1px solid rgba(217,172,82,.55); border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6), 0 0 24px rgba(217,172,82,.12);
  animation: float-pop .35s cubic-bezier(.2, 1.6, .4, 1);
  cursor: pointer;
}
@keyframes float-pop { from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(.8); } to { opacity: 1; transform: translateX(-50%); } }
.roll-float.out { transition: opacity .35s, transform .35s; opacity: 0; transform: translateX(-50%) translateY(10px) scale(.92); }
.roll-float .rf-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.roll-float .rf-total {
  font-family: var(--font-head); font-size: 44px; font-weight: 700; line-height: 1.05;
  color: var(--gold-soft); text-shadow: 0 0 20px rgba(217,172,82,.4);
}
.roll-float .rf-detail { font-size: 11.5px; color: var(--muted); }
.roll-float.crit-hit .rf-total { color: #ffd76e; text-shadow: 0 0 26px rgba(255,205,90,.8); }
.roll-float.crit-fail .rf-total { color: var(--danger); }

/* ---------- тосты ---------- */
#toast-root { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  max-width: 86%; padding: 10px 18px; border-radius: 999px;
  background: rgba(34,28,60,.95); border: 1px solid var(--border);
  color: var(--text); font-size: 13.5px; font-weight: 600; text-align: center;
  box-shadow: var(--shadow);
  animation: toast-in .25s cubic-bezier(.2, 1.4, .4, 1);
}
.toast.error { border-color: rgba(227,93,106,.6); background: rgba(64,22,30,.95); }
.toast.ok { border-color: rgba(88,201,139,.55); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.9); } to { opacity: 1; transform: none; } }
.toast.out { transition: opacity .3s, transform .3s; opacity: 0; transform: translateY(-10px); }

@media (min-width: 520px) {
  .abilities { grid-template-columns: repeat(6, 1fr); }
  .dice-grid { grid-template-columns: repeat(8, 1fr); }
}
