/* ==========================================================================
   WP Suika Merge Game — Frontend Styles
   ========================================================================== */

.wpsmg-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 15px;
    font-family: sans-serif;
    box-sizing: border-box;
    margin: 20px 0;
    margin: 20px 0;
    width: 100%;
    container-type: inline-size;
}

@container (max-width: 850px) {
    .wpsmg-game-container, .wpsmg-game-container-react {
        order: 1 !important; /* Đẩy Game lên trên cùng */
        margin: 0 auto;
    }
    .wpsmg-left {
        order: 2 !important; /* Đẩy Cây tiến hoá xuống dưới */
        flex: 1 1 calc(50% - 15px) !important;
        max-width: none !important;
    }
    .wpsmg-right {
        order: 3 !important; /* Đẩy BXH xuống dưới */
        flex: 1 1 calc(50% - 15px) !important;
        max-width: none !important;
    }
    .wpsmg-left-tree {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
    }
    .wpsmg-tree-item {
        flex: 0 1 auto;
    }
}

@container (max-width: 500px) {
    .wpsmg-left, .wpsmg-right {
        flex: 1 1 100% !important;
    }
}

/* ---------- Sidebars ---------- */
.wpsmg-sidebar {
    flex: 1 1 150px;
    max-width: 220px;
    min-width: 150px;
    background: #fff;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border-radius: 12px;
    border: 1px solid #eee;
}

/* ---------- Game Container ---------- */
.wpsmg-game-container {
    flex: 0 1 500px;
    max-width: 500px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    background: #87CEEB;
}

/* ---------- Evolution Tree (left sidebar) ---------- */
.wpsmg-left-tree {
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.wpsmg-tree-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9f9f9;
    padding: 5px 10px;
    border-radius: 8px;
    transition: 0.2s;
}

.wpsmg-tree-item:hover {
    background: #f0f0f0;
}

.wpsmg-tree-item .wpsmg-tree-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ddd;
    background: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    font-weight: bold;
    overflow: hidden;
}

.wpsmg-tree-item span {
    font-weight: bold;
    color: #555;
}

/* ---------- Score Box ---------- */
.wpsmg-score-box {
    background: #ffebeb;
    border: 2px solid #ffcccc;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
}

.wpsmg-score-box h3 {
    margin: 0 0 5px 0 !important;
    font-size: 14px;
    color: #d32f2f;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.wpsmg-current-score {
    font-size: 32px;
    font-weight: bold;
    color: #d32f2f;
    line-height: 1;
}

/* ---------- Leaderboard ---------- */
.wpsmg-lb-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wpsmg-lb-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed #ccc;
    font-size: 15px;
}

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

.wpsmg-lb-item.wpsmg-top-1 {
    font-weight: bold;
    color: #d32f2f;
    font-size: 16px;
}

.wpsmg-lb-item.wpsmg-top-2 {
    font-weight: bold;
    color: #f57c00;
}

.wpsmg-lb-item.wpsmg-top-3 {
    font-weight: bold;
    color: #388e3c;
}

/* ---------- Responsive ---------- */
@media (max-width: 850px) {
    .wpsmg-sidebar {
        flex: 1 1 100%;
        max-width: 100%;
        order: 2;
    }

    .wpsmg-game-container {
        order: 1;
    }

    .wpsmg-left-tree {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .wpsmg-tree-item {
        flex-direction: column;
        padding: 5px;
        min-width: 60px;
        text-align: center;
    }

    .wpsmg-tree-item span {
        font-size: 11px;
    }
}

/* ==========================================================================
   Game List — Card Grid ([wpsmg_game_list] shortcode)
   ========================================================================== */

.wpsmg-game-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 0;
    font-family: sans-serif;
}

.wpsmg-game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    border-radius: 16px;
    padding: 24px 16px 20px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wpsmg-game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    border-color: #d32f2f;
}

.wpsmg-game-card.wpsmg-card-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.wpsmg-game-thumb {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ff6b6b, #ffa07a);
    margin-bottom: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.wpsmg-game-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.wpsmg-game-icon {
    font-size: 48px;
    line-height: 1;
}

.wpsmg-game-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    text-align: center;
    color: #222;
}

.wpsmg-badge-soon {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    background: #eee;
    color: #999;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

@media (max-width: 600px) {
    .wpsmg-game-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .wpsmg-game-thumb {
        width: 70px;
        height: 70px;
    }

    .wpsmg-game-icon {
        font-size: 36px;
    }

    .wpsmg-game-title {
        font-size: 15px;
    }
}


/* ==========================================================================
   Overlay Buttons (Audio / Fullscreen)
   ========================================================================== */
.wpsmg-overlay-btn {
    position: absolute;
    top: 15px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.7);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: 0.2s;
}

.wpsmg-overlay-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.wpsmg-btn-audio {
    left: 15px;
}

.wpsmg-btn-fullscreen {
    right: 15px;
}

/* When in fullscreen, ensure container fills screen */
.wpsmg-game-container:fullscreen {
    max-width: none !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
}
.wpsmg-game-container:-webkit-full-screen {
    max-width: none !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
}

/* ---------- Settings Panel ---------- */
.wpsmg-settings-panel {
    position: absolute;
    top: 60px;
    left: 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    display: none;
    flex-direction: column;
    gap: 15px;
    min-width: 220px;
}
.wpsmg-settings-panel.active {
    display: flex;
}
.wpsmg-settings-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}
.wpsmg-settings-row label {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}
.wpsmg-settings-row input[type="range"] {
    width: 100%;
    margin: 0;
}
.wpsmg-toggle-btn {
    background: #ccc;
    border: none;
    border-radius: 20px;
    width: 44px;
    height: 24px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
    padding: 0;
    margin: 0;
}
.wpsmg-toggle-btn.on {
    background: #4CAF50;
}
.wpsmg-toggle-btn::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: left 0.3s;
}
.wpsmg-toggle-btn.on::after {
    left: 22px;
}
