/* ========================================
   PEYTON 2048 — Game Styles
   ======================================== */

/* ---- Snake Page Collage ---- */
#snake-collage {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.collage-photo {
    position: absolute;
    object-fit: cover;
    border-radius: 4px;
    border: 3px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    transform: rotate(var(--rot, 0deg)) scale(0.5);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.35s ease;
}

.collage-photo.collage-visible {
    transform: rotate(var(--rot, 0deg)) scale(1);
    opacity: 0.82;
}

.collage-photo.collage-gone {
    transform: rotate(var(--rot, 0deg)) scale(0.4);
    opacity: 0;
    transition: transform 0.5s ease-in, opacity 0.5s ease-in;
}

/* ---- Page Layout ---- */
.games-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

.games-header {
    text-align: center;
    margin-bottom: 1rem;
}

.games-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

/* ---- Game Tabs ---- */
.game-tabs {
    display: flex;
    justify-content: center;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.game-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    color: var(--text-gray);
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.55rem 2.25rem;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.game-tab:hover { color: var(--primary-color); }

.game-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* ---- Panel subtitle ---- */
.panel-subtitle {
    text-align: center;
    color: var(--text-gray);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

/* ---- Snake canvas ---- */
.snake-canvas {
    display: block;
    width: 780px;
    height: 780px;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    background: #0f0f0f;
    cursor: pointer;
    touch-action: none;
}

@media (max-width: 860px) {
    .snake-canvas {
        width: 580px;
        height: 580px;
    }
}

@media (max-width: 640px) {
    .snake-canvas {
        width: 420px;
        height: 420px;
    }
}

@media (max-width: 460px) {
    .snake-canvas {
        width: 340px;
        height: 340px;
    }
}

.game-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    justify-content: center;
}

/* ---- Stats Row ---- */
.stats-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stat-box {
    flex: 1;
    background: var(--bg-medium);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.25rem;
    text-align: center;
    min-width: 0;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

@keyframes statBump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35); color: var(--accent-color); }
    100% { transform: scale(1); }
}

.stat-bump {
    animation: statBump 0.3s ease;
}

/* ---- Controls Row ---- */
.controls-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.btn-new-game {
    background: var(--primary-color);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    white-space: nowrap;
}

.btn-new-game:hover {
    background: var(--accent-color);
    transform: translateY(-1px);
}

.hint-text {
    font-size: 0.75rem;
    color: var(--text-gray);
}

/* ---- Board Wrapper ---- */
.board-wrapper {
    position: relative;
}

.tap-guide {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-gray);
    margin-top: 0.5rem;
    opacity: 0.7;
}

#solverTrigger {
    cursor: default;
    color: inherit;
    user-select: none;
}

/* ---- Game Board ---- */
.game-board {
    position: relative;
    width: 420px;
    height: 420px;
    background: var(--bg-medium);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 8px;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}

/* ---- Background Grid ---- */
.grid-cells {
    position: absolute;
    inset: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 8px;
    pointer-events: none;
}

.grid-cell {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

/* ---- Tile Container ---- */
.tile-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* ---- Tiles ---- */
.tile {
    position: absolute;
    border-radius: 6px;
    overflow: hidden;
    transition: left 0.12s ease, top 0.12s ease;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
}

@keyframes tileAppear {
    0%   { transform: scale(0); opacity: 0; }
    70%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.tile-appear {
    animation: tileAppear 0.2s ease forwards;
}

@keyframes tileMerge {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); }
    75%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.tile-merge {
    animation: tileMerge 0.25s ease forwards;
    z-index: 10 !important;
}

/* ---- Click Zones ---- */
.click-zone {
    position: absolute;
    z-index: 20;
    cursor: pointer;
    /* Transparent but interactive */
}

.click-zone-up    { top: 0;   left: 0;   right: 0;  height: 25%; }
.click-zone-down  { bottom: 0; left: 0; right: 0;   height: 25%; }
.click-zone-left  { top: 25%; left: 0;  width: 25%; height: 50%; }
.click-zone-right { top: 25%; right: 0; width: 25%; height: 50%; }

/* ---- Overlays ---- */
.overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(11, 11, 11, 0.88);
    border-radius: 10px;
    z-index: 30;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}

.overlay-content h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.overlay-content p {
    color: var(--text-gray);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.btn-overlay {
    background: var(--primary-color);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    margin: 0.25rem;
    transition: background 0.2s ease, transform 0.15s ease;
    display: inline-block;
}

.btn-overlay:hover {
    background: var(--accent-color);
    transform: translateY(-1px);
}

.btn-overlay-secondary {
    background: var(--bg-light);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-overlay-secondary:hover {
    background: var(--border-color);
}

/* ---- Unlock Sidebar ---- */
.unlock-sidebar {
    flex-shrink: 0;
    width: 200px;
}

.unlock-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    text-align: center;
}

.unlock-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.unlock-item {
    text-align: center;
}

.unlock-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-medium);
}

.unlock-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lock-overlay {
    display: none;
}

.unlock-label {
    font-size: 0.6rem;
    color: var(--primary-color);
    margin-top: 0.2rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Locked state — hidden until earned */
.unlock-item:not(.unlocked) {
    visibility: hidden;
}

/* Unlocked state */
.unlock-item.unlocked {
    visibility: visible;
}

/* Unlock animation */
@keyframes unlockFlash {
    0%   { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.8); }
    50%  { box-shadow: 0 0 0 8px rgba(var(--primary-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0); }
}

.unlock-item.unlock-anim .unlock-img-wrap {
    animation: unlockFlash 0.6s ease;
}

/* ---- Mobile ---- */
@media (max-width: 700px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
    }

    .unlock-sidebar {
        width: 100%;
        max-width: 420px;
    }

    .unlock-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 480px) {
    .game-board {
        width: 320px;
        height: 320px;
    }

    .stats-row {
        max-width: 320px;
    }

    .controls-row {
        max-width: 320px;
    }

    .hint-text {
        display: none;
    }
}
