:root {
  --bg: var(--tg-theme-bg-color, #1a1a1a);
  --text: var(--tg-theme-text-color, #ffffff);
  --btn-primary: var(--tg-theme-button-color, #3390ec);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --hp-good: #2ecc71; --hp-warn: #f1c40f; --hp-bad: #e74c3c;
  --pixel-border: 2px solid var(--text);
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
html, body { background: var(--bg); color: var(--text); min-height: 100vh; padding: env(safe-area-inset); overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
.screen { display: none; flex-direction: column; min-height: 100vh; padding: 20px; gap: 16px; }
.screen.active { display: flex; }
#battle-screen { padding: 16px; gap: 14px; }
.title { text-align: center; margin: 10px 0 20px; font-size: 1.5rem; letter-spacing: 1px; }
.btn { padding: 14px; border: var(--pixel-border); border-radius: 10px; background: rgba(128,128,128,0.1); color: var(--text); font-weight: 600; cursor: pointer; transition: opacity 0.15s; text-align: center; user-select: none; }
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--btn-primary); color: var(--btn-text); border-color: var(--btn-primary); }
.btn-secondary { border-color: var(--btn-primary); color: var(--btn-primary); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn-danger { background: #e74c3c; color: white; border-color: #c0392b; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: auto; margin-bottom: 20px; }
.boss-timer { text-align: center; font-weight: 600; padding: 8px; background: rgba(0,0,0,0.2); border-radius: 8px; font-size: 0.9rem; }
.battle-header, .player-hp-container { padding: 12px; background: rgba(128,128,128,0.08); border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); }
.hp-bar { height: 16px; background: #222; border: 1px solid #444; border-radius: 8px; overflow: hidden; margin: 6px 0; }
.hp-fill { height: 100%; width: 100%; background: var(--hp-good); transition: width 0.2s ease; }
.hp-fill.warn { background: var(--hp-warn); } .hp-fill.crit { background: var(--hp-bad); }
.ult-pips { letter-spacing: 6px; font-size: 1.3rem; text-align: center; margin: 8px 0; }
.ult-pips .active { color: gold; }
.battle-log { height: 130px; max-height: 130px; background: rgba(0,0,0,0.15); border: 1px dashed rgba(255,255,255,0.2); padding: 10px; overflow-y: auto; flex-shrink: 0; font-size: 0.85rem; line-height: 1.4; border-radius: 8px; margin: 8px 0; }
.battle-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; margin-bottom: 16px; }
.shop-list, .inventory-list, .quest-list, .settings-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.card-item, .setting-item { background: rgba(128,128,128,0.1); padding: 12px; border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; display: flex; justify-content: space-between; align-items: center; }
.merchant-header, .quest-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.shop-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.shop-card { background: rgba(25,25,25,0.9); border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.shop-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--rarity-color, #888); border-radius: 8px 0 0 8px; }
.shop-card-name { font-weight: 600; font-size: 1rem; padding-left: 8px; }
.shop-card-desc { font-size: 0.75rem; color: #aaa; padding-left: 8px; }
.shop-card-price { display: flex; gap: 10px; font-weight: 600; font-size: 0.85rem; margin-top: 2px; padding-left: 8px; }
.shop-buy-btn { margin-top: 4px; padding: 8px; width: 100%; font-size: 0.85rem; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0; }
.mode-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 12px; text-align: center; min-height: 120px; background: rgba(128,128,128,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; }
.mode-btn:active:not(:disabled) { opacity: 0.8; border-color: var(--btn-primary); }
.mode-btn:disabled { opacity: 0.4; pointer-events: none; }
.mode-icon { font-size: 2.4rem; display: block; }
.mode-info { display: flex; flex-direction: column; gap: 4px; }
.mode-title { font-weight: 600; font-size: 0.95rem; display: block; }
.mode-desc { font-size: 0.7rem; color: #aaa; display: block; }
#boss-status { color: #2ecc71; font-weight: 600; } #boss-status.locked { color: #e74c3c; }
.quest-timer { font-size: 0.75rem; color: #aaa; }
.quest-card { background: rgba(25,25,25,0.9); border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quest-info { flex: 1; } .quest-desc { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; } .quest-progress { font-size: 0.75rem; color: #888; } .quest-progress.done { color: #2ecc71; }
.quest-claim-btn { padding: 8px 14px; min-width: 80px; font-size: 0.8rem; } .quest-claim-btn:disabled { opacity: 0.5; pointer-events: none; }
.setting-item { background: rgba(25,25,25,0.9); border-radius: 10px; border: 1px solid rgba(255,255,255,0.1); } .setting-label { font-weight: 500; font-size: 0.9rem; }
.setting-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 4px 0; }
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; } .toggle input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #444; border-radius: 24px; transition: 0.2s; } .slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
input:checked + .slider { background: var(--btn-primary); } input:checked + .slider::before { transform: translateX(20px); }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 100; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--bg); border: 1px solid var(--btn-primary); border-radius: 14px; padding: 24px; width: 85%; max-width: 380px; text-align: center; transform: scale(0.95); transition: transform 0.2s; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-overlay.active .modal-content { transform: scale(1); }
.reward-items { display: flex; justify-content: center; gap: 16px; margin: 20px 0; }
.reward-card { background: rgba(128,128,128,0.15); border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 14px; min-width: 90px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.reward-icon { font-size: 1.8rem; } .reward-amount { font-size: 1.4rem; font-weight: bold; color: var(--btn-primary); }
.case-modal-content { max-width: 300px; } .case-reveal-area { min-height: 80px; display: flex; align-items: center; justify-content: center; margin: 12px 0; }
.case-loader { width: 30px; height: 30px; border: 3px solid #333; border-top: 3px solid var(--btn-primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
.case-reward { font-size: 1.1rem; font-weight: bold; color: var(--btn-primary); animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes spin { to { transform: rotate(360deg); } } @keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.enemy-display { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; padding: 4px 0; } .enemy-sprite { font-size: 3.2rem; margin-bottom: 4px; }
.app-info { text-align: center; font-size: 0.8rem; color: #888; margin-top: 10px; line-height: 1.5; } .app-info code { background: rgba(255,255,255,0.1); padding: 2px 5px; border-radius: 3px; font-family: monospace; }
.hero-showcase { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 15px 0 8px; gap: 6px; }
.hero-sprite { font-size: 4rem; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3)); }
.hero-name { font-size: 1rem; font-weight: 600; color: var(--text); opacity: 0.85; }
.currency-bar-bottom { display: flex; justify-content: space-around; font-weight: 600; background: rgba(128,128,128,0.15); padding: 12px 18px; border-radius: 10px; margin: 8px 0 4px; border: 1px solid var(--btn-primary); font-size: 1rem; }
@media (min-width: 600px) {
  .shop-list, .quest-list { grid-template-columns: 1fr 1fr; gap: 14px; }
}
/* 🔧 Страховка для Telegram Mobile WebView */
@media (pointer: coarse) {
  .btn, .mode-btn, .action-btn, .shop-buy-btn, .quest-claim-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}
/* 🛠️ DEV PANEL */
#dev-toggle { position: fixed; bottom: 12px; right: 12px; width: 42px; height: 42px; background: #1a202c; color: #e2e8f0; border: 2px solid #4a5568; border-radius: 50%; font-size: 18px; cursor: pointer; z-index: 200; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 10px rgba(0,0,0,0.4); transition: transform 0.1s; }
#dev-toggle:active { transform: scale(0.9); }
#dev-panel { position: fixed; top: 0; right: -320px; width: 290px; height: 100vh; background: rgba(10,10,10,0.96); border-left: 2px solid #4a5568; color: #e2e8f0; font: 12px/1.4 'Courier New', monospace; padding: 15px; overflow-y: auto; z-index: 199; transition: right 0.25s ease; box-shadow: -6px 0 20px rgba(0,0,0,0.5); }
#dev-panel.open { right: 0; }
.dev-section { margin-bottom: 14px; border-bottom: 1px solid #333; padding-bottom: 10px; }
.dev-title { font-size: 13px; font-weight: bold; color: #63b3ed; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.dev-btn { display: inline-block; padding: 6px 9px; margin: 3px 2px; background: #2b6cb0; color: #fff; border: none; border-radius: 4px; cursor: pointer; font: 11px monospace; }
.dev-btn:hover { background: #3182ce; }
.dev-btn.danger { background: #c53030; }
.dev-log { background: #0d1117; padding: 8px; border-radius: 4px; max-height: 160px; overflow-y: auto; font-size: 10px; color: #48bb78; line-height: 1.5; }
.dev-stat { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #222; }
.dev-stat span:last-child { color: #f6e05e; font-weight: bold; }
.dev-close { position: absolute; top: 10px; right: 10px; background: none; border: none; color: #a0aec0; font-size: 18px; cursor: pointer; }
/* 🖼️ Стили для спрайтов */
.sprite-img {
  display: block;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
}
.hero-sprite-img { width: 90px; height: 90px; margin-bottom: 5px; }
.enemy-sprite-img { width: 80px; height: 80px; margin-bottom: 4px; transition: transform 0.2s; }

/* Анимация при получении урона */
.sprite-img.hit { animation: shake 0.3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-3deg); }
  75% { transform: translateX(6px) rotate(3deg); }
}

@media (min-width: 600px) {
  .hero-sprite-img { width: 120px; height: 120px; }
  .enemy-sprite-img { width: 100px; height: 100px; }
}