/* Камни Бесконечности — Apple-style визуальный язык.
   SF Pro system font · true-neutral dark palette · vibrancy-материалы ·
   один спокойный акцент · капсульные контролы · сдержанная физика движения. */

:root {
  /* Нейтральная тёмная база (Apple dark: black → elevated grays). */
  --bg: #000000;
  --surface: rgba(28, 28, 30, 0.72);      /* systemGray6 @ vibrancy */
  --surface-2: rgba(44, 44, 46, 0.7);     /* systemGray5 */
  --fill: rgba(120, 120, 128, 0.24);      /* secondarySystemFill */
  --fill-strong: rgba(120, 120, 128, 0.36);
  --hairline: rgba(255, 255, 255, 0.10);
  --hairline-soft: rgba(255, 255, 255, 0.06);

  /* Текст (Apple label hierarchy, dark). */
  --label: #f5f5f7;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);

  /* Один спокойный акцент + системные семафоры. */
  --accent: #6c63ff;          /* indigo-violet, под самоцветы */
  --accent-press: #5a52e0;
  --green: #30d158;           /* systemGreen */
  --red: #ff453a;             /* systemRed */
  --orange: #ff9f0a;          /* systemOrange */

  /* Радиусы — единая шкала, крупные и мягкие. */
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Тени — низкие, мягкие, без «глоу». */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 10px 40px rgba(0, 0, 0, 0.5);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }

/* Спокойный фон: чистый чёрный + один мягкий акцент-ореол сверху. */
.screen::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(90% 60% at 50% -10%, rgba(108, 99, 255, 0.18), transparent 60%),
    radial-gradient(80% 60% at 50% 120%, rgba(48, 209, 88, 0.06), transparent 60%),
    #000;
}
/* Тонкая виньетка для глубины (без тяжёлого inset-glow). */
.screen::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  box-shadow: inset 0 0 160px 20px rgba(0, 0, 0, 0.55);
}

/* Едва заметное статичное звёздное поле — глубина, без мерцания. */
.stars {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5;
  background-image:
    radial-gradient(1px 1px at 22% 28%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 72% 18%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 42% 72%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 86% 62%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 12% 82%, rgba(255,255,255,0.3), transparent);
}

/* ===== МЕНЮ ===== */
.menu { display: grid; place-items: center; }
.menu-inner {
  position: relative; z-index: 1;
  width: min(560px, 92vw);
  text-align: center;
  padding: 24px;
}
.eyebrow {
  letter-spacing: 0.02em; text-transform: none;
  color: var(--label-2); font-weight: 600;
  font-size: clamp(13px, 3vw, 15px); margin: 0 0 10px;
}
.game-title {
  font-weight: 700;
  font-size: clamp(30px, 9vw, 72px); line-height: 1.03; margin: 0 0 16px;
  letter-spacing: -0.03em;
  color: var(--label);
  overflow-wrap: break-word; hyphens: none;
}
.tagline {
  color: var(--label-2); font-size: clamp(15px, 3.6vw, 18px);
  margin: 0 auto 22px; max-width: 42ch; line-height: 1.5; font-weight: 400;
}
.preview { width: 100%; height: clamp(90px, 18vw, 140px); display: block; margin: 4px auto 24px; }

/* ===== КНОПКИ (Apple filled / tinted) ===== */
.btn {
  font-family: var(--font); font-weight: 590; cursor: pointer;
  border: none; color: var(--label);
  background: var(--fill);
  padding: 12px 22px; border-radius: 980px; /* capsule */
  font-size: 16px; letter-spacing: -0.01em;
  transition: transform 0.18s var(--ease), background-color 0.18s var(--ease), filter 0.18s var(--ease);
}
.btn:hover { background: var(--fill-strong); }
.btn:active { transform: scale(0.97); }
.btn-hero {
  font-weight: 600; font-size: clamp(17px, 4.2vw, 19px);
  padding: 15px 52px; color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-1);
}
.btn-hero:hover { background: var(--accent); filter: brightness(1.08); }
.btn-hero:active { background: var(--accent-press); }
.btn-ghost { background: var(--fill); color: var(--label); }
.btn-attack {
  color: #fff;
  background: var(--orange);
}
.btn-attack:hover { filter: brightness(1.06); }

/* ===== ЛЕГЕНДА ===== */
.legend {
  margin-top: 24px; display: grid; gap: 8px; justify-content: center;
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 16px 20px;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}
.legend-row {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: clamp(13px, 3vw, 14px); color: var(--label-2); font-weight: 400;
}
.legend-row b { color: var(--label); font-weight: 600; }
.legend-row .arrow { color: var(--label-3); font-size: 0.9em; padding: 0 2px; }
.legend .dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--c, #fff);
  box-shadow: 0 0 8px var(--c, #fff); display: inline-block;
}
.legend-note { color: var(--label-3); font-size: 12px; margin: 6px 0 0; }

/* ===== БОЙ ===== */
.battle { display: flex; flex-direction: column; z-index: 1; }
.stage { position: relative; flex: 1 1 auto; min-height: 0; z-index: 1; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.panel {
  position: relative; z-index: 2;
  margin: 10px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-1);
}
.enemy-panel { }
.panel-main { display: flex; align-items: center; gap: 14px; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 0 auto; }
.sigil { font-size: 18px; opacity: 0.9; }
.enemy-sigil { color: var(--red); }
.player-sigil { color: var(--accent); }
.name {
  font-weight: 600; font-size: clamp(15px, 3.6vw, 18px);
  letter-spacing: -0.01em; white-space: nowrap; color: var(--label);
}

.hp { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.hp-bar {
  flex: 1 1 auto; height: 10px; border-radius: 980px; overflow: hidden;
  background: var(--fill);
}
.hp-fill {
  display: block; height: 100%; width: 100%; border-radius: 980px;
  transition: width 0.35s var(--ease);
}
.player-fill { background: var(--green); }
.enemy-fill { background: var(--red); }
.hp-num {
  font-size: clamp(12px, 2.8vw, 14px); color: var(--label-2);
  white-space: nowrap; flex: 0 0 auto;
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.count-num {
  margin-left: auto; flex: 0 0 auto; white-space: nowrap;
  font-size: clamp(12px, 3vw, 15px); color: var(--label-2);
  font-variant-numeric: tabular-nums; font-weight: 600;
}

.stone-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.stone-badge { width: 40px; height: 40px; }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Фазовый контроль Ход → Атака (§8). */
.phase-control { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.phase-step {
  padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--label-3); background: var(--fill); transition: all 0.25s var(--ease);
}
.phase-step.active { color: #fff; background: var(--accent); }
.phase-arrow { color: var(--label-3); font-size: 13px; }

/* Док артефактов — locked / recharging / ready / targeting (§7). */
.artifact-dock { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.artifact {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 7px 12px; border-radius: var(--r-sm);
  background: var(--fill); border: 1px solid var(--hairline);
  color: var(--label-2); font: inherit; cursor: pointer;
  transition: all 0.2s var(--ease); min-height: 44px; min-width: 44px;
}
.artifact:disabled { opacity: 0.5; cursor: default; }
.artifact.ready { color: var(--label); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.artifact.targeting { background: var(--accent); color: #fff; }
.art-name { font-size: 12px; font-weight: 600; }
.art-charge { font-size: 11px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.artifact.ready .art-charge { color: var(--green); }
.artifact.targeting .art-charge { color: rgba(255,255,255,0.8); }

.turn-info {
  color: var(--label-2); font-size: 13px; font-weight: 500;
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.actions .btn { padding: 9px 18px; font-size: 15px; }
.actions .btn:disabled { opacity: 0.4; cursor: default; }
.rules-note { margin-top: 12px; font-size: 12px; color: var(--label-3); font-style: italic; }

/* Тряска при попадании — короткая и сдержанная. */
.panel.hit { animation: panelHit 0.32s var(--ease); }
@keyframes panelHit {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

/* ===== ОВЕРЛЕЙ ===== */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  opacity: 0; transition: opacity 0.35s var(--ease);
}
.overlay.shown { opacity: 1; }
.overlay-card {
  position: relative; text-align: center; width: min(420px, 90vw);
  padding: 36px 28px; border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-2);
  transform: scale(0.92); transition: transform 0.35s var(--ease);
}
.overlay.shown .overlay-card { transform: scale(1); }
.overlay-title {
  font-weight: 700; font-size: clamp(28px, 8vw, 40px); margin: 0 0 10px;
  letter-spacing: -0.02em; color: var(--label);
}
.overlay.win .overlay-title { color: var(--green); }
.overlay.lose .overlay-title { color: var(--red); }
.overlay-sub { color: var(--label-2); font-size: 15px; line-height: 1.5; margin: 0 0 24px; }
.overlay-btns { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.overlay-btns .btn { width: 100%; max-width: 280px; }

/* ===== МОДАЛКА ПРАВИЛ ===== */
.modal {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); padding: 16px;
}
.modal-card {
  position: relative; width: min(500px, 94vw); max-height: 86vh; overflow: auto;
  padding: 28px; border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-2);
}
.modal-card h3 { font-weight: 700; font-size: 22px; margin: 0 0 16px; color: var(--label); letter-spacing: -0.02em; }
.modal-card ul { margin: 0; padding-left: 20px; color: var(--label-2); line-height: 1.6; font-size: 15px; }
.modal-card li { margin-bottom: 12px; }
.modal-card b { color: var(--label); font-weight: 600; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--fill); color: var(--label-2); cursor: pointer; font-size: 14px;
  transition: background-color 0.18s var(--ease);
}
.modal-close:hover { background: var(--fill-strong); color: var(--label); }

/* ===== АДАПТИВ ===== */
@media (min-width: 720px) {
  .panel { margin: 14px auto; width: min(820px, 94vw); }
  .stone-badge { width: 46px; height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel.hit { animation-duration: 0.15s; }
  * { transition-duration: 0.01ms !important; }
}
