/* Tactics And Wars — UI поверх canvas */

@font-face {
  font-family: "8bitoperator JVE";
  src: url("../assets/fonts/8bitoperatorJVE.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #1a1510;
  --panel: #241c14;
  --ink: #f0e6d8;
  --muted: #a89880;
  --red: #c44a3a;
  --blue: #3a6fc4;
  --accent: #d4a04a;
  --gold: #be9948;
  --mana: #0082db;
  --army: #b14dff;
  --ok: #4a9a5a;
  --bad: #a04040;
  --line: #3d3228;
  --field-fill: #e8e8e8;
  --field-ink: #222222;
  --font-ui: "8bitoperator JVE", "Bitcell", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-min: 20px;
  /* UI kit (assets/ui): native px × scale */
  --ui-scale: 2;
  --ui-border-native: 1;
  --ui-btn-border-native: 2;
  --ui-field-border-native: 2;
  --ui-tooltip-border-native: 4;
  --ui-border: calc(var(--ui-border-native) * var(--ui-scale) * 1px);
  --ui-btn-border: calc(var(--ui-btn-border-native) * var(--ui-scale) * 1px);
  --ui-field-border: calc(var(--ui-field-border-native) * var(--ui-scale) * 1px);
  --ui-tooltip-border: calc(var(--ui-tooltip-border-native) * var(--ui-scale) * 1px);
  --ui-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%23333333' d='M1 3h6L4 6z'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--font-min);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: crosshair;
  touch-action: none;
  background: #1a1510;
}

/* CRT present-pass: поверх world-canvas, ниже HTML UI; клики идут в #game */
.game-crt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 1;
  image-rendering: auto;
}

.game-crt[hidden] {
  display: none;
}

.debug-panel__check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  font-size: var(--font-min);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.debug-panel__check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.debug-panel__crt {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debug-panel__crt.is-disabled {
  opacity: 0.45;
}

.debug-panel__slider {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--font-min);
  color: var(--ink);
  cursor: pointer;
}

.debug-panel__slider span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}

.debug-panel__slider em {
  font-style: normal;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.debug-panel__slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.debug-hud {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 8;
  padding: 8px 10px;
  background: rgba(26, 21, 16, 0.82);
  border: 1px solid var(--line);
  font-size: var(--font-min);
  line-height: 1.45;
  color: var(--muted);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

#app.debug-mode-on .debug-hud {
  top: 56px;
  right: 100px;
}

.debug-hud strong {
  color: var(--ink);
  font-weight: 600;
}

.debug-hud__red strong {
  color: var(--red);
}

.debug-hud__blue strong {
  color: var(--blue);
}

/* ─── Debug mode (cheats) ─────────────────────────────────────────────────── */

.debug-mode-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 12;
  min-width: 72px;
  padding: 8px 14px;
  border: var(--ui-btn-border) solid transparent;
  border-image-source: url("../assets/ui/button.png");
  border-image-slice: 2 fill;
  border-image-width: var(--ui-btn-border);
  border-image-repeat: stretch;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--font-min);
  cursor: pointer;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: auto;
}

.debug-mode-btn:hover {
  filter: brightness(1.08);
}

.debug-mode-btn.is-open {
  filter: brightness(1.12);
}

/* ─── UI kit: панели / тултипы (9-slice) ─────────────────────────────────── */

.ui-panel,
.ui-tooltip {
  position: relative;
  background: transparent;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.ui-panel {
  padding: calc(var(--ui-border) + 12px);
  border: var(--ui-border) solid transparent;
  border-image-source: url("../assets/ui/panel.png");
  border-image-slice: 1 fill;
  border-image-width: var(--ui-border);
  border-image-repeat: stretch;
}

.ui-tooltip {
  padding: calc(var(--ui-tooltip-border) + 12px);
  border: var(--ui-tooltip-border) solid transparent;
  border-image-source: url("../assets/ui/tooltip.png");
  border-image-slice: 4 fill;
  border-image-width: var(--ui-tooltip-border);
  border-image-repeat: stretch;
  opacity: 0.9;
}

.ui-panel[hidden],
.ui-tooltip[hidden],
.ui-panel-stack[hidden] {
  display: none;
}

/* Связка: заголовок + панель (одинаковая ширина, gap 12px) */
.ui-panel-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.ui-panel-title {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: calc(var(--ui-border) + 0.2em) calc(var(--ui-border) + 12px);
  border: var(--ui-border) solid transparent;
  border-image-source: url("../assets/ui/panel title.png");
  border-image-slice: 1 fill;
  border-image-width: var(--ui-border);
  border-image-repeat: stretch;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--font-min);
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.ui-panel-stack > .ui-panel {
  width: 100%;
  box-sizing: border-box;
}

.ui-panel__body {
  position: relative;
  z-index: 1;
}

/* после .ui-panel — иначе position:relative перебивает absolute */
.debug-panel {
  position: absolute;
  top: 56px;
  right: 14px;
  z-index: 13;
  width: min(320px, calc(100vw - 28px));
  pointer-events: auto;
}

.debug-panel__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(70vh, 520px);
  overflow: auto;
}

.debug-panel__stat {
  font-size: var(--font-min);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.debug-panel__stat strong {
  color: var(--blue);
}

.debug-panel__stat #debug-enemy-cards {
  display: inline;
  font-weight: 700;
  color: var(--blue);
  word-break: break-word;
}

.debug-panel__section {
  margin-top: 4px;
  font-size: var(--font-min);
  color: var(--muted);
}

.debug-panel__units {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.debug-panel__hint {
  font-size: var(--font-min);
  color: var(--muted);
  line-height: 1.35;
}

.ui-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 12px;
  border: var(--ui-btn-border) solid transparent;
  border-image-source: url("../assets/ui/button.png");
  border-image-slice: 2 fill;
  border-image-width: var(--ui-btn-border);
  border-image-repeat: stretch;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--font-min);
  cursor: pointer;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.ui-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.ui-btn.is-active,
.ui-btn:disabled.is-active {
  filter: brightness(1.12);
}

.ui-btn--accept {
  border-image-source: url("../assets/ui/button accept.png");
}

.ui-btn--decline {
  border-image-source: url("../assets/ui/button decline.png");
}

.ui-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.debug-unit-btn {
  flex: 1 1 calc(50% - 8px);
  min-width: 120px;
}

/* ─── Панель стройки / выбранного здания ─────────────────────────────────── */

.build-dock {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.build-dock[hidden] {
  display: none;
}

.build-dock > .build-bar,
.build-dock > .building-panel {
  pointer-events: auto;
}

.build-bar {
  position: relative;
  left: auto;
  bottom: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 100px;
}

.build-bar[hidden] {
  display: none;
}

/* Ресурсы + тултип стройки над панелью */
.build-float {
  position: relative;
  left: auto;
  bottom: auto;
  margin-bottom: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.build-resources {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
}

.build-gold,
.build-mana,
.build-army {
  position: relative;
  z-index: 4;
  width: max-content;
  padding: calc(var(--ui-border) + 2px) calc(var(--ui-border) + 10px);
  pointer-events: none;
}

.build-gold__text,
.build-mana__text,
.build-army__text {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  font-size: max(var(--font-min), calc(11 * var(--ui-scale) * 1px));
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
  font-variant-numeric: tabular-nums;
}

.build-res-icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.build-res-icon--gold {
  background-image: url("../assets/ui/gold.png");
}

.build-res-icon--mana {
  background-image: url("../assets/ui/mana.png");
}

.build-res-icon--army {
  background-image: url("../assets/ui/army.png");
}

.build-gold__text strong {
  font-weight: normal;
  color: var(--gold);
}

.build-mana__text strong {
  font-weight: normal;
  color: var(--mana);
}

.build-army__text strong {
  font-weight: normal;
  color: var(--army);
}

#build-mana-max.is-preview,
#build-army-max.is-preview {
  color: #8ecf9a;
}

.build-bar__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-start;
  max-width: min(92vw, 720px);
}

.build-btn {
  display: block;
  width: 64px;
  height: 64px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.build-btn__art {
  box-sizing: border-box;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--ui-btn-border) solid transparent;
  border-image-source: url("../assets/ui/button.png");
  border-image-slice: 2 fill;
  border-image-width: var(--ui-btn-border);
  border-image-repeat: stretch;
  background: transparent;
}

.build-btn:disabled,
.build-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.build-btn:disabled:hover .build-btn__art,
.build-btn.is-disabled:hover .build-btn__art {
  filter: none;
}

.build-btn:hover .build-btn__art {
  filter: brightness(1.08);
}

.build-btn:disabled.is-active .build-btn__art,
.build-btn.is-disabled.is-active .build-btn__art {
  filter: none;
}

.build-btn.is-active .build-btn__art {
  filter: brightness(1.12);
}

.build-btn__icon {
  display: block;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: transparent;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Тултип стройки — слева над блоками ресурсов */
#tower-info.tower-info {
  position: relative;
  left: auto;
  bottom: auto;
  z-index: 11;
  width: 350px;
  max-width: min(92vw, 720px);
  pointer-events: none;
  margin: 0;
}

/* Панель выбранного здания — вместо стройки */
#building-panel {
  position: relative;
  left: auto;
  bottom: auto;
  z-index: 12;
  width: 600px;
  max-width: calc(100vw - 24px);
  pointer-events: auto;
  margin: 0;
  gap: 8px;
}

.building-panel__title {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  white-space: normal;
}

.building-panel__title-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.building-panel__title-bonuses {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.building-panel__title-stat {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  font-size: var(--font-min);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.building-panel__title-stat[hidden] {
  display: none;
}

.building-panel__title-stat--hp {
  color: #ffffff;
}

.building-panel__title-stat--mana {
  color: var(--mana);
}

.building-panel__title-stat--army {
  color: var(--army);
}

.building-panel__body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-height: 0;
}

.building-panel__stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
  color: #ffffff;
  font-size: var(--font-min);
  line-height: 1.2;
}

.building-panel.is-upgrade-preview .building-panel__stats {
  color: #8ecf9a;
}

.building-panel__row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 32px;
  width: 100%;
}

.building-panel__row[hidden] {
  display: none;
}

.building-panel__icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.building-panel__unit-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.building-panel__unit-icon {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.building-panel__unit-left #building-panel-unit-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.building-panel__unit-stats {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.building-panel__stat {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.building-panel__sep {
  flex: 0 0 auto;
  opacity: 0.85;
}

.building-panel__icon--hp {
  background-image: url("../assets/ui/hp.png");
}

.building-panel__icon--attack {
  background-image: url("../assets/ui/attack.png");
}

.building-panel__icon--army {
  background-image: url("../assets/ui/army.png");
}

.building-panel__icon--mana {
  background-image: url("../assets/ui/mana.png");
}

.building-panel__icon--timer {
  background-image: url("../assets/ui/timer.png");
}

.building-panel__val {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.building-panel__actions {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.building-panel__btn {
  display: inline-flex;
  flex: 1 1 0;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 36px;
  padding: 6px 12px;
  white-space: nowrap;
}

.building-panel__btn[hidden] {
  display: none;
}

.building-panel__btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.building-panel__btn.is-disabled:hover {
  filter: none;
}

.building-panel__btn-cost {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.tower-info__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #ffffff;
  font-size: var(--font-min);
  line-height: 1.25;
}

.tower-info__name {
  color: #ffffff;
  font-size: 24px;
  line-height: 1.2;
}

.tower-info__cost {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.tower-info__gold {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  background: url("../assets/ui/gold.png") center / contain no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.tower-info__cost-val {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-size: var(--font-min);
}

.tower-info__desc {
  color: #a89880;
  font-size: 16px;
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-word;
}

.tower-info__desc:empty {
  display: none;
}

.tower-info__stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #ffffff;
  font-size: var(--font-min);
  line-height: 1.2;
}

.tower-info__stat {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.tower-info__stat[hidden] {
  display: none;
}

.tower-info__stat--mana {
  color: var(--mana);
}

.tower-info__stat--army {
  color: var(--army);
}

.tower-info__icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.tower-info__icon--hp {
  background-image: url("../assets/ui/hp.png");
}

.tower-info__icon--mana {
  background-image: url("../assets/ui/mana.png");
}

.tower-info__icon--army {
  background-image: url("../assets/ui/army.png");
}

.tower-info__icon--attack {
  background-image: url("../assets/ui/attack.png");
}

.tower-info__unit-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(196, 74, 58, 0.18), transparent 50%),
    radial-gradient(ellipse at 70% 50%, rgba(58, 111, 196, 0.18), transparent 50%),
    rgba(12, 10, 8, 0.82);
  padding: 20px;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: min(420px, 100%);
  text-align: center;
}

.panel__body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel__text {
  margin: 0 0 8px;
  line-height: 1.45;
  color: var(--ink);
}

.panel__text--dim {
  color: var(--muted);
  font-size: var(--font-min);
  margin-bottom: 16px;
}

.panel__label {
  display: block;
  margin: 0 0 6px;
  font-size: var(--font-min);
  color: var(--muted);
}

.panel__select {
  display: block;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 20px;
  padding: 8px 28px 8px 12px;
  border: var(--ui-field-border) solid transparent;
  border-image-source: url("../assets/ui/field.png");
  border-image-slice: 2;
  border-image-width: var(--ui-field-border);
  border-image-repeat: stretch;
  background-color: var(--field-fill);
  background-image: var(--ui-select-arrow);
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  color: var(--field-ink);
  font: inherit;
  font-size: var(--font-min);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.panel__select:focus {
  border-image-source: url("../assets/ui/field focus.png");
  outline: none;
}

.panel__btn {
  min-height: 44px;
  padding: 10px 36px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ─── Карты AoE (правый нижний угол, полускрытые) ─────────────────────────── */

.card-hand {
  position: absolute;
  right: 18px;
  bottom: 0;
  z-index: 9;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 12px;
  padding: 0 4px;
  pointer-events: none;
}

.card-hand[hidden] {
  display: none;
}

.spell-card {
  --card-w: 250px;
  --card-h: 400px;
  --card-slice: 12px;
  --card-ink: #2a3036;
  --card-muted: #7a858e;
  --card-font: 18px;
  /* сколько карты видно снизу экрана */
  --card-peek: 64px;
  --card-peek-cd: 48px;
  --card-peek-aim: 96px;
  --card-hover-lift: -12px;
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: var(--card-w);
  height: var(--card-h);
  margin: 0;
  padding: 8px 13px 12px;
  border: var(--card-slice) solid transparent;
  border-image-source: url("../assets/ui/card.png");
  border-image-slice: 12 fill;
  border-image-width: var(--card-slice);
  border-image-repeat: stretch;
  background: transparent;
  color: var(--card-ink);
  font: inherit;
  font-size: var(--card-font);
  text-align: left;
  cursor: pointer;
  transform: translateY(calc(100% - var(--card-peek)));
  transition: transform 0.16s ease-out, filter 0.12s;
  overflow: visible;
  image-rendering: pixelated;
}

.spell-card.is-aiming {
  transform: translateY(calc(100% - var(--card-peek-aim))) scale(1.06);
  transform-origin: bottom center;
  z-index: 3;
  filter: none;
}

.spell-card:disabled,
.spell-card.is-cooling {
  cursor: default;
}

.spell-card.is-cooling {
  transform: translateY(calc(100% - var(--card-peek-cd)));
  filter: brightness(0.45) saturate(0.55);
  z-index: 1;
}

/* Пока выбираем цель: остальные карты как на кулдауне (48px) */
.card-hand.is-aiming .spell-card:not(.is-aiming) {
  transform: translateY(calc(100% - var(--card-peek-cd)));
  z-index: 1;
}

/* Полный подъём только на hover вне режима цели */
.spell-card:hover,
.spell-card.is-cooling:hover {
  transform: translateY(var(--card-hover-lift));
  z-index: 4;
}

/* В режиме цели выбранная карта не всплывает по hover */
.spell-card.is-aiming:hover {
  transform: translateY(calc(100% - var(--card-peek-aim))) scale(1.06);
  transform-origin: bottom center;
  z-index: 3;
}

/* Остальные в режиме цели тоже не всплывают */
.card-hand.is-aiming .spell-card:not(.is-aiming):hover {
  transform: translateY(calc(100% - var(--card-peek-cd)));
  z-index: 1;
}

.spell-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  flex-shrink: 0;
}

.spell-card__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--card-font);
  font-weight: 700;
  color: var(--card-ink);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spell-card__cd-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.spell-card__cd-icon {
  display: block;
  width: 16px;
  height: 16px;
  background: url("../assets/ui/timer.png") center / contain no-repeat;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.spell-card__cd-wrap.is-mana .spell-card__cd-icon {
  background-image: url("../assets/ui/mana.png");
}

.spell-card__cd {
  font-size: var(--card-font);
}

.spell-card__cd-wrap.is-ready {
  color: var(--card-muted);
}

.spell-card__cd-wrap.is-cooling {
  color: var(--card-ink);
}

.spell-card__cd-wrap.is-mana {
  color: var(--mana);
}

.spell-card__art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  flex-shrink: 0;
  overflow: hidden;
  background: #c8ced2;
  border: 1px solid #9aa4ac;
  image-rendering: pixelated;
}

.spell-card--damage .spell-card__art:not(.has-art) {
  background: radial-gradient(circle at 40% 35%, #c47868, #8a3a2a 70%);
}

.spell-card--heal .spell-card__art:not(.has-art) {
  background: radial-gradient(circle at 40% 35%, #78b888, #3a7a4a 70%);
}

.spell-card--buff .spell-card__art:not(.has-art) {
  background: radial-gradient(circle at 40% 35%, #a878c8, #5a2a8a 70%);
}

.spell-card--vamp .spell-card__art:not(.has-art) {
  background: radial-gradient(circle at 40% 35%, #c85858, #7a2020 70%);
}

.spell-card--clone .spell-card__art:not(.has-art) {
  background: radial-gradient(circle at 40% 35%, #68b0d8, #286888 70%);
}

.spell-card--ice .spell-card__art:not(.has-art) {
  background: radial-gradient(circle at 40% 35%, #88d0e8, #387898 70%);
}

.spell-card__art-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.spell-card__art-img[hidden] {
  display: none;
}

.spell-card__desc {
  flex: 1 1 auto;
  margin: 0;
  font-size: var(--card-font);
  color: var(--card-ink);
  line-height: 1.3;
  text-align: left;
  overflow: hidden;
}

/* ─── Меню / лобби ─────────────────────────────────────────────────────────── */

.panel__input {
  display: block;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 14px;
  padding: 8px 12px;
  border: var(--ui-field-border) solid transparent;
  border-image-source: url("../assets/ui/field.png");
  border-image-slice: 2 fill;
  border-image-width: var(--ui-field-border);
  border-image-repeat: stretch;
  background-color: var(--field-fill);
  color: var(--field-ink);
  font: inherit;
  font-size: var(--font-min);
  text-align: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.panel__input:focus {
  border-image-source: url("../assets/ui/field focus.png");
  outline: none;
}

.menu-screen {
  align-items: stretch;
  justify-content: stretch;
  padding: 16px;
}

.menu-layout {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(220px, 1fr);
  gap: 16px;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.menu-rooms-panel,
.menu-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.menu-rooms-panel > .ui-panel,
.menu-panel > .ui-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.menu-rooms-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top: 8px;
  padding-bottom: 8px;
}

.menu-rooms-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.menu-rooms-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--ink);
  font-size: var(--font-min);
}

.menu-rooms-table th,
.menu-rooms-table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-rooms-table th {
  opacity: 0.75;
  font-weight: normal;
  position: sticky;
  top: 0;
  background: rgba(20, 17, 14, 0.92);
  z-index: 1;
}

.menu-rooms-table th:nth-child(2),
.menu-rooms-table td:nth-child(2),
.menu-rooms-table th:nth-child(3),
.menu-rooms-table td:nth-child(3),
.menu-rooms-table th:nth-child(4),
.menu-rooms-table td:nth-child(4),
.menu-rooms-table th:nth-child(5),
.menu-rooms-table td:nth-child(5) {
  width: 7.5rem;
  text-align: center;
}

.menu-rooms-table th:nth-child(6),
.menu-rooms-table td:nth-child(6) {
  width: 7rem;
  text-align: right;
}

.menu-rooms-table .menu-room__code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.menu-rooms-table .ui-btn {
  margin: 0;
  min-width: 88px;
  padding-left: 12px;
  padding-right: 12px;
}

.menu-rooms__empty-row td {
  text-align: center;
  opacity: 0.55;
  border-bottom: none;
  padding-top: 28px;
  padding-bottom: 28px;
}

.menu-panel__body {
  justify-content: flex-start;
}

.menu-panel__body .panel__btn {
  width: 100%;
  max-width: none;
  margin-bottom: 12px;
}

.menu-panel__body .panel__input {
  max-width: none;
}

.menu-join {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  margin-top: 4px;
}

.menu-join .panel__input {
  margin: 0;
  flex: 1;
  max-width: none;
}

.menu-join .panel__btn {
  margin: 0;
  width: 100%;
}

@media (max-width: 900px) {
  .menu-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.4fr) minmax(0, 1fr);
  }
}

.lobby-screen {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(196, 74, 58, 0.2), transparent 45%),
    radial-gradient(ellipse at 80% 40%, rgba(58, 111, 196, 0.2), transparent 45%),
    #14110e;
}

.lobby-screen[hidden] {
  display: none;
}

.lobby-top {
  flex: 0 0 auto;
  width: 100%;
}

.lobby-top__body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lobby-top__back,
.lobby-top__start {
  box-sizing: border-box;
  height: 40px;
  min-height: 40px;
  padding: 0 18px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.lobby-top__start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lobby-top__name {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 160px;
  flex: 1 1 220px;
}

.lobby-top__code,
.lobby-top__title {
  padding: 6px 10px;
  border: var(--ui-field-border) solid transparent;
  border-image-source: url("../assets/ui/field.png");
  border-image-slice: 2 fill;
  border-image-width: var(--ui-field-border);
  border-image-repeat: stretch;
  background-color: var(--field-fill);
  color: var(--field-ink);
  font: inherit;
  font-size: var(--font-min);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-sizing: border-box;
}

.lobby-top__code {
  flex: 0 0 auto;
  width: 7.5em;
  letter-spacing: 0.08em;
  text-align: center;
  cursor: text;
}

.lobby-top__title {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.lobby-top__title:focus {
  border-image-source: url("../assets/ui/field focus.png");
  outline: none;
}

.lobby-top__title:disabled {
  opacity: 0.85;
}

.lobby-top__map {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lobby-top__select {
  margin: 0;
  max-width: 200px;
}

.lobby-map-thumb {
  width: 56px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(196, 74, 58, 0.35), rgba(58, 111, 196, 0.35)),
    #2a2218;
  border: 2px solid #3d3228;
  color: var(--ink);
  font-size: 12px;
  overflow: hidden;
  text-align: center;
  line-height: 1.1;
  padding: 2px;
}

.lobby-cols {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  gap: 12px;
  box-sizing: border-box;
}

.lobby-team {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.lobby-team__title {
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  padding: 6px 10px;
  box-sizing: border-box;
  border: var(--ui-field-border) solid transparent;
  border-image-source: url("../assets/ui/field.png");
  border-image-slice: 2;
  border-image-width: var(--ui-field-border);
  border-image-repeat: stretch;
  color: var(--ink);
  font: inherit;
  font-size: var(--font-min);
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-align: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.lobby-team--red .lobby-team__title {
  background-color: var(--red);
}

.lobby-team--blue .lobby-team__title {
  background-color: var(--blue);
}

.lobby-team__slots {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 0 2px;
}

.lobby-team__footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 2px 2px 0;
}

.lobby-team__footer:empty {
  display: none;
}

.lobby-team__swap {
  width: 100%;
}

.lobby-team__swap:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lobby-seat {
  width: 100%;
  gap: 0;
  opacity: 1;
}

.lobby-seat.is-ready > .lobby-seat__card {
  box-shadow: 0 0 0 2px var(--ok);
}

.lobby-seat.is-mine > .lobby-seat__card {
  outline: 1px solid rgba(212, 160, 74, 0.55);
}

/* Заголовок слота = обычный field-dropdown (как раса), не panel title. */
.lobby-seat__kind {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 4px 28px 4px 8px;
  box-sizing: border-box;
}

.lobby-seat__card {
  width: 100%;
  min-width: 0;
}

.lobby-seat__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  min-height: 72px;
}

.lobby-seat__status {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 8px;
  color: var(--muted);
  font-size: var(--font-min);
  line-height: 1.3;
}

.lobby-seat__main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lobby-seat__info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lobby-seat__color {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #3d3228;
  box-sizing: border-box;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.lobby-seat__color--red {
  background: #b4202a;
}

.lobby-seat__color--blue {
  background: #249fde;
}

.lobby-seat__meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lobby-seat__cells {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}

.lobby-seat__cell {
  width: 36px;
  height: 64px;
  padding: 0;
  border: 1px solid #3d3228;
  background: #2a2218;
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-sizing: border-box;
}

.lobby-seat__cell--back {
  border: none;
  background-color: transparent;
  background-image: url("../assets/ui/card-suit.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.lobby-seat__cell:disabled {
  cursor: default;
}

.lobby-seat__cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lobby-seat__nick {
  width: 100%;
  padding: 4px 8px;
  border: var(--ui-field-border) solid transparent;
  border-image-source: url("../assets/ui/field.png");
  border-image-slice: 2 fill;
  border-image-width: var(--ui-field-border);
  border-image-repeat: stretch;
  background-color: var(--field-fill);
  color: var(--field-ink);
  font: inherit;
  font-size: var(--font-min);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-sizing: border-box;
}

.lobby-seat__nick:focus {
  border-image-source: url("../assets/ui/field focus.png");
  outline: none;
}

.lobby-seat__race {
  margin: 0;
  max-width: none;
  width: 100%;
  padding: 4px 28px 4px 8px;
  box-sizing: border-box;
}

.lobby-seat__value {
  width: 100%;
  min-height: 28px;
  padding: 2px 0;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: var(--font-min);
  line-height: 1.2;
  box-sizing: border-box;
}

.lobby-seat__nick-value {
  font-weight: 600;
}

.lobby-seat__race-value {
  color: var(--muted);
}

.lobby-catalog {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
}

.lobby-catalog > .ui-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lobby-catalog__body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  overflow: auto;
  max-height: calc(100vh - 140px);
  align-content: start;
  justify-items: center;
  padding: 4px 2px 12px;
}

/* Те же spell-card, что в матче — без «peek» из-под экрана */
.lobby-catalog .spell-card.lobby-spell-card {
  transform: none;
  filter: none;
  margin: 0;
  width: min(100%, var(--card-w));
  height: auto;
  aspect-ratio: 250 / 400;
  flex-shrink: 1;
}

.lobby-catalog .spell-card.lobby-spell-card:hover,
.lobby-catalog .spell-card.lobby-spell-card:focus-visible {
  transform: translateY(-6px);
  z-index: 2;
}

.lobby-catalog .spell-card.lobby-spell-card.is-selected {
  box-shadow: 0 0 0 3px var(--ok);
}

.lobby-spell-card__badge {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 40, 24, 0.72);
  color: #b6e0be;
  font-size: var(--font-min);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.lobby-spell-card__badge[hidden] {
  display: none;
}

.countdown-num {
  font-size: 96px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 4px 0 #1a1510;
  letter-spacing: 0.06em;
}

@media (max-width: 1100px) {
  .lobby-cols {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .lobby-catalog__body {
    max-height: 50vh;
  }
}

