/* ============================================================
   Совиное Гнездо — дизайн-система «Ночной лес»
   Тёмная тема: глубокая ночь, лунный свет, янтарные совиные глаза.
   ============================================================ */

:root {
  --font-display: "Alegreya", "PT Serif", serif;
  --font-body: "Fira Sans", "PT Sans", system-ui, sans-serif;

  --bg-deep: #0a0e15;
  --bg-panel: rgba(21, 26, 37, 0.86);
  --bg-panel-2: rgba(28, 34, 48, 0.9);
  --bg-sheet: #141926;
  --bg-toast: #1b2233;
  --border: rgba(232, 179, 75, 0.13);
  --border-strong: rgba(232, 179, 75, 0.28);

  --text: #ece7d8;
  --text-dim: #9aa3b4;

  --accent: #e8b34b;
  --accent-2: #f2d492;
  --accent-glow: rgba(232, 179, 75, 0.35);
  --green: #7fb069;
  --red: #e06c5c;
  --blurple: #5865f2;

  --rarity-common: #9aa3b4;
  --rarity-rare: #5ea8e0;
  --rarity-epic: #e07b39;
  --rarity-legendary: #e8b34b;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-name {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

code {
  background: rgba(232, 179, 75, 0.12);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 6px;
  font-size: 0.9em;
  color: var(--accent-2);
}

/* ---------- Ночное небо ---------- */

.night-sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(88, 101, 242, 0.12), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(232, 179, 75, 0.05), transparent 60%),
    linear-gradient(180deg, #0a0e15 0%, #0c1220 55%, #0a0e15 100%);
}

/* Звёзды */
.night-sky::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 32% 8%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 48% 30%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 63% 12%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 76% 26%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 88% 6%, rgba(255, 255, 255, 0.65), transparent),
    radial-gradient(1px 1px at 24% 44%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 55% 52%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 94% 40%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 5% 62%, rgba(255, 255, 255, 0.35), transparent);
  animation: stars-twinkle 5s ease-in-out infinite alternate;
}

@keyframes stars-twinkle {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

/* Луна */
.moon {
  position: absolute;
  top: 56px;
  right: 8%;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #f6ecd2, #d9c99a 62%, #b8a878);
  box-shadow:
    0 0 40px 12px rgba(240, 220, 160, 0.22),
    0 0 120px 50px rgba(240, 220, 160, 0.1);
  opacity: 0.9;
}

.moon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(14px 14px at 62% 30%, rgba(160, 145, 100, 0.5), transparent 70%),
    radial-gradient(9px 9px at 35% 58%, rgba(160, 145, 100, 0.45), transparent 70%),
    radial-gradient(7px 7px at 68% 66%, rgba(160, 145, 100, 0.4), transparent 70%);
}

.moon.big { width: 160px; height: 160px; right: 12%; top: 80px; }

/* ---------- Верхняя панель ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  background: rgba(10, 14, 21, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.brand-owl { font-size: 26px; filter: drop-shadow(0 0 8px var(--accent-glow)); }

.brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-2);
}

.topnav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }

.nav-btn {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nav-btn:hover {
  color: var(--accent-2);
  border-color: var(--border-strong);
  background: rgba(232, 179, 75, 0.07);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel);
}

.user-avatar { width: 28px; height: 28px; border-radius: 50%; }

.user-name { font-size: 13.5px; font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logout {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.logout:hover { color: var(--red); background: rgba(224, 108, 92, 0.12); }

.wake-banner {
  text-align: center;
  font-size: 13px;
  color: var(--accent-2);
  background: rgba(232, 179, 75, 0.09);
  border-bottom: 1px solid var(--border);
  padding: 7px 14px;
}

/* ---------- Игровая сетка ---------- */

.game-grid {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr) 330px;
  gap: 20px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px;
  align-items: start;
}

.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.col-right { position: sticky; top: 76px; }

/* ---------- Панели ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel.clickable { cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.panel.clickable:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.panel-title {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 700;
  color: var(--accent-2);
}

/* Появление колонок при загрузке страницы (класс на статичных контейнерах,
   чтобы htmx-обновления партиалов не проигрывали анимацию заново) */
.reveal { animation: fade-up 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.col-left.reveal { animation-delay: 0.05s; }
.col-center.reveal { animation-delay: 0.15s; }
.col-right.reveal { animation-delay: 0.2s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Карточка совы ---------- */

.owl-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }

.owl-avatar {
  font-size: 40px;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2a3247, #171c28);
  border: 2px solid var(--border);
}

.owl-avatar.big { width: 92px; height: 92px; flex-basis: 92px; font-size: 48px; }

.rarity-ring-common { border-color: var(--rarity-common); box-shadow: 0 0 14px rgba(154, 163, 180, 0.25); }
.rarity-ring-rare { border-color: var(--rarity-rare); box-shadow: 0 0 14px rgba(94, 168, 224, 0.35); }
.rarity-ring-epic { border-color: var(--rarity-epic); box-shadow: 0 0 16px rgba(224, 123, 57, 0.4); }
.rarity-ring-legendary { border-color: var(--rarity-legendary); box-shadow: 0 0 20px var(--accent-glow); }

.owl-title h2 { margin: 0 0 2px; font-size: 26px; }
.owl-cosmetic { margin-right: 6px; }
.owl-title-badge { font-size: 12px; color: #ffd166; margin-bottom: 2px; }
.owl-ability { font-size: 12px; color: #a29bfe; margin-bottom: 4px; }

.rarity { font-size: 13px; font-weight: 600; }
.stars { font-size: 13px; letter-spacing: 2px; }

.rarity-common { color: var(--rarity-common); }
.rarity-rare { color: var(--rarity-rare); }
.rarity-epic { color: var(--rarity-epic); }
.rarity-legendary { color: var(--rarity-legendary); }

.level-block { margin-bottom: 14px; }

.level-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.level-badge {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-2);
}

.xp-text { font-size: 12.5px; color: var(--text-dim); }

/* ---------- Прогресс-бары ---------- */

.bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #b97f26, var(--accent) 60%, var(--accent-2));
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.6s ease;
  position: relative;
}

.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: shimmer 2.6s linear infinite;
}

@keyframes shimmer {
  from { background-position: 180% 0; }
  to { background-position: -80% 0; }
}

.bar-warn { background: linear-gradient(90deg, #a33f2e, var(--red)); box-shadow: 0 0 10px rgba(224, 108, 92, 0.4); }

.boss-bar .bar-fill,
.enemy-bar .bar-fill {
  background: linear-gradient(90deg, #8e2f22, var(--red) 70%, #f0937f);
  box-shadow: 0 0 12px rgba(224, 108, 92, 0.45);
}

.bar-label { font-size: 12px; color: var(--text-dim); margin-top: 5px; }

/* ---------- Статы ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
}

.stat-ico { font-size: 17px; }
.stat-val { font-size: 18px; font-weight: 700; }
.stat-name { font-size: 10.5px; color: var(--text-dim); }

.owl-meta { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13.5px; color: var(--text-dim); }

.artifacts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.artifact { font-size: 19px; cursor: help; }

.points-badges { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
}
.badge-amber { color: var(--accent-2); border-color: var(--border-strong); background: rgba(232, 179, 75, 0.1); }
.badge-green { color: var(--green); border-color: rgba(127, 176, 105, 0.4); background: rgba(127, 176, 105, 0.1); }
.badge-purple { color: #c77dff; border-color: rgba(199, 125, 255, 0.4); background: rgba(199, 125, 255, 0.1); }
.badge-muted { color: var(--text-dim); border-color: rgba(154, 163, 180, 0.3); }

.actions { display: flex; gap: 10px; margin-bottom: 10px; }

/* ---------- Кнопки ---------- */

.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s, border-color 0.15s;
}

.btn-primary {
  flex: 1;
  color: #241a05;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 4px 16px rgba(232, 179, 75, 0.25);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(232, 179, 75, 0.4); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  color: var(--text);
  background: rgba(232, 179, 75, 0.07);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

.hint { font-size: 12px; color: var(--text-dim); margin: 8px 0 0; }
.muted { color: var(--text-dim); font-size: 13.5px; }

/* ---------- Пустое состояние ---------- */

.owl-card.empty { text-align: center; padding: 34px 22px; }
.empty-emoji { font-size: 52px; margin-bottom: 10px; }
.owl-card.empty h2 { margin: 0 0 8px; }
.owl-card.empty p { color: var(--text-dim); margin: 0; }
.empty-note { text-align: center; color: var(--text-dim); padding: 18px 0; }

/* ---------- Ресурсы ---------- */

.res-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.res-grid.small .res { padding: 6px 3px; }

.res {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 4px;
}

.res-grid.small .res { flex-direction: row; justify-content: center; gap: 5px; }

.res-ico { font-size: 18px; }
.res-val { font-size: 16px; font-weight: 700; }
.res-name { font-size: 10.5px; color: var(--text-dim); }

/* ---------- Таймеры ---------- */

.timer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.timer-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-2);
  border: 1px solid transparent;
}

.t-ico { font-size: 16px; }
.t-name { flex: 1; font-size: 13.5px; color: var(--text-dim); }
.t-val { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.t-val.ready { color: var(--green); }

.raid-timer { border-color: rgba(224, 108, 92, 0.35) !important; background: rgba(224, 108, 92, 0.07) !important; }

/* ---------- Гнездо (сводка) ---------- */

.nest-level { font-size: 13px; color: var(--text-dim); font-family: var(--font-body); font-weight: 400; }
.storage-bar { margin-bottom: 4px; }
.nest-summary .res-grid { margin-top: 12px; }

.blessed {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--accent-2);
  background: rgba(232, 179, 75, 0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}

/* ---------- Сцена ---------- */

.scene-card { min-height: 320px; }

.scene-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  border: 1px solid rgba(224, 108, 92, 0.4);
  background: rgba(224, 108, 92, 0.1);
  border-radius: 999px;
  padding: 3px 12px;
  margin-bottom: 10px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.scene-title { margin: 0 0 14px; font-size: 27px; }

.scene-meta {
  display: flex;
  gap: 18px;
  font-size: 13.5px;
  color: var(--text-dim);
  margin: 12px 0;
  flex-wrap: wrap;
}

.ptable { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
.ptable th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.ptable td { padding: 7px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.ptable tr:last-child td { border-bottom: none; }
.ptable tr.fallen td { opacity: 0.4; text-decoration: line-through; }
.ptable tr.self td { background: rgba(232, 179, 75, 0.07); }

/* ---------- Мини-топ: сегмент-контрол «Совы / Игроки» ---------- */

.top-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.top-head .panel-title { margin: 0; }

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.seg {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.seg:hover { color: var(--text); }
.seg.active {
  color: #241a05;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}

.top-table-wrap { cursor: pointer; }

/* Плавная подмена строк мини-топа при переключении «Совы/Игроки» (hx-swap transition:true) */
#top-mini-body { opacity: 1; transition: opacity 0.18s ease-in; }
#top-mini-body.htmx-swapping { opacity: 0; transition: opacity 0.18s ease-out; }
#top-mini-body.htmx-added { opacity: 0; }

.top-formula-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: underline dotted;
}
.top-formula-link:hover { color: var(--accent-2); }

.formula-line {
  font-size: 13.5px;
  color: var(--accent-2);
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 0 12px;
}
.formula-list { margin: 0 0 4px; padding-left: 18px; font-size: 13.5px; color: var(--text); }
.formula-list li { margin-bottom: 8px; }

.room-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.room-ico { font-size: 26px; }
.room-name { font-weight: 700; font-size: 16px; }
.room-card .bar { flex: 1 1 100%; }

/* Плейсхолдер HP-бара в небоевых комнатах: занимает то же место,
   чтобы кнопки данжа не прыгали при смене комнаты */
.room-hp-placeholder { visibility: hidden; }

/* Кнопки боя прибиты к низу карточки сцены: позиция не зависит от
   высоты контента выше (тип комнаты, таблица участников) */
.scene-card.dungeon, .scene-card.raid { display: flex; flex-direction: column; }
.scene-card .battle-actions { margin-top: auto; padding-top: 14px; }

/* ---------- Центральная подсетка: лента + мини-топ ---------- */

.center-sub {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  align-items: start;
}

.feed-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.feed-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-2);
  border: 1px solid transparent;
}

.feed-raid_won, .feed-dungeon_won { border-color: rgba(232, 179, 75, 0.3); }
.feed-raid_lost, .feed-dungeon_lost { opacity: 0.75; }
.feed-build { border-color: rgba(127, 176, 105, 0.3); }

.feed-time { color: var(--text-dim); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.dim { color: var(--text-dim); }

.welcome { text-align: center; }
.moon-emblem {
  font-size: 54px;
  margin: 8px 0 4px;
  filter: drop-shadow(0 0 18px var(--accent-glow));
  animation: float 5s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.welcome h2 { margin: 6px 0 8px; font-size: 30px; }
.welcome p { color: var(--text-dim); max-width: 460px; margin: 0 auto 8px; }

/* Сцена-приветствие вертикально центрирована — меньше пустоты на высоких экранах */
.scene-card.welcome {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dungeon-list-title { margin: 22px 0 12px; font-size: 20px; color: var(--accent-2); }

.diff-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: left;
}

.diff-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.diff-head { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.diff-blessed { font-size: 12px; color: #ffd166; margin-bottom: 6px; }
.diff-card ul { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--text-dim); display: flex; flex-direction: column; gap: 3px; }

/* ---------- Модалки ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 11, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease both;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  width: 100%;
  max-width: 660px;
  max-height: min(84vh, 860px);
  display: flex;
  flex-direction: column;
  background: var(--bg-sheet);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 40px rgba(232, 179, 75, 0.06);
  animation: sheet-in 0.3s cubic-bezier(0.2, 0.8, 0.3, 1.05) both;
  overflow: hidden;
}

.modal-sheet.wide { max-width: 1000px; }

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(26px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Анимированное закрытие: closeModal вешает .closing, затем очищает #modal-root */
.modal-backdrop.closing { animation: fade-out 0.19s ease both; }
.modal-backdrop.closing .modal-sheet { animation: sheet-out 0.19s ease-in both; }

@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes sheet-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(16px) scale(0.96); }
}

.modal-handle { display: none; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(232, 179, 75, 0.04);
}

.modal-head h3 { margin: 0; font-size: 21px; color: var(--accent-2); }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.modal-close:hover { color: var(--red); border-color: rgba(224, 108, 92, 0.5); }

.modal-body { padding: 18px 20px 22px; overflow-y: auto; }
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(232, 179, 75, 0.2); border-radius: 8px; }

.section-title {
  margin: 20px 0 10px;
  font-size: 16px;
  color: var(--accent-2);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head .stars { margin: 2px 0; }

.modal-quicknav { display: flex; gap: 8px; margin: 16px 0 4px; flex-wrap: wrap; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
}
.kv span { color: var(--text-dim); }
.kv b { font-size: 15px; }

.factor-list { display: flex; flex-direction: column; gap: 9px; }
.factor { display: grid; grid-template-columns: 90px 1fr 30px; align-items: center; gap: 10px; font-size: 13.5px; }
.factor b { text-align: right; }

.artifact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.artifact-list li { background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }

/* Коллекция */
.owl-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.owl-list-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.owl-list-item.active { border-color: var(--border-strong); background: rgba(232, 179, 75, 0.06); }
.owl-list-emoji { font-size: 26px; }
.owl-list-info { flex: 1; display: flex; flex-direction: column; }
.owl-list-level { color: var(--text-dim); font-size: 13px; }

.note-block {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(232, 179, 75, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.note-block p { margin: 4px 0; }

/* Навыки */
.skill-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 7px; }

.skill-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--bg-panel-2);
}

.skill-item.learned { border-color: rgba(127, 176, 105, 0.45); background: rgba(127, 176, 105, 0.07); }
.skill-item.available { border-color: var(--border-strong); }
.skill-item.locked { opacity: 0.55; }

.skill-emoji { font-size: 22px; }
.skill-info { flex: 1; }
.skill-info p { margin: 2px 0; font-size: 13px; color: var(--text-dim); }
.skill-req { font-size: 11.5px; color: var(--text-dim); opacity: 0.8; }
.skill-status { font-size: 15px; }

/* Классы и локации */
.class-cards, .location-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.class-card, .location-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}

.class-card.chosen { border-color: rgba(127, 176, 105, 0.5); background: rgba(127, 176, 105, 0.06); }
.class-card.available { border-color: var(--border-strong); }
.class-card.locked, .location-card.locked { opacity: 0.6; }
.location-card.current { border-color: var(--border-strong); background: rgba(232, 179, 75, 0.06); }

.class-head, .location-head { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.class-emoji, .location-emoji { font-size: 24px; }
.class-status { margin-left: auto; font-size: 12px; color: var(--text-dim); }
.class-desc { font-size: 12.5px; color: var(--text-dim); margin: 0 0 8px; }

.bonus-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.bonus-list li.bonus { color: var(--green); }
.bonus-list li.penalty { color: var(--red); }
.class-preview { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; }
.class-req { font-size: 11.5px; color: var(--text-dim); }

/* Инвентарь */
.inventory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.inv-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 6px;
}
.inv-ico { font-size: 26px; }
.inv-item b { font-size: 20px; }
.inv-item span:last-child { font-size: 11.5px; color: var(--text-dim); }

/* Гнездо (модалка) */
.nest-top { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.nest-player .section-title:first-child { margin-top: 0; }
.limit-list { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }

.building-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }

.building-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.building-card.affordable { border-color: rgba(127, 176, 105, 0.4); }
.building-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.building-cost { display: flex; gap: 10px; font-size: 13px; }
.cost-item.lack { color: var(--red); }

/* Топ */
.top-table td:first-child { width: 40px; }

/* ---------- Страница логина ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  padding: 40px 34px 30px;
  box-shadow: var(--shadow), 0 0 60px rgba(232, 179, 75, 0.07);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fade-up 0.5s ease both;
}

.login-emblem {
  font-size: 62px;
  filter: drop-shadow(0 0 22px var(--accent-glow));
  animation: float 5s ease-in-out infinite;
}

.login-title { font-size: 34px; margin: 10px 0 6px; color: var(--accent-2); }
.login-sub { color: var(--text-dim); margin: 0 0 22px; }

.login-error {
  font-size: 13.5px;
  color: #f0b3a7;
  background: rgba(224, 108, 92, 0.1);
  border: 1px solid rgba(224, 108, 92, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--blurple);
  border-radius: 12px;
  padding: 13px 26px;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.15s;
  box-shadow: 0 6px 24px rgba(88, 101, 242, 0.35);
}
.btn-discord:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(88, 101, 242, 0.5); }

.login-hint { font-size: 12px; color: var(--text-dim); margin-top: 20px; }

/* ---------- Нижняя навигация (мобильная) ---------- */

.bottomnav { display: none; }

/* ---------- Мобильная раскладка ---------- */

@media (max-width: 1023px) {
  body { font-size: 14.5px; padding-bottom: 76px; }

  .moon { width: 70px; height: 70px; top: 70px; right: 6%; }

  .topbar { padding: 8px 14px; gap: 10px; }
  .topnav { display: none; }
  .brand-name { font-size: 19px; }
  .user-chip { margin-left: auto; }
  .user-name { max-width: 90px; }

  .game-grid {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 14px;
  }
  .col { gap: 14px; }
  .col-right { position: static; }

  .diff-cards { grid-template-columns: 1fr; }
  .class-cards, .location-cards, .nest-top, .center-sub { grid-template-columns: 1fr; }
  .inventory-grid { grid-template-columns: repeat(2, 1fr); }

  /* Нижняя навигация */
  .bottomnav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: rgba(10, 14, 21, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }

  .bnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 10.5px;
    padding: 6px 2px;
    cursor: pointer;
    border-radius: 10px;
    transition: color 0.15s, background 0.15s;
  }
  .bnav-btn span { font-size: 21px; }
  .bnav-btn:hover, .bnav-btn:active { color: var(--accent-2); background: rgba(232, 179, 75, 0.08); }

  /* Модалки — нижние шторки */
  .modal-backdrop { align-items: flex-end; padding: 0; }

  .modal-sheet, .modal-sheet.wide {
    max-width: none;
    width: 100%;
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    animation: sheet-up 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) both;
  }

  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-handle {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(232, 179, 75, 0.3);
    margin: 10px auto 4px;
  }
}

/* ---------- Широкие экраны (2K/4K): масштабируем UI ---------- */

@media (min-width: 1700px) {
  .topbar, .game-grid, .modal-sheet { zoom: 1.12; }
  .game-grid { max-width: 1820px; }
  .scene-card { min-height: 400px; }
}

@media (min-width: 2200px) {
  .topbar, .game-grid, .modal-sheet { zoom: 1.25; }
  .game-grid { max-width: 2000px; }
  .scene-card { min-height: 480px; }
}

/* Уменьшение анимаций по системной настройке */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Действия (фаза 2): тосты, формы, выбор события ---------- */

/* Тосты */
#toast-root {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-toast);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(232, 179, 75, 0.08);
  animation: toast-life 4.5s ease both;
  max-width: min(90vw, 560px);
  text-align: center;
}

.toast-ok { color: var(--accent-2); }
.toast-error { color: #f0b3a7; border-color: rgba(224, 108, 92, 0.45); }

@keyframes toast-life {
  0% { opacity: 0; transform: translateY(14px) scale(0.95); }
  7% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(8px); }
}

/* Формы (вылупление, покупка яйца) */
.hatch-form { display: flex; gap: 10px; margin-top: 14px; }

.hatch-form input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.hatch-form input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(232, 179, 75, 0.12);
}

.hatch-form .btn { flex: 0 0 auto; }

/* Форма переименования совы в коллекции */
.rename-form { display: flex; gap: 4px; flex: 1 1 100%; margin-top: 6px; }

.rename-form input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rename-form input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(232, 179, 75, 0.12);
}

/* Кнопки-бейджи (прокачать/навыки на карточке совы) */
.badge-btn { cursor: pointer; background: transparent; font-family: var(--font-body); }
.badge-btn:hover { filter: brightness(1.25); }

.btn-small { padding: 6px 12px; font-size: 12.5px; }
.btn-plus { padding: 6px 14px; font-size: 15px; font-weight: 700; }

/* Кнопка в состоянии подтверждения (выбор класса) */
.btn-choose { width: 100%; margin-top: 8px; }
.btn.armed {
  background: linear-gradient(180deg, #f0937f, var(--red));
  color: #2a0d08;
  animation: pulse 1s ease-in-out infinite;
}

/* Событие разведки в «сцене» */
.event-tag { color: var(--green); border-color: rgba(127, 176, 105, 0.4); background: rgba(127, 176, 105, 0.1); animation: none; }
.outcome-tag { color: var(--accent-2); border-color: var(--border-strong); background: rgba(232, 179, 75, 0.08); animation: none; }

.event-desc { font-style: italic; color: var(--text-dim); font-size: 15px; max-width: 520px; }

.event-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.event-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.event-choice:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.choice-emoji { font-size: 24px; }
.choice-label { font-weight: 700; font-size: 15px; }
.choice-desc { font-size: 12.5px; color: var(--text-dim); font-weight: 400; }

/* Итог разведки */
.outcome-text { font-size: 15.5px; line-height: 1.5; }
.outcome-rewards { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.outcome-rewards .badge:not(.badge-amber):not(.badge-green) {
  color: var(--text); border-color: var(--border); background: var(--bg-panel-2);
}

.egg-note {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(232, 179, 75, 0.08);
  border: 1px solid var(--border-strong);
  font-size: 14px;
}

/* Прокачка */
.allocate-list { display: flex; flex-direction: column; gap: 8px; }

.allocate-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.allocate-info { flex: 1; display: flex; flex-direction: column; }
.allocate-info .skill-req { margin-top: 2px; }

/* Переводы ресурсов (гнездо) */
.transfer-list { display: flex; flex-direction: column; gap: 6px; }

.transfer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}

.transfer-have { flex: 1; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.transfer-btns { display: flex; gap: 6px; }
.transfer-custom { display: flex; gap: 6px; margin: 0; }
.transfer-custom input[type="number"] {
  width: 110px;
  padding: 6px 10px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
}
.transfer-custom input[type="number"]::placeholder { color: var(--text-dim); }
.transfer-custom input[type="number"]:focus { outline: none; border-color: var(--accent); }

.building-card .btn-small { margin-top: 10px; width: 100%; }

@media (max-width: 1023px) {
  #toast-root { bottom: 84px; width: calc(100% - 24px); }
  .toast { max-width: 100%; }
  .event-choices { grid-template-columns: 1fr; }
}

/* Боевые действия в «сцене» (фаза 3) */
.battle-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.diff-card .btn-small { margin-top: 10px; width: 100%; }

/* Эмодзи-картинки (Fluent Emoji 3D, fluent-emoji.js): ведут себя как символ шрифта */
img.emoji {
  display: inline-block;
  height: 1.15em;
  width: 1.15em;
  vertical-align: -0.2em;
  user-select: none;
}

/* Скрытая служебная страница /admin */
.admin-page {
  max-width: 560px;
  margin: 40px auto;
  padding: 0 16px;
  color: var(--text);
}

.admin-page h1 { font-size: 22px; margin-bottom: 8px; }

.admin-hint { color: var(--text-dim); font-size: 13px; }

.admin-owl {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 8px;
}

.admin-owl-name { font-weight: 600; }
.admin-owl-meta { color: var(--text-dim); font-size: 12px; flex: 1; }

.admin-flag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.admin-back { color: var(--text-dim); font-size: 13px; }
