/* ============================================
   DnD Codex — Стили
   Тема: средневековый манускрипт, пергамент, руны
   ============================================ */

:root {
  --ink: #1a1410;
  --ink-soft: #3a2f25;
  --parchment: #f4e8d0;
  --parchment-dark: #d9c4a0;
  --gold: #b8860b;
  --gold-light: #d4af37;
  --crimson: #8b1a1a;
  --forest: #2d4a2b;
  --shadow: rgba(26, 20, 16, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Georgia', 'Times New Roman', serif;
  color: var(--ink);
  background: #0a0805;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background: linear-gradient(135deg, #0a0805 0%, #1a1410 50%, #0a0805 100%);
  display: flex;
  flex-direction: column;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

/* === ЭКРАНЫ === */
.screen {
  position: absolute;
  inset: 0;
  background: var(--parchment);
  background-image:
    radial-gradient(ellipse at top, rgba(184, 134, 11, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at bottom, rgba(139, 26, 26, 0.05) 0%, transparent 60%);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* Текстура пергамента */
.bg-paper {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 20px, rgba(184, 134, 11, 0.02) 20px, rgba(184, 134, 11, 0.02) 21px),
    repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(184, 134, 11, 0.02) 20px, rgba(184, 134, 11, 0.02) 21px);
  pointer-events: none;
  z-index: 0;
}

.screen > * {
  position: relative;
  z-index: 1;
}

/* === ТИПОГРАФИКА === */
.title-rune {
  font-family: 'Georgia', serif;
  font-size: 2.5rem;
  text-align: center;
  color: var(--ink);
  margin-bottom: 0.25rem;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 4px rgba(184, 134, 11, 0.2);
}

.subtitle {
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

.hint {
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* === ЭКРАН ВЫБОРА ПЕРСОНАЖА === */
.hero-header {
  padding: 2rem 1.5rem 1rem;
  border-bottom: 2px solid var(--gold);
  background: linear-gradient(to bottom, rgba(184, 134, 11, 0.08), transparent);
}

.character-grid {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  -webkit-overflow-scrolling: touch;
}

/* v49: world-grid — такой же grid, как character, но пресеты миров */
.world-grid {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  -webkit-overflow-scrolling: touch;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.world-card {
  background: var(--paper);
  border: 2px solid var(--ink-soft);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: all 0.2s;
}
.world-card:hover { border-color: var(--ink); background: var(--paper-light); transform: translateY(-1px); }
.world-card:active { transform: translateY(0); }
.world-card .world-icon { font-size: 2rem; flex: 0 0 auto; }
.world-card .world-body { flex: 1; min-width: 0; }
.world-card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.world-card p { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.world-card .world-tag { font-size: 0.7rem; padding: 0.1rem 0.4rem; background: var(--ink-soft); color: var(--paper); border-radius: 4px; }
.world-card-custom {
  border-style: dashed;
  background: transparent;
  color: var(--ink-soft);
}
.world-card-custom:hover { background: var(--paper-light); color: var(--ink); }

/* v49: маленький бейдж «свой мир» в character-select */
.world-current-badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  background: var(--ink-soft);
  color: var(--paper);
  border-radius: 12px;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.world-change-btn {
  display: block;
  margin: 0.5rem auto;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink-soft);
  border-radius: 14px;
  cursor: pointer;
}
.world-change-btn:hover { background: var(--ink-soft); color: var(--paper); }

/* v49: NPC-форма в конструкторе мира */
.npc-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: var(--paper-light);
  border-radius: 6px;
  position: relative;
}
.npc-form-row input { margin: 0; }
.npc-form-row input.full { grid-column: 1 / -1; }
.npc-remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.4rem;
}
.npc-remove-btn:hover { color: #8b1a1a; }

.char-card {
  background: rgba(255, 250, 240, 0.6);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  box-shadow: 0 2px 8px var(--shadow);
}

.char-card:active {
  transform: scale(0.98);
  background: rgba(255, 250, 240, 0.9);
}

.char-card-custom {
  border-style: dashed;
  background: rgba(184, 134, 11, 0.05);
}

.char-portrait {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.char-portrait-img {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: cover;
  margin: 0 auto 0.5rem;
  border-radius: 6px;
  border: 2px solid var(--gold);
  background: var(--parchment-dark);
}

.big-portrait-img {
  display: block;
  width: 140px;
  height: 140px;
  object-fit: cover;
  margin: 0 auto 0.5rem;
  border-radius: 8px;
  border: 2px solid var(--gold);
  background: var(--parchment-dark);
  box-shadow: 0 4px 12px var(--shadow);
}

.char-card h3 {
  text-align: center;
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.char-class {
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.char-tag {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
  font-style: italic;
  line-height: 1.4;
}

.char-stats {
  display: flex;
  justify-content: space-around;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: rgba(184, 134, 11, 0.08);
  border-radius: 4px;
}

.continue-section {
  padding: 1rem;
  text-align: center;
  border-top: 1px dashed var(--gold);
}

/* === КНОПКИ === */
.btn-rune {
  display: block;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(to bottom, var(--gold-light), var(--gold));
  color: white;
  border: 2px solid var(--ink);
  border-radius: 4px;
  font-family: 'Georgia', serif;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 4px var(--shadow);
  transition: all 0.15s;
}

.btn-rune:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px var(--shadow);
}

.btn-rune-outline {
  display: block;
  width: 100%;
  padding: 0.6rem 1.5rem;
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--gold);
  border-radius: 4px;
  font-family: 'Georgia', serif;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
  transition: all 0.15s;
}

.btn-rune-outline:active {
  background: rgba(184, 134, 11, 0.1);
}

.btn-back {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem;
  font-family: 'Georgia', serif;
}

.btn-icon {
  background: none;
  border: 1px solid var(--gold);
  color: var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-icon:active {
  background: rgba(184, 134, 11, 0.1);
}

.btn-mini {
  background: var(--gold);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-mini:active {
  transform: scale(0.9);
}

.btn-send {
  background: var(--crimson);
  color: white;
  border: 2px solid var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

.btn-send:active {
  transform: scale(0.95);
}

.btn-send:disabled {
  background: var(--ink-soft);
  cursor: not-allowed;
}

.btn-mic {
  position: relative;
}

.btn-mic.recording {
  background: var(--crimson);
  color: white;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* === ФОРМЫ === */
.screen-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(to bottom, rgba(184, 134, 11, 0.1), transparent);
  border-bottom: 2px solid var(--gold);
}

.screen-header h2 {
  font-size: 1.3rem;
  color: var(--ink);
}

.parchment-form {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  -webkit-overflow-scrolling: touch;
}

.parchment-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.parchment-form label > span {
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.parchment-form input,
.parchment-form select,
.parchment-form textarea {
  font-family: 'Georgia', serif;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 250, 240, 0.6);
  border: 1px solid var(--ink-soft);
  border-radius: 4px;
  color: var(--ink);
}

.parchment-form input:focus,
.parchment-form select:focus,
.parchment-form textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(255, 250, 240, 0.9);
}

.portrait-preview {
  margin-top: 0.5rem;
  min-height: 60px;
}

.portrait-preview img {
  max-width: 140px;
  max-height: 140px;
  border-radius: 6px;
  border: 2px solid var(--gold);
  display: block;
}

.parchment-form input[type="file"] {
  font-family: 'Georgia', serif;
  font-size: 0.85rem;
  padding: 0.4rem;
  background: rgba(255, 250, 240, 0.6);
  border: 1px solid var(--ink-soft);
  border-radius: 4px;
  color: var(--ink);
}

/* === ИГРОВОЙ ЭКРАН === */
.game-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(to bottom, rgba(184, 134, 11, 0.15), rgba(184, 134, 11, 0.05));
  border-bottom: 2px solid var(--gold);
}

.game-title {
  flex: 1;
  text-align: center;
}

.game-title h2 {
  font-size: 1.2rem;
  color: var(--ink);
}

.game-title p {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-style: italic;
}

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.event-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  -webkit-overflow-scrolling: touch;
}

.event {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.4;
  font-size: 0.95rem;
  word-wrap: break-word;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.event-dm {
  background: linear-gradient(135deg, rgba(184, 134, 11, 0.1), rgba(184, 134, 11, 0.05));
  border: 1px solid var(--gold);
  align-self: flex-start;
  color: var(--ink);
}

.event-dm::before {
  content: '🎲 Мастер: ';
  font-weight: bold;
  color: var(--gold);
}

.event-player {
  background: var(--ink);
  color: var(--parchment);
  align-self: flex-end;
}

.event-player::before {
  content: '⚔ Ты: ';
  font-weight: bold;
  color: var(--gold-light);
}

.event-system {
  background: rgba(139, 26, 26, 0.1);
  border: 1px dashed var(--crimson);
  align-self: center;
  font-style: italic;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.85rem;
}

.event-typing {
  align-self: flex-start;
  font-style: italic;
  color: var(--ink-soft);
  padding: 0.5rem 1rem;
  background: rgba(184, 134, 11, 0.05);
  border-radius: 12px;
}

.event-typing::after {
  content: '...';
  display: inline-block;
  animation: dots 1.2s infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

.event-dice {
  align-self: center;
  background: rgba(45, 74, 43, 0.15);
  border: 1px solid var(--forest);
  color: var(--ink);
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  text-align: center;
}

.event-dice .dice-total {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--forest);
}

.btn-roll-inline {
  display: inline-block;
  margin: 0.4rem 0 0 0;
  padding: 0.5rem 1rem;
  background: linear-gradient(to bottom, var(--crimson), #5d1010);
  color: white;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-family: 'Georgia', serif;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 4px var(--shadow);
  transition: all 0.15s;
}

.btn-roll-inline:hover {
  background: var(--crimson);
  transform: translateY(-1px);
}

.btn-roll-inline:active {
  transform: translateY(1px);
}

.btn-roll-inline.rolled {
  background: linear-gradient(to bottom, var(--forest), #1a2e1a);
  cursor: default;
  pointer-events: none;
}

.input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--parchment-dark);
  border-top: 1px solid var(--gold);
}

#action-input {
  flex: 1;
  font-family: 'Georgia', serif;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 250, 240, 0.8);
  border: 1px solid var(--ink-soft);
  border-radius: 20px;
  color: var(--ink);
  min-width: 0;
}

#action-input:focus {
  outline: none;
  border-color: var(--gold);
}

/* === БОКОВОЕ МЕНЮ === */
.side-menu {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80%;
  max-width: 320px;
  background: var(--parchment);
  border-left: 2px solid var(--gold);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transform: translateX(100%);
  transition: transform 0.3s;
  z-index: 10;
  box-shadow: -4px 0 12px var(--shadow);
}

.side-menu.open {
  transform: translateX(0);
}

.side-menu h3 {
  margin-bottom: 1rem;
  color: var(--ink);
  text-align: center;
}

.menu-divider {
  height: 1px;
  background: var(--gold);
  opacity: 0.3;
  margin: 0.5rem 0;
}

.btn-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

/* === ЛИСТ ПЕРСОНАЖА === */
.sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}

.sheet-portrait {
  text-align: center;
  margin-bottom: 0.75rem;
}

.big-portrait {
  font-size: 4rem;
  margin-bottom: 0.25rem;
  text-align: center;
}

.sheet-portrait h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.sheet-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin-bottom: 1rem;
}

@media (max-width: 480px) {
  .sheet-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-card {
  background: rgba(184, 134, 11, 0.08);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 0.5rem 0.25rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--ink);
}

.hp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.hp-controls .stat-value {
  min-width: 40px;
}

.sheet-section {
  margin-bottom: 1rem;
}

.sheet-section h3 {
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 0.25rem;
}

.ability-list, .inventory-list, .inventory-list-big, .journal-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ability-list li, .inventory-list li, .inventory-list-big li, .journal-list li {
  background: rgba(184, 134, 11, 0.05);
  border-left: 3px solid var(--gold);
  padding: 0.5rem 0.75rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  line-height: 1.4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ability-list li .ability-name {
  font-weight: bold;
  color: var(--ink);
}

.ability-list li .ability-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: normal;
  margin-top: 0.2rem;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--crimson);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

.add-item {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.add-item input {
  flex: 1;
  font-family: 'Georgia', serif;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 250, 240, 0.6);
  border: 1px solid var(--ink-soft);
  border-radius: 4px;
  font-size: 0.9rem;
}

.add-item .btn-rune {
  width: auto;
  padding: 0.5rem 1rem;
}

#sheet-notes {
  width: 100%;
  font-family: 'Georgia', serif;
  padding: 0.75rem;
  background: rgba(255, 250, 240, 0.6);
  border: 1px solid var(--ink-soft);
  border-radius: 4px;
  font-size: 0.9rem;
  resize: vertical;
}

/* === ИНВЕНТАРЬ === */
.inventory-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

/* === ЖУРНАЛ === */
.journal-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.journal-section {
  margin-bottom: 2rem;
}

.journal-section h3 {
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 0.25rem;
}

.journal-list li {
  font-size: 0.9rem;
}

.journal-list li.done {
  opacity: 0.6;
  text-decoration: line-through;
}

/* === КУБИКИ (модалка) === */
.dice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s;
}

.dice-modal {
  background: var(--parchment);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  overflow-y: auto;
}

.dice-modal h3 {
  text-align: center;
  color: var(--ink);
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.dice-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.dice-btn {
  background: linear-gradient(to bottom, var(--parchment), var(--parchment-dark));
  color: var(--ink);
  border: 2px solid var(--gold);
  border-radius: 6px;
  padding: 0.85rem 0.5rem;
  font-family: 'Georgia', serif;
  font-size: 1.05rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
}

.dice-btn:active {
  transform: scale(0.95);
  background: var(--parchment-dark);
}

.dice-btn.rolling {
  background: var(--gold-light);
  color: white;
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-3deg); }
  40% { transform: translateX(4px) rotate(3deg); }
  60% { transform: translateX(-3px) rotate(-2deg); }
  80% { transform: translateX(3px) rotate(2deg); }
}

.dice-custom {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.dice-custom > span {
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dice-custom-row {
  display: flex;
  gap: 0.5rem;
}

.dice-custom-row input {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 250, 240, 0.6);
  border: 1px solid var(--ink-soft);
  border-radius: 4px;
  color: var(--ink);
}

.dice-custom-row .btn-rune {
  width: auto;
  padding: 0.6rem 1.2rem;
}

.dice-log {
  max-height: 180px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  padding: 0.5rem;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dice-log:empty::before {
  content: 'Здесь будут логи бросков';
  font-style: italic;
  opacity: 0.5;
  text-align: center;
  display: block;
  padding: 0.5rem;
}

.dice-log-entry {
  color: var(--ink);
}

/* === ТОСТЫ (v50: баннер сверху, sticky) === */
.toast {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: linear-gradient(180deg, var(--ink) 0%, #2a1a0a 100%);
  color: var(--parchment);
  padding: 0.6rem 1.5rem;
  border-radius: 0 0 12px 12px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  transition: transform 0.3s ease-out;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
  border-bottom: 2px solid #c9a548;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.toast-error { background: linear-gradient(180deg, #8b1a1a 0%, #4a0a0a 100%); border-bottom-color: #ff6b6b; }
.toast.toast-success { background: linear-gradient(180deg, #1a5a2a 0%, #0a2a1a 100%); border-bottom-color: #5fc97a; }

/* === ЧАТ МУЛЬТИПЛЕЕРА === */
.chat-overlay {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(8, 4, 2, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  backdrop-filter: blur(2px);
}
.chat-modal {
  width: 100%; max-width: 720px; height: 78vh; max-height: 720px;
  background: var(--paper, #f4e4c1);
  border: 1px solid var(--ink-soft, #5a3a18);
  border-radius: 12px 12px 0 0;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
  overflow: hidden;
}
@media (min-width: 600px) {
  .chat-overlay { align-items: center; padding: 1rem; }
  .chat-modal { border-radius: 12px; height: 70vh; }
}
.chat-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: linear-gradient(180deg, #5a3a18 0%, #3a2410 100%);
  color: #f4e4c1;
  border-bottom: 2px solid #2a1808;
}
.chat-header h3 { flex: 1; margin: 0; font-size: 1.1rem; }
.chat-players-mini { font-size: 0.85rem; opacity: 0.85; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 0.7rem 1rem;
  display: flex; flex-direction: column; gap: 0.4rem;
  background: rgba(255, 250, 230, 0.5);
}
.chat-empty {
  text-align: center; opacity: 0.5; padding: 2rem 1rem; font-style: italic;
}
.chat-msg {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: rgba(244, 228, 193, 0.6);
  border-left: 3px solid var(--ink-soft, #5a3a18);
  word-wrap: break-word;
}
.chat-msg.local { background: rgba(200, 230, 255, 0.4); border-left-color: #2a6aaa; }
.chat-msg.system { background: transparent; border-left-color: transparent; font-style: italic; opacity: 0.7; text-align: center; }
.chat-msg-author { font-size: 0.78rem; font-weight: 600; color: var(--ink, #2a1808); opacity: 0.85; }
.chat-msg.local .chat-msg-author { color: #2a6aaa; }
.chat-msg-text { font-size: 0.95rem; color: var(--ink, #2a1808); line-height: 1.35; }
.chat-msg-time { font-size: 0.7rem; opacity: 0.5; align-self: flex-end; }
.chat-input-bar {
  display: flex; gap: 0.4rem; padding: 0.6rem 0.7rem;
  background: var(--paper-light, #faf0d8);
  border-top: 1px solid var(--ink-soft, #5a3a18);
}
.chat-input-bar input {
  flex: 1; padding: 0.5rem 0.7rem; font-size: 1rem;
  border: 1px solid var(--ink-soft, #5a3a18);
  border-radius: 4px; background: #fff;
  color: var(--ink, #2a1808);
}
.chat-input-bar input:focus { outline: 2px solid #5a3a18; outline-offset: -2px; }
.chat-input-bar .btn-send {
  padding: 0.5rem 0.9rem; font-size: 1.1rem;
  background: linear-gradient(180deg, #5a3a18 0%, #3a2410 100%);
  color: #f4e4c1; border: none; border-radius: 4px; cursor: pointer;
}
.chat-input-bar .btn-send:active { transform: scale(0.95); }

/* Бэйдж непрочитанных на кнопке чата */
.chat-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: #c0392b; color: #fff;
  font-size: 0.7rem; font-weight: 700; line-height: 18px;
  text-align: center; border-radius: 9px;
  border: 1.5px solid #1a1410;
  pointer-events: none;
}
#btn-chat { position: relative; }


/* === АДАПТИВ === */
@media (min-width: 600px) {
  body {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
}

/* Скроллбар */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 3px;
}

/* === МУЛЬТИПЛЕЕР (mp-block) === */
.mp-block {
  padding: 1rem;
  border-top: 1px dashed var(--gold);
  background: linear-gradient(to bottom, rgba(45, 74, 43, 0.04), transparent);
}

.mp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mp-title {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--forest);
  letter-spacing: 0.03em;
}

.mp-status {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-style: italic;
  white-space: nowrap;
}

.mp-status.connected { color: var(--forest); font-weight: bold; }
.mp-status.connecting { color: var(--gold); }
.mp-status.disconnected { color: var(--crimson); }
.mp-status.error { color: var(--crimson); font-weight: bold; }

.mp-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.mp-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mp-field span {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mp-field input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  background: rgba(255, 250, 240, 0.6);
  border: 1px solid var(--gold);
  border-radius: 3px;
  color: var(--ink);
  text-align: left;
}

.mp-field-code input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
.mp-field-max select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  font-size: 1rem;
  border: 1px solid var(--ink-soft);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
}
.mp-room-count {
  margin-left: auto;
  padding: 0.2rem 0.6rem;
  background: var(--ink-soft);
  color: var(--paper);
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
  font-weight: bold;
  text-align: center;
}

.mp-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.mp-buttons .btn-rune-outline {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

.mp-hint {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.4;
  margin-top: 0.4rem;
  text-align: center;
}

.mp-body-room {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mp-room-info {
  background: rgba(184, 134, 11, 0.08);
  border: 1px dashed var(--gold);
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
}

.mp-room-code-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.mp-room-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.mp-room-code {
  font-size: 1.6rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.8);
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--gold);
  border-radius: 3px;
}

.mp-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.3;
  justify-content: center;
}

.mp-player-chip {
  background: rgba(255, 250, 240, 0.7);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 0.15rem 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.mp-player-chip.local {
  background: var(--forest);
  color: white;
  border-color: var(--forest);
}

.mp-player-chip .chip-char {
  opacity: 0.75;
  font-style: italic;
  font-size: 0.8em;
}

/* === СОБЫТИЯ МУЛЬТИПЛЕЕРА В ЛЕНТЕ === */
.event-mp {
  background: rgba(45, 74, 43, 0.07);
  border-left: 3px solid var(--forest);
  padding: 0.5rem 0.75rem;
  margin: 0.25rem 0;
  border-radius: 0 4px 4px 0;
  font-size: 0.95rem;
  line-height: 1.45;
}

.event-mp.system {
  background: rgba(184, 134, 11, 0.07);
  border-left-color: var(--gold);
  font-style: italic;
  color: var(--ink-soft);
  text-align: center;
}

.event-mp .mp-author {
  font-weight: bold;
  color: var(--forest);
  margin-right: 0.4rem;
}

.event-mp.system .mp-author { display: none; }

.event-mp .mp-roll-total {
  font-weight: bold;
  color: var(--crimson);
  margin-left: 0.3rem;
}
