/* Play Page Styles */

/* Game Page */
.game-page {
    min-height: 100vh;
    padding: 90px 24px 40px;
    display: flex;
    justify-content: center;
}

.game-container {
    width: 100%;
    max-width: 500px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.back-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary);
}

.game-title h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.game-score {
    display: flex;
    gap: 12px;
}

.score-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px;
    text-align: center;
    min-width: 70px;
}

.score-box.best {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
}

.score-box.best .score-label,
.score-box.best .score-value {
    color: white;
}

.score-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.score-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* XP Stats Bar */
.xp-stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.xp-stat {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.xp-stat i {
    font-size: 1rem;
    color: var(--primary);
}

.xp-stat-info {
    display: flex;
    flex-direction: column;
}

.xp-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.xp-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Game Area */
.game-area {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    touch-action: none;
}

/* 2048 Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: var(--bg-elevated);
    padding: 10px;
    border-radius: 12px;
    position: relative;
}

.grid-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

/* Tiles with slide animation */
.tile {
    position: absolute;
    width: calc((100% - 50px) / 4);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    transition: top 0.12s ease-out, left 0.12s ease-out;
    top: calc(10px + var(--row) * (calc((100% - 50px) / 4) + 10px));
    left: calc(10px + var(--col) * (calc((100% - 50px) / 4) + 10px));
}

/* Tile positioning using CSS calc */
.tile {
    --cell-size: calc((100% - 50px) / 4);
    --gap: 10px;
    top: calc(var(--gap) + var(--row) * (var(--cell-size) + var(--gap)));
    left: calc(var(--gap) + var(--col) * (var(--cell-size) + var(--gap)));
    width: var(--cell-size);
}

/* New tile animation */
.tile-new {
    animation: tile-appear 0.15s ease-out;
}

@keyframes tile-appear {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Merged tile animation */
.tile-merged {
    animation: tile-pop 0.15s ease-out;
}

@keyframes tile-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Tile Colors */
.tile-2 { background: #eee4da; color: #776e65; font-size: 2rem; }
.tile-4 { background: #ede0c8; color: #776e65; font-size: 2rem; }
.tile-8 { background: #f2b179; color: white; font-size: 2rem; }
.tile-16 { background: #f59563; color: white; font-size: 1.8rem; }
.tile-32 { background: #f67c5f; color: white; font-size: 1.8rem; }
.tile-64 { background: #f65e3b; color: white; font-size: 1.8rem; }
.tile-128 { background: #edcf72; color: white; font-size: 1.5rem; }
.tile-256 { background: #edcc61; color: white; font-size: 1.5rem; }
.tile-512 { background: #edc850; color: white; font-size: 1.5rem; }
.tile-1024 { background: #edc53f; color: white; font-size: 1.2rem; }
.tile-2048 {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
}
.tile-4096, .tile-8192 { background: #3c3a32; color: white; font-size: 1rem; }

/* Game Controls */
.game-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3);
}

/* Game Instructions */
.game-instructions {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

.game-instructions p { margin-bottom: 6px; }
.xp-info { color: var(--primary); }
.xp-info i { margin-right: 4px; }

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.login-overlay.active {
    opacity: 1;
    visibility: visible;
}

.login-prompt {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 48px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.prompt-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 2rem;
    color: white;
}

.login-prompt h2 {
    font-size: 1.75rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.login-prompt p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.prompt-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.prompt-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.prompt-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3);
}

.prompt-btn.secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 1.75rem;
}

.modal-icon.success {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.modal-icon.fail {
    background: var(--error);
    color: white;
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.modal-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 28px;
}

.modal-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-stat .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-stat .stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-stat .stat-value.xp {
    color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.modal-btn.secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.modal-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

/* Responsive */
@media (max-width: 500px) {
    .game-header {
        flex-wrap: wrap;
    }
    
    .game-title {
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 12px;
    }
    
    .xp-stats-bar {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .xp-stat {
        min-width: 0;
        flex-direction: column;
        justify-content: flex-start;
        gap: 4px;
        padding: 10px 6px;
        text-align: center;
    }

    .xp-stat-info {
        min-width: 0;
        overflow-wrap: anywhere;
    }
    
    .tile {
        font-size: 1.4rem !important;
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 1.2rem !important;
    }
    
    .tile-1024, .tile-2048, .tile-4096, .tile-8192 {
        font-size: 0.9rem !important;
    }
    
    .modal-actions {
        flex-direction: column;
    }
}

/* Light Theme for 2048 */
[data-theme="light"] .game-grid {
    background: #d6d3d1;
}

[data-theme="light"] .grid-cell {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .game-area {
    background: #f5f5f4;
}

[data-theme="light"] .score-box {
    background: #e7e5e4;
}

[data-theme="light"] .control-btn {
    background: #e7e5e4;
    color: var(--text-primary);
}

[data-theme="light"] .control-btn:hover {
    background: #d6d3d1;
}

/* Daily Complete Modal - Simple Design */
.modal-content.daily-complete {
    text-align: center;
    padding: 32px 40px;
}

.daily-complete-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.daily-complete-header .daily-check {
    width: 40px;
    height: 40px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.daily-complete-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.daily-reward {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 24px;
}

.daily-reward .xp-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.daily-reward .streak-info {
    font-size: 1rem;
    color: var(--text-secondary);
}
