:root {
    --bg: #0f172a;
    --text: #e2e8f0;
    --hint: #94a3b8;
    --card: #1e293b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 480px;
    padding: 16px;
    padding-bottom: 30px;
    position: relative;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.screen { display: none; animation: fadeIn 0.3s ease-out forwards; }
.screen.active { display: block; }

/* --- ГЛАВНЫЙ ЭКРАН --- */
.profile-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.avatar {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: bold; color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
    flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-info h2 {
    font-size: 22px; margin-bottom: 6px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.edit-icon {
    font-size: 14px; opacity: 0.6; cursor: pointer;
    transition: opacity 0.2s;
    background: rgba(255,255,255,0.1); padding: 4px; border-radius: 6px;
}
.edit-icon:active { opacity: 1; background: rgba(255,255,255,0.2); }

.stats { display: flex; gap: 8px; font-size: 13px; color: var(--hint); flex-wrap: wrap; }
.stat-pill {
    background: rgba(255,255,255,0.08); padding: 4px 8px; border-radius: 8px;
    display: flex; align-items: center; gap: 4px;
}
.stat-pill b { color: var(--text); }

/* Кнопки */
.btn {
    width: 100%; padding: 16px; border-radius: 16px; border: none;
    font-size: 16px; font-weight: 600; cursor: pointer; margin-bottom: 12px;
    transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
    background: linear-gradient(90deg, #6366f1, #a855f7); color: white;
    box-shadow: 0 8px 20px var(--accent-glow);
}
.btn-primary.disabled {
    background: rgba(255,255,255,0.05); color: var(--hint);
    box-shadow: none; cursor: not-allowed; transform: none;
}

.btn-outline {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: var(--text);
}

.row { display: flex; gap: 12px; }
.row .btn { flex: 1; margin-bottom: 0; }

.timer-text {
    text-align: center; font-size: 14px; color: var(--hint);
    margin-top: 10px; margin-bottom: 20px; font-weight: 500;
}
.timer-text span { color: #a855f7; font-weight: 700; font-family: monospace; }

/* --- МОДАЛЬНОЕ ОКНО --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
    animation: fadeIn 0.2s ease-out;
}
.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--card); border-radius: 20px; padding: 24px;
    width: 100%; max-width: 320px; border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.modal-content h3 { margin-bottom: 16px; font-size: 18px; text-align: center; }
.modal-input {
    width: 100%; padding: 14px 16px; background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
    color: white; font-size: 16px; margin-bottom: 20px; outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { margin-bottom: 0; padding: 12px; font-size: 15px; }

/* --- КВИЗ --- */
.quiz-header { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--hint); margin-bottom: 16px; }
.timer-bar { height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; margin-bottom: 24px; overflow: hidden; }
.timer-fill { height: 100%; background: linear-gradient(90deg, #22c55e, #4ade80); transition: width 1s linear; box-shadow: 0 0 10px rgba(34,197,94,0.5); }

.question { font-size: 22px; font-weight: 700; margin-bottom: 24px; line-height: 1.4; }
.option {
    width: 100%; padding: 18px 20px; background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 16px;
    color: var(--text); font-size: 16px; font-weight: 500;
    text-align: left; margin-bottom: 10px; cursor: pointer; transition: all 0.2s;
}
.option:active { transform: scale(0.98); }
.option.correct { background: rgba(34,197,94,0.2); border-color: #22c55e; color: #4ade80; }
.option.wrong { background: rgba(239,68,68,0.2); border-color: #ef4444; color: #f87171; }

/* --- СПИСКИ --- */
.list-item {
    display: grid;
    grid-template-columns: 1fr 65px; /* 1fr - текст, 65px - фиксированная колонка для очков */
    gap: 12px; /* Отступ между текстом и очками */
    align-items: center; /* Центрируем контент по вертикали */
    padding: 16px;
    background: var(--card);
    border-radius: 16px;
    margin-bottom: 10px;
    border: 1px solid rgba(255,255,255,0.05);
}

.list-item.today {
    border: 1px solid var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.list-item .title {
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}

.list-item .date {
    font-size: 12px;
    color: var(--hint);
}

/* Фиксированный блок для очков */
.score-badge {
    font-size: 15px;
    font-weight: 700;
    color: #fbbf24;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Прижимаем к правому краю */
    width: 100%;
    white-space: nowrap; /* Запрещаем перенос строки внутри очков */
}

/* --- РЕЗУЛЬТАТ --- */
.result-screen { text-align: center; padding-top: 40px; }
.result-emoji { font-size: 80px; margin-bottom: 20px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
.result-score { font-size: 48px; font-weight: 800; color: #a855f7; margin: 10px 0; }

.loader { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 50vh; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.1); border-top-color: #6366f1; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

.header-title { font-size: 24px; font-weight: 800; margin-bottom: 20px; }
.back-btn { background: none; border: none; color: var(--hint); font-size: 16px; cursor: pointer; padding: 10px 0; display: flex; align-items: center; gap: 6px; margin-bottom: 10px;}
.avatar {
    /* ... ваши существующие стили ... */
    position: relative;
    overflow: hidden; /* Обрезаем картинку по кругу */
    padding: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Картинка заполняет круг без искажений */
    display: block;
}
/* --- ЛИДЕРБОРД (ПЬЕДЕСТАЛ) --- */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 30px;
    margin-top: 20px;
    height: 220px; /* Фиксированная высота для выравнивания */
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90px;
    animation: slideUp 0.5s ease-out;
}

.podium-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--card);
    border: 2px solid rgba(255,255,255,0.2);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    overflow: hidden;
}

.podium-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.podium-name {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    margin-bottom: 4px;
}

.podium-score {
    font-size: 12px;
    color: #fbbf24;
    font-weight: 700;
    margin-bottom: 8px;
}

.podium-block {
    width: 100%;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
    font-size: 18px;
    font-weight: 800;
    color: rgba(0,0,0,0.5);
}

/* Высоты и цвета пьедестала */
.podium-1 .podium-block { height: 100px; background: linear-gradient(180deg, #fbbf24, #d97706); }
.podium-2 .podium-block { height: 75px; background: linear-gradient(180deg, #e5e7eb, #9ca3af); }
.podium-3 .podium-block { height: 55px; background: linear-gradient(180deg, #fdba74, #b45309); }

.podium-1 .podium-avatar { border-color: #fbbf24; box-shadow: 0 0 15px rgba(251,191,36,0.4); }
.podium-2 .podium-avatar { border-color: #e5e7eb; box-shadow: 0 0 10px rgba(229,231,235,0.3); }
.podium-3 .podium-avatar { border-color: #fdba74; box-shadow: 0 0 10px rgba(253,186,116,0.3); }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- ТАБЛИЦА ЛИДЕРОВ (4+ МЕСТА) --- */
.leaderboard-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    background: var(--card);
    border-radius: 12px;
    padding: 10px 16px;
    gap: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.leaderboard-row .place {
    font-size: 14px;
    font-weight: 700;
    color: var(--hint);
    width: 25px;
}

.leaderboard-row .avatar-small {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    overflow: hidden;
}

.leaderboard-row .avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.leaderboard-row .name {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-row .score {
    font-size: 14px;
    font-weight: 700;
    color: #fbbf24;
}
/* --- МАГАЗИН --- */
.shop-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.shop-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: 0.2s;
    color: var(--hint);
    border: 1px solid transparent;
}

.shop-tab.active {
    background: rgba(99, 102, 241, 0.2);
    color: #a78bfa;
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.1);
}

.shop-tab:active {
    transform: scale(0.96);
}
.shop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-bottom: 20px;
}

.shop-card {
    background: var(--card);
    border-radius: 16px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.shop-card:active {
    transform: scale(0.96);
}

/* Квадратная область для рамки */
.shop-preview-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1; /* Делает блок идеально квадратным */
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    position: relative;
}

/* Сама круглая рамка внутри квадрата */
.shop-preview {
    width: 75%;
    height: 75%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 36px;
    background: rgba(255,255,255,0.1);
}

.shop-name {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 8px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Плашка с ценой (заменяет кнопку) */
.shop-price-tag {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.15);
    color: #a78bfa;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
    transition: background 0.2s;
}

/* Стили для разных состояний */
.shop-card.owned .shop-price-tag {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.shop-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.shop-card.disabled .shop-price-tag {
    background: rgba(255,255,255,0.05);
    color: var(--hint);
}
/* --- КЕЙС (ИСПЫТАЙ УДАЧУ) --- */
.case-container {
    width: 100%;
    height: 120px;
    background: #1e293b;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    margin: 20px 0;
    border: 2px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

/* Красная стрелочка по центру */
.case-pointer {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 100%;
    background: #ef4444;
    z-index: 10;
    box-shadow: 0 0 10px #ef4444;
}
.case-pointer::after {
    content: '▼'; position: absolute; top: -5px; left: -6px;
    color: #ef4444; font-size: 16px;
}

.case-track {
    display: flex;
    gap: 10px;
    padding: 10px;
    position: absolute;
    left: 0;
    transition: transform 5s cubic-bezier(0.1, 0.7, 0.1, 1); /* Плавное замедление */
}

.case-item {
    min-width: 90px;
    height: 100px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    font-size: 30px;
    border: 1px solid rgba(255,255,255,0.1);
}
.case-item .item-name { font-size: 10px; text-align: center; margin-top: 5px; color: #94a3b8; }

/* Редкости */
.case-item.common { border-bottom: 4px solid #64748b; }
.case-item.rare { border-bottom: 4px solid #3b82f6; background: rgba(59,130,246,0.1); }
.case-item.epic { border-bottom: 4px solid #a855f7; background: rgba(168,85,247,0.1); }
.case-item.legendary { border-bottom: 4px solid #fbbf24; background: rgba(251,191,36,0.15); box-shadow: 0 0 15px rgba(251,191,36,0.3); }
/* Подсказки на главном экране */
.hints-bar {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 20px;
}

.hint-item {
    flex: 1; /* Все элементы делят ширину поровну */
    background: rgba(255,255,255,0.05);
    padding: 8px 2px;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    display: flex;
    flex-direction: column; /* Иконка сверху, цифра снизу */
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.hint-item i {
    font-size: 16px;
    margin-bottom: 4px;
}

/* Кнопки подсказок в квизе */
.hints-use-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.hint-btn {
    flex: 1;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a78bfa;
    padding: 8px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.hint-btn:active { transform: scale(0.95); }
.hint-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.text-secondary { color: #94a3b8 !important; }
.text-success { color: #22c55e !important; }
.text-purple { color: #a855f7 !important; }