* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: var(--tg-theme-bg-color, #0f0f14);
  --text: var(--tg-theme-text-color, #fff);
  --hint: var(--tg-theme-hint-color, #8b8b9a);
  --accent: var(--tg-theme-button-color, #5b8dff);
  --btn: var(--tg-theme-button-text-color, #fff);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: url('/static/images/bg.jpg') no-repeat center center fixed;
  background-size: cover;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  padding-bottom: 80px;
  background: rgba(15, 15, 20, 0.78);
  backdrop-filter: blur(8px);
  min-height: 100vh;
}

/* === HEADER === */
.header {
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(91, 141, 255, 0.15), transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.user-info { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #5b8dff, #a35bff);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: bold;
}
.name { font-size: 16px; font-weight: 600; }
.power { font-size: 13px; color: var(--hint); margin-top: 2px; }
.wallet { margin-left: auto; text-align: right; font-size: 12px; font-weight: 600; }
.currency { margin-bottom: 2px; }

/* === TABS === */
.tabs { display: flex; padding: 12px 8px; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px; border-radius: 20px;
  background: rgba(255, 255, 255, 0.06); color: var(--text);
  border: none; font-size: 13px; font-weight: 500;
  white-space: nowrap; cursor: pointer; transition: all .2s;
}
.tab.active { background: var(--accent); color: var(--btn); }
.tab-content { display: none; padding: 12px 16px; }
.tab-content.active { display: block; animation: fadeIn .25s ease; }

.section-title { text-align: center; margin-bottom: 15px; font-size: 18px; }
.hint { font-size: 12px; color: var(--hint); margin-bottom: 10px; }

/* === GRID === */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

/* === CARD === */
.card {
  aspect-ratio: 1/1;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  animation: fadeIn .3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  border: 2px solid var(--rar-color, #444);
}

.card:hover { transform: translateY(-3px); }

/* Свечение по редкости */
.card.rarity-rare     { box-shadow: 0 4px 15px rgba(59, 130, 246, .25),  0 0 10px rgba(59, 130, 246, .15); }
.card.rarity-epic     { box-shadow: 0 4px 15px rgba(168, 85, 247, .35),  0 0 15px rgba(168, 85, 247, .25); }
.card.rarity-legendary{ box-shadow: 0 4px 15px rgba(245, 158, 11, .45),  0 0 20px rgba(245, 158, 11, .35);
                        animation: glowGold 2.5s ease-in-out infinite; }
.card.rarity-mythic   { box-shadow: 0 4px 15px rgba(239, 68, 68, .55),   0 0 25px rgba(239, 68, 68, .45);
                        animation: glowRed 1.5s ease-in-out infinite; }

@keyframes glowGold {
  0%, 100% { box-shadow: 0 4px 15px rgba(245, 158, 11, .45), 0 0 20px rgba(245, 158, 11, .35); }
  50%      { box-shadow: 0 4px 20px rgba(245, 158, 11, .7),  0 0 35px rgba(245, 158, 11, .55); }
}
@keyframes glowRed {
  0%, 100% { box-shadow: 0 4px 20px rgba(239, 68, 68, .55), 0 0 25px rgba(239, 68, 68, .45); }
  50%      { box-shadow: 0 4px 25px rgba(239, 68, 68, .85), 0 0 40px rgba(239, 68, 68, .7); }
}

.card-inner { width: 100%; height: 100%; position: relative; }
.card-bg-img {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover; z-index: 0;
}
.card-content {
  position: absolute; inset: 0; z-index: 1; padding: 8px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(to bottom,
    rgba(0, 0, 0, 0.3) 0%, transparent 40%,
    transparent 60%, rgba(0, 0, 0, 0.95) 100%);
}
.card-rarity {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.card-name {
  font-size: 14px; font-weight: 800; text-align: center; color: #fff;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.9);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-class { font-size: 10px; text-align: center; color: #ccc; }
.card-stats {
  display: flex; justify-content: space-around;
  font-size: 12px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); margin-top: 4px;
}
.card-level-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: bold;
  padding: 2px 6px; border-radius: 10px; z-index: 2;
}
.card-dupe-badge {
  position: absolute; top: 8px; left: 8px;
  background: #a855f7; color: #fff;
  font-size: 9px; font-weight: bold;
  padding: 2px 6px; border-radius: 10px; z-index: 2;
}
.card.compact { width: 80px; flex-shrink: 0; }
.card.compact .card-name { font-size: 11px; }
.card.compact .card-stats { font-size: 10px; }
.card.compact .card-rarity { font-size: 9px; }
.card.selected {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px var(--accent), 0 0 20px var(--accent);
}
.card.reveal { animation: reveal .7s cubic-bezier(0.34, 1.56, 0.64, 1) backwards; }

@keyframes reveal {
  0%   { opacity: 0; transform: scale(0.3) rotateY(180deg); }
  100% { opacity: 1; transform: scale(1) rotateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* === PACK === */
.pack-container { display: flex; flex-direction: column; align-items: center; padding: 20px 0; }
.pack { font-size: 120px; margin: 20px 0; transition: transform .2s; }
.pack.shaking { animation: shake .4s infinite; }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-10deg) scale(1.05); }
  75%      { transform: rotate(10deg) scale(1.05); }
}

.pack-result {
  display: flex; gap: 10px; justify-content: center;
  margin-top: 20px; flex-wrap: wrap;
}
.pack-result .card { width: 110px; }

/* === BUTTONS === */
.btn {
  padding: 12px 24px; border-radius: 12px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--btn);
  transition: opacity .2s, transform .1s;
}
.btn:hover:not(:disabled) { opacity: .9; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { min-width: 200px; }
.cooldown { margin-top: 12px; font-size: 13px; color: var(--hint); }

/* === SHOP === */
.shop-section {
  background: rgba(255, 255, 255, 0.05);
  padding: 15px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.shop-section h3 { margin-bottom: 5px; font-size: 16px; }

.promo-row { display: flex; gap: 8px; margin-top: 10px; }
.promo-input {
  flex: 1; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text); font-size: 14px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
}
.promo-input:focus { outline: none; border-color: var(--accent); }

.premium-active {
  display: inline-block; padding: 6px 14px;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #000; font-weight: 800; border-radius: 20px;
}

.case-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.case-item {
  padding: 12px; background: rgba(255, 255, 255, 0.08);
  border-radius: 10px; text-align: center;
  font-weight: 600; cursor: pointer;
  transition: background .2s;
}
.case-item:active { background: rgba(91, 141, 255, 0.3); }

/* === DUEL === */
.duel-list { display: flex; flex-direction: column; gap: 10px; }
.duel-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
}
.btn-duel { margin-left: auto; padding: 8px 16px; font-size: 13px; }

/* === LEADERBOARD === */
.leader-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  margin-bottom: 6px; background: rgba(255, 255, 255, 0.04);
}
.place { font-size: 18px; min-width: 30px; }
.lname { flex: 1; font-weight: 500; }
.lpoints { color: var(--accent); font-weight: 600; }

/* === ADMIN === */
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-user-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 10px; border-radius: 8px;
}
.admin-input {
  width: 70px; background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff; padding: 6px; border-radius: 6px; font-size: 12px;
}
.admin-btn {
  padding: 6px 10px; font-size: 12px;
  background: var(--accent); border: none; color: #fff;
  border-radius: 6px; cursor: pointer; font-weight: 600;
}

/* === WORLD BOSS === */
.boss-card {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(168, 85, 247, 0.15));
  border: 2px solid rgba(239, 68, 68, 0.4);
  border-radius: 16px; padding: 20px; text-align: center;
}
.boss-header { font-size: 22px; font-weight: 800; margin-bottom: 15px;
  background: linear-gradient(90deg, #ef4444, #a855f7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.boss-hp-bar {
  height: 24px; background: rgba(0, 0, 0, 0.6);
  border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}
.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #ef4444);
  background-size: 200% 100%;
  transition: width .5s ease, background-position .5s;
  animation: hpFlow 3s linear infinite;
}
@keyframes hpFlow { from { background-position: 0% 0; } to { background-position: 200% 0; } }
.boss-hp-text { margin-top: 8px; font-weight: 700; font-size: 14px; }

/* === MODAL === */
.modal {
  position: fixed; inset: 0; display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-bg {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(4px);
}
.modal-content {
  position: relative; background: var(--bg);
  padding: 24px; border-radius: 16px;
  max-width: 90%; min-width: 280px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: popIn .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.empty { text-align: center; color: var(--hint); padding: 40px 20px; }

/* === CONFETTI === */
.confetti {
  position: fixed;
  top: -10px;
  width: 10px; height: 10px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation: confettiFall 2.2s linear forwards;
}
@keyframes confettiFall {
  0%   { top: -10px; transform: translateX(0) rotate(0deg); opacity: 1; }
  100% { top: 100vh; transform: translateX(50px) rotate(720deg); opacity: 0; }
}

/* === DUNGEONS === */
.dungeon-list { display: flex; gap: 10px; margin-top: 10px; overflow-x: auto; padding-bottom: 5px; }
.dungeon-item { 
  flex: 1; min-width: 90px; padding: 12px 8px; text-align: center; 
  background: rgba(255,255,255,0.06); border: 2px solid transparent; 
  border-radius: 12px; cursor: pointer; transition: all 0.2s; 
}
.dungeon-item.active { border-color: var(--accent); background: rgba(91,141,255,0.15); }
.d-name { font-weight: bold; font-size: 14px; margin-bottom: 4px; }
.d-time { font-size: 11px; color: var(--hint); }
.d-reward { font-size: 12px; color: #ffd700; margin-top: 4px; font-weight: bold; }

.raid-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; background: rgba(255,255,255,0.04); border-radius: 12px;
  margin-bottom: 8px; border-left: 4px solid #444;
}
.raid-item.ready { border-left-color: #22c55e; background: rgba(34,197,94,0.1); }