/* 2048 game styles */

.g2048-wrap {
    display: grid;
    place-items: center;
    gap: 1rem;
}

.g2048-hud {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    color: var(--grey-color);
    font-weight: 700;
}

.g2048-board {
    width: min(520px, 100%);
    aspect-ratio: 1 / 1;
    background: rgba(108, 92, 231, 0.08);
    border: 2px solid rgba(108, 92, 231, 0.18);
    border-radius: 18px;
    padding: 0.9rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 0.75rem;
    position: relative;
    user-select: none;
    touch-action: none; /* enable swipe without page scroll */
}

.g2048-bg {
    border-radius: 16px;
    background: rgba(45, 52, 54, 0.06);
}

body.dark-theme .g2048-bg {
    background: rgba(255, 255, 255, 0.04);
}

.g2048-tiles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.g2048-hint-arrow {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: clamp(2.2rem, 7vw, 3.2rem);
    font-weight: 900;
    color: rgba(0, 206, 201, 0.0);
    text-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
    transform: scale(0.96);
    transition: color 160ms ease-out, transform 160ms ease-out;
    pointer-events: none;
    z-index: 2;
}

.g2048-board.hint .g2048-hint-arrow {
    color: rgba(0, 206, 201, 0.95);
    transform: scale(1);
}

.g2048-board.hint-up .g2048-hint-arrow::before { content: "↑"; }
.g2048-board.hint-down .g2048-hint-arrow::before { content: "↓"; }
.g2048-board.hint-left .g2048-hint-arrow::before { content: "←"; }
.g2048-board.hint-right .g2048-hint-arrow::before { content: "→"; }

.g2048-board.hint .g2048-hint-arrow::before {
    animation: g2048HintPulse 700ms ease-out infinite;
}

@keyframes g2048HintPulse {
    0% { transform: translateY(0); opacity: 0.92; }
    45% { transform: translateY(-4px); opacity: 1; }
    100% { transform: translateY(0); opacity: 0.92; }
}

.g2048-tile {
    position: absolute;
    width: 0;
    height: 0;
    will-change: transform;
    transition: transform 140ms ease-out;
}

.g2048-tile-inner {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: clamp(1.2rem, 4.5vw, 2.2rem);
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.65);
    color: var(--light-text);
}

body.dark-theme .g2048-tile-inner {
    border-color: rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.18);
    color: var(--dark-text);
}

.g2048-tile.spawn {
    /* kept for outer flag */
}

.g2048-tile.merge {
    /* kept for outer flag */
}

.g2048-tile.vanish {
    opacity: 0;
    transition: transform 140ms ease-out, opacity 120ms ease-out;
}

.g2048-tile.spawn .g2048-tile-inner {
    animation: g2048Pop 140ms ease-out;
}

.g2048-tile.merge .g2048-tile-inner {
    animation: g2048Merge 180ms ease-out;
}

@keyframes g2048Pop {
    from { transform: scale(0.7); }
    to { transform: scale(1); }
}

@keyframes g2048Merge {
    0% { transform: scale(1); }
    45% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

body.dark-theme .g2048-board {
    background: rgba(162, 155, 254, 0.10);
    border-color: rgba(162, 155, 254, 0.20);
}

.g2048-cell {
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: clamp(1.2rem, 4.5vw, 2.2rem);
    color: var(--light-text);
    transition: transform 120ms ease-out, background-color 120ms ease-out;
}

body.dark-theme .g2048-cell {
    background: rgba(0, 0, 0, 0.18);
    border-color: rgba(255, 255, 255, 0.06);
    color: var(--dark-text);
}

.g2048-cell.empty {
    background: rgba(45, 52, 54, 0.06);
}

body.dark-theme .g2048-cell.empty {
    background: rgba(255, 255, 255, 0.04);
}

.g2048-cell.pop {
    transform: scale(1.05);
}

.g2048-2 { background: #eee4da; color: #776e65; }
.g2048-4 { background: #ede0c8; color: #776e65; }
.g2048-8 { background: #f2b179; color: #f9f6f2; }
.g2048-16 { background: #f59563; color: #f9f6f2; }
.g2048-32 { background: #f67c5f; color: #f9f6f2; }
.g2048-64 { background: #f65e3b; color: #f9f6f2; }
.g2048-128 { background: #edcf72; color: #f9f6f2; font-size: clamp(1.05rem, 4vw, 1.9rem); }
.g2048-256 { background: #edcc61; color: #f9f6f2; font-size: clamp(1.05rem, 4vw, 1.9rem); }
.g2048-512 { background: #edc850; color: #f9f6f2; font-size: clamp(1.05rem, 4vw, 1.9rem); }
.g2048-1024 { background: #edc53f; color: #f9f6f2; font-size: clamp(0.95rem, 3.8vw, 1.6rem); }
.g2048-2048 { background: #edc22e; color: #f9f6f2; font-size: clamp(0.95rem, 3.8vw, 1.6rem); }
.g2048-big { background: #3c3a32; color: #f9f6f2; font-size: clamp(0.85rem, 3.5vw, 1.4rem); }

.g2048-overlay {
    position: absolute;
    inset: 0;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease-out;
}

.g2048-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.g2048-overlay-card {
    width: min(420px, calc(100% - 2rem));
    background: var(--light-card-bg);
    border-radius: 18px;
    padding: 1.25rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    text-align: center;
    box-shadow: var(--shadow-strong);
}

body.dark-theme .g2048-overlay-card {
    background: var(--dark-card-bg);
    border-color: rgba(255, 255, 255, 0.10);
}

.g2048-overlay-card h2 {
    margin-bottom: 0.5rem;
}

.g2048-overlay-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.9rem;
}
