:root {
    --bg-color: #0b0c10;
    --panel-bg: #1f2833;
    --text-color: #c5c6c7;
    --accent-color: #66fcf1;
    --accent-hover: #45a29e;
    --diamond-color: #00e5ff;
    --success-color: #2ecc71;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* =========================================
   ОСНОВНОЙ ЭКРАН И ДИНАМИЧЕСКИЙ ФОН
========================================= */
#main-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 1s ease;
    overflow: hidden;
}

/* Базовые фоны космоса в зависимости от планеты */
#main-screen.theme-moon { background: radial-gradient(circle at center, #1a1a2e 0%, #050508 100%); }
#main-screen.theme-mars { background: radial-gradient(circle at center, #2e1010 0%, #0a0303 100%); }
#main-screen.theme-neptune { background: radial-gradient(circle at center, #0b1a26 0%, #02070a 100%); }

/* Звездная пыль на фоне */
#main-screen::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    pointer-events: none;
    z-index: 1;
    background-image: radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 3px);
    background-size: 150px 150px;
    opacity: 0.3;
    animation: rotateStars 120s linear infinite;
}

@keyframes rotateStars {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================
   ЛЕТАЮЩИЕ ПЛАНЕТЫ И МЕТЕОРИТЫ
========================================= */
#space-background {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
}

.distant-planet {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    box-shadow: inset -10px -10px 20px rgba(0,0,0,0.8);
    animation: drift 60s linear infinite;
}

/* Настраиваем орбиты дальних планет */
.dp-1 { width: 60px; height: 60px; background: radial-gradient(circle at 30% 30%, #a569bd, #512e5f); top: 15%; left: -10%; animation-duration: 70s; }
.dp-2 { width: 40px; height: 40px; background: radial-gradient(circle at 30% 30%, #5dade2, #154360); bottom: 25%; right: -10%; animation-duration: 45s; animation-direction: reverse; filter: blur(1px); }
.dp-3 { width: 100px; height: 100px; background: radial-gradient(circle at 30% 30%, #e67e22, #7e5109); top: 70%; left: -20%; animation-duration: 90s; opacity: 0.4; filter: blur(3px); }

@keyframes drift {
    0% { transform: translateX(0) translateY(0) rotate(0deg); }
    100% { transform: translateX(120vw) translateY(-20vh) rotate(360deg); }
}

/* Общий класс для падающих объектов */
.falling-object {
    position: absolute;
    top: -10%;
    right: 20%;
    opacity: 0;
}

/* АНИМАЦИЯ: Падающие звезды (Луна) */
.theme-moon .falling-object {
    width: 150px; height: 2px;
    background: linear-gradient(90deg, transparent, #fff);
    transform: rotate(-45deg);
    animation: shootingStar 5s cubic-bezier(0.4, 0, 1, 1) infinite;
}

/* АНИМАЦИЯ: Метеориты (Марс) */
.theme-mars .falling-object {
    width: 80px; height: 8px;
    background: linear-gradient(90deg, transparent, #ff4500, #ffea00);
    border-radius: 50px;
    transform: rotate(-30deg);
    filter: drop-shadow(0 0 15px #ff4500);
    animation: meteorFall 4s ease-in infinite;
}

/* АНИМАЦИЯ: Кометы изо льда (Нептун) */
.theme-neptune .falling-object {
    width: 120px; height: 4px;
    background: linear-gradient(90deg, transparent, var(--diamond-color), #fff);
    border-radius: 50px;
    transform: rotate(-60deg);
    filter: drop-shadow(0 0 10px var(--diamond-color));
    animation: shootingStar 6s ease-in infinite;
}

@keyframes shootingStar {
    0% { transform: translate(0, 0) rotate(-45deg); opacity: 1; }
    20% { transform: translate(-50vw, 50vh) rotate(-45deg); opacity: 0; }
    100% { opacity: 0; }
}

@keyframes meteorFall {
    0% { transform: translate(0, 0) scale(1) rotate(-30deg); opacity: 1; }
    30% { transform: translate(-60vw, 60vh) scale(1.5) rotate(-30deg); opacity: 0; }
    100% { opacity: 0; }
}

/* =========================================
   СТАТИСТИКА И ПЛАНЕТА С ТЕКСТУРАМИ
========================================= */
#stats {
    position: absolute;
    top: 30px;
    text-align: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.4);
    padding: 15px 30px;
    border-radius: 15px;
    border: 1px solid rgba(102, 252, 241, 0.2);
    backdrop-filter: blur(5px);
}

#stats h1 {
    font-size: 3.5rem;
    color: var(--diamond-color);
    text-shadow: 0 0 15px var(--diamond-color), 0 0 30px rgba(0, 229, 255, 0.5);
    margin-bottom: 10px;
    line-height: 1;
}

#stats p { font-size: 1.2rem; margin-bottom: 4px; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }

#planet-container {
    position: relative;
    width: 450px;
    height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* БАЗОВЫЙ ШАР ПЛАНЕТЫ С ТЕНЯМИ */
#planet {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    box-shadow: 
        inset -30px -30px 50px rgba(0, 0, 0, 0.8), /* Темная сторона */
        inset 15px 15px 30px rgba(255, 255, 255, 0.4), /* Свет от звезды */
        0 0 60px rgba(255, 255, 255, 0.1); /* Легкое свечение атмосферы */
    cursor: pointer;
    position: relative;
    animation: floatPlanet 6s ease-in-out infinite;
    transition: transform 0.1s, box-shadow 0.2s;
    overflow: hidden; /* Чтобы текстуры не вылазили за круг */
}

/* ПРОЦЕДУРНЫЕ ТЕКСТУРЫ ДЛЯ ПЛАНЕТ (!important нужен для перекрытия JS) 
*/
/* Текстура 1: ЛУНА (Серые кратеры разного размера) */
.theme-moon #planet {
    background: 
        radial-gradient(circle at 40% 40%, rgba(0,0,0,0.15) 8%, transparent 10%),
        radial-gradient(circle at 65% 70%, rgba(0,0,0,0.2) 12%, transparent 15%),
        radial-gradient(circle at 75% 30%, rgba(255,255,255,0.3) 15%, transparent 20%),
        radial-gradient(circle at 20% 60%, rgba(0,0,0,0.1) 6%, transparent 8%),
        radial-gradient(circle at 30% 30%, #e0e0e0, #888) !important;
}

/* Текстура 2: МАРС (Красно-оранжевый рельеф и пылевые пятна) */
.theme-mars #planet {
    background: 
        repeating-radial-gradient(ellipse at center, rgba(0,0,0,0.05) 0%, transparent 10%, rgba(0,0,0,0.05) 20%),
        radial-gradient(circle at 50% 80%, rgba(0,0,0,0.2) 20%, transparent 40%),
        radial-gradient(circle at 20% 20%, rgba(255,255,255,0.1) 15%, transparent 30%),
        radial-gradient(circle at 30% 30%, #b03a2e, #641e16) !important;
    box-shadow: inset -30px -30px 50px rgba(0,0,0,0.9), inset 15px 15px 30px rgba(255, 160, 122, 0.4), 0 0 60px rgba(255, 69, 0, 0.2);
}

/* Текстура 3: НЕПТУН (Газовые полосы и Великое темное пятно) */
.theme-neptune #planet {
    background: 
        radial-gradient(ellipse at 60% 45%, rgba(0,0,0,0.25) 5%, transparent 12%), /* Темное пятно */
        repeating-linear-gradient(0deg, rgba(0,0,0,0.1) 0%, transparent 8%, rgba(255,255,255,0.05) 15%), /* Кольца ветра */
        radial-gradient(circle at 30% 30%, #1f618d, #0b2233) !important;
    box-shadow: inset -30px -30px 50px rgba(0,0,0,0.9), inset 15px 15px 30px rgba(100, 200, 255, 0.3), 0 0 60px rgba(0, 100, 255, 0.2);
}

@keyframes floatPlanet {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

#planet:active {
    animation: none;
    transform: scale(0.93) translateY(5px);
    box-shadow: inset -15px -15px 30px rgba(0, 0, 0, 0.9), inset 5px 5px 20px rgba(255, 255, 255, 0.2), 0 0 30px rgba(255, 255, 255, 0.1);
}

/* Визуальные элементы на планете */
.visual-item {
    position: absolute;
    font-size: 2.2rem;
    z-index: 3;
    pointer-events: none;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}
        
@keyframes popIn {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

#pet-visual {
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3.5rem;
    animation: petHover 3s ease-in-out infinite;
}

@keyframes petHover {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-10px); }
}

/* =========================================
   БОКОВАЯ ПАНЕЛЬ И ВЫПАДАЮЩИЕ МЕНЮ
========================================= */
#sidebar {
    width: 380px;
    background-color: var(--panel-bg);
    border-left: 2px solid var(--accent-color);
    box-shadow: -5px 0 20px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.tab-menu {
    display: flex;
    background-color: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(102, 252, 241, 0.3);
}

.tab-btn {
    flex: 1;
    padding: 18px 5px;
    background: none;
    border: none;
    color: #888;
    font-weight: bold;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 1px;
}

.tab-btn:hover { background-color: rgba(102, 252, 241, 0.05); color: var(--text-color); }
.tab-btn.active { color: var(--accent-color); background-color: var(--panel-bg); border-bottom: 3px solid var(--accent-color); text-shadow: 0 0 10px rgba(102, 252, 241, 0.5); }

.tab-content { display: none; flex: 1; padding: 20px; overflow-y: auto; overflow-x: hidden; }
.tab-content.active { display: flex; flex-direction: column; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

.tab-content h2 {
    color: var(--accent-color); text-align: center; margin-bottom: 25px; text-transform: uppercase; letter-spacing: 3px; font-size: 1.5rem; text-shadow: 0 0 8px rgba(102, 252, 241, 0.4);
}

.tab-content::-webkit-scrollbar { width: 6px; }
.tab-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.tab-content::-webkit-scrollbar-thumb { background: var(--accent-hover); border-radius: 3px; }

/* =========================================
   МАГАЗИН И ЭЛЕМЕНТЫ UI
========================================= */
.shop-item {
    display: flex; align-items: center; background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(0,0,0,0.2));
    margin-bottom: 15px; padding: 15px; border-radius: 10px; cursor: pointer; border: 1px solid rgba(255,255,255,0.02);
    opacity: 0.5; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); transform: scale(0.98);
}
.shop-item.affordable { opacity: 1; border-color: rgba(102, 252, 241, 0.3); transform: scale(1); }
.shop-item.affordable:hover { background: linear-gradient(145deg, rgba(102, 252, 241, 0.1), rgba(0,0,0,0.3)); border-color: var(--accent-color); box-shadow: 0 5px 15px rgba(102, 252, 241, 0.15); transform: scale(1.02); }
.shop-item:active.affordable { transform: scale(0.98); }

.shop-icon { font-size: 2.8rem; margin-right: 15px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.shop-info { flex: 1; }
.shop-name { font-weight: bold; font-size: 1.15rem; margin-bottom: 5px; color: #fff; }
.shop-desc { font-size: 0.85rem; color: #aaa; margin-bottom: 8px; line-height: 1.3; }
.shop-price { color: var(--diamond-color); font-weight: bold; font-size: 1.1rem; }
.shop-count { font-size: 1.4rem; font-weight: bold; color: var(--accent-color); background: rgba(0,0,0,0.3); padding: 5px 12px; border-radius: 8px; }

/* Статистика, Настройки, Достижения */
.stats-block, .settings-block { background: rgba(0, 0, 0, 0.25); padding: 20px; border-radius: 10px; margin-bottom: 20px; border: 1px solid rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 10px rgba(0,0,0,0.5); }
.stats-line { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 1.05rem; border-bottom: 1px dashed rgba(255,255,255,0.1); padding-bottom: 5px; }
.stats-line:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.stats-val { color: var(--accent-color); font-weight: bold; text-shadow: 0 0 5px rgba(102, 252, 241, 0.3); }

.achievements-list { display: flex; flex-direction: column; gap: 12px; }
.ach-item { display: flex; align-items: center; background: rgba(0, 0, 0, 0.3); padding: 12px; border-radius: 8px; border-left: 5px solid #cc5252; transition: all 0.3s; }
.ach-item.unlocked { border-left-color: var(--success-color); background: linear-gradient(90deg, rgba(46, 204, 113, 0.1) 0%, rgba(0,0,0,0.3) 100%); }
.ach-icon { font-size: 2rem; margin-right: 15px; filter: grayscale(100%); opacity: 0.5; transition: 0.3s; }
.ach-item.unlocked .ach-icon { filter: grayscale(0%); opacity: 1; }
.ach-details { flex: 1; }
.ach-title { font-weight: bold; font-size: 1rem; color: #fff; margin-bottom: 3px; }
.ach-desc { font-size: 0.85rem; color: #999; }
.ach-status { font-size: 0.85rem; font-weight: bold; color: #cc5252; text-transform: uppercase; letter-spacing: 1px; }
.ach-item.unlocked .ach-status { color: var(--success-color); }

/* Настройки */
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.setting-row label { font-size: 1.1rem; color: #eee; }
select, button.btn-action { background-color: rgba(255, 255, 255, 0.05); border: 1px solid rgba(102, 252, 241, 0.5); color: var(--text-color); padding: 10px 15px; border-radius: 6px; font-size: 1rem; outline: none; cursor: pointer; transition: all 0.2s; }
select:hover, button.btn-action:hover { background-color: rgba(102, 252, 241, 0.15); border-color: var(--accent-color); box-shadow: 0 0 12px rgba(102, 252, 241, 0.4); }
select option { background-color: var(--panel-bg); color: #fff; }
button.btn-action { width: 100%; font-weight: bold; text-transform: uppercase; letter-spacing: 2px; padding: 15px; margin-top: 15px; background: linear-gradient(45deg, rgba(102, 252, 241, 0.1), transparent); }

.switch { position: relative; display: inline-block; width: 54px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); transition: .3s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: #888; transition: .3s cubic-bezier(0.68, -0.55, 0.265, 1.55); border-radius: 50%; }
input:checked + .slider { background-color: rgba(102, 252, 241, 0.2); border-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(26px); background-color: var(--accent-color); box-shadow: 0 0 8px var(--accent-color); }

/* =========================================
   АНИМАЦИЯ: Падающие алмазы при клике
========================================= */
.click-particle {
    position: absolute; font-weight: 900; font-size: 1.8rem; pointer-events: none; z-index: 100;
    display: flex; flex-direction: column; align-items: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 10px var(--diamond-color);
    animation: fallAndFade 0.9s cubic-bezier(0.21, 0.83, 0.26, 1.1) forwards;
}
.particle-diamond { font-size: 1.4rem; margin-bottom: -5px; filter: drop-shadow(0 0 5px var(--diamond-color)); }
.particle-text { color: #fff; }

@keyframes fallAndFade {
    0% { opacity: 1; transform: translate(0, 0) scale(0.5) rotate(0deg); }
    15% { transform: translate(calc(var(--dir-x) * 0.5), -40px) scale(1.2) rotate(calc(var(--rot) * 0.5)); }
    100% { opacity: 0; transform: translate(var(--dir-x), 250px) scale(0.8) rotate(var(--rot)); }
}
/* Таблица лидеров (webim.cz) */
.lb-input { width: 100%; padding: 12px 14px; border-radius: 6px; font-size: 1rem; color: var(--text-color); background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(102, 252, 241, 0.5); outline: none; user-select: text; }
.lb-input:focus { border-color: var(--accent-color); box-shadow: 0 0 10px rgba(102, 252, 241, 0.3); }
.lb-msg { margin-top: 10px; font-size: 0.9rem; color: #aaa; }
.lb-msg:empty { display: none; }
.lb-list { list-style: none; margin-top: 10px; }
.lb-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,0.1); }
.lb-list li:last-child { border-bottom: none; }
.lb-list li.me { color: var(--success-color); font-weight: bold; }

/* Узкий экран (телефон, маленькое окно на сайте): панель под планетой */
@media (max-width: 820px) {
    body { flex-direction: column; }
    #main-screen { flex: none; height: 58vh; min-height: 330px; }
    #sidebar { width: 100%; flex: 1; min-height: 0; border-left: none; border-top: 2px solid var(--accent-color); }
    #stats { top: 10px; padding: 8px 18px; }
    #stats h1 { font-size: 2.2rem; margin-bottom: 4px; }
    #stats p { font-size: 0.95rem; }
    #planet-container { width: 280px; height: 280px; margin-top: 70px; }
    #planet { width: 200px; height: 200px; }
    .tab-btn { padding: 12px 6px; font-size: 0.85rem; }
    .shop-icon { font-size: 2rem; }
}
