/* 2048 Specific Styles */

:root {
    --grid-size: min(450px, 90vw);
    --tile-gap: 12px;
    --tile-size: calc((var(--grid-size) - (var(--tile-gap) * 5)) / 4);
}

.container {
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 600px;
}

/* Header UI */
.game-header-ui {
    width: 100%;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-title-banner {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    margin-bottom: 20px;
    text-align: center;
}

.title-neon {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary), 0 0 30px rgba(0, 243, 255, 0.4);
}

.title-puzzle {
    color: var(--secondary);
    text-shadow: 0 0 10px var(--secondary), 0 0 30px rgba(189, 0, 255, 0.4);
}

.score-container {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.score-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 20px;
    min-width: 100px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.score-box .label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 5px;
    font-family: 'Press Start 2P', monospace;
}

.score-box span:not(.label) {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
}

.score-box.highlight {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.1);
}

/* Grid Container */
.grid-container {
    position: relative;
    width: var(--grid-size);
    height: var(--grid-size);
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    padding: var(--tile-gap);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: var(--tile-gap);
    box-sizing: border-box;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.grid-cell {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    width: 100%;
    height: 100%;
}

/* Tiles */
.tile-container {
    position: absolute;
    inset: var(--tile-gap);
    z-index: 2;
    pointer-events: none;
}

.tile {
    position: absolute;
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.8rem, 4vw, 1.4rem);
    font-weight: bold;
    border-radius: 8px;
    transition: transform 100ms ease-in-out;
    z-index: 10;
}

.tile-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    animation: tileAppear 200ms ease-out;
}

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

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

.tile.tile-merged .tile-inner {
    animation: tilePop 200ms ease-in-out;
}

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

    50% {
        transform: scale(1.15);
    }

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

/* Tile Colors - Neon Variations */
.tile-2 .tile-inner {
    background: rgba(0, 243, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(0, 243, 255, 0.3);
}

.tile-4 .tile-inner {
    background: rgba(0, 243, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(0, 243, 255, 0.6);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.tile-8 .tile-inner {
    background: rgba(189, 0, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(189, 0, 255, 0.6);
    box-shadow: 0 0 10px rgba(189, 0, 255, 0.2);
}

.tile-16 .tile-inner {
    background: rgba(189, 0, 255, 0.4);
    color: #fff;
    border: 1px solid rgba(189, 0, 255, 0.8);
    box-shadow: 0 0 15px rgba(189, 0, 255, 0.3);
}

.tile-32 .tile-inner {
    background: rgba(255, 0, 85, 0.3);
    color: #fff;
    border: 1px solid rgba(255, 0, 85, 0.6);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.3);
}

.tile-64 .tile-inner {
    background: rgba(255, 0, 85, 0.5);
    color: #fff;
    border: 1px solid rgba(255, 0, 85, 0.8);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.4);
}

.tile-128 .tile-inner {
    background: rgba(0, 255, 136, 0.4);
    color: #000;
    border: 1px solid rgba(0, 255, 136, 0.7);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.4);
    font-size: 0.9rem;
}

.tile-256 .tile-inner {
    background: rgba(0, 255, 136, 0.6);
    color: #000;
    border: 1px solid rgba(0, 255, 136, 1.0);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
    font-size: 0.9rem;
}

.tile-512 .tile-inner {
    background: rgba(255, 230, 0, 0.5);
    color: #000;
    border: 1px solid rgba(255, 230, 0, 0.8);
    box-shadow: 0 0 35px rgba(255, 230, 0, 0.5);
    font-size: 0.9rem;
}

.tile-1024 .tile-inner {
    background: rgba(255, 230, 0, 0.7);
    color: #000;
    border: 1px solid rgba(255, 230, 0, 1.0);
    box-shadow: 0 0 40px rgba(255, 230, 0, 0.6);
    font-size: 0.7rem;
}

.tile-2048 .tile-inner {
    background: #fff;
    color: #000;
    border: 2px solid var(--primary);
    box-shadow: 0 0 50px var(--primary);
    font-size: 0.7rem;
    animation: winningTile 2s infinite alternate;
}

@keyframes winningTile {
    from {
        box-shadow: 0 0 30px var(--primary);
    }

    to {
        box-shadow: 0 0 60px var(--secondary);
    }
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 16px;
    backdrop-filter: blur(8px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
}

.overlay-content h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.overlay-content p {
    color: var(--text-dim);
    margin-bottom: 30px;
}

/* Controls UI */
.game-controls-ui {
    margin-top: 30px;
    text-align: center;
    width: 100%;
}

.control-hints {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-bottom: 25px;
}

.control-hints b {
    color: var(--primary);
}

@media (max-width: 600px) {
    :root {
        --tile-gap: 8px;
    }

    .score-container {
        gap: 8px;
    }

    .score-box {
        padding: 8px 12px;
        min-width: 80px;
    }

    .score-box span:not(.label) {
        font-size: 1rem;
    }

    .grid-container {
        padding: var(--tile-gap);
    }
}