/* css/2048.css */
/* Main layout */
.game-2048-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
}

/* Header section with scores */
.game-header-2048 {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    background: var(--surface-light);
    padding: 15px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.score-container-2048 {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    min-width: 80px;
}

.score-title-2048 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: bold;
}

.score-value-2048 {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text);
}

.game-status-2048 {
    font-weight: bold;
    font-size: 1.2rem;
    text-align: center;
    flex-grow: 1;
}

.game-status-2048.win {
    color: var(--success);
    animation: pulse 1.5s infinite;
}

.game-status-2048.lose {
    color: var(--danger);
}

.waiting-msg {
    display: block;
    font-size: 0.85rem;
    font-weight: normal;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}


/* Both Boards Layout for Race Mode */
.boards-layout-2048 {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 20px;
}

/* Opponent Stats Bar (Race Mode) */
.opponent-stats-bar {
    display: none;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    background: rgba(187, 173, 160, 0.3);
    padding: 12px 15px;
    border-radius: var(--radius-md);
    gap: 10px;
}

.opponent-stats-label {
    font-weight: bold;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.opponent-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.opponent-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: bold;
}

.opponent-stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text);
}

/* Player Board Container */
.player-board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}


/* The Grid Board */
.board-2048 {
    position: relative;
    background: var(--g2048-grid);
    /* Grid lines color */
    border-radius: 6px;
    padding: 10px;
    width: min(90vw, 400px);
    height: min(90vw, 400px);
    touch-action: none;
}

/* Grid Background Cells */
.grid-container-2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.grid-cell-2048 {
    background: var(--g2048-board);
    /* Empty cell / Board color */
    border-radius: 3px;
    width: 100%;
    height: 100%;
}

/* The actual moveable tiles container */
.tile-container-2048 {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    pointer-events: none;
}

/* Individual Tiles */
.tile-2048 {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    border-radius: 3px;
    transition: transform 100ms ease-in-out;
    /* Calculated dynamic width/height: (100% - 3*gap) / 4 */
    width: calc((100% - 30px) / 4);
    height: calc((100% - 30px) / 4);
}

.tile-inner {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 3px;
    font-size: 2.5rem;
    animation: appear 200ms ease 100ms;
    animation-fill-mode: backwards;
}

.tile-2048.merged .tile-inner {
    animation: pop 200ms ease 100ms;
    animation-fill-mode: backwards;
}


/* Tile Colors - Base Variables */
.tile-inner {
    background: var(--g2048-tile-bg);
    color: var(--g2048-tile-text);
}

/* Theme-specific Tile Logic */

/* General shifts for both themes to distinguish blocks */
.tile-2 .tile-inner {
    filter: brightness(0.9);
}

.tile-4 .tile-inner {
    filter: brightness(1);
}

.tile-8 .tile-inner {
    filter: brightness(1.1) saturate(1.2);
}

.tile-16 .tile-inner {
    filter: brightness(1.2) saturate(1.4);
}

.tile-32 .tile-inner {
    filter: brightness(1.3) saturate(1.6);
}

.tile-64 .tile-inner {
    filter: brightness(1.4) saturate(1.8);
}

/* High value tiles get more distinct effects */
.tile-128 .tile-inner,
.tile-256 .tile-inner,
.tile-512 .tile-inner {
    filter: brightness(1.5) saturate(2);
    box-shadow: 0 0 15px var(--g2048-grid);
}

.tile-1024 .tile-inner,
.tile-2048 .tile-inner {
    filter: brightness(1.6) saturate(2.5);
    box-shadow: 0 0 25px var(--g2048-grid);
    border: 2px solid var(--g2048-tile-text);
}

.tile-4096 .tile-inner,
.tile-super .tile-inner {
    filter: brightness(1.8) saturate(3);
    box-shadow: 0 0 35px var(--g2048-grid), 0 0 10px rgba(255, 215, 0, 0.6);
    border: 2px solid gold;
    color: gold;
}

/* Specific Cyberpunk adjustments for neon feel */
[data-theme="default"] .tile-inner,
body:not([data-theme]) .tile-inner {
    text-shadow: 0 0 5px rgba(251, 191, 36, 0.5);
}

/* Specific Sakura adjustments for soft feel */
[data-theme="kawaii"] .tile-inner {
    text-shadow: 0 0 3px rgba(255, 212, 229, 0.5);
}



/* Position Classes */
/* Based on grid 4x4. Each cell is 25% wide, with some gap logic handled in JS for translation */

@keyframes appear {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* 4096 mode label in game header */
.mode-label-2048 {
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    color: gold;
    letter-spacing: 0.05em;
    background: rgba(255, 215, 0, 0.15);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 215, 0, 0.4);
}

/* 4096 unlock in CPU modal */
.game-option-unlocked {
    border-color: rgba(255, 215, 0, 0.5) !important;
    background: rgba(255, 215, 0, 0.08) !important;
}

.game-option-unlocked:hover {
    border-color: gold !important;
    background: rgba(255, 215, 0, 0.15) !important;
}

.unlock-badge {
    display: block;
    font-size: 0.65rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: gold;
    margin-top: 2px;
}

.game-option-locked {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
    padding: 6px 14px;
    opacity: 0.5;
    text-align: center;
}