/* ===== Game Section ===== */
.game-section { padding-bottom: 80px; }

.user-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 100px;
    margin-bottom: 24px;
    font-size: 0.92rem;
    font-weight: 600;
}

.user-nick { color: var(--accent); }

/* Tabs */
.game-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.game-tabs::-webkit-scrollbar { display: none; }

.game-tab {
    padding: 10px 22px;
    border-radius: 100px;
    border: 1.5px solid var(--border);
    background: var(--white);
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.game-tab:hover { border-color: var(--text-muted); }

.game-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
}

/* Game wrapper */
.game-wrapper {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

/* Game panel */
.game-container {
    position: relative;
    background: #1a1a2e;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4 / 3;
    max-height: 480px;
    touch-action: none;
}

.game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.game-container .grid-2048,
.game-container .whack-grid {
    touch-action: none;
}

/* Game overlay */
.game-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10,10,20,0.85);
    z-index: 5;
    text-align: center;
    padding: 24px;
    color: var(--white);
}

.game-overlay.hidden { display: none; }

.game-overlay h3 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.game-overlay p {
    font-size: 0.92rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 24px;
    max-width: 280px;
}

.game-start-btn { padding: 12px 36px; }

/* HUD */
.game-hud {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    pointer-events: none;
    z-index: 3;
}

.game-hud b { color: var(--white); font-weight: 700; }

/* D-pad for snake */
.dpad {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 10;
}

.dpad-mid {
    display: flex;
    gap: 44px;
}

.dpad-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: var(--white);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dpad-btn:active { background: rgba(255,255,255,0.3); }

/* 2048 grid */
.grid-2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.tile-2048 {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 800;
    font-size: 1.6rem;
    font-family: 'Outfit', sans-serif;
    background: #2a2a4a;
    color: var(--white);
    transition: transform 0.12s;
    user-select: none;
}

.tile-2048.t2    { background: #4a90d9; }
.tile-2048.t4    { background: #4a7ad9; }
.tile-2048.t8    { background: #e8734a; color: #fff; }
.tile-2048.t16   { background: #e85d3a; }
.tile-2048.t32   { background: #e84a2a; }
.tile-2048.t64   { background: #d93a1a; }
.tile-2048.t128  { background: #edcf72; color: #333; }
.tile-2048.t256  { background: #edcc61; color: #333; }
.tile-2048.t512  { background: #edc850; color: #333; }
.tile-2048.t1024 { background: #edc53f; color: #333; font-size: 1.3rem; }
.tile-2048.t2048 { background: #edc22e; color: #333; font-size: 1.3rem; }

.tile-2048.pop {
    animation: tilePop 0.15s ease;
}

@keyframes tilePop {
    0% { transform: scale(0.5); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Whack-a-mole grid */
.whack-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 24px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.whack-hole {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a4a;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.15s;
    aspect-ratio: 1;
}

.whack-hole::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 30%;
    background: #1a1a30;
    border-radius: 50% 50% 0 0;
}

.whack-mole {
    width: 60%;
    height: 60%;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    bottom: -100%;
    transition: bottom 0.15s ease;
    z-index: 2;
}

.whack-hole.active .whack-mole {
    bottom: 20%;
}

.whack-hole.hit .whack-mole {
    background: #28ca42;
}

/* Leaderboard */
.leaderboard-panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: sticky;
    top: 100px;
}

.leaderboard-panel h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.lb-list {
    list-style: none;
    counter-reset: lb;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    margin: 0;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--cream);
}

.lb-item:last-child { border-bottom: none; }

.lb-rank {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.lb-item:nth-child(1) .lb-rank { background: #ffd700; color: #333; }
.lb-item:nth-child(2) .lb-rank { background: #c0c0c0; color: #333; }
.lb-item:nth-child(3) .lb-rank { background: #cd7f32; color: #fff; }

.lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
}

.lb-score {
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.lb-empty {
    font-size: 0.88rem;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .game-wrapper {
        grid-template-columns: 1fr;
    }
    .leaderboard-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    .game-container {
        aspect-ratio: 3 / 4;
        max-height: 520px;
    }
    .tile-2048 { font-size: 1.2rem; }
    .tile-2048.t1024, .tile-2048.t2048 { font-size: 1rem; }
}
