/* ══════════════ Базовое ══════════════ */
:root {
  --bg:        #14110d;
  --bg-2:      #1d1913;
  --panel:     #241f17;
  --panel-2:   #2e2718;
  --line:      #453a26;
  --gold:      #c9a961;
  --gold-hi:   #e8cf8e;
  --gold-dim:  #8a7440;
  --ink:       #ece1c8;
  --ink-dim:   #a89b80;
  --red:       #a3392f;
  --green:     #5d8a4a;
  --blue:      #4a7fb5;
  /* Типографика: заголовки — антиква Cormorant, интерфейс и цифры — Manrope. */
  --font-display: 'Cormorant', Georgia, serif;
  --font-ui: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  /* Поверхности */
  --radius: 10px;
  --radius-s: 7px;
  --surface: linear-gradient(180deg, #2a2419 0%, #221d14 100%);
  --shadow: 0 10px 28px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.045);
  /* Размеры считаются от высоты экрана: на большом мониторе карты крупные,
     но шесть рядов, рука и панели всегда влезают без прокрутки. */
  --hand-h: clamp(112px, 20dvh, 210px);
  --hand-w: calc(var(--hand-h) * 0.75);
  --card-h: clamp(64px, calc((100dvh - var(--hand-h) - 168px) / 6), 140px);
  --card-w: calc(var(--card-h) * 0.75);
}

* { box-sizing: border-box; }

/* Любое правило с display перебивает атрибут hidden — возвращаем ему силу.
   Иначе скрытые экраны (меню, доска, модалка) остаются на странице. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse 120% 70% at 50% -10%, #322a1b 0%, transparent 55%),
    radial-gradient(ellipse 90% 60% at 50% 115%, #251e13 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }

/* Все игровые числа — моноширинные цифры Manrope, строго по центру своих плашек. */
.card-power, .row-score, .pi-total, .round-scores b {
  font-family: var(--font-ui);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.screen { height: 100vh; }

/* ══════════════ Меню ══════════════ */
#menu {
  display: grid;
  place-items: center;
  overflow-y: auto;
}
.menu-inner {
  width: min(880px, 92vw);
  padding: 32px 0 48px;
  text-align: center;
}
.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 76px;
  letter-spacing: 16px;
  margin: 8px 0 0;
  background: linear-gradient(180deg, var(--gold-hi) 20%, var(--gold) 55%, #9a7d43 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 44px rgba(201,169,97,.28);
}
.subtitle { color: var(--ink-dim); margin: 0 0 30px; letter-spacing: 3px; font-size: 13px; }

.menu-block { margin-bottom: 24px; }
.menu-block h2 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 3.5px;
  color: var(--gold-dim); font-weight: 700; margin-bottom: 10px;
}

.faction-list { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.faction-card {
  width: 190px; padding: 13px 14px; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--radius); text-align: left;
  color: var(--ink); transition: border-color .15s, transform .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.faction-list.small .faction-card { width: 150px; padding: 9px 11px; }
.faction-card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.faction-card.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow); }
.faction-card b { display: block; font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.faction-card span { font-size: 11.5px; color: var(--ink-dim); line-height: 1.45; }

.leader-list { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.leader-card {
  width: 254px; padding: 9px 11px; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--radius); text-align: left; color: var(--ink);
  display: flex; gap: 11px; align-items: center;
  transition: border-color .15s, transform .15s;
  box-shadow: var(--shadow);
}
.leader-card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.leader-card.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow); }
.leader-portrait {
  width: 44px; height: 61px; flex: none; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--gold-dim);
}
.leader-portrait svg { width: 100%; height: 100%; display: block; }
.leader-info { min-width: 0; }
.leader-card b { display: block; font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.leader-card span { font-size: 11px; color: var(--ink-dim); line-height: 1.4; }

/* — Лобби — */
.mode-switch { display: flex; gap: 8px; justify-content: center; }
.mode-btn { min-width: 170px; }
.mode-btn.sel { border-color: var(--gold); color: var(--gold); background: var(--panel-2); }

.net-connect { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.nick-input {
  background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: var(--radius-s);
  color: var(--ink); padding: 10px 14px; font-family: inherit; font-size: 14px; width: 220px;
  transition: border-color .15s;
}
.nick-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,169,97,.15); }
.net-status { color: var(--ink-dim); font-size: 12.5px; margin-bottom: 10px; }
.net-players { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 40px; }
.net-empty { color: var(--ink-dim); font-size: 12px; }
.net-player {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-s);
  color: var(--ink); padding: 9px 15px; text-align: left; min-width: 130px;
  transition: border-color .15s, transform .15s;
}
.net-player:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-1px); }
.net-player b { display: block; font-size: 13px; font-weight: 700; }
.net-player span { font-size: 10.5px; color: var(--ink-dim); }
.net-player.busy { opacity: .45; cursor: not-allowed; }

a.btn { text-decoration: none; display: inline-block; }
.btn {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); padding: 11px 24px; border-radius: var(--radius-s);
  letter-spacing: .09em; font-size: 12.5px; font-weight: 700; text-transform: uppercase;
  transition: border-color .15s, color .15s, transform .12s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-hi); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #57482a, #33291a);
  border-color: var(--gold-dim); color: var(--gold-hi); margin-top: 8px;
}
.btn-ghost { background: none; border-color: transparent; color: var(--ink-dim); box-shadow: none; }
.btn.small { padding: 7px 13px; font-size: 11px; }

/* ══════════════ Поле ══════════════ */
/* Доска — тёплое дерево с едва заметными досками, как стол в оригинале. */
#board {
  display: grid;
  grid-template-columns: clamp(210px, 15vw, 260px) minmax(0, 1fr) clamp(260px, 21vw, 340px);
  gap: 8px;
  padding: 10px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.014) 0 2px, transparent 2px 170px),
    radial-gradient(ellipse 110% 80% at 50% 0%, #2c2011 0%, transparent 60%),
    linear-gradient(180deg, #211708, #180f06);
}

.col-left, .col-right {
  display: flex; flex-direction: column; gap: 8px; min-height: 0;
}
/* Слева: соперник сверху, погода по центру, вы — снизу, как в оригинале. */
.col-left { justify-content: space-between; }
.col-field { display: flex; flex-direction: column; gap: 4px; min-height: 0; }

/* — Инфо игрока — */
.player-info {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; font-size: 13.5px;
  box-shadow: var(--shadow);
}
.player-info.active { border-color: var(--gold); box-shadow: 0 0 12px rgba(201,169,97,.15); }
.pi-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.pi-leader {
  width: 42px; height: 42px; overflow: hidden;
  border: 1px solid var(--gold-dim); border-radius: 50%; background: var(--panel-2);
  flex: none;
}
.pi-leader svg { width: 100%; height: 100%; display: block; }
.pi-name { font-size: 15px; font-weight: 700; }
.pi-faction { font-size: 11.5px; color: var(--ink-dim); }
.pi-stats { display: flex; gap: 10px; align-items: center; }
.pi-total {
  margin-left: auto; font-size: 21px; color: var(--gold-hi);
  min-width: 48px; height: 48px; display: grid; place-items: center;
  border: 1px solid var(--gold-dim); border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, rgba(201,169,97,.18), rgba(0,0,0,.35));
}
.pi-row { display: flex; justify-content: space-between; color: var(--ink-dim); font-size: 12.5px; margin-top: 5px; }
.gems { display: flex; gap: 5px; }
.gem { width: 13px; height: 13px; border-radius: 50%; background: #3a3226; border: 1px solid var(--line); }
.gem.on { background: radial-gradient(circle at 35% 30%, #ffe9a8, var(--gold)); border-color: var(--gold); }
.pi-passed { color: var(--red); font-size: 11px; }
.pi-counts { display: none; }

/* — Погода — */
.weather-zone {
  flex: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px 12px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.zone-label { font-size: 10px; text-transform: uppercase; letter-spacing: 2.5px; font-weight: 700; color: var(--gold-dim); margin-bottom: 8px; }
.weather-cards {
  display: flex; gap: 6px; flex-wrap: wrap;
  align-items: center; justify-content: center; min-height: 96px;
}
/* Слоты погоды — карты заметного размера, максимум три штуки. */
.weather-zone .card { width: 68px; height: 92px; }
.weather-zone.targetable { border-color: var(--gold); box-shadow: 0 0 14px rgba(201,169,97,.3) inset; cursor: pointer; }

/* — Ряды — */
/* Ряды делят доступную высоту поровну, поэтому доска всегда влезает в экран. */
.rows { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; }
.row {
  display: grid; grid-template-columns: 46px 30px 42px 1fr;
  align-items: center; gap: 6px;
  background: linear-gradient(180deg, rgba(66,50,28,.5), rgba(36,27,15,.62));
  border: 1px solid rgba(97,76,42,.55); border-radius: var(--radius-s);
  flex: 1; min-height: 0; padding: 4px 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045), inset 0 -8px 18px rgba(0,0,0,.25);
}
/* Своя половина стола чуть теплее вражеской. */
.row[data-side="player"] { background: linear-gradient(180deg, rgba(78,58,30,.5), rgba(42,31,16,.62)); }
.row.targetable { border-color: var(--gold); box-shadow: 0 0 20px rgba(201,169,97,.25) inset; cursor: pointer; }
.row.targetable:hover { background: linear-gradient(180deg, rgba(96,78,44,.6), rgba(52,40,22,.7)); }
/* Медальон счёта ряда */
.row-score {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid #9c7f47;
  background: radial-gradient(circle at 35% 28%, #4a3a20, #241a0c 75%);
  color: var(--gold-hi); font-size: 16px;
  box-shadow: 0 3px 8px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12);
}
.row-horn {
  width: 28px; height: 42px; display: grid; place-items: center;
  border: 1px dashed rgba(97,76,42,.6); border-radius: var(--radius-s); font-size: 15px; color: var(--ink-dim);
}
.row-horn.on {
  border-style: solid; border-color: var(--gold); color: var(--gold-hi);
  background: radial-gradient(circle, rgba(201,169,97,.28), transparent 72%);
  animation: hornPulse 2.4s ease-in-out infinite;
}
@keyframes hornPulse { 50% { box-shadow: 0 0 14px rgba(201,169,97,.55); } }
/* Фоновая иконка типа ряда — как чеканка на планке. */
.row-icon { width: 42px; height: 42px; color: var(--gold); opacity: .17; }
.row-icon svg { width: 100%; height: 100%; display: block; }
/* Карты в ряду и в руке не переносятся, а надвигаются друг на друга:
   отступ считает JS в зависимости от того, сколько их набралось. */
.row-cards { display: flex; gap: 0; flex-wrap: nowrap; align-items: center; }
.row-cards .card { margin-right: 3px; flex: none; }
.row-cards .card:hover { transform: translateY(-6px); z-index: 20; }
.row.weathered { filter: saturate(.8) brightness(.92); }

.mid-line {
  height: 24px; display: grid; place-items: center;
  border-top: 1px solid rgba(201,169,97,.18); border-bottom: 1px solid rgba(201,169,97,.18);
  background: linear-gradient(90deg, transparent, rgba(201,169,97,.08) 30%, rgba(201,169,97,.08) 70%, transparent);
  font-size: 11px; letter-spacing: 3.5px; font-weight: 700; color: var(--gold-dim); text-transform: uppercase;
}

/* ══════════════ Карты ══════════════ */
/* Иллюстрация занимает всю карту; поверх — сила, имя и значки способностей. */
.card {
  width: var(--card-w); height: var(--card-h);
  border: 1px solid #6a5834; border-radius: 8px;
  background: #221d15;
  position: relative; overflow: hidden;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 3px 10px rgba(0,0,0,.5), inset 0 0 0 1px rgba(0,0,0,.35);
  /* Шрифты и значки внутри меряются от ширины карты (cqw) —
     одна и та же разметка работает от ряда на телефоне до крупного просмотра. */
  container-type: size;
}
.card-art { position: absolute; inset: 0; }
.card-art svg { width: 100%; height: 100%; display: block; }
/* Настоящая иллюстрация ложится поверх SVG-заглушки, когда загрузится. */
.card-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.pi-leader, .leader-mini, .leader-portrait { position: relative; }

.card.hero {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(201,169,97,.35), 0 2px 8px rgba(0,0,0,.5);
}
.card.special { border-color: #4a6a88; }
.card.spy { border-color: #8a63b0; }
.card.back { border-color: var(--gold-dim); }

.card-power {
  position: absolute; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(16,12,6,.9); border: 1px solid var(--gold-dim);
  color: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08);
  top: 4cqw; left: 4cqw;
  width: 20px; height: 20px; font-size: 11px;      /* фолбэк без container queries */
  width: 33cqw; height: 33cqw; font-size: 17cqw;
}
.card.hero .card-power {
  background: radial-gradient(circle at 35% 28%, #ffeeb2, var(--gold) 70%);
  color: #241c0c; border-color: #f0dfa4;
  box-shadow: 0 2px 6px rgba(0,0,0,.55), 0 0 10px rgba(201,169,97,.45);
}
.card-power.buffed { border-color: var(--green); color: #b6e39a; }
.card-power.nerfed { border-color: #7fa9d8; color: #a9d0ff; }

.card-name {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  text-align: center; line-height: 1.2; color: #f2ead6;
  font-weight: 600; letter-spacing: .01em;
  background: linear-gradient(180deg, transparent, rgba(8,6,2,.85) 48%, rgba(8,6,2,.96));
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
  font-size: 6.5px; padding: 7px 2px 2px;          /* фолбэк */
  font-size: 10.5cqw; padding: 14cqw 3cqw 4cqw;
}
.card-badges {
  position: absolute; z-index: 2;
  display: flex; flex-direction: column; gap: 1px; align-items: center;
  background: rgba(16,12,6,.8); border-radius: 999px; padding: 2cqw 3cqw;
  border: 1px solid rgba(138,116,64,.5);
  top: 4cqw; right: 4cqw;
  font-size: 8px;                                  /* фолбэк */
  font-size: 13cqw;
}
.card-badges:empty { display: none; }

/* — Рука: отдельная планка внизу стола, как в оригинале — */
.hand-wrap {
  flex: none; margin-top: 5px; padding: 8px 10px;
  height: calc(var(--hand-h) + 22px);
  background: linear-gradient(180deg, rgba(84,63,33,.35), rgba(44,32,16,.55));
  border: 1px solid rgba(122,96,52,.5); border-radius: var(--radius-s);
  box-shadow: inset 0 2px 10px rgba(0,0,0,.35);
}
.hand {
  display: flex; gap: 0; justify-content: center; flex-wrap: nowrap;
  height: var(--hand-h); align-items: flex-end;
}
.hand .card { width: var(--hand-w); height: var(--hand-h); cursor: pointer; flex: none; }
.hand .card:hover { transform: translateY(-12px); box-shadow: 0 8px 22px rgba(0,0,0,.6); z-index: 40 !important; }
.hand .card.sel { transform: translateY(-14px); border-color: var(--gold); box-shadow: 0 0 16px rgba(201,169,97,.5); z-index: 41 !important; }
.hand .card.unplayable { opacity: .4; }

/* — Правая колонка — */
.actions { display: flex; flex-direction: column; gap: 6px; }
.btn-leader {
  text-align: left; font-size: 12.5px; letter-spacing: 0; padding: 9px 11px;
  line-height: 1.4; text-transform: none; font-weight: 600;
  display: flex; gap: 11px; align-items: center;
}
.leader-mini {
  width: 38px; height: 53px; flex: none; border-radius: 5px; overflow: hidden;
  border: 1px solid var(--gold-dim);
}
.leader-mini svg { width: 100%; height: 100%; display: block; }
.leader-text { min-width: 0; }
.btn-leader.used { opacity: .4; }
.btn-pass { border-color: var(--red); color: #e0a49c; }
.btn-pass:hover:not(:disabled) { background: #3a1e1a; border-color: var(--red); color: #ffc9c0; }

.log {
  flex: 1; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 11px;
  font-size: 12.5px; line-height: 1.5; color: var(--ink-dim);
  box-shadow: var(--shadow);
}
.log div { margin-bottom: 5px; padding-left: 7px; border-left: 2px solid transparent; }
.log .player { border-left-color: var(--blue); color: var(--ink); }
.log .enemy  { border-left-color: var(--red); }
.log .round  { border-left-color: var(--gold); color: var(--gold); text-align: center; padding: 3px 0; }
.log .burn   { border-left-color: #d2691e; color: #e8a06a; }
.log .weather{ border-left-color: #6a9ec0; color: #a8cde0; }

/* ══════════════ Модалка ══════════════ */
.modal {
  position: fixed; inset: 0; background: rgba(8,6,4,.82);
  display: grid; place-items: center; z-index: 50; backdrop-filter: blur(2px);
}
/* display в правиле выше перебивает атрибут hidden — возвращаем его силу,
   иначе затемняющая подложка висит поверх страницы всё время. */
.modal[hidden] { display: none; }
.modal-box {
  background: linear-gradient(180deg, #221d14, #1a1610);
  border: 1px solid var(--gold-dim);
  border-radius: 16px; padding: 24px 28px; width: min(940px, 94vw);
  max-height: 90vh; overflow-y: auto; text-align: center;
  box-shadow: 0 28px 80px rgba(0,0,0,.75), inset 0 1px 0 rgba(255,255,255,.05);
}
.modal-box h2 {
  font-family: var(--font-display); font-size: 27px;
  color: var(--gold-hi); font-weight: 700; letter-spacing: 3px; margin: 0 0 8px;
}
.modal-box p { color: var(--ink-dim); font-size: 13.5px; margin: 0 0 16px; line-height: 1.55; }
.modal-cards { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; }
.modal-cards .card { cursor: pointer; width: 138px; height: 184px; }
.modal-cards .card:hover { transform: translateY(-6px); border-color: var(--gold); }
/* Кнопки в модалке всегда одного размера — и «Новая партия», и «В меню». */
.modal-actions { display: flex; gap: 10px; justify-content: center; align-items: stretch; }
.modal-actions .btn { margin: 0; min-width: 176px; }
.modal-rules { text-align: left; }
.modal-rules p, .modal-rules li { color: var(--ink); font-size: 13px; line-height: 1.6; }
.modal-rules h3 { color: var(--gold); font-size: 14px; letter-spacing: 2px; font-weight: normal; margin: 16px 0 6px; }
.modal-rules ul { margin: 0; padding-left: 20px; }

.round-scores { display: flex; gap: 26px; justify-content: center; margin-bottom: 16px; }
.round-scores div { font-size: 13px; color: var(--ink-dim); }
.round-scores b { display: block; font-size: 34px; color: var(--gold); }

/* ══════════════ Панель просмотра карты ══════════════ */
.card-preview {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px; display: flex; flex-direction: column; align-items: center;
  gap: 10px; min-height: 240px;
  box-shadow: var(--shadow);
}
.preview-empty { color: var(--ink-dim); font-size: 13px; margin: auto; text-align: center; }
.card.big { width: clamp(130px, 11.5vw, 178px); height: calc(clamp(130px, 11.5vw, 178px) * 1.34); flex: none; }
.preview-info { width: 100%; }
.preview-name {
  font-family: var(--font-display); font-weight: 700;
  color: var(--gold-hi); font-size: 19px; text-align: center; margin-bottom: 4px;
}
.preview-row { color: var(--ink-dim); font-size: 12.5px; text-align: center; }
.preview-abils { margin: 9px 0 0; padding-left: 16px; }
.preview-abils li { color: #9dc48a; font-size: 12.5px; line-height: 1.45; margin-bottom: 4px; }
.preview-plain { color: var(--ink-dim); font-size: 12.5px; margin-top: 9px; text-align: center; }
.preview-lore { color: var(--ink-dim); font-size: 12px; font-style: italic; margin-top: 9px; text-align: center; }
.bottom-bar { display: flex; gap: 6px; }
.bottom-bar .btn { flex: 1; }

/* ══════════════ Слой анимаций ══════════════ */
.fx-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 80;
  display: grid; place-items: center;
}
/* Канвас частиц: над картами и призраками, под баннерами. */
.fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 56; }

/* Герои на столе слегка мерцают золотом. */
.row-cards .card.hero { animation: heroGlow 3.2s ease-in-out infinite; }
@keyframes heroGlow {
  50% { box-shadow: 0 0 16px rgba(201,169,97,.55), 0 0 0 1px rgba(201,169,97,.45); }
}

.banner { text-align: center; }
.banner-text {
  font-family: var(--font-display); font-weight: 700;
  font-size: 60px; letter-spacing: 12px; color: var(--gold-hi); text-transform: uppercase;
  text-shadow: 0 0 44px rgba(0,0,0,.95), 0 0 20px rgba(201,169,97,.5);
}
.banner-sub {
  font-size: 14px; letter-spacing: 4px; color: var(--ink); font-weight: 600;
  text-shadow: 0 0 20px rgba(0,0,0,.95); margin-top: 7px;
}
.banner-good .banner-text { color: #d8c07a; }
.banner-bad .banner-text { color: #c98a7a; }

/* Монета */
.coin-wrap { display: grid; place-items: center; gap: 26px; }
.coin { width: 96px; height: 96px; position: relative; transform-style: preserve-3d; }
.coin-face {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  font-size: 42px; backface-visibility: hidden;
  background: radial-gradient(circle at 34% 28%, #ffeaa8, #c9a961 55%, #7a6330);
  color: #4a3a16; border: 2px solid #e8d59a;
  box-shadow: 0 10px 40px rgba(0,0,0,.7), inset 0 0 18px rgba(255,255,255,.35);
}
.coin-back { transform: rotateY(180deg); }
.coin-label {
  font-size: 20px; letter-spacing: 5px; color: var(--gold); opacity: 0;
  text-shadow: 0 0 24px rgba(0,0,0,.9); text-transform: uppercase;
}

/* Пульс счётчика при изменении */
.bump { animation: bump .42s ease-out; }
.bump.up { animation-name: bumpUp; }
.bump.down { animation-name: bumpDown; }
@keyframes bump { 50% { transform: scale(1.2); } }
@keyframes bumpUp {
  50% { transform: scale(1.28); box-shadow: 0 0 16px rgba(150,220,120,.7); border-color: #8fc47a; }
}
@keyframes bumpDown {
  50% { transform: scale(1.22); box-shadow: 0 0 16px rgba(220,120,110,.7); border-color: #c9847a; }
}

/* Вспышка над рядом */
.row-flash { position: absolute; inset: 0; pointer-events: none; border-radius: 3px; }
.row-flash-burn {
  background: radial-gradient(ellipse at center, rgba(255,150,40,.55), transparent 70%);
}

/* ══════════════ Погодные эффекты ══════════════ */
/* Без overflow:hidden — иначе обрежется карта, летящая из руки в ряд. */
.row { position: relative; }
/* Погода на ряду: холодная вуаль + медленное, спокойное движение.
   Первый слой каждого эффекта — неподвижная тонировка, дальше — редкие
   крупные элементы с длинным периодом, чтобы ничего не рябило. */
.row.weathered::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background-repeat: repeat;
}
.row.weather-frost::after {
  background-image:
    linear-gradient(180deg, rgba(140,190,235,.20), rgba(140,190,235,.06)),
    radial-gradient(1.8px 1.8px at 22% 28%, rgba(240,248,255,.85), transparent 60%),
    radial-gradient(1.4px 1.4px at 64% 58%, rgba(240,248,255,.7), transparent 60%),
    radial-gradient(1.9px 1.9px at 86% 24%, rgba(240,248,255,.75), transparent 60%);
  background-size: 100% 100%, 150px 190px, 200px 240px, 260px 300px;
  animation: snowdrift 17s linear infinite;
}
@keyframes snowdrift {
  to { background-position: 0 0, 14px 190px, -18px 240px, 10px 300px; }
}
.row.weather-fog::after {
  background-image:
    linear-gradient(180deg, rgba(205,212,222,.16), rgba(205,212,222,.05)),
    radial-gradient(60% 120% at 30% 55%, rgba(218,224,232,.26), transparent 70%),
    radial-gradient(50% 100% at 78% 45%, rgba(218,224,232,.2), transparent 70%);
  background-size: 100% 100%, 230% 100%, 250% 100%;
  animation: fogflow 26s ease-in-out infinite alternate;
}
@keyframes fogflow {
  to { background-position: 0 0, 55% 0, -45% 0; }
}
.row.weather-rain::after {
  background-image:
    linear-gradient(180deg, rgba(70,100,140,.24), rgba(70,100,140,.08)),
    repeating-linear-gradient(100deg,
      transparent 0 17px, rgba(178,205,235,.3) 17px 18px, transparent 18px 34px);
  background-size: 100% 100%, 100% 300%;
  animation: rainfall 1.3s linear infinite;
}
@keyframes rainfall {
  to { background-position: 0 0, -34px 200px; }
}

/* Активная сторона слегка подсвечивается */
.player-info.active { animation: activeGlow 2.6s ease-in-out infinite; }
@keyframes activeGlow {
  50% { box-shadow: 0 0 22px rgba(201,169,97,.3); }
}

@media (prefers-reduced-motion: reduce) {
  .row.weathered::after, .player-info.active, .row-cards .card.hero { animation: none; }
}

@media (max-width: 1100px) and (min-width: 761px) {
  #board { grid-template-columns: 178px minmax(0,1fr) 200px; }
}

.only-mobile { display: none; }
/* Журнал внутри модального окна виден на любом экране. */
.modal .log.log-modal { display: block; max-height: 60vh; text-align: left; }

/* ═══════════════════════════════════════════════════════════════════
   ТЕЛЕФОН, ПОРТРЕТ. Рассчитано на 360–460 CSS-пикселей:
   iPhone 14 Pro (393×852) и OnePlus 15 (420×912).
   Колонки раскладываются в одну ленту через display: contents.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 760px) {
  :root {
    --card-w: 50px; --card-h: 68px;
    --hand-w: 66px; --hand-h: 92px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  html, body { overflow: hidden; overscroll-behavior: none; }
  .screen { height: 100dvh; }
  .only-mobile { display: block; }

  /* — Меню — */
  #menu { overflow-y: auto; padding: calc(var(--safe-top) + 10px) 10px calc(var(--safe-bottom) + 16px); }
  .menu-inner { width: 100%; padding: 8px 0 24px; }
  .title { font-size: 40px; letter-spacing: 8px; }
  .subtitle { font-size: 12px; margin-bottom: 18px; }
  .faction-list, .leader-list { gap: 6px; }
  .faction-card { width: calc(50% - 4px); padding: 9px 10px; }
  .faction-list.small .faction-card { width: calc(50% - 4px); }
  .faction-card b { font-size: 13px; }
  .faction-card span { font-size: 10px; }
  .leader-card { width: 100%; }
  .mode-btn { flex: 1; min-width: 0; padding: 10px 6px; font-size: 11px; }
  .nick-input { width: 100%; }
  .net-connect { flex-direction: column; }
  .net-player { flex: 1; min-width: 120px; }
  .btn { padding: 12px 20px; }

  /* — Доска: одна колонка — */
  /* Именно flex, а не grid: с ним `order` уживается с растяжимыми рядами. */
  #board {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: calc(var(--safe-top) + 4px) 6px calc(var(--safe-bottom) + 4px);
  }
  /* Колонки исчезают как контейнеры — их дети встают в общую ленту. */
  .col-left, .col-right, .col-field { display: contents; }
  #board > * , .col-left > *, .col-right > *, .col-field > * { flex: none; width: 100%; }
  #rows-enemy, #rows-player { flex: 1 1 0; min-height: 0; }

  #info-enemy   { order: 1; }
  #weather-zone { order: 2; }
  #rows-enemy   { order: 3; min-height: 0; }
  .mid-line     { order: 4; }
  #rows-player  { order: 5; min-height: 0; }
  #info-player  { order: 6; }
  .hand-wrap    { order: 7; }
  .actions      { order: 8; }
  .bottom-bar   { order: 9; }
  #card-preview { order: 0; }
  .log          { display: none; }

  /* Панели игроков — одной строкой */
  .player-info { display: flex; align-items: center; gap: 8px; padding: 5px 8px; }
  .pi-head { margin: 0; flex: 1; min-width: 0; gap: 6px; }
  .pi-leader { width: 28px; height: 28px; flex: none; }
  .pi-name { font-size: 12px; }
  .pi-faction { font-size: 9px; }
  .pi-total { width: 38px; min-width: 38px; height: 28px; font-size: 17px; }
  .pi-stats { flex: none; }
  .pi-row { display: none; }
  .pi-counts { display: flex; gap: 7px; font-size: 10px; color: var(--ink-dim); flex: none; }

  /* Погода — тонкая полоска */
  .weather-zone { flex: none; min-height: 0; flex-direction: row; align-items: center; gap: 8px; padding: 4px 8px; }
  .zone-label { margin: 0; flex: none; }
  .weather-cards { flex: 1; align-items: center; justify-content: flex-start; min-height: 0; }
  .weather-zone .card { width: 32px; height: 44px; }
  .weather-zone .card .card-name, .weather-zone .card .card-badges { display: none; }

  .rows { gap: 3px; }
  .row { grid-template-columns: 28px 20px 1fr; gap: 4px; padding: 3px 4px; }
  .row-icon { display: none; }
  .row-score { width: 26px; height: 26px; font-size: 12px; border-width: 1px; }
  .row-horn { width: 18px; height: 26px; font-size: 10px; }
  .mid-line { height: 16px; font-size: 9px; letter-spacing: 2px; }

  /* Рука прокручивается пальцем — карты не налезают друг на друга,
     так название и сила читаются целиком. */
  .hand-wrap { height: calc(var(--hand-h) + 14px); padding: 4px 6px 6px; }
  .hand {
    justify-content: flex-start; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    padding: 6px 2px 0;
  }
  .hand::-webkit-scrollbar { display: none; }

  /* Кнопки действий — в строку, крупные для пальца */
  .actions { display: flex; flex-direction: row; gap: 6px; align-items: stretch; }
  .btn-leader {
    flex: 1; min-width: 0; font-size: 11px; padding: 4px 8px; line-height: 1.3;
    overflow: hidden; height: 44px; align-items: center;
  }
  /* Описание лидера на телефоне не помещается — оставляем имя. */
  .btn-leader .leader-text span { display: none; }
  .btn-leader .leader-text br { display: none; }
  .leader-mini { width: 24px; height: 34px; }
  .btn-pass { flex: none; width: 96px; padding: 8px; height: 44px; }
  .bottom-bar .btn { padding: 7px 8px; font-size: 10px; }

  /* Просмотр карты — всплывает над рукой, когда карта выбрана */
  #card-preview {
    position: fixed; left: 8px; right: 8px; bottom: calc(var(--hand-h) + 98px);
    z-index: 45; flex-direction: row; align-items: flex-start; gap: 10px;
    min-height: 0; padding: 8px; display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,.7);
  }
  body.preview-open #card-preview { display: flex; }
  .card.big { width: 86px; height: 120px; }
  .preview-info { text-align: left; }
  .preview-name, .preview-row, .preview-lore, .preview-plain { text-align: left; }
  .preview-abils { padding-left: 12px; }

  /* Модалки на всю ширину */
  .modal-box { width: 96vw; padding: 16px 12px; max-height: 86dvh; }
  .modal-box h2 { font-size: 18px; letter-spacing: 2px; }
  .modal-cards { gap: 4px; }
  .modal-cards .card { width: 62px; height: 86px; }
  .modal-actions { flex-wrap: wrap; }
  .banner-text { font-size: 34px; letter-spacing: 5px; }
  .banner-sub { font-size: 12px; }
  .coin { width: 72px; height: 72px; }
  .coin-face { font-size: 32px; }
  .coin-label { font-size: 15px; letter-spacing: 2px; }
}

/* На узких телефонах (iPhone 14 Pro и уже) ужимаем ещё немного. */
@media (max-width: 400px) {
  :root { --card-w: 46px; --card-h: 64px; --hand-w: 62px; --hand-h: 88px; }
  .btn-pass { width: 84px; }
}

/* ═══════════════════════════════════════════════════════════════════
   ТЕЛЕФОН, АЛЬБОМ. iPhone 14 Pro (852×393) и OnePlus 15 (~915×412).
   Три колонки: панели и погода слева, поле с рукой в центре,
   просмотр карты и кнопки справа. Учитываются вырезы по бокам.
   ═══════════════════════════════════════════════════════════════════ */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  :root {
    --card-w: 34px; --card-h: 44px;
    --hand-w: 56px; --hand-h: 76px;
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
  }

  html, body { overflow: hidden; overscroll-behavior: none; }
  .screen { height: 100dvh; }
  .only-mobile { display: block; }

  /* — Меню — */
  #menu {
    overflow-y: auto;
    padding: 8px calc(var(--safe-r) + 12px) 16px calc(var(--safe-l) + 12px);
  }
  .menu-inner { width: 100%; padding: 4px 0 16px; }
  .title { font-size: 34px; letter-spacing: 7px; margin: 0; }
  .subtitle { font-size: 11px; margin-bottom: 12px; }
  .menu-block { margin-bottom: 14px; }
  .faction-card { width: calc(33% - 7px); padding: 8px 10px; }
  .faction-card b { font-size: 12px; }
  .faction-card span { font-size: 9.5px; }
  .faction-list.small .faction-card { width: calc(33% - 7px); }
  .leader-card { width: calc(50% - 5px); }
  .btn { padding: 11px 18px; }

  /* — Доска: три колонки — */
  #board {
    display: grid;
    grid-template-columns: 146px minmax(0, 1fr) 176px;
    gap: 5px;
    padding: 4px calc(var(--safe-r) + 4px) calc(env(safe-area-inset-bottom, 0px) + 4px) calc(var(--safe-l) + 4px);
  }
  .col-left, .col-right { display: flex; flex-direction: column; gap: 5px; }
  .col-field { display: flex; flex-direction: column; gap: 3px; }

  /* Левая колонка */
  .player-info { padding: 6px 7px; font-size: 11px; }
  .pi-head { margin-bottom: 4px; gap: 6px; }
  .pi-leader { width: 26px; height: 26px; }
  .pi-name { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pi-faction { font-size: 8.5px; }
  .pi-total { min-width: 32px; height: 26px; font-size: 15px; }
  .pi-row { display: none; }
  .pi-counts { display: flex; gap: 6px; font-size: 9.5px; color: var(--ink-dim); }

  .weather-zone { min-height: 46px; padding: 5px 7px; }
  .zone-label { font-size: 9px; margin-bottom: 3px; }
  .weather-cards { min-height: 0; }
  .weather-zone .card { width: 40px; height: 54px; }
  .weather-zone .card .card-name, .weather-zone .card .card-badges { display: none; }

  /* Поле */
  .rows { gap: 3px; }
  .row { grid-template-columns: 26px 17px 1fr; gap: 3px; padding: 2px 4px; }
  .row-icon { display: none; }
  .row-score { width: 24px; height: 24px; font-size: 11px; border-width: 1px; }
  .row-horn { width: 16px; height: 24px; font-size: 9px; }
  .mid-line { height: 14px; font-size: 8px; letter-spacing: 2px; }

  /* В ряду имя не читается при такой высоте — картинка и сила скажут всё.
     Полное описание в панели справа по тапу. */
  .row-cards .card .card-name { display: none; }

  /* Рука — прокрутка пальцем */
  .hand-wrap { height: calc(var(--hand-h) + 12px); padding: 3px 5px 5px; }
  .hand {
    justify-content: flex-start; gap: 4px;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    padding: 5px 2px 0;
  }
  .hand::-webkit-scrollbar { display: none; }

  /* Правая колонка: просмотр карты, кнопки, журнал — кнопкой */
  #card-preview {
    position: static; display: flex; flex-direction: row; align-items: flex-start;
    flex: 1; min-height: 0; gap: 7px; padding: 6px; overflow-y: auto;
  }
  .card.big { width: 64px; height: 89px; }
  .preview-empty { font-size: 10px; }
  .preview-info { text-align: left; min-width: 0; }
  .preview-name { font-size: 11px; text-align: left; }
  .preview-row { font-size: 9px; text-align: left; }
  .preview-abils { margin-top: 5px; padding-left: 11px; }
  .preview-abils li { font-size: 9px; margin-bottom: 2px; }
  .preview-plain { font-size: 9px; text-align: left; margin-top: 5px; }
  .preview-lore { font-size: 8.5px; text-align: left; margin-top: 5px; }

  .actions { flex: none; flex-direction: column; gap: 5px; }
  .btn-leader { height: 42px; font-size: 10px; padding: 3px 7px; }
  .btn-leader .leader-text span { display: none; }
  .btn-leader .leader-text br { display: none; }
  .leader-mini { width: 22px; height: 32px; }
  .btn-pass { height: 38px; padding: 6px; }
  .log { display: none; }
  .bottom-bar .btn { padding: 6px 6px; font-size: 9.5px; letter-spacing: 1px; }

  /* Модалки и эффекты */
  .modal-box { width: min(92vw, 640px); padding: 14px 14px; max-height: 90dvh; }
  .modal-box h2 { font-size: 16px; letter-spacing: 2px; }
  .modal-cards { gap: 4px; }
  .modal-cards .card { width: 58px; height: 80px; }
  .banner-text { font-size: 30px; letter-spacing: 5px; }
  .banner-sub { font-size: 11px; }
  .coin { width: 64px; height: 64px; }
  .coin-face { font-size: 28px; }
  .coin-label { font-size: 13px; letter-spacing: 2px; }
}

/* Совсем низкие экраны в альбоме (iPhone 14 Pro: 393 по высоте). */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 420px) {
  :root {
    --card-w: 30px; --card-h: 40px;
    --hand-w: 50px; --hand-h: 68px;
  }
  .mid-line { height: 12px; }
  .weather-zone { min-height: 40px; }
}

/* Без мыши подсветка по наведению только мешает. */
@media (hover: none) {
  .hand .card:hover { transform: none; box-shadow: none; }
  .row-cards .card:hover { transform: none; }
  .hand .card.sel { transform: translateY(-10px); }
}
