:root {
    --tg-theme-bg-color: #1a1a2e;
    --tg-theme-text-color: #ffffff;
    --tg-theme-button-color: #0f4c75;
    --tg-theme-button-text-color: #ffffff;
    --primary: #00d4ff;
    --secondary: #7b2cbf;
    --success: #4cc9f0;
    --warning: #f72585;
    --card-bg: #16213e;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 20px;
    border-radius: 0 0 30px 30px;
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.energy-display {
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    backdrop-filter: blur(10px);
}

.main {
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* Загрузка */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Главное меню */
.profile-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    position: relative;
    overflow: hidden;
}

.avatar::after {
    content: '👤';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.menu-item {
    background: var(--card-bg);
    border: none;
    border-radius: 15px;
    padding: 20px;
    color: white;
    font-size: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-item:active {
    transform: scale(0.95);
}

.menu-item .emoji {
    font-size: 32px;
}

/* Онбординг */
.onboarding {
    text-align: center;
}

.test-question {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
}

.test-options {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

.test-option {
    background: rgba(255,255,255,0.1);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 15px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.test-option:hover {
    background: rgba(255,255,255,0.2);
}

.test-option.selected {
    border-color: var(--primary);
    background: rgba(0,212,255,0.1);
}

.age-buttons, .subjects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.age-buttons button, .subject-btn {
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    padding: 15px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.age-buttons button.selected, .subject-btn.selected {
    background: var(--primary);
    color: var(--tg-theme-bg-color);
    font-weight: bold;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 25px;
    padding: 15px 30px;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
}

/* Миссия */
.mission-screen {
    text-align: center;
}

.question-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 25px;
    margin: 20px 0;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-text {
    font-size: 20px;
    margin-bottom: 25px;
    line-height: 1.5;
}

.options-grid {
    display: grid;
    gap: 12px;
}

.option-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 15px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.option-btn:hover {
    background: rgba(255,255,255,0.15);
}

.option-btn.correct {
    background: #4caf50;
    border-color: #fff;
}

.option-btn.incorrect {
    background: #f44336;
    border-color: #fff;
}

.explanation {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    font-style: italic;
}

.mission-progress {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.3s ease;
}

/* Карточки */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.card-item {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.card-item.legendary {
    background: linear-gradient(135deg, #ffd700, #ffa500);
    color: #1a1a2e;
}

.card-item.epic {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.card-item.rare {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.card-item.common {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.card-rarity {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 20px;
}

/* Рейтинг */
.rating-list {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 15px;
    margin: 20px 0;
}

.rating-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.rating-item:last-child {
    border-bottom: none;
}

.rating-position {
    width: 30px;
    font-weight: bold;
    font-size: 18px;
}

.rating-name {
    flex: 1;
}

.rating-score {
    font-weight: bold;
    color: var(--primary);
}

/* Кнопка назад */
.back-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
}

.back-btn:hover {
    background: rgba(255,255,255,0.15);
}
