@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700;900&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --bg-0: #08070c;
  --bg-1: #0f0d17;
  --bg-2: #171423;
  --panel: rgba(24, 20, 36, 0.72);
  --panel-solid: #171325;
  --border: rgba(255, 255, 255, 0.08);
  --text: #ece7f5;
  --text-dim: #a79fc0;
  --text-faint: #6f6885;
  --accent: #b463ff;
  --accent-2: #ff9d33;
  --gold: #ffcf6b;

  --c-common: #9aa5b1;
  --c-uncommon: #3ddc7a;
  --c-rare: #3fa9ff;
  --c-epic: #b463ff;
  --c-legendary: #ff9d33;
  --c-mythic: #ff4d6d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 20% -10%, #241a38 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--text);
  font-family: 'Manrope', system-ui, sans-serif;
  overflow-x: hidden;
}

h1, h2, h3, .heading {
  font-family: 'Cinzel', serif;
  letter-spacing: 0.02em;
  margin: 0;
}

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: var(--text);
}

#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Иконки ---------- */
.icon { width: 17px; height: 17px; vertical-align: -3px; flex: none; margin-right: 5px; }
.icon:last-child { margin-right: 0; }
.icon-lg { width: 26px; height: 26px; margin-right: 8px; }
.icon-only { margin-right: 0; }
.logo .icon { width: 20px; height: 20px; color: var(--accent-2); }
.pill .icon { color: inherit; margin-right: 5px; }

/* ---------- Кнопки ---------- */
.btn {
  padding: 12px 22px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2a2340, #1a1628);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(180, 99, 255, 0.5); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7a2fe0);
  box-shadow: 0 8px 24px rgba(180, 99, 255, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 30px rgba(180, 99, 255, 0.55); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), #ff9d33);
  color: #241608;
  box-shadow: 0 8px 24px rgba(255, 157, 51, 0.35);
}
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-danger { background: linear-gradient(135deg, #ff4d6d, #b3223f); }
.btn-sm { padding: 8px 14px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }

/* ---------- Landing / Auth ---------- */
.landing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.landing-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  max-width: 1000px;
  width: 100%;
  align-items: center;
}
.hero-title {
  font-size: clamp(36px, 6vw, 58px);
  background: linear-gradient(135deg, #fff 10%, var(--accent) 60%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
  margin-bottom: 16px;
  text-shadow: 0 0 60px rgba(180, 99, 255, 0.35);
}
.hero-sub { color: var(--text-dim); font-size: 16px; line-height: 1.6; max-width: 480px; }
.hero-features { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; }
.hero-feature { display: flex; gap: 12px; align-items: flex-start; color: var(--text-dim); font-size: 14px; }
.hero-feature .dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}

.auth-card {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.tabs { display: flex; gap: 6px; background: rgba(0,0,0,0.25); padding: 5px; border-radius: 12px; margin-bottom: 20px; }
.tab-btn {
  flex: 1; padding: 10px; border-radius: 9px; background: transparent; color: var(--text-dim); font-weight: 700; font-size: 13px;
}
.tab-btn.active { background: linear-gradient(135deg, var(--accent), #7a2fe0); color: #fff; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(0,0,0,0.3); color: var(--text); font-size: 14px; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--accent); }
.form-error {
  background: rgba(255, 77, 109, 0.12); border: 1px solid rgba(255, 77, 109, 0.4); color: #ff9db1;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: none;
}
.form-error.show { display: block; }
.form-success {
  background: rgba(61, 220, 122, 0.12); border: 1px solid rgba(61, 220, 122, 0.4); color: #b8f3cf;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: none;
}
.form-success.show { display: block; }
.auth-form { display: none; }
.auth-form.active { display: block; }
.flow-hint { font-size: 13px; color: var(--text-dim); margin: 0 0 16px; line-height: 1.5; }
.flow-hint b { color: var(--text); }
.code-input { letter-spacing: 8px; font-size: 20px; font-weight: 700; text-align: center; }
.link-btn {
  display: block; width: 100%; text-align: center; background: transparent; border: none;
  color: var(--text-faint); font-size: 12.5px; font-weight: 600; padding: 10px 0 0; text-decoration: underline;
}
.link-btn:hover:not(:disabled) { color: var(--accent); }
.link-btn:disabled { opacity: 0.5; cursor: not-allowed; text-decoration: none; }

/* ---------- Top bar (game) ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: rgba(10, 8, 16, 0.6); backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 5;
}
.logo { font-family: 'Cinzel', serif; font-weight: 900; font-size: 18px; letter-spacing: 0.04em;
  background: linear-gradient(135deg, #fff, var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wallet-strip { display: flex; align-items: center; gap: 18px; }
.pill {
  display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,0.05);
  border: 1px solid var(--border); padding: 7px 13px; border-radius: 999px; font-weight: 700; font-size: 13.5px;
}
.pill[data-icon="shard"] .icon { color: #7fd8ff; }
.pill[data-icon="crystal"] .icon { color: var(--gold); }
.pill[data-icon="levelUp"] .icon { color: var(--accent-2); }
.user-menu { display: flex; align-items: center; gap: 12px; }
.username-tag { font-weight: 700; font-size: 13.5px; color: var(--text-dim); }

/* ---------- Layout ---------- */
.game-body { flex: 1; display: flex; }
.nav-rail {
  width: 210px; flex: none; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--border);
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: transparent; color: var(--text-dim); font-weight: 700; font-size: 14px; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(180,99,255,0.25), rgba(180,99,255,0.05)); color: #fff; box-shadow: inset 0 0 0 1px rgba(180,99,255,0.4); }
.view { flex: 1; padding: 28px 32px; max-width: 1200px; }
.view-panel { display: none; }
.view-panel.active { display: block; animation: fadeUp 0.35s ease; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px);} to {opacity:1; transform:none;} }

.section-title { font-size: 22px; margin-bottom: 4px; }
.section-sub { color: var(--text-faint); font-size: 13.5px; margin-bottom: 22px; }

/* ---------- Cards grid ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

.recipe-card, .expedition-card, .bundle-card {
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden;
}
.recipe-card::before, .bundle-card::before {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 0.25s;
  background: radial-gradient(circle at 30% 0%, rgba(180,99,255,0.25), transparent 60%);
  pointer-events: none;
}
.recipe-card:hover::before, .bundle-card:hover::before { opacity: 1; }
.recipe-card h3, .bundle-card h3 { font-size: 16px; }
.cost-row { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--text-dim); }
.cost-chip { background: rgba(255,255,255,0.06); padding: 4px 9px; border-radius: 999px; }
.base-type-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.base-type-chip {
  padding: 6px 10px; border-radius: 9px; border: 1px solid var(--border); background: rgba(255,255,255,0.03);
  font-size: 12px; color: var(--text-dim); font-weight: 700;
}
.base-type-chip.selected { border-color: var(--accent); color: #fff; background: rgba(180,99,255,0.18); }
.boost-toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }

.expedition-card .duration { color: var(--accent-2); font-weight: 700; font-size: 13px; }
.progress-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s linear; }
.timer-text { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------- Item cards ---------- */
.item-card {
  background: var(--panel-solid); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  border: 1px solid var(--border); position: relative;
}
.item-card .icon-wrap {
  display: flex; align-items: center; justify-content: center; height: 120px; border-radius: 12px;
  background: radial-gradient(circle, rgba(255,255,255,0.05), transparent 70%);
}
.item-card .icon-wrap svg { width: 92px; height: 92px; }
.item-name { font-weight: 800; font-size: 14.5px; line-height: 1.3; }
.item-meta { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.item-primary { font-size: 13px; color: var(--text-dim); }
.affix-list { display: flex; flex-direction: column; gap: 4px; margin: 2px 0; }
.affix-item { font-size: 11.5px; color: var(--text-dim); padding-left: 10px; position: relative; }
.affix-item::before { content: '✦'; position: absolute; left: 0; color: var(--accent-2); }
.power-tag { font-size: 11.5px; color: var(--gold); font-weight: 700; }
.item-actions { display: flex; gap: 8px; margin-top: auto; }
.item-card.equipped { box-shadow: 0 0 0 2px var(--accent), 0 0 24px rgba(180,99,255,0.35); }

.rarity-common { --rc: var(--c-common); }
.rarity-uncommon { --rc: var(--c-uncommon); }
.rarity-rare { --rc: var(--c-rare); }
.rarity-epic { --rc: var(--c-epic); }
.rarity-legendary { --rc: var(--c-legendary); }
.rarity-mythic { --rc: var(--c-mythic); }
.item-card[class*="rarity-"] { border-color: color-mix(in srgb, var(--rc) 55%, var(--border)); }
.item-name { color: var(--rc, var(--text)); }
.item-card .icon-wrap { box-shadow: inset 0 0 40px color-mix(in srgb, var(--rc) 25%, transparent); }

.item-card.rarity-legendary, .item-card.rarity-mythic { animation: rarity-shimmer 2.6s ease-in-out infinite; }
@keyframes rarity-shimmer {
  0%, 100% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--rc) 45%, transparent), 0 0 18px color-mix(in srgb, var(--rc) 25%, transparent); }
  50% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--rc) 80%, transparent), 0 0 34px color-mix(in srgb, var(--rc) 55%, transparent); }
}

/* ---------- Shop ---------- */
.bundle-card { align-items: center; text-align: center; }
.bundle-crystals { font-size: 30px; font-weight: 900; color: var(--gold); font-family: 'Cinzel', serif; }
.bundle-bonus { font-size: 12px; color: var(--c-uncommon); font-weight: 700; }
.bundle-price { font-size: 20px; font-weight: 800; margin-top: 6px; }
.payment-note {
  margin-top: 18px; font-size: 12.5px; color: var(--text-faint); background: rgba(255,255,255,0.03);
  border: 1px solid var(--border); padding: 12px 14px; border-radius: 12px;
}
.payment-history { margin-top: 26px; }
.payment-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.status-pending { color: var(--accent-2); }
.status-succeeded { color: var(--c-uncommon); }
.status-canceled { color: var(--c-mythic); }

/* ---------- Craft reveal overlay ---------- */
.craft-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 3, 8, 0.78); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.craft-overlay.show { opacity: 1; pointer-events: all; }
.craft-reveal {
  width: 320px; background: var(--panel-solid); border: 1px solid var(--border); border-radius: 22px; padding: 26px;
  text-align: center; transform: scale(0.85); opacity: 0; transition: transform 0.4s cubic-bezier(.2,1.4,.4,1), opacity 0.3s;
}
.craft-overlay.show .craft-reveal { transform: scale(1); opacity: 1; }
.craft-reveal .icon-wrap { height: 160px; margin-bottom: 10px; }
.craft-reveal .icon-wrap svg { width: 130px; height: 130px; }
.craft-reveal .rarity-label { font-family: 'Cinzel', serif; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; color: var(--rc); margin-bottom: 6px; }

/* ---------- Toast ---------- */
#toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--panel-solid); border: 1px solid var(--border); padding: 12px 16px; border-radius: 12px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); animation: toastIn 0.25s ease;
  max-width: 320px;
}
.toast.error { border-color: rgba(255,77,109,0.5); color: #ffb3c1; }
.toast.success { border-color: rgba(61,220,122,0.5); color: #b8f3cf; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px);} to { opacity:1; transform:none; } }

.empty-hint { color: var(--text-faint); font-size: 13.5px; padding: 30px 0; text-align: center; }

/* ---------- Админ-панель ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-tile {
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px;
}
.stat-tile .stat-label { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-tile .stat-value { font-family: 'Cinzel', serif; font-size: 26px; font-weight: 800; color: var(--text); }
.stat-tile.accent .stat-value { color: var(--accent-2); }
.stat-tile.gold .stat-value { color: var(--gold); }
.stat-tile.danger .stat-value { color: var(--c-mythic); }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; margin-bottom: 26px; }
.chart-card { background: var(--panel-solid); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.chart-card h3 { font-size: 14.5px; margin-bottom: 12px; color: var(--text-dim); }
.chart-svg { width: 100%; height: auto; display: block; }
.legend-row { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.admin-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.admin-toolbar input, .admin-toolbar select {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: rgba(0,0,0,0.3);
  color: var(--text); font-size: 13px; font-family: inherit;
}
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.admin-table th {
  text-align: left; padding: 12px 14px; background: rgba(255,255,255,0.03); color: var(--text-faint);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
table.admin-table td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.admin-table tr:hover td { background: rgba(255,255,255,0.02); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-yes { background: rgba(61,220,122,0.15); color: #7fe3a8; }
.badge-no { background: rgba(255,255,255,0.06); color: var(--text-faint); }
.badge-banned { background: rgba(255,77,109,0.18); color: #ff9db1; }
.badge-admin { background: rgba(255,157,51,0.18); color: var(--accent-2); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--text-dim); }

@media (max-width: 860px) {
  .landing-grid { grid-template-columns: 1fr; }
  .game-body { flex-direction: column; }
  .nav-rail { width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .view { padding: 20px; }
}
