:root {
  --bg: #070b14;
  --bg-grad: radial-gradient(circle at 18% 0%, #16223f 0%, #070b14 60%);
  --panel: rgba(15, 23, 42, 0.88);
  --panel-soft: rgba(30, 41, 59, 0.55);
  --border: rgba(148, 163, 184, 0.16);
  --cyan: #38bdf8;
  --indigo: #818cf8;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-grad);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Верхняя панель навигации и бренда NetPulse --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
}

.brand-title { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.8rem; color: var(--muted); }

.node-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

.node-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}

/* --- Общие карточки панелей --- */
.card-panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

/* --- Секция SpeedTest --- */
.speedtest-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  align-items: center;
}

@media (max-width: 820px) {
  .speedtest-grid { grid-template-columns: 1fr; }
}

.gauge-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.gauge-svg-wrap {
  position: relative;
  width: 210px;
  height: 145px;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 12px;
}

.gauge-value {
  font-size: 2.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}

.gauge-unit {
  font-size: 0.8rem;
  color: var(--cyan);
  margin-top: 4px;
  font-weight: 600;
}

.btn {
  border: 1px solid var(--border);
  background: #1e293b;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); background: #283548; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #4f46e5);
  border: none;
  color: #fff;
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  box-shadow: 0 10px 26px rgba(56, 189, 248, 0.38);
}

.btn-amber {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #0b0f19;
}

.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 8px; }

.speedtest-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.st-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.phase-badge {
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: var(--cyan);
  font-weight: 600;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
}

.metric-tile {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.metric-label { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.metric-num { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metric-num span { font-size: 0.75rem; font-weight: 500; color: var(--muted); margin-left: 3px; }

.chart-wrap {
  height: 76px;
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  padding: 4px;
}

.chart-wrap canvas { width: 100%; height: 100%; display: block; }

.st-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.83rem;
  color: var(--muted);
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-weight: 500;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--cyan);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* --- Секция Карточного Рогалика «Лапки и Руны» --- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.game-title-wrap h2 {
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.game-top-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.cat-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.32);
  color: var(--amber);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  user-select: none;
}

.cat-toggle-pill input {
  accent-color: var(--amber);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.run-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(7, 11, 20, 0.55);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.run-stats { display: flex; gap: 18px; flex-wrap: wrap; font-weight: 600; }
.relic-strip { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.relic-badge {
  padding: 3px 9px;
  border-radius: 8px;
  background: rgba(129, 140, 248, 0.16);
  border: 1px solid rgba(129, 140, 248, 0.35);
  font-size: 0.78rem;
  color: #c7d2fe;
  cursor: help;
}

/* --- Карта подземелья --- */
.map-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.map-legend {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.map-floors {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}

.map-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid transparent;
}

.map-row.current-row {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
}

.floor-num {
  width: 68px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.map-node {
  min-width: 122px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #131c31;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: default;
  opacity: 0.55;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.16s ease;
}

.map-node.visited { opacity: 0.35; text-decoration: line-through; }

.map-node.available {
  opacity: 1;
  cursor: pointer;
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.25);
}

.map-node.available:hover {
  transform: translateY(-2px) scale(1.03);
  background: #1a2947;
}

/* --- Арена боя --- */
.combat-arena {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fighters-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 720px) {
  .fighters-row { grid-template-columns: 1fr; }
  .vs-badge { display: none; }
}

.fighter-card {
  background: rgba(11, 18, 34, 0.82);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
}

.fighter-card.hit-flash { animation: shakeFlash 0.35s ease; }

@keyframes shakeFlash {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); border-color: var(--rose); }
  75% { transform: translateX(6px); border-color: var(--rose); }
}

.intent-pill {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(251, 113, 133, 0.16);
  border: 1px solid rgba(251, 113, 133, 0.38);
  color: #fda4af;
}

.intent-pill.defend {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
}

.portrait-frame {
  width: 136px;
  height: 112px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #070b14;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-frame video,
.portrait-frame img,
.portrait-frame svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hp-wrap {
  width: 100%;
  background: #070b14;
  border-radius: 999px;
  height: 18px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #fb7185);
  transition: width 0.25s ease;
}

.hp-fill.hero { background: linear-gradient(90deg, #10b981, #34d399); }

.hp-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.74rem;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}

.status-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 22px;
}

.st-tag {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.16);
}
.st-tag.block { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; }
.st-tag.str { background: rgba(251, 191, 36, 0.2); color: #fde68a; }
.st-tag.vuln { background: rgba(251, 113, 133, 0.22); color: #fda4af; }
.st-tag.weak { background: rgba(167, 139, 250, 0.2); color: #ddd6fe; }
.st-tag.poison { background: rgba(52, 211, 153, 0.2); color: #6ee7b7; }

.vs-badge {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--muted);
  font-size: 0.95rem;
}

/* --- Панель энергии и управления ходом --- */
.turn-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
}

.energy-orb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.12));
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: var(--amber);
  font-weight: 800;
}

.combat-log {
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1;
  text-align: center;
  min-width: 200px;
}

/* --- Рука карт --- */
.hand-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  min-height: 215px;
  padding: 6px 2px;
}

.play-card {
  width: 158px;
  background: linear-gradient(180deg, #1a2642 0%, #0e172a 100%);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  position: relative;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  user-select: none;
}

.play-card.attack { border-top: 3px solid var(--rose); }
.play-card.skill  { border-top: 3px solid var(--cyan); }
.play-card.power  { border-top: 3px solid var(--amber); }

.play-card:hover:not(.disabled) {
  transform: translateY(-8px) scale(1.03);
  border-color: var(--cyan);
  box-shadow: 0 14px 28px rgba(56, 189, 248, 0.25);
  z-index: 4;
}

.play-card.disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.card-cost {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--amber);
  color: #0b0f19;
  font-weight: 800;
  font-size: 0.82rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.card-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  text-align: right;
}

.card-name.upgraded { color: var(--emerald); }

.card-art {
  width: 100%;
  height: 82px;
  border-radius: 9px;
  overflow: hidden;
  background: #060a14;
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.card-art video,
.card-art img,
.card-art svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-desc {
  font-size: 0.75rem;
  color: #cbd5e1;
  text-align: center;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-type-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
}

/* --- Экраны Награды / Костра / Лавки --- */
.choice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 4px;
  text-align: center;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

.shop-item {
  width: 185px;
  background: #131c31;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* --- Модальное окно колоды --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-backdrop.open { display: flex; }

.modal-box {
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 860px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-grid {
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 4px;
}
