body {
  font-family: var(--font-family);
  background: var(--gradient-body);
  color: var(--color-text);
  overflow: hidden;
  min-height: 100vh;
}

#game-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#ui-layer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

#hud-layer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}

#hud-layer .action-bar {
  pointer-events: auto;
}

#hud-layer .action-bar[data-chat-open="true"],
#hud-layer .action-bar.action-bar--chat-open {
  pointer-events: none;
}

#modal-layer {
  position: fixed;
  inset: 0;
  z-index: 1400;
  pointer-events: none;
}

#modal-layer .modal,
#modal-layer .guide,
#modal-layer .tooltip {
  pointer-events: auto;
}

body[data-modal-open="true"] #ui-layer,
body[data-modal-open="true"] #hud-layer .action-bar {
  pointer-events: none;
}

#ui-layer .arena-shell__hud,
#ui-layer .arena-shell__panels,
#ui-layer .arena-shell__overlays,
#ui-layer .action-bar,
#ui-layer .modal {
  pointer-events: auto;
}

/* === Каркас зон === */
.arena-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.arena-shell__canvas,
#game {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* === Панели и карточки === */
.panel-stack {
  position: relative;
  z-index: 7;
}

.card {
  position: absolute;
  padding: 10px;
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, rgba(34, 24, 14, 0.96), rgba(23, 16, 10, 0.96));
  backdrop-filter: blur(4px);
  border: 1px solid var(--color-border-panel);
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text);
  box-shadow: var(--shadow-card);
  z-index: 6;
}

.panel-toggle {
  width: 28px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.7);
  color: var(--color-text);
  cursor: pointer;
}

/* === Оверлеи, загрузка и модальные окна === */
.hidden {
  display: none !important;
}

.overlay {
  pointer-events: auto;
}

#preloader {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, #0a0f21, #030712 55%);
  display: grid;
  place-items: center;
  color: var(--color-text);
  gap: 8px;
  z-index: 10;
}

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 4px solid rgba(148, 163, 184, 0.4);
  border-top-color: #38bdf8;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal-box {
  background: #0b1229;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  width: min(360px, 90vw);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.modal-box h3 {
  margin-bottom: 8px;
}

.modal-box input {
  width: 100%;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: var(--color-text);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.92), rgba(194, 65, 12, 0.92));
  color: rgba(15, 23, 42, 0.95);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.modal-actions button.secondary {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.75);
  color: var(--color-text);
  box-shadow: none;
}

.modal-actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(253, 230, 138, 0.55);
}

.modal-actions button:active {
  transform: translateY(0);
}

.modal-actions button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.modal-actions button:focus-visible {
  outline: none;
  box-shadow: var(--border-focus);
}

.guide {
  position: fixed;
  bottom: calc(160px + var(--safe-bottom) + var(--action-bar-chat-offset, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  min-width: 280px;
  max-width: min(560px, 92vw);
  padding: 12px 14px;
  background: var(--gradient-panel-velvet);
  border-color: var(--color-border-panel-strong);
  box-shadow: var(--shadow-float-soft);
}

.guide h2 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.2;
}

.guide small {
  color: var(--color-muted-subtle);
}

.guide #guide-body {
  font-size: 14px;
  color: rgba(226, 232, 240, 0.92);
}

.guide-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.guide-controls input {
  width: 16px;
  height: 16px;
  accent-color: var(--color-gold-strong);
}

.guide-actions {
  margin-top: 8px;
}
