:root {
    --bg-dark: #0f172a; --bg-card: #1e293b; --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5); --text-main: #f8fafc; --text-muted: #94a3b8;
    --prestige-color: #c084fc;
}
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body { 
    background-color: var(--bg-dark); 
    color: var(--text-main); 
    font-family: 'Montserrat', sans-serif; 
    height: 100dvh; 
    display: flex; 
    justify-content: center; 
    overflow: hidden; 
}

#fps-counter { position: fixed; top: 5px; left: 5px; color: #00ff00; font-family: monospace; font-weight: bold; font-size: 11px; z-index: 1000; pointer-events: none; }
.app-container { width: 100%; max-width: 1200px; display: flex; flex-direction: column; height: 100%; }

.game-section { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    position: relative; 
    overflow: hidden; /* Запрещаем скролл внутри игровой зоны */
    padding-bottom: 10px; 
}
.header { 
    text-align: center; 
    padding: 8px 0; 
    width: 100%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 10; 
    flex-shrink: 0;
}
.brand-title { font-size: 20px; letter-spacing: 2px; margin: 0 auto; }
.brand-title span { color: var(--accent); }
.icon-btn { background: none; border: none; font-size: 20px; color: var(--text-main); cursor: pointer; position: absolute; right: 15px; }

.game-area { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: space-around; /* Равномерно распределяем элементы по высоте */
    flex: 1; 
    padding: 5px 0;
}
.score-board { text-align: center; z-index: 10; }
.score-title { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.score-value { font-size: 42px; font-weight: 800; color: var(--accent); text-shadow: 0 0 15px var(--accent-glow); margin: 2px 0; }
.stats { display: flex; gap: 12px; justify-content: center; font-size: 13px; color: var(--text-muted); }
.prestige-stats { margin-top: 5px; font-size: 12px; color: var(--prestige-color); font-weight: bold; }
.prestige-stats.hidden { display: none; }

.interaction-area { display: flex; align-items: center; justify-content: center; gap: 15px; position: relative; z-index: 10; width: 100%; max-width: 450px; }

/* Уменьшены размеры контейнера 3D под компактный вид */
.companion-container-3d { position: relative; width: 140px; height: 210px; cursor: pointer; flex-shrink: 0; }
.companion-container-3d canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; outline: none; filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4)); }

/* Облачко поднято выше головы */
.dialog-bubble { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); background: #fff; color: #000; padding: 4px 8px; border-radius: 8px; font-size: 11px; font-weight: bold; white-space: nowrap; pointer-events: none; animation: popIn 0.3s ease-out; z-index: 20; }
.dialog-bubble::after { content: ''; position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); border-width: 4px 4px 0; border-style: solid; border-color: #fff transparent transparent transparent; }

@keyframes popIn { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 100% { opacity: 1; transform: translate(-50%, 0) scale(1); } }

.click-zone { position: relative; width: 140px; height: 140px; display: flex; justify-content: center; align-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; flex-shrink: 0; }
.crystal { font-size: 80px; filter: drop-shadow(0 0 15px var(--accent-glow)); transition: transform 0.05s ease; animation: float 3s ease-in-out infinite; }
.click-zone:active .crystal { transform: scale(0.9); }
.shake { animation: shake 0.2s ease-in-out; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px) rotate(-5deg); } 75% { transform: translateX(5px) rotate(5deg); } }
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-8px); } 100% { transform: translateY(0px); } }

.particle { position: absolute; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; pointer-events: none; z-index: 50; }
.floating-text { position: absolute; color: #fff; font-weight: bold; font-size: 20px; pointer-events: none; animation: floatUp 1s ease-out forwards; z-index: 50; }
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-40px) scale(1.4); } }

.prestige-btn { background: linear-gradient(45deg, #7e22ce, #c084fc); border: 1px solid #e9d5ff; width: 80%; max-width: 280px; margin: 5px auto; padding: 10px; font-size: 13px; z-index: 10; display: block; flex-shrink: 0;}
.prestige-btn.hidden { display: none; }

.store-area { background-color: var(--bg-card); padding: 15px; flex-shrink: 0; height: 42dvh; overflow-y: auto; z-index: 100;}
.store-title { font-size: 16px; margin-bottom: 12px; text-align: center; }
.upgrades-list { display: flex; flex-direction: column; gap: 10px; }

.upgrade-card { display: flex; align-items: center; background: rgba(255,255,255,0.05); padding: 10px 12px; border-radius: 12px; cursor: pointer; transition: background 0.2s; }
.upgrade-card:hover { background: rgba(255,255,255,0.1); }
.upgrade-card.disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(100%); }
.upgrade-icon { font-size: 24px; margin-right: 12px; width: 30px; text-align: center; }
.upgrade-info { flex-grow: 1; }
.upgrade-info h3 { font-size: 14px; margin-bottom: 2px; }
.upgrade-info p { font-size: 11px; color: var(--text-muted); }
.price { font-weight: bold; color: #facc15; font-size: 14px; }

.asteroid { position: absolute; font-size: 35px; cursor: pointer; z-index: 500; animation: spin 2s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.settings-group { margin: 15px 0; text-align: left; font-size: 14px; }
.fps-options { display: flex; gap: 8px; margin-top: 8px; }
.fps-btn { flex: 1; background: rgba(255,255,255,0.1); color: white; border: none; padding: 8px; border-radius: 6px; font-size: 13px; }
.fps-btn.active { background: var(--accent); color: black; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 2000; }
.modal.hidden { display: none; }
.modal-content { background: var(--bg-card); padding: 25px; border-radius: 16px; text-align: center; border: 1px solid rgba(255,255,255,0.1); width: 85%; max-width: 320px; }
.action-btn { background: var(--accent); color: #000; font-weight: bold; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-size: 14px; }

@media (min-width: 768px), (orientation: landscape) {
    .app-container { flex-direction: row; align-items: stretch; }
    .game-section { border-right: 2px solid rgba(255,255,255,0.05); justify-content: flex-start; }
    .game-area { margin-top: 10px; }
    .store-area { width: 350px; height: 100dvh; }
    .companion-container-3d { width: 220px; height: 320px; }
    .click-zone { width: 160px; height: 160px; }
    .crystal { font-size: 90px; }
}
