/* ===== Глобальные переменные для игр (соответствуют стилю сайта) ===== */
:root {
    --game-primary: #8CB890;
    --game-hover: #7aa67d;
    --game-bg: #ffffff;
    --game-text: #333333;
    --game-glass: rgba(140, 184, 144, 0.1);
    --game-glass-border: rgba(140, 184, 144, 0.2);
}

.hidden {
    display: none !important;
}

.games-section {
    padding: 60px 20px;
    background: #fdfdfd;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.games-section h1 {
    font-size: 2.2rem;
    margin-bottom: 40px;
    color: #1a1a1a;
}

/* Lobby Styles */
.lobby {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: opacity 0.5s ease;
}

.lobby.hidden {
    display: none;
}

.lobby-content {
    width: 100%;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    justify-items: center;
}

.game-card {
    position: relative;
    width: 250px;
    height: 350px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(140, 184, 144, 0.2);
}

.game-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.3s ease;
}

.card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-card:hover img {
    filter: blur(5px);
}

.game-card:hover .card-overlay {
    opacity: 1;
}

.card-overlay h2 {
    color: white;
    font-size: 1.6rem;
    margin-bottom: 20px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.play-btn {
    background: var(--game-primary);
    color: white;
    padding: 10px 24px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.play-btn:hover {
    background: var(--game-hover);
    transform: scale(1.1);
}

/* Game Container Styles */
.game-container {
    position: relative;
    width: 900px;
    height: 600px;
    max-width: 95vw;
    max-height: 80vh;
    margin: 40px auto;
    background: #fff;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--game-glass-border);
    touch-action: none;
    /* Prevent scrolling/zooming while playing */
}

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

canvas {
    flex: 1;
    background: #f9fafb;
}

.ui-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.score-board {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.8rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 24px;
    border-radius: 100px;
    border: 1px solid var(--game-glass-border);
    color: var(--game-primary);
}

.menu {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 32px;
    text-align: center;
    border: 1px solid var(--game-glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    max-width: 80%;
}

.menu.hidden {
    display: none;
}

.menu h1 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--game-primary);
}

.menu p {
    color: #666;
    margin-bottom: 20px;
}

.menu button {
    background: var(--game-primary);
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    /* Finger friendly */
}

.menu button:hover {
    background: var(--game-hover);
    transform: translateY(-2px);
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.secondary-btn {
    background: transparent !important;
    border: 2px solid var(--game-primary) !important;
    color: var(--game-primary) !important;
}

.ball-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: #f0f0f0;
    padding: 10px 20px;
    border-radius: 100px;
    margin-bottom: 20px;
}

#catchCountdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 6rem;
    font-weight: 900;
    color: var(--game-primary);
    z-index: 100;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#catchCountdown.pulse {
    transform: translate(-50%, -50%) scale(1.3);
    color: #f59e0b;
}

@media (max-width: 768px) {
    .games-section h1 {
        font-size: 1.6rem;
    }

    .game-container {
        height: 500px;
        /* Slightly taller for better mobile play area */
    }

    .game-card {
        width: 200px;
        height: 280px;
    }

    .game-card h2 {
        font-size: 1.2rem;
    }
}