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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding: 10px;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    min-height: calc(100vh - 20px);
}

.screen {
    display: none;
    padding: 15px;
    min-height: calc(100vh - 20px);
}

.screen.active {
    display: block;
}

/* Загрузочный экран */
#loadingScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Заголовок */
.header {
    text-align: center;
    padding: 15px 0;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 15px;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.stat-icon {
    font-size: 18px;
}

/* XP бар */
.xp-bar-container {
    margin-top: 10px;
}

.xp-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.xp-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    width: 0%;
}

/* Игровая область */
.game-area {
    margin-bottom: 20px;
}

.game-field {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 15px;
    margin-bottom: 15px;
    min-height: 300px;
}

.game-cell {
    aspect-ratio: 1;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.game-cell:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.game-cell.selected {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.game-cell.has-item {
    border-color: #f5576c;
}

.game-item {
    font-size: 32px;
    position: relative;
}

.game-item-level {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

/* Кнопка создания предмета */
.game-controls {
    text-align: center;
}

.btn-create {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-create:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-create:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 24px;
}

.btn-cost {
    font-size: 14px;
    opacity: 0.9;
}

/* Вкладки */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: #f0f0f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    white-space: nowrap;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Контент вкладок */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 20px;
}

/* Лидерборд */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    background: #f9f9f9;
    border-radius: 15px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.leaderboard-rank {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    min-width: 40px;
    text-align: center;
}

.leaderboard-rank.top {
    color: #f5576c;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
}

.leaderboard-stats {
    font-size: 14px;
    color: #666;
}

.leaderboard-level {
    font-size: 20px;
    font-weight: bold;
    color: #f5576c;
}

/* Логи */
.logs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-item {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    border-left: 3px solid #667eea;
}

.log-type {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.log-details {
    color: #666;
    font-size: 12px;
}

.log-date {
    color: #999;
    font-size: 11px;
    margin-top: 5px;
}

/* Сообщения */
.message {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: center;
    animation: slideIn 0.3s ease;
}

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

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Анимация появления предмета */
@keyframes itemAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.game-item.new-item {
    animation: itemAppear 0.3s ease;
}

/* Адаптивность */
@media (max-width: 480px) {
    .container {
        border-radius: 0;
        min-height: 100vh;
    }
    
    .screen {
        min-height: 100vh;
        padding: 10px;
    }
    
    .game-field {
        gap: 5px;
        padding: 8px;
        min-height: 250px;
    }
    
    .game-item {
        font-size: 24px;
    }
    
    .user-stats {
        gap: 10px;
    }
    
    .stat-item {
        padding: 6px 12px;
        font-size: 14px;
    }
}
