/* ==========================================================================
   Mapwright - Buttons, Toolbars, Docks & HUD Controls CSS
   ========================================================================== */

/* ---------- 1. Базовые кнопки и модификаторы ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  padding: 6px 11px;
  border-radius: var(--r-item, 7px);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.btn.warn {
  border-color: var(--danger);
  color: var(--danger);
}

.btn.sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn.xs {
  padding: 2px 7px;
  font-size: 11px;
  border-radius: var(--r-sm, 5px);
  line-height: 1.3;
}

.btn.ico {
  width: 28px;
  padding: 4px 0;
  text-align: center;
  justify-content: center;
}

.btn:disabled {
  opacity: .45;
  cursor: default;
}

.btn:disabled:hover {
  border-color: var(--line);
}

.eraser-btn {
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, rgba(45, 212, 191, .14), rgba(200, 166, 104, .12));
  border: 1px solid rgba(200, 166, 104, .35);
  color: #e8eef3;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.eraser-btn:hover {
  transform: translateY(-1px);
  border-color: var(--brass);
  background: rgba(45, 212, 191, .22);
}

/* ---------- 2. Переключатели, табы и чипы ---------- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel2);
  padding: 3px;
  border-radius: var(--r-item, 7px);
}

.tab {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: var(--r-item, 7px);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.tab[aria-selected="true"] {
  background: var(--brass);
  color: #090d14;
  border-radius: var(--r-item, 7px);
  font-weight: 700;
}

.seg {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--r-item, 7px);
  border: 1px solid var(--line);
}

.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 5px 8px;
  border-radius: var(--r-sm, 5px);
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.seg button.active,
.seg button[aria-pressed="true"] {
  background: var(--brass);
  color: #090d14;
}

.seg.actors-subtabs button {
  font-size: 11px;
  padding: 6px 2px;
  white-space: nowrap;
}

.seg.sm button {
  padding: 3px 6px;
  font-size: 11px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: var(--r-sm, 5px);
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--brass);
  color: #090d14;
  border-color: var(--brass);
}

.dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.dots button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.dots button[aria-pressed="true"] {
  border-color: var(--fg);
}

.dots button.none {
  background: repeating-linear-gradient(45deg, var(--panel2), var(--panel2) 4px, var(--line) 4px, var(--line) 6px);
}

.mini {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fg);
}

.rowbtns {
  display: flex;
  gap: 3px;
}

/* ---------- 3. Кнопки верхней шапки ---------- */
#btn-role {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  flex-shrink: 0;
}

#btn-role svg {
  display: block;
  pointer-events: none;
}

#btn-sfx {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 13px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--brass);
  cursor: pointer;
  transition: all 0.15s ease;
}

#btn-sfx:hover {
  background: var(--line);
  border-color: var(--brass);
  transform: translateY(-1px);
}

.mapbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.map-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 4px 10px;
  border-radius: var(--r-item, 7px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.map-pill-btn:hover {
  border-color: var(--brass);
  background: color-mix(in srgb, var(--panel2) 80%, var(--brass) 20%);
  color: #fff;
  transform: translateY(-1px);
}

.map-pill-ico {
  font-size: 14px;
  line-height: 1;
}

.map-pill-name {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-status-dot {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
}

.map-status-dot.online {
  color: var(--hp-ok, #10b981);
  text-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.map-status-warn {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  line-height: 1.2;
}

/* ---------- 4. Кнопки зума и прицела ---------- */
.zoom-stack {
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--r-panel, 10px);
  padding: 2px;
  gap: 2px;
  box-shadow: var(--hud-shadow);
}

.zb {
  width: 32px;
  height: 32px;
  border-radius: var(--r-item, 7px);
  border: 0;
  background: transparent;
  color: var(--fg);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.zb:hover {
  background: var(--panel2);
  color: var(--accent);
}

.zb.fit {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zb.fit svg {
  display: block;
}

.pad-scope-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 9px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  color: var(--accent);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pad-scope-btn:hover {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.pad-scope-btn svg {
  pointer-events: none;
}

/* ---------- 5. Левый тулбар инструментов ---------- */
.tools {
  position: fixed;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  width: 48px;
  max-height: calc(100vh - 24px);
  padding: 6px;
  border-radius: var(--r-panel, 10px);
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  box-shadow: var(--hud-shadow);
  display: flex;
  flex-direction: column;
}

.dockbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tw {
  position: static;
}

.dockbar .tool {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: var(--r-item, 7px);
}

.tool {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: var(--r-item, 7px);
  padding: 7px 6px;
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
  transition: all 0.15s ease;
}

.tool svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.tool kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

.tool[aria-pressed="true"] {
  background: var(--brass);
  color: #090d14;
  border-color: var(--brass);
}

.tool[aria-pressed="true"] svg {
  stroke: #090d14;
}

.tool[aria-pressed="true"] kbd {
  color: inherit;
  opacity: .7;
}

/* AI Settings Tool Button */
.tool.ai-tool-btn {
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool.ai-tool-btn:hover {
  border-color: rgba(45, 212, 191, 0.6);
  color: #2dd4bf;
  box-shadow: 0 0 10px rgba(45, 212, 191, 0.3), 0 0 4px rgba(200, 166, 104, 0.35);
}

.tool.ai-tool-btn:active {
  transform: scale(0.94);
}

.tool.ai-tool-btn.has-key::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2dd4bf;
  box-shadow: 0 0 6px #2dd4bf;
  pointer-events: none;
}

/* AI Settings Modal Styles */
.ai-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.ai-status-badge.configured {
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: #2dd4bf;
}

.ai-status-badge.unconfigured {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.ai-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-field-group label {
  font-size: 13px;
  font-weight: 600;
  color: #e6ca8d;
}

.ai-field-group .hint {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
}

.ai-test-output {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.ai-test-output.success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

.ai-test-output.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.ai-test-output.loading {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
}

.dsep {
  display: block;
  height: 1px;
  background: var(--line);
  margin: 4px 6px;
}

.dockpop {
  position: absolute;
  z-index: 12;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  width: 230px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-panel, 10px);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--hud-shadow);
}

.dockpop.wide {
  width: 256px;
}

.dockpop .seg {
  flex-wrap: wrap;
}

.dockpop .seg button[data-act="pshape"] {
  flex: 1 1 auto;
  white-space: nowrap;
  font-size: 12px;
  padding: 6px 8px;
}

.dockpop .props {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dockpop .props canvas {
  width: 34px;
  height: 34px;
}

.dockpop .props button {
  font-size: 10.5px;
  padding: 4px 2px;
}

.pal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.pal button {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 7px;
  padding: 5px 7px;
  font-size: 12.5px;
  text-align: left;
  min-width: 0;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
}

.pal button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 600;
}

.pal i {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, .35);
}

.props {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.props button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 7px;
  padding: 5px 3px;
  font-size: 11.5px;
  min-width: 0;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
}

.props button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 600;
}

.props canvas {
  width: 40px;
  height: 40px;
}

/* ---------- 6. Правый вертикальный док ---------- */

.right-dock {
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  padding: 6px;
  border-radius: var(--r-panel, 10px);
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  box-shadow: var(--hud-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.dock-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--r-item, 7px);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  cursor: pointer;
}

.dock-btn:hover {
  background: var(--panel2);
  color: var(--fg);
  border-color: var(--line);
}

.dock-btn[aria-pressed="true"],
.dock-btn.active {
  background: var(--brass);
  color: #090d14;
  border-color: var(--brass);
  box-shadow: 0 0 10px var(--brass-glow);
}

.dock-btn[aria-pressed="true"] svg,
.dock-btn.active svg {
  stroke: #090d14;
}

/* ---------- 7. Нижний центральный HUD и хотбар слотов ---------- */
.hud-bottom-center {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.hud-hero-pill {
  pointer-events: auto;
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--r-panel, 10px);
  padding: 5px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--hud-shadow);
  transition: all 0.15s ease;
  user-select: none;
}

.hud-hero-pill:hover {
  border-color: var(--accent);
  background: var(--panel2);
  transform: translateY(-1px);
}

.hud-hero-pill.placing-glow {
  border-color: #f1c40f !important;
  box-shadow: 0 0 16px rgba(241, 196, 15, 0.5), inset 0 0 10px rgba(241, 196, 15, 0.2) !important;
  animation: pulse-placing-gold 1.8s ease-in-out infinite;
  background: rgba(28, 22, 10, 0.9) !important;
}

@keyframes pulse-placing-gold {
  0%, 100% {
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.4), inset 0 0 8px rgba(241, 196, 15, 0.2);
    border-color: #f1c40f;
  }
  50% {
    box-shadow: 0 0 24px rgba(241, 196, 15, 0.8), inset 0 0 16px rgba(241, 196, 15, 0.35);
    border-color: #ffe066;
  }
}

.hero-pill-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--fg);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-pill-hp {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: #2ecc71;
}

.hero-pill-ac {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--brass);
}

/* DM Bottom HUD Pill & Context Bar */
.hud-hero-pill.dm-pill {
  cursor: default;
  gap: 8px;
  max-width: min(760px, calc(100vw - 440px));
  overflow-x: auto;
  scrollbar-width: none;
}

.hud-hero-pill.dm-pill:hover {
  border-color: var(--line);
  background: var(--panel);
  transform: none;
}

.hud-hero-pill .dm-pill-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg);
  white-space: nowrap;
}

.hud-hero-pill .dm-pill-status b {
  color: var(--brass);
}

.hud-hero-pill .dm-pill-status i {
  color: var(--accent);
  font-style: normal;
}

/* World Mode HUD Bar */
.hud-hero-pill .world-hud-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg);
  white-space: nowrap;
}

.hud-hero-pill .world-hud-bar span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hud-hero-pill .world-hud-bar b {
  color: var(--brass);
}

.hud-hero-pill .world-hud-bar i {
  color: var(--accent);
  font-style: normal;
}

.hud-hero-pill:has(.world-hud-bar) {
  cursor: default;
  transform: none;
}

.hud-hero-pill:has(.world-hud-bar):hover {
  border-color: var(--line);
  background: var(--panel);
  transform: none;
}

.world-mode .hud-hero-pill {
  cursor: default;
}

.world-mode .hud-hero-pill:hover {
  transform: none;
}

.hud-hero-pill .dm-pill-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.hud-hero-pill .dm-pill-hp-btn {
  padding: 2px 5px !important;
  font-size: 11px !important;
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1;
  min-width: 24px;
  height: 22px;
}

.hud-hero-pill .btn.xs {
  padding: 3px 8px;
  font-size: 11px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
}

.hud-hero-pill .btn.xs.ico {
  width: 24px;
  padding: 0;
}

.hud-hero-pill .dm-pill-inp {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  height: 24px;
  font-family: inherit;
  box-sizing: border-box;
}

.hud-hero-pill .dm-pill-inp:focus {
  border-color: var(--accent);
  outline: none;
}

.spell-icon-img {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(200, 166, 104, 0.25);
  background: rgba(10, 15, 22, 0.6);
  vertical-align: middle;
}

/* ---------- 7.1. Боевая Консоль Героя (Hero Combat Console / HUD - Monolith) ---------- */
.hero-combat-hud {
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: relative;
  user-select: none;
  font-family: var(--font-body);
}

/* Единый корпус Монолита */
.hud-monolith {
  background: linear-gradient(180deg, rgba(18, 26, 38, 0.95) 0%, rgba(10, 15, 22, 0.98) 100%);
  border: 1px solid rgba(200, 166, 104, 0.38);
  border-radius: 14px;
  padding: 8px 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  user-select: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.hud-monolith.my-turn-glow {
  border-color: rgba(241, 196, 15, 0.85);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.8), 0 0 22px rgba(200, 166, 104, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* Плавающий баннер активного хода над монолитом */
.hud-turn-banner {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: auto;
  white-space: nowrap;
}

.hud-turn-end-btn {
  background: linear-gradient(135deg, #d4af37 0%, #aa8024 100%) !important;
  color: #0b1016 !important;
  font-family: var(--font-body) !important;
  font-weight: 800 !important;
  font-size: 11.5px !important;
  padding: 5px 14px !important;
  border-radius: 20px !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.5), 0 0 12px rgba(241, 196, 15, 0.35) !important;
  cursor: pointer;
  animation: turnPulse 2s infinite ease-in-out;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hud-turn-end-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.65), 0 0 16px rgba(241, 196, 15, 0.5) !important;
}

.hud-roll-init-btn {
  background: rgba(24, 32, 44, 0.92) !important;
  color: var(--muted, #94a3b8) !important;
  font-family: var(--font-body) !important;
  font-weight: 600 !important;
  font-size: 10.5px !important;
  padding: 3px 10px !important;
  border-radius: 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45) !important;
  cursor: pointer;
  animation: none !important;
  transition: all 0.15s ease;
}

.hud-roll-init-btn:hover {
  background: rgba(36, 48, 66, 0.96) !important;
  color: var(--fg, #e8eef5) !important;
  border-color: var(--brass, #c8a668) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6) !important;
}

.hud-monolith.has-resource-shelf .hud-turn-banner {
  bottom: calc(100% + 44px);
}

@keyframes turnPulse {
  0%, 100% {
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.5), 0 0 12px rgba(241, 196, 15, 0.35);
  }
  50% {
    box-shadow: 0 6px 22px rgba(245, 158, 11, 0.75), 0 0 20px rgba(251, 191, 36, 0.6);
  }
}

/* Тонкие вертикальные разделители */
.hud-divider {
  width: 1px;
  height: 48px;
  background: linear-gradient(180deg, transparent, rgba(200, 166, 104, 0.3), transparent);
  flex-shrink: 0;
}

/* Крылья монолита */
.hud-wing-left,
.hud-wing.hud-wing-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-wing-right,
.hud-wing.hud-wing-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Slot Wrappers */
.hud-slot-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

/* Ровные квадратные слоты 54x54 */
.hud-slot-box {
  width: 54px;
  height: 54px;
  border-radius: 9px;
  background: rgba(15, 22, 32, 0.85);
  border: 1px solid rgba(200, 166, 104, 0.22);
  color: var(--fg);
  padding: 2px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: var(--font-body);
  box-sizing: border-box;
}

.hud-slot-box:hover {
  border-color: var(--brass);
  background: rgba(200, 166, 104, 0.12);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.hud-slot-box:active {
  transform: translateY(0);
}

.hud-slot-box.empty {
  border-style: dashed;
  opacity: 0.65;
}

.hud-slot-box.empty:hover {
  opacity: 1;
  border-style: solid;
}

.hud-slot-box.weapon-slot.has-weapon {
  border-color: rgba(200, 166, 104, 0.35);
  background: linear-gradient(180deg, rgba(30, 41, 56, 0.9) 0%, rgba(18, 25, 36, 0.9) 100%);
}

.hud-slot-box.item-slot.has-item {
  border-color: rgba(45, 212, 191, 0.3);
  background: linear-gradient(180deg, rgba(20, 38, 38, 0.9) 0%, rgba(14, 26, 28, 0.9) 100%);
}

.hud-slot-box.spell-slot.has-spell {
  border-color: rgba(129, 140, 248, 0.35);
  background: linear-gradient(180deg, rgba(30, 32, 60, 0.9) 0%, rgba(18, 20, 42, 0.9) 100%);
}

/* Мини-триггер меню в правом верхнем углу слота */
.hud-slot-menu-trigger {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  font-size: 10px;
  color: rgba(200, 166, 104, 0.4);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 2;
}

.hud-slot-box:hover .hud-slot-menu-trigger,
.hud-slot-menu-trigger:hover {
  color: var(--brass);
  background: rgba(200, 166, 104, 0.25);
  text-shadow: 0 0 6px rgba(200, 166, 104, 0.8);
}

/* Бейджики и горячие клавиши внутри слота */
.slot-hotkey {
  position: absolute;
  bottom: 2px;
  left: 4px;
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: rgba(200, 166, 104, 0.55);
  line-height: 1;
  pointer-events: none;
}

.slot-badge-mod {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.slot-badge-qty {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--brass);
  line-height: 1;
}

.slot-badge-circle {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 8px;
  font-family: var(--font-mono);
  font-weight: 800;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.35);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 1.2;
}

.slot-main-icon {
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.slot-spell-img {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
  pointer-events: none;
}

.slot-subtext {
  font-size: 9px;
  line-height: 1.1;
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  margin-top: 2px;
  opacity: 0.9;
}

/* Central Core */
.hud-center-core {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.hud-center-core.hud-core-empty {
  padding: 10px 16px;
  background: rgba(13, 19, 26, 0.92);
  border: 1px dashed var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.hud-core-empty-text {
  font-size: 11px;
  color: var(--muted);
}

/* Portrait Frame 56x56 */
.hud-core-portrait {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 2px solid var(--brass);
  background: rgba(13, 19, 26, 0.95);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.65), 0 0 10px rgba(200, 166, 104, 0.15);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.hud-core-portrait:hover {
  transform: translateY(-1px);
  border-color: #ffd700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.75), 0 0 14px rgba(241, 196, 15, 0.4);
}

.hud-core-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hud-core-avatar.fallback,
.hud-core-portrait.empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

.hud-core-avatar.fallback span {
  font-size: 24px;
  font-weight: 800;
  color: var(--brass);
  font-family: var(--font-serif, serif);
}

/* AC Shield & Scope Buttons on Portrait */
.hud-core-ac {
  position: absolute;
  bottom: 2px;
  left: 2px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 3px;
  background: rgba(10, 15, 22, 0.92);
  border: 1px solid rgba(200, 166, 104, 0.45);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 800;
  color: var(--brass);
  line-height: 1.1;
  z-index: 2;
}

.ac-shield-icon {
  font-size: 8.5px;
}

.hud-core-scope {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 22, 0.92);
  border: 1px solid rgba(200, 166, 104, 0.4);
  border-radius: 4px;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 2;
}

.hud-core-scope:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.2);
}

/* Status Stack (Right of portrait) */
.hud-core-status-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
}

.hud-core-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-core-hero-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--fg);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Action Economy Dots */
.hud-action-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 5px;
  background: rgba(10, 15, 22, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.hud-action-dot {
  width: 16px;
  height: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-action-dot svg {
  transition: all 0.2s ease;
}

/* Action: Circle (Teal) */
.hud-action-dot.act-circle.active svg {
  color: #2dd4bf;
  filter: drop-shadow(0 0 6px rgba(45, 212, 191, 0.8));
}

.hud-action-dot.act-circle.spent svg {
  color: #334155;
  opacity: 0.45;
}

/* Bonus Action: Square (Gold/Orange) */
.hud-action-dot.act-square.active svg {
  color: #f59e0b;
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.8));
}

.hud-action-dot.act-square.spent svg {
  color: #334155;
  opacity: 0.45;
}

/* Reaction: Triangle (Purple) */
.hud-action-dot.act-triangle.active svg {
  color: #c084fc;
  filter: drop-shadow(0 0 6px rgba(192, 132, 252, 0.8));
}

.hud-action-dot.act-triangle.spent svg {
  color: #334155;
  opacity: 0.45;
}

.hud-action-dot:hover svg {
  transform: scale(1.18);
}

/* HP Row with -1 / +1 Buttons */
.hud-core-hp-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hud-hp-adj-btn {
  width: 18px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 28, 38, 0.85);
  border: 1px solid rgba(200, 166, 104, 0.25);
  border-radius: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.hud-hp-adj-btn:hover {
  color: var(--brass);
  border-color: var(--brass);
  background: rgba(200, 166, 104, 0.2);
}

.hud-core-hp-wrap {
  width: 150px;
  height: 20px;
  background: rgba(10, 15, 22, 0.85);
  border: 1px solid rgba(200, 166, 104, 0.3);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.hud-core-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  border-radius: 3px;
  transition: width 0.25s ease;
}

.hud-core-hp-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  pointer-events: none;
}

/* Right Wing: Quick Spells Row */
.hud-quick-spells-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Floating Resource Shelf */
.hud-floating-resource-shelf {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(11, 16, 22, 0.96);
  border: 1px solid rgba(200, 166, 104, 0.35);
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  white-space: nowrap;
  user-select: none;
}

.hud-shelf-sep {
  width: 1px;
  height: 18px;
  background: rgba(200, 166, 104, 0.25);
  margin: 0 2px;
  flex-shrink: 0;
}

.hud-resource-chip {
  border-color: rgba(245, 158, 11, 0.35) !important;
  background: rgba(28, 22, 14, 0.85) !important;
}
.hud-resource-chip:hover {
  border-color: #f59e0b !important;
}

/* Позиционирование баннера активного хода при наличии полочки ресурсов */
.hud-monolith.has-resource-shelf .hud-turn-banner,
.hero-combat-hud:has(.has-resource-shelf) .hud-turn-banner {
  bottom: calc(100% + 40px);
}

.hud-spell-slots-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
}

.hud-circle-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(20, 28, 38, 0.85);
  border: 1px solid rgba(200, 166, 104, 0.25);
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 22px;
}

.hud-circle-block:hover {
  border-color: var(--brass);
  background: rgba(200, 166, 104, 0.15);
  transform: translateY(-1px);
}

.hud-circle-num {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 800;
  color: var(--brass);
  line-height: 1;
}

.hud-circle-pips {
  display: flex;
  align-items: center;
  gap: 2px;
}

.hud-slot-pip {
  width: 5px;
  height: 5px;
  border-radius: 1px;
  box-sizing: border-box;
}

.hud-slot-pip.filled {
  background: #818cf8;
  box-shadow: 0 0 4px rgba(129, 140, 248, 0.7);
}

.hud-slot-pip.spent {
  background: transparent;
  border: 1px solid #475569;
  opacity: 0.45;
}

/* Upward Popup Menus */
.hud-popup-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 260px;
  max-width: 330px;
  background: rgba(11, 16, 22, 0.97);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--brass);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75);
  padding: 8px 10px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-popup-menu::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--brass);
}

.hud-pop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
}

.hud-pop-title {
  font-weight: 700;
  font-size: 11.5px;
  color: var(--brass);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-pop-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 4px;
}

.hud-pop-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.hud-pop-body {
  max-height: 230px;
  overflow-y: auto;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-pop-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(20, 28, 38, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 6px 8px;
}

.hud-pop-sec-title {
  font-size: 11px;
  color: var(--fg);
}

.hud-pop-sec-title b {
  color: var(--brass);
}

.hud-pop-sec-desc {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
}

.hud-pop-btn {
  align-self: flex-start;
  margin-top: 3px;
}

.hud-pop-lvl-header {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--brass);
  letter-spacing: 0.5px;
  padding: 4px 2px 2px;
  border-bottom: 1px solid rgba(200, 166, 104, 0.15);
}

.hud-pop-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(20, 28, 38, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.hud-pop-item-row:hover {
  background: rgba(20, 28, 38, 0.8);
  border-color: rgba(200, 166, 104, 0.2);
}

.hud-pop-item-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.hud-pop-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.hud-pop-icon-fallback {
  font-size: 14px;
  flex-shrink: 0;
}

.hud-pop-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hud-pop-item-name {
  font-size: 11px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-pop-item-meta {
  font-size: 9.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-pop-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.hud-pop-feat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-pop-feat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hud-pop-feat-info {
  display: flex;
  flex-direction: column;
  font-size: 10px;
  min-width: 0;
}

.hud-pop-feat-info b {
  color: var(--fg);
}

.hud-pop-feat-info span {
  color: var(--muted);
  font-size: 9px;
}

.hud-pop-empty {
  padding: 12px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* ---------- 8. Адаптивность для кнопок, тулбаров и доков ---------- */
@media (max-width: 940px) {
  .tools {
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    padding: 4px;
  }
  .dockbar .tool {
    width: 34px;
    height: 34px;
  }
  .dockpop {
    width: min(220px, calc(100vw - 80px));
  }
}

@media (max-width: 640px) {
  .tab {
    padding: 5px 10px;
  }
  .mapbar .inp {
    max-width: 150px;
  }
}

@media (max-height: 520px) {
  .dockbar .tool {
    width: 32px;
    height: 32px;
  }
  .tools {
    width: 42px;
    padding: 4px;
  }
}
