/* ============================================================
   Аркана: Ставка Судьбы — тёмное фэнтези, AAA-подача
   ============================================================ */
:root {
  --gold: #d8a94b;
  --gold-bright: #ffd97a;
  --ink: #0d0a14;
  --ink-2: #171226;
  --parchment: #e8dcc0;
  --player: #3aa0ff;
  --player-glow: rgba(58, 160, 255, 0.55);
  --enemy: #ff4d5e;
  --enemy-glow: rgba(255, 77, 94, 0.55);
  --rar-common: #8b8fa3;
  --rar-uncommon: #4fc47a;
  --rar-rare: #4f9cf0;
  --rar-legendary: #e8a33d;
  --font-title: Georgia, 'Times New Roman', serif;
  --font-body: 'Segoe UI', Tahoma, Verdana, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app { position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; }

/* Фоновые слои с кроссфейдом */
.bg-layer {
  position: absolute; inset: -2%;
  background-size: cover; background-position: center;
  filter: brightness(0.55) saturate(0.9);
  opacity: 0; transition: opacity 1.2s ease;
  transform: scale(1.02);
}
.bg-layer.visible { opacity: 1; }
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(5, 3, 10, 0.72) 100%);
}

/* ---------- Экраны ---------- */
.screen {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 1; transition: opacity 0.45s ease;
}
.screen.hidden { display: none; }
.screen.fade-out { opacity: 0; }
.screen.fade-in { animation: screenIn 0.6s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Кнопки ---------- */
.btn {
  font-family: var(--font-title);
  font-size: 1.05rem; letter-spacing: 0.06em;
  color: var(--parchment);
  background: linear-gradient(180deg, #2a2140, #1a1430);
  border: 1px solid #4a3d6b;
  border-radius: 8px;
  padding: 0.7em 1.6em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.btn:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: 0 4px 18px rgba(216, 169, 75, 0.25); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(180deg, #6d5424, #4a3616);
  border-color: var(--gold);
  color: var(--gold-bright);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.hidden { display: none !important; }

/* ---------- SVG-иконки ---------- */
.icn { vertical-align: -0.18em; flex-shrink: 0; }
.ic-coin { color: var(--gold-bright); }
.ic-ante { color: var(--parchment); }
.ic-boss { color: var(--enemy); }
.ic-relic { color: var(--gold-bright); }
.ic-scroll { color: #b79bff; }
.ic-region { color: var(--gold); }
.ic-deck, .ic-lbl { color: var(--parchment); opacity: 0.85; }
.ic-back { color: rgba(216, 169, 75, 0.75); }
.ic-audio { color: var(--parchment); }
.hud-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 14px;
  background: rgba(20, 14, 36, 0.75);
  border: 1px solid rgba(140, 120, 200, 0.28);
  font-size: 0.82rem; letter-spacing: 0.04em;
}
.hud-chip b { color: var(--gold-bright); }

/* ---------- Меню ---------- */
#menu-logo { margin-bottom: 0.6rem; }
#menu-logo .logo-mark {
  color: var(--gold-bright);
  filter: drop-shadow(0 0 14px rgba(216, 169, 75, 0.55));
  animation: logoSpin 26s linear infinite;
}
@keyframes logoSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.menu-box {
  text-align: center; padding: 3rem 2.4rem;
  background: rgba(10, 7, 18, 0.72);
  border: 1px solid rgba(216, 169, 75, 0.35);
  border-radius: 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(216, 169, 75, 0.04);
  max-width: min(92vw, 560px);
  animation: menuIn 1s ease both;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
.game-title {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 5.5vw, 3.2rem);
  color: var(--gold-bright);
  text-shadow: 0 0 24px rgba(216, 169, 75, 0.5), 0 2px 4px #000;
  letter-spacing: 0.04em;
}
.title-sep { color: var(--gold); margin: 0 0.3em; font-size: 0.7em; vertical-align: middle; }
.game-subtitle { margin-top: 0.5rem; opacity: 0.75; font-style: italic; letter-spacing: 0.12em; }
.menu-buttons { display: flex; flex-direction: column; gap: 0.8rem; margin: 2rem auto 1rem; max-width: 280px; }
.menu-footer { opacity: 0.5; font-size: 0.85rem; margin-top: 1.4rem; font-style: italic; }

/* ---------- Сюжет ---------- */
.story-box {
  max-width: min(92vw, 640px);
  background: rgba(10, 7, 18, 0.82);
  border: 1px solid rgba(216, 169, 75, 0.3);
  border-radius: 14px;
  padding: 2.4rem 2.2rem;
  text-align: center;
  backdrop-filter: blur(5px);
  animation: menuIn 0.8s ease both;
}
#story-emblem { display: flex; justify-content: center; margin-bottom: 0.7rem; }
.emblem-ring .icn, .story-emblem-ic {
  color: var(--gold-bright);
  padding: 10px; border-radius: 50%;
  border: 1px solid rgba(216, 169, 75, 0.5);
  background: radial-gradient(circle, rgba(216, 169, 75, 0.14), transparent 72%);
  box-shadow: 0 0 22px rgba(216, 169, 75, 0.25);
  box-sizing: content-box;
}
.emblem-ring.boss .icn, .story-emblem-ic.boss {
  color: var(--enemy);
  border-color: rgba(255, 77, 94, 0.55);
  background: radial-gradient(circle, rgba(255, 77, 94, 0.14), transparent 72%);
  box-shadow: 0 0 26px rgba(255, 77, 94, 0.3);
}
.story-portrait {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(216, 169, 75, 0.6);
  box-shadow: 0 0 24px rgba(216, 169, 75, 0.3);
}
.story-portrait.boss {
  border-color: var(--enemy);
  box-shadow: 0 0 30px rgba(255, 77, 94, 0.45);
  animation: bossPortrait 2.2s ease-in-out infinite;
}
@keyframes bossPortrait { 0%,100% { box-shadow: 0 0 18px rgba(255,77,94,0.35);} 50% { box-shadow: 0 0 36px rgba(255,77,94,0.6);} }
.story-badge {
  display: inline-block; margin-bottom: 0.7rem;
  font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 3px 14px; border-radius: 14px;
  border: 1px solid rgba(216, 169, 75, 0.45);
  color: var(--gold-bright);
  background: rgba(216, 169, 75, 0.08);
}
.story-badge.boss { border-color: rgba(255, 77, 94, 0.5); color: #ff9aa5; background: rgba(255, 77, 94, 0.08); }
#story-title { font-family: var(--font-title); color: var(--gold-bright); font-size: 1.6rem; margin-bottom: 1.2rem; letter-spacing: 0.05em; }
#story-text p { margin: 0.7em 0; line-height: 1.65; font-size: 1.02rem; opacity: 0; animation: lineIn 0.8s ease both; }
#story-text p:nth-child(1) { animation-delay: 0.15s; }
#story-text p:nth-child(2) { animation-delay: 0.7s; }
#story-text p:nth-child(3) { animation-delay: 1.25s; }
#story-text p:nth-child(4) { animation-delay: 1.8s; }
#story-text p:nth-child(5) { animation-delay: 2.35s; }
@keyframes lineIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 0.92; transform: none; } }
#story-text .boss-line { color: var(--enemy); font-style: italic; }
#btn-story-next { margin-top: 1.6rem; }

/* ---------- Бой: каркас ---------- */
#screen-battle { flex-direction: row; justify-content: stretch; align-items: stretch; padding: 0; }
#battle-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem;
  background: linear-gradient(180deg, rgba(8, 5, 15, 0.92), rgba(8, 5, 15, 0.55) 75%, transparent);
  pointer-events: none;
}
#blind-name { font-family: var(--font-title); color: var(--gold-bright); font-size: 1.05rem; letter-spacing: 0.05em; }
#blind-region { font-size: 0.78rem; opacity: 0.65; font-style: italic; }

/* Скоринг-плашки (Balatro-стиль): ЦЕЛЬ | ФИШКИ × МНОЖ = ИТОГ */
#score-panel { display: flex; gap: 8px; align-items: stretch; pointer-events: auto; }
.plate {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 74px; padding: 4px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.plate-label {
  font-size: 0.6rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.16em;
  opacity: 0.75;
}
.plate b {
  font-family: 'Consolas', monospace;
  font-size: 1.3rem; line-height: 1.15;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.plate.p-target { background: linear-gradient(180deg, #3d1420, #240c13); border-color: rgba(255, 77, 94, 0.45); }
.plate.p-target b { color: #ff8b97; }
.plate.p-chips { background: linear-gradient(180deg, #123a63, #0a2340); border-color: rgba(58, 160, 255, 0.5); }
.plate.p-chips b { color: #8fd0ff; }
.plate.p-mult { background: linear-gradient(180deg, #63220f, #3c1206); border-color: rgba(255, 122, 61, 0.5); }
.plate.p-mult b { color: #ffb37a; }
.plate.p-total { background: linear-gradient(180deg, #4d3a12, #2c1f07); border-color: rgba(216, 169, 75, 0.55); }
.plate.p-total b { color: var(--gold-bright); }
.plate.p-total.reached {
  border-color: var(--rar-uncommon);
  box-shadow: 0 0 16px rgba(79, 196, 122, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.plate.p-total.reached b { color: #8ff0b4; }
.score-op {
  align-self: center;
  font-size: 1.3rem; font-weight: 800;
  color: var(--gold); opacity: 0.85;
  text-shadow: 0 1px 3px #000;
}
.score-op.big { font-size: 1.7rem; }
.plate.bump b { animation: plateBump 0.3s ease; display: inline-block; }
@keyframes plateBump { 30% { transform: scale(1.22); } 100% { transform: scale(1); } }
.plate.big { min-width: 110px; padding: 8px 16px; }
.plate.big b { font-size: 1.9rem; }

#run-info { display: flex; gap: 0.6rem; font-size: 0.95rem; align-items: center; }

#boss-rule-banner {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  z-index: 19; padding: 0.3em 1.2em;
  background: rgba(120, 20, 30, 0.75);
  border: 1px solid var(--enemy);
  border-radius: 20px;
  font-size: 0.82rem; letter-spacing: 0.06em;
  animation: bannerPulse 2.4s ease-in-out infinite;
  white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
@keyframes bannerPulse { 0%, 100% { box-shadow: 0 0 8px rgba(255, 77, 94, 0.4); } 50% { box-shadow: 0 0 22px rgba(255, 77, 94, 0.75); } }

#battle-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 3.4rem 0.5rem 0.5rem; min-width: 0;
}
#battle-side {
  width: 210px; flex-shrink: 0; z-index: 15;
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 3.6rem 0.7rem 0.7rem;
  background: linear-gradient(270deg, rgba(8, 5, 15, 0.85), rgba(8, 5, 15, 0.35));
}

/* ---------- Сетка ---------- */
#board-wrap { display: flex; align-items: center; justify-content: center; flex: 1; width: 100%; min-height: 0; }
#board {
  display: grid; gap: 6px;
  --cell: min(17vh, 19vw, 118px);
  grid-template-columns: repeat(var(--n, 4), var(--cell));
  grid-template-rows: repeat(var(--n, 4), var(--cell));
  padding: 10px;
  background: rgba(12, 8, 22, 0.6);
  border: 1px solid rgba(216, 169, 75, 0.22);
  border-radius: 12px;
  box-shadow: 0 0 44px rgba(0, 0, 0, 0.6), inset 0 0 30px rgba(0, 0, 0, 0.5);
}
#board.n5 { --cell: min(13.2vh, 15vw, 96px); }
.cell {
  position: relative; border-radius: 8px;
  background:
    radial-gradient(circle at 50% 40%, rgba(120, 100, 190, 0.14), transparent 70%),
    linear-gradient(160deg, rgba(56, 45, 92, 0.55), rgba(26, 19, 48, 0.7));
  border: 1px solid rgba(150, 130, 215, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
/* Подсветка валидных клеток при поднятой карте */
.cell.free.selectable {
  cursor: pointer;
  border: 1px dashed rgba(216, 169, 75, 0.65);
  animation: cellPulse 1.4s ease-in-out infinite;
}
@keyframes cellPulse {
  0%, 100% { box-shadow: inset 0 0 10px rgba(216, 169, 75, 0.08); }
  50% { box-shadow: inset 0 0 18px rgba(216, 169, 75, 0.25), 0 0 10px rgba(216, 169, 75, 0.2); }
}
.cell.free.selectable:hover, .cell.free.selectable.touch-hover {
  border-color: var(--gold-bright);
  box-shadow: 0 0 18px rgba(216, 169, 75, 0.45), inset 0 0 20px rgba(216, 169, 75, 0.18);
}
/* Семантика валидных клеток при выбранной карте:
   зелёный ореол = ход даст ЗАХВАТ без боя, оранжевый = будет БОЙ, золото-пунктир = просто валидная */
.cell.free.selectable.sel-capture {
  border: 1px solid rgba(79, 196, 122, 0.85);
  animation: cellPulseCap 1.2s ease-in-out infinite;
}
@keyframes cellPulseCap {
  0%, 100% { box-shadow: 0 0 8px rgba(79, 196, 122, 0.35), inset 0 0 12px rgba(79, 196, 122, 0.12); }
  50% { box-shadow: 0 0 18px rgba(79, 196, 122, 0.65), inset 0 0 18px rgba(79, 196, 122, 0.28); }
}
.cell.free.selectable.sel-battle {
  border: 1px solid rgba(255, 157, 77, 0.85);
  animation: cellPulseBtl 1.2s ease-in-out infinite;
}
@keyframes cellPulseBtl {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 157, 77, 0.35), inset 0 0 12px rgba(255, 157, 77, 0.12); }
  50% { box-shadow: 0 0 18px rgba(255, 157, 77, 0.65), inset 0 0 18px rgba(255, 157, 77, 0.28); }
}
/* Превью на ховере: помечаем сами карты-цели */
.cell.will-capture {
  border-color: var(--rar-uncommon) !important;
  box-shadow: 0 0 16px rgba(79, 196, 122, 0.55), inset 0 0 14px rgba(79, 196, 122, 0.25) !important;
}
.cell.will-battle {
  border-color: #ff9d4d !important;
  box-shadow: 0 0 16px rgba(255, 157, 77, 0.55), inset 0 0 14px rgba(255, 157, 77, 0.25) !important;
}
/* Тонировка занятых клеток по владельцу */
.cell.own-player { border-color: rgba(58, 160, 255, 0.4); background: linear-gradient(160deg, rgba(24, 52, 96, 0.6), rgba(14, 26, 52, 0.7)); }
.cell.own-enemy { border-color: rgba(255, 77, 94, 0.4); background: linear-gradient(160deg, rgba(88, 22, 34, 0.6), rgba(44, 12, 20, 0.7)); }
/* Блок-клетки: явно мёртвые, с цепью (SVG, без эмодзи) */
.cell.blocked {
  background:
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.5) 0 7px, rgba(70, 42, 38, 0.45) 7px 14px),
    linear-gradient(160deg, #1f1412, #0c0806);
  border: 1px solid rgba(150, 84, 66, 0.5);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.75);
}
.cell.blocked::after {
  content: ''; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c98a6a' stroke-width='1.9' stroke-linecap='round'%3E%3Crect x='2.5' y='9.5' width='9' height='5' rx='2.5'/%3E%3Crect x='12.5' y='9.5' width='9' height='5' rx='2.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
  background-size: 46% 46%;
  opacity: 0.85;
  filter: drop-shadow(0 1px 2px #000);
}

/* ---------- Карта ---------- */
.card {
  position: absolute; inset: 3px;
  border-radius: 7px;
  overflow: hidden;
  background: #1c1530;
  border: 2px solid var(--rar-common);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
  transition: transform 0.16s ease, box-shadow 0.2s ease;
  transform-style: preserve-3d;
}
.card.rarity-common { border-color: #a8adc2; box-shadow: 0 3px 10px rgba(0,0,0,0.6), 0 0 7px rgba(168, 173, 194, 0.28); }
.card.rarity-uncommon { border-color: var(--rar-uncommon); box-shadow: 0 3px 10px rgba(0,0,0,0.6), 0 0 8px rgba(79, 196, 122, 0.25); }
.card.rarity-rare { border-color: var(--rar-rare); box-shadow: 0 3px 10px rgba(0,0,0,0.6), 0 0 10px rgba(79, 156, 240, 0.3); }
.card.rarity-legendary {
  border-color: var(--rar-legendary);
  box-shadow: 0 3px 10px rgba(0,0,0,0.6), 0 0 14px rgba(232, 163, 61, 0.45);
  animation: legGlow 2.6s ease-in-out infinite;
}
@keyframes legGlow { 0%,100% { box-shadow: 0 3px 10px rgba(0,0,0,0.6), 0 0 10px rgba(232,163,61,0.35);} 50% { box-shadow: 0 3px 10px rgba(0,0,0,0.6), 0 0 20px rgba(232,163,61,0.6);} }

.card img.art {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  filter: saturate(1.05);
}
.card .art-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell, 100px) * 0.42);
  background: radial-gradient(circle at 50% 35%, #3a2d5e, #191128 75%);
  text-shadow: 0 0 18px rgba(216, 169, 75, 0.5);
}
.card .owner-tint { position: absolute; inset: 0; pointer-events: none; transition: background 0.3s, box-shadow 0.3s; }
.card.owner-player .owner-tint { background: linear-gradient(200deg, rgba(58,160,255,0.28), transparent 55%); box-shadow: inset 0 0 0 2px var(--player), inset 0 0 16px var(--player-glow); }
.card.owner-enemy .owner-tint { background: linear-gradient(200deg, rgba(255,77,94,0.28), transparent 55%); box-shadow: inset 0 0 0 2px var(--enemy), inset 0 0 16px var(--enemy-glow); }

/* Стат-блок TM-стиля: [⚔атака][тип][🛡физ][◎маг] — крупно и раздельно */
.card .stats {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1%;
  /* нижний отступ 16% — полоса у края остаётся стрелкам S/SW/SE: статы и стрелки не пересекаются */
  padding: 8% 4.5% 16%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.9) 38%);
  z-index: 3;
}
/* центр свободен: атака+тип уходят влево, защиты — вправо */
.card .stats .tchip { margin-right: auto; }
.card .stats .st {
  display: inline-flex; align-items: center; gap: 1px;
  font-family: 'Consolas', monospace;
  line-height: 1;
}
.card .stats .st b {
  font-size: calc(var(--cell, 100px) * 0.155);
  font-weight: 800;
  text-shadow: 0 1px 2px #000, 0 0 5px #000;
}
.card .stats .sti { width: calc(var(--cell, 100px) * 0.095); height: calc(var(--cell, 100px) * 0.095); opacity: 0.9; }
.card .stats .st-atk { color: #ffe9b0; }
.card .stats .st-atk b { color: #fff; }
.card .stats .st-pd { color: #9cc4ef; }
.card .stats .st-pd b { color: #cfe6ff; }
.card .stats .st-md { color: #c9a6ff; }
.card .stats .st-md b { color: #e7d4ff; }
/* Тип атаки — отдельная цветная фишка */
.card .stats .tchip {
  font-family: 'Consolas', monospace;
  font-weight: 800;
  font-size: calc(var(--cell, 100px) * 0.12);
  line-height: 1;
  padding: 6% 4.5%;
  border-radius: 20%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 1px #000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.card .stats .tchip.t-P { background: #7a3b12; color: #ffcf9e; }
.card .stats .tchip.t-M { background: #4a2a86; color: #dcc8ff; }
.card .stats .tchip.t-X { background: #0e5a56; color: #a8f0e6; }
.card .stats .tchip.t-A { background: #7a5c10; color: #ffe9a8; }

/* Имя — плашка ниже верхних стрелок, не пересекается с ними */
.card .cname {
  position: absolute; top: 17%; left: 50%; transform: translateX(-50%);
  max-width: 86%;
  display: flex; align-items: center; gap: 3px;
  font-size: calc(var(--cell, 100px) * 0.1);
  font-weight: 600;
  padding: 1.5% 6%;
  border-radius: 20px;
  background: rgba(6, 4, 12, 0.62);
  border: 1px solid rgba(216, 169, 75, 0.28);
  text-shadow: 0 1px 2px #000;
  white-space: nowrap; z-index: 3;
}
.card .cname span { overflow: hidden; text-overflow: ellipsis; }
.card .cname .clvl { font-style: normal; color: var(--gold-bright); font-size: 0.9em; }

/* Стрелки-руны: у самого края, тёмная обводка + золотое свечение */
.arr {
  position: absolute; width: 20%; height: 20%;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell, 100px) * 0.15);
  color: var(--gold-bright);
  text-shadow:
    -1px -1px 0 #14100a, 1px -1px 0 #14100a, -1px 1px 0 #14100a, 1px 1px 0 #14100a,
    0 0 7px rgba(255, 217, 122, 0.95);
  pointer-events: none; z-index: 5;
  line-height: 1;
}
.arr-N  { top: -3%; left: 40%; }
.arr-NE { top: -3%; right: -2%; }
.arr-E  { top: 40%; right: -2%; }
.arr-SE { bottom: -3%; right: -2%; }
.arr-S  { bottom: -3%; left: 40%; }
.arr-SW { bottom: -3%; left: -2%; }
.arr-W  { top: 40%; left: -2%; }
.arr-NW { top: -3%; left: -2%; }
/* Выбранная карта: стрелки пульсируют — читаются направления захвата */
.hand-card.selected .arr { animation: arrGlow 0.9s ease-in-out infinite; }
@keyframes arrGlow {
  0%, 100% { text-shadow: -1px -1px 0 #14100a, 1px -1px 0 #14100a, -1px 1px 0 #14100a, 1px 1px 0 #14100a, 0 0 6px rgba(255, 217, 122, 0.8); }
  50% { text-shadow: -1px -1px 0 #14100a, 1px -1px 0 #14100a, -1px 1px 0 #14100a, 1px 1px 0 #14100a, 0 0 14px rgba(255, 236, 170, 1); }
}

/* ---------- Руки ---------- */
.hand {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  min-height: calc(var(--hand-h, 108px) + 14px);
  padding: 4px 8px; z-index: 14;
  max-width: 100vw; overflow-x: auto; overflow-y: visible;
}
.hand-card {
  position: relative;
  width: calc(var(--hand-h, 108px) * 0.78); height: var(--hand-h, 108px);
  flex-shrink: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  /* масштаб типографики карты = реальная ШИРИНА карты, чтобы 4-й стат не подрезался */
  --cell: calc(var(--hand-h, 108px) * 0.78);
}
/* на узких картах руки иконки статов прячем — числа+цвета читаются полностью */
.hand-card .card .stats .sti { display: none; }
.hand-card .card .stats { padding-left: 6%; padding-right: 6%; }
/* зазор между физ- и маг-защитой, чтобы «6 3» не читалось как «63» */
.card .stats .st-md { margin-left: 3.5%; }
.hand-card .card { position: absolute; inset: 0; }
#player-hand .hand-card:hover { transform: translateY(-10px) scale(1.06); z-index: 5; }
.hand-card.selected { transform: translateY(-14px) scale(1.1) !important; z-index: 6; }
.hand-card.selected .card { box-shadow: 0 0 0 2px var(--gold-bright), 0 0 24px rgba(216, 169, 75, 0.6), 0 8px 20px rgba(0,0,0,0.6); }
.hand-card.disabled { opacity: 0.45; pointer-events: none; }
.card-back {
  position: absolute; inset: 0; border-radius: 7px;
  background:
    radial-gradient(circle at 50% 42%, rgba(216, 169, 75, 0.16), transparent 58%),
    linear-gradient(160deg, #241a44, #120c24);
  border: 2px solid #443463;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; opacity: 0.95;
}
#enemy-hand { --hand-h: 70px; min-height: 84px; }
#enemy-zone { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.zone-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--enemy); opacity: 0.9;
  background: rgba(30, 8, 12, 0.6);
  border: 1px solid rgba(255, 77, 94, 0.3);
  padding: 2px 12px; border-radius: 12px;
}
.zone-label b { color: #ff9aa5; }
.zone-label i { font-style: normal; color: var(--gold-bright); text-transform: none; letter-spacing: 0; }

/* ---------- Колесо Судьбы: слот-машина ---------- */
#wheel-box {
  background: linear-gradient(175deg, #251a3e, #120c22 70%);
  border: 1px solid rgba(216, 169, 75, 0.45);
  border-radius: 12px; padding: 0.6rem;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.wheel-title {
  font-family: var(--font-title); font-size: 0.78rem; letter-spacing: 0.14em;
  color: var(--gold-bright); text-transform: uppercase; margin-bottom: 0.5rem;
  text-shadow: 0 0 10px rgba(216, 169, 75, 0.5);
}
/* Металлическая рама вокруг рилов + пэйлайн */
#wheel-frame {
  position: relative;
  padding: 6px;
  border-radius: 9px;
  background: linear-gradient(180deg, #8a7a58, #3d3524 18%, #262013 50%, #3d3524 82%, #8a7a58);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
/* idle-shimmer: блик пробегает по раме */
#wheel-frame::after {
  content: ''; position: absolute; top: -60%; bottom: -60%; width: 34%;
  left: -50%;
  background: linear-gradient(105deg, transparent, rgba(255, 236, 180, 0.14), transparent);
  transform: rotate(12deg);
  animation: wheelShimmer 5.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes wheelShimmer { 0%, 62% { left: -50%; } 86%, 100% { left: 130%; } }
#wheel-reels { display: flex; gap: 4px; justify-content: center; }
.reel {
  width: 52px; height: 66px; overflow: hidden;
  border-radius: 5px;
  border: 1px solid #6b5a35;
  background: #0a0613;
  position: relative;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.9), inset 0 -3px 8px rgba(0, 0, 0, 0.9);
}
.reel::before, .reel::after {
  content: ''; position: absolute; left: 0; right: 0; height: 16px; z-index: 2; pointer-events: none;
}
.reel::before { top: 0; background: linear-gradient(rgba(6, 3, 12, 0.95), transparent); }
.reel::after { bottom: 0; background: linear-gradient(transparent, rgba(6, 3, 12, 0.95)); }
/* Пэйлайн по центру рилов */
#wheel-payline {
  position: absolute; left: 4px; right: 4px; top: 50%;
  height: 2px; margin-top: -1px;
  background: linear-gradient(90deg, transparent, rgba(255, 217, 122, 0.8), transparent);
  box-shadow: 0 0 8px rgba(255, 217, 122, 0.6);
  z-index: 3; pointer-events: none;
}
.reel-strip { transition: none; }
.reel-item {
  width: 52px; height: 66px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
}
.reel-item img { width: 38px; height: 38px; object-fit: cover; border-radius: 5px; border: 1px solid rgba(216, 169, 75, 0.35); }
.reel-item .reel-emoji { font-size: 25px; line-height: 38px; }
.reel-item .reel-num {
  font-size: 13px; font-weight: 800; color: #cfd2e2;
  font-family: 'Consolas', monospace;
  text-shadow: 0 1px 2px #000;
}
.reel-item .reel-num.seven {
  color: var(--gold-bright);
  text-shadow: 0 0 8px rgba(255, 217, 122, 0.9), 0 1px 2px #000;
}
.reel.spinning .reel-strip { filter: blur(2px); }
.reel.match {
  border-color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(255, 217, 122, 0.85), inset 0 0 12px rgba(255, 217, 122, 0.3);
}
/* Заряд: полоса + цифры X/100 */
#wheel-charge-row { display: flex; align-items: center; gap: 6px; margin-top: 0.55rem; }
#wheel-charge-wrap {
  flex: 1; height: 9px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.07); overflow: hidden;
  border: 1px solid rgba(216, 169, 75, 0.3);
}
#wheel-charge {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #7a5cff, var(--gold-bright));
  transition: width 0.5s ease;
  border-radius: 5px;
}
#wheel-charge-text {
  font-size: 0.66rem; font-family: 'Consolas', monospace;
  color: var(--gold-bright); opacity: 0.85;
  min-width: 42px; text-align: right;
}
#wheel-state {
  margin-top: 0.3rem;
  font-size: 0.64rem; letter-spacing: 0.08em;
  color: var(--gold); opacity: 0.75;
  font-style: italic;
}
#wheel-state.low { color: #8b8fa3; animation: lowBlink 1.6s ease-in-out infinite; }
@keyframes lowBlink { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.9; } }
/* SP кончился — Колесо дремлет */
#wheel-box.low-sp #wheel-frame { filter: saturate(0.55) brightness(0.8); }
#wheel-box.low-sp #wheel-payline { opacity: 0.35; }
/* Фаза Модуляции: напряжение — рамка и пэйлайн пульсируют */
#wheel-frame.modulation {
  animation: modulationPulse 0.55s ease-in-out infinite;
}
#wheel-frame.modulation #wheel-payline {
  background: linear-gradient(90deg, transparent, rgba(255, 120, 90, 0.95), transparent);
  box-shadow: 0 0 14px rgba(255, 120, 90, 0.85);
}
@keyframes modulationPulse {
  0%, 100% { box-shadow: inset 0 0 8px rgba(0,0,0,0.8), 0 0 10px rgba(255, 157, 77, 0.35); }
  50% { box-shadow: inset 0 0 8px rgba(0,0,0,0.8), 0 0 26px rgba(255, 157, 77, 0.8); }
}

/* ---------- ПРИЗЫВ: синематика покровителя ---------- */
.summon-overlay {
  position: absolute; inset: 0; z-index: 46;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.7rem;
  background: radial-gradient(ellipse at center, rgba(30, 16, 50, 0.55), rgba(5, 3, 10, 0.92) 78%);
  animation: summonIn 0.35s ease both;
  pointer-events: none;
}
@keyframes summonIn { from { opacity: 0; } to { opacity: 1; } }
.summon-overlay.leaving { animation: summonOut 0.45s ease both; }
@keyframes summonOut { to { opacity: 0; } }
.summon-rays {
  position: absolute; width: 130vmax; height: 130vmax;
  background: repeating-conic-gradient(rgba(216, 169, 75, 0.14) 0 7deg, transparent 7deg 18deg);
  animation: raysSpin 9s linear infinite;
  border-radius: 50%;
}
@keyframes raysSpin { to { transform: rotate(360deg); } }
.summon-portrait {
  position: relative; z-index: 2;
  width: min(38vmin, 220px); height: min(38vmin, 220px);
  border-radius: 50%;
  border: 3px solid var(--gold-bright);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(216, 169, 75, 0.75), 0 0 130px rgba(216, 169, 75, 0.3);
  animation: portraitIn 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes portraitIn { from { transform: scale(0.2) rotate(-16deg); opacity: 0; } to { transform: none; opacity: 1; } }
.summon-portrait img { width: 100%; height: 100%; object-fit: cover; }
.summon-emoji { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 5rem; background: #241a44; }
.summon-name {
  position: relative; z-index: 2;
  font-family: var(--font-title);
  font-size: clamp(1.4rem, 5vw, 2.6rem);
  letter-spacing: 0.1em; color: var(--gold-bright);
  text-shadow: 0 0 26px rgba(216, 169, 75, 0.9), 0 3px 8px #000;
  animation: lineIn 0.5s 0.25s ease both;
}
.summon-desc {
  position: relative; z-index: 2;
  font-size: 0.95rem; opacity: 0.9; font-style: italic;
  max-width: 80vw; text-align: center;
  animation: lineIn 0.5s 0.45s ease both;
}

/* ---------- Сайдбар: секции, реликвии-слоты, свитки, инфо ---------- */
.side-section { display: flex; flex-direction: column; gap: 4px; }
.side-label {
  font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.2em;
  color: var(--gold); opacity: 0.8;
}
#side-info {
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(14, 9, 26, 0.7);
  border: 1px solid rgba(140, 120, 200, 0.22);
  border-radius: 10px; padding: 0.55rem;
}
.region-emblem { display: flex; align-items: center; gap: 8px; }
.region-emblem .ic-region {
  padding: 4px; border-radius: 50%;
  border: 1px solid rgba(216, 169, 75, 0.45);
  background: radial-gradient(circle, rgba(216, 169, 75, 0.12), transparent 75%);
  box-sizing: content-box;
}
.region-name { font-family: var(--font-title); font-size: 0.82rem; color: var(--gold-bright); line-height: 1.2; }
#blind-ladder { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ladder-step {
  font-size: 0.66rem; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 10px;
  border: 1px solid rgba(140, 120, 200, 0.3);
  opacity: 0.55;
}
.ladder-step.done { opacity: 0.8; border-color: rgba(79, 196, 122, 0.5); color: #8ff0b4; }
.ladder-step.now {
  opacity: 1; color: var(--gold-bright);
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(216, 169, 75, 0.35);
}
.ladder-sep { opacity: 0.4; font-size: 0.7rem; }
.deck-count { font-size: 0.74rem; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.deck-count b { color: var(--gold-bright); }

#relic-bar, #scroll-bar { display: flex; flex-wrap: wrap; gap: 5px; }
.relic-chip, .scroll-chip {
  width: 38px; height: 38px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(170deg, rgba(38, 27, 66, 0.95), rgba(18, 12, 34, 0.95));
  border: 1px solid rgba(216, 169, 75, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 5px rgba(0, 0, 0, 0.5);
  cursor: help; position: relative;
}
.relic-chip.empty-slot {
  background: rgba(14, 9, 24, 0.6);
  border: 1px dashed rgba(140, 120, 200, 0.3);
  box-shadow: none;
}
.slot-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(140, 120, 200, 0.35); }
.scrolls-none { font-size: 0.68rem; opacity: 0.45; font-style: italic; padding: 4px 0; }
.scroll-chip { cursor: pointer; border-color: rgba(122, 92, 255, 0.55); }
.scroll-chip:hover { border-color: var(--gold-bright); box-shadow: 0 0 10px rgba(216, 169, 75, 0.4); transform: translateY(-1px); }
.relic-chip:hover .tip, .scroll-chip:hover .tip, .relic-chip.tip-open .tip { display: block; }
.tip {
  display: none; position: absolute; right: 105%; top: 50%; transform: translateY(-50%);
  width: 180px; padding: 7px 9px; z-index: 60;
  background: rgba(8, 5, 15, 0.96); border: 1px solid var(--gold);
  border-radius: 8px; font-size: 0.72rem; line-height: 1.4;
  pointer-events: none; text-align: left;
}
.tip b { color: var(--gold-bright); }

#turn-indicator { text-align: center; font-size: 0.85rem; letter-spacing: 0.1em; opacity: 0.85; min-height: 1.4em; }
#turn-indicator.enemy-turn { color: var(--enemy); }
#turn-indicator.player-turn { color: var(--player); }

/* ---------- Лавка ---------- */
.shop-box {
  width: min(94vw, 760px); max-height: 92vh; overflow-y: auto;
  background: rgba(10, 7, 18, 0.88);
  border: 1px solid rgba(216, 169, 75, 0.35);
  border-radius: 14px; padding: 1.6rem;
  backdrop-filter: blur(6px);
}
.shop-box h2 { font-family: var(--font-title); color: var(--gold-bright); text-align: center; letter-spacing: 0.06em; }
#shop-flavor { text-align: center; opacity: 0.6; font-style: italic; font-size: 0.85rem; margin: 0.3rem 0 1rem; }
.shop-gold { text-align: center; font-size: 1.25rem; color: var(--gold-bright); margin-bottom: 1rem; }
#shop-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.shop-item {
  position: relative;
  background: rgba(24, 17, 44, 0.8);
  border: 1px solid rgba(140, 120, 200, 0.25);
  border-radius: 10px; padding: 0.7rem;
  display: flex; flex-direction: column; gap: 0.3rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.shop-item:not(.sold):hover { border-color: var(--gold); box-shadow: 0 0 14px rgba(216, 169, 75, 0.25); transform: translateY(-2px); }
.shop-item.sold { opacity: 0.35; filter: grayscale(0.8); }
.shop-item .si-head { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.shop-item .si-icon { display: inline-flex; align-items: center; color: var(--gold-bright); }
.shop-item .si-emoji { font-size: 1.35rem; line-height: 1; }
.shop-item .si-kind { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.12em; opacity: 0.55; }
.shop-item .si-desc { font-size: 0.78rem; opacity: 0.8; line-height: 1.45; flex: 1; }
.shop-item .si-buy {
  align-self: stretch; margin-top: 0.4rem;
  font-size: 0.9rem; padding: 0.45em;
}
.shop-item .si-card-mini { font-family: 'Consolas', monospace; font-size: 0.8rem; color: var(--gold-bright); }
.shop-actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; }
#shop-deck-info { margin-top: 1rem; font-size: 0.8rem; opacity: 0.65; text-align: center; }
#shop-scrolls { display: flex; gap: 6px; justify-content: center; margin-top: 0.5rem; flex-wrap: wrap; }

/* ---------- Финал ---------- */
.end-box {
  text-align: center; width: min(92vw, 620px); max-height: 92vh; overflow-y: auto;
  background: rgba(10, 7, 18, 0.88);
  border: 1px solid rgba(216, 169, 75, 0.4);
  border-radius: 14px; padding: 2.2rem;
  animation: menuIn 0.9s ease both;
}
#end-title { font-family: var(--font-title); font-size: 2rem; letter-spacing: 0.05em; }
#end-title.victory { color: var(--gold-bright); text-shadow: 0 0 26px rgba(216, 169, 75, 0.6); }
#end-title.defeat { color: var(--enemy); text-shadow: 0 0 26px rgba(255, 77, 94, 0.5); }
#end-story { margin: 1.2rem 0; line-height: 1.65; opacity: 0.9; }
#end-story p { margin: 0.5em 0; }
#end-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px;
  margin: 1.4rem 0;
}
.stat-tile {
  background: rgba(24, 17, 44, 0.8); border: 1px solid rgba(140, 120, 200, 0.25);
  border-radius: 10px; padding: 0.6rem;
}
.stat-tile .sv { font-size: 1.3rem; font-weight: 700; color: var(--gold-bright); }
.stat-tile .sl { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.6; }

/* ---------- Оверлеи ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(5, 3, 10, 0.78);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  animation: overlayIn 0.3s ease both;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.recap-box, .howto-box {
  width: min(92vw, 520px); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(170deg, #1c1433, #100b1f);
  border: 1px solid var(--gold); border-radius: 14px;
  padding: 1.8rem; text-align: center;
  box-shadow: 0 0 60px rgba(216, 169, 75, 0.2);
}
.recap-box h3, .howto-box h3 { font-family: var(--font-title); color: var(--gold-bright); margin-bottom: 1rem; letter-spacing: 0.08em; }
#recap-plates { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 1rem; }
#recap-steps { display: flex; flex-direction: column; gap: 5px; margin-bottom: 1rem; min-height: 40px; max-height: 34vh; overflow-y: auto; }
.recap-step {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.35em 0.8em; border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.9rem;
  opacity: 0; transform: translateX(-14px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.recap-step.shown { opacity: 1; transform: none; }
.recap-step .rv { font-weight: 700; font-family: 'Consolas', monospace; }
.recap-step.k-chips .rv { color: var(--player); }
.recap-step.k-mult .rv { color: var(--gold-bright); }
.recap-step.k-xmult .rv { color: #c77dff; }
#recap-total {
  font-size: 2rem; font-weight: 800; font-family: 'Consolas', monospace;
  color: var(--gold-bright); text-shadow: 0 0 20px rgba(216, 169, 75, 0.55);
  margin: 0.6rem 0; min-height: 1.2em;
}
#recap-verdict { font-family: var(--font-title); font-size: 1.2rem; min-height: 1.5em; letter-spacing: 0.1em; }
#recap-verdict.win { color: var(--rar-uncommon); }
#recap-verdict.lose { color: var(--enemy); }
.howto-text { text-align: left; font-size: 0.88rem; line-height: 1.6; }
.howto-text p { margin: 0.6em 0; }
.howto-text b { color: var(--gold-bright); }

/* ---------- FX-слои ---------- */
#fx-canvas { position: absolute; inset: 0; z-index: 35; pointer-events: none; }
#shout-layer {
  position: absolute; inset: 0; z-index: 38; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.shout {
  font-family: var(--font-title);
  font-size: clamp(2rem, 7vw, 4.4rem);
  font-weight: 800; letter-spacing: 0.06em;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(216, 169, 75, 0.8), 0 4px 10px #000;
  animation: shoutIn 1.1s cubic-bezier(0.22, 1.4, 0.36, 1) both;
  white-space: nowrap;
}
.shout.combo-2 { color: #ffb86b; }
.shout.combo-3 { color: #ff8c5a; font-size: clamp(2.4rem, 8vw, 5rem); }
.shout.combo-big { color: #ff5a5a; font-size: clamp(2.8rem, 9vw, 5.8rem); }
@keyframes shoutIn {
  0% { opacity: 0; transform: scale(2.4); }
  18% { opacity: 1; transform: scale(1); }
  78% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(1.08) translateY(-12px); }
}
.float-text {
  position: absolute; z-index: 37; pointer-events: none;
  font-weight: 800; font-family: 'Consolas', monospace;
  text-shadow: 0 1px 3px #000;
  animation: floatUp 1s ease-out both;
}
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-46px); } }

#toast-layer {
  position: absolute; left: 50%; bottom: 14vh; transform: translateX(-50%);
  z-index: 42; display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: rgba(10, 7, 18, 0.92);
  border: 1px solid rgba(216, 169, 75, 0.5);
  color: var(--parchment);
  padding: 0.5em 1.1em; border-radius: 20px;
  font-size: 0.88rem;
  animation: toastIn 3.2s ease both;
  max-width: 92vw; text-align: center;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateY(12px); }
  8%, 82% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-8px); }
}

/* Тряска экрана */
#app.shake-1 { animation: shake1 0.25s; }
#app.shake-2 { animation: shake2 0.4s; }
#app.shake-3 { animation: shake3 0.6s; }
@keyframes shake1 { 25% { transform: translate(3px, -2px); } 50% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, 1px); } }
@keyframes shake2 { 20% { transform: translate(6px, -4px) rotate(0.3deg); } 40% { transform: translate(-6px, 4px); } 60% { transform: translate(4px, -3px) rotate(-0.3deg); } 80% { transform: translate(-3px, 2px); } }
@keyframes shake3 { 15% { transform: translate(10px, -7px) rotate(0.6deg); } 30% { transform: translate(-10px, 7px) rotate(-0.5deg); } 45% { transform: translate(8px, -5px); } 60% { transform: translate(-7px, 4px) rotate(0.4deg); } 75% { transform: translate(5px, -3px); } 90% { transform: translate(-3px, 2px); } }

/* Анимации карт */
.card.placing { animation: cardPlace 0.32s cubic-bezier(0.34, 1.5, 0.64, 1) both; }
@keyframes cardPlace {
  0% { transform: translateY(-60px) scale(1.25); opacity: 0.4; }
  70% { transform: translateY(2px) scale(0.97); opacity: 1; }
  100% { transform: none; }
}
.card.flipping { animation: cardFlip 0.5s ease both; }
@keyframes cardFlip {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(90deg) scale(1.08); }
  100% { transform: rotateY(0); }
}
.card.battle-flash { animation: battleFlash 0.5s ease; }
@keyframes battleFlash {
  0%, 100% { filter: none; }
  30% { filter: brightness(2.2) saturate(1.6); }
}

/* ---------- Аудио-контролы ---------- */
#audio-controls {
  position: absolute; right: 10px; bottom: 10px; z-index: 50;
  display: flex; gap: 6px; align-items: center;
  background: rgba(10, 7, 18, 0.75);
  border: 1px solid rgba(140, 120, 200, 0.3);
  border-radius: 20px; padding: 4px 10px;
}
#btn-mute { background: none; border: none; font-size: 1.1rem; cursor: pointer; }
#vol-slider { width: 74px; accent-color: var(--gold); }

/* ---------- Мобильная раскладка (портрет, ≤820px) ----------
   Колесо переезжает компактной лентой вверх боевого экрана (JS перевешивает DOM),
   сайдбар (регион/реликвии/свитки) — в шторку по кнопке. */
#side-toggle {
  position: absolute;
  left: calc(10px + env(safe-area-inset-left, 0px));
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 55;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(14, 9, 26, 0.92);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.6);
}
#side-toggle.active { background: rgba(60, 44, 16, 0.95); box-shadow: 0 0 16px rgba(216, 169, 75, 0.5); }

@media (max-width: 820px) {
  #screen-battle { flex-direction: column; }
  #battle-top {
    flex-wrap: wrap; row-gap: 3px;
    padding: 0.35rem calc(0.5rem + env(safe-area-inset-right, 0px)) 0.35rem calc(0.5rem + env(safe-area-inset-left, 0px));
  }
  #blind-info { display: flex; gap: 6px; align-items: baseline; max-width: 55vw; }
  #blind-name { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #score-panel { order: 3; width: 100%; justify-content: center; gap: 4px; }
  .plate { min-width: 0; padding: 3px 7px; }
  .plate b { font-size: 0.95rem; }
  .plate-label { font-size: 0.5rem; letter-spacing: 0.1em; }
  .score-op { font-size: 0.95rem; }
  #run-info { flex-direction: column; gap: 3px; align-items: flex-end; }
  .hud-chip { padding: 2px 7px; font-size: 0.7rem; }
  #blind-region { display: none; }
  #boss-rule-banner { top: 84px; font-size: 0.68rem; }

  /* Нижняя строка-панель для плавающих контролов: рука приподнята,
     кнопка-шторка и аудио живут в собственной зоне — хит-боксы не пересекаются с картами */
  #battle-main { padding: 5.6rem 0.3rem calc(56px + env(safe-area-inset-bottom, 0px)); }
  #screen-battle::after {
    content: '';
    position: absolute; left: 0; right: 0; bottom: 0;
    height: calc(52px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(0deg, rgba(6, 4, 12, 0.95) 60%, transparent);
    border-top: 1px solid rgba(140, 120, 200, 0.18);
    pointer-events: none;
    z-index: 40;
  }

  /* Колесо — компактная лента вверху боевого экрана (всегда видно) */
  #battle-main > #wheel-box {
    display: flex; align-items: center; gap: 8px;
    padding: 0.25rem 0.6rem;
    margin-bottom: 0.2rem;
    align-self: center;
  }
  #battle-main > #wheel-box .wheel-title { display: none; }
  #battle-main > #wheel-box #wheel-frame { padding: 3px; }
  #battle-main > #wheel-box .reel { width: 34px; height: 44px; }
  #battle-main > #wheel-box .reel-item { width: 34px; height: 44px; }
  #battle-main > #wheel-box .reel-item img { width: 24px; height: 24px; }
  #battle-main > #wheel-box .reel-item .reel-emoji { font-size: 16px; line-height: 24px; }
  #battle-main > #wheel-box .reel-item .reel-num { font-size: 10px; }
  #battle-main > #wheel-box #wheel-charge-row { margin-top: 0; width: 92px; flex-direction: column; gap: 2px; }
  #battle-main > #wheel-box #wheel-charge-text { min-width: 0; text-align: center; font-size: 0.6rem; }
  #battle-main > #wheel-box #wheel-state { display: none; }

  /* Сайдбар — шторка снизу */
  #battle-side.drawer { display: none; }
  #battle-side.drawer.open {
    display: flex; flex-direction: column; gap: 0.8rem;
    position: absolute; left: 0; right: 0; bottom: 0;
    max-height: 62vh; overflow-y: auto;
    width: auto;
    z-index: 54;
    background: rgba(8, 5, 15, 0.97);
    border-top: 1px solid var(--gold);
    border-radius: 14px 14px 0 0;
    padding: 0.9rem 1rem calc(4.2rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7);
    animation: drawerUp 0.25s ease both;
  }
  @keyframes drawerUp { from { transform: translateY(30%); opacity: 0; } to { transform: none; opacity: 1; } }
  /* тап-таргеты в шторке ≥44px */
  #battle-side.drawer.open .relic-chip,
  #battle-side.drawer.open .scroll-chip { width: 44px; height: 44px; }
  #battle-side.drawer.open .tip { right: auto; left: 0; top: auto; bottom: 110%; transform: none; }
  #battle-side.drawer.open #turn-indicator { display: block; text-align: left; }

  /* Руки: горизонтальная лента, центр — авто-полями (без обрезки начала) */
  .hand { --hand-h: 86px; justify-content: flex-start; }
  .hand > :first-child { margin-left: auto; }
  .hand > :last-child { margin-right: auto; }
  #enemy-hand { --hand-h: 50px; min-height: 58px; }
  .zone-label { font-size: 0.6rem; padding: 1px 8px; }

  #board { --cell: min(10.5vh, 20vw, 92px); gap: 5px; padding: 7px; }
  #board.n5 { --cell: min(8.6vh, 16vw, 72px); }

  #recap-plates .plate.big { min-width: 84px; padding: 5px 10px; }
  #recap-plates .plate.big b { font-size: 1.4rem; }
  .summon-portrait { width: 34vmin; height: 34vmin; }
  .summon-rays { display: none; } /* облегчённый вариант на мобиле */

  /* контролы — в нижней строке-панели (НЕ поверх карт руки) */
  #side-toggle {
    width: 42px; height: 42px;
    bottom: calc(5px + env(safe-area-inset-bottom, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    z-index: 56;
  }
  #audio-controls {
    bottom: calc(7px + env(safe-area-inset-bottom, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    z-index: 56;
  }

  /* читаемость статов на картах руки — крупнее */
  .hand-card .card .stats b { font-size: calc(var(--cell, 100px) * 0.175); }
  .hand-card .card .stats .tchip { font-size: calc(var(--cell, 100px) * 0.135); }
}
@media (max-width: 400px) {
  #board { --cell: min(10vh, 21.5vw, 84px); gap: 4px; padding: 6px; }
  #board.n5 { --cell: min(8.4vh, 17vw, 66px); }
  .hand { --hand-h: 78px; }
  #battle-main { padding-top: 5.4rem; }
  #battle-main > #wheel-box #wheel-charge-row { width: 74px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
