@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}

body {
    /* Perpaduan warna gradien (Pink, Ungu, Biru Muda) */
    background: linear-gradient(45deg, #fef0a7, #a6c1ee, #ffe3ba, #68e6c9);
    background-size: 300% 300%;
    /* Memanggil animasi agar warnanya bergeser perlahan */
    animation: gradientBG 12s ease infinite;
    
    color: #2c3e50;
    padding: 20px;
    min-height: 100vh;
}

/* Kunci Animasi (Tambahkan tepat di bawah blok body) */
@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 850px;
    margin: 0 auto;
    text-align: center;
}

header h1 {
    margin-bottom: 5px;
    color: #1a252f;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#status-indicator {
    margin-bottom: 25px;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 10px 20px;
    background: white;
    display: inline-block;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.control-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.5);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

select, input {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    outline: none;
    font-family: inherit;
}

button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.6);
}

button:active {
    transform: translateY(1px);
}

.board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.board {
    display: grid;
    grid-template-columns: repeat(7, 65px);
    grid-template-rows: repeat(6, 65px);
    gap: 12px;
    background: linear-gradient(145deg, #1e5799, #2989d8);
    padding: 18px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3), inset 0 5px 15px rgba(255,255,255,0.2);
    border-bottom: 8px solid #1a4a80;
}

.cell {
    width: 65px;
    height: 65px;
    background-color: #fdfbfb;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: inset 0 6px 10px rgba(0,0,0,0.5);
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.cell:hover {
    transform: scale(1.05);
}

@keyframes dropIn {
    0% { transform: translateY(-400px); opacity: 0; }
    60% { transform: translateY(20px); opacity: 1; }
    80% { transform: translateY(-10px); }
    100% { transform: translateY(0); opacity: 1; }
}

/* =========================================
   NAMA KELAS CSS BARU UNTUK KEPINGAN
   ========================================= */
.yellow-piece {
    background: radial-gradient(circle at 30% 30%, #ffdf00, #d4af37) !important;
    box-shadow: inset -4px -4px 8px rgba(0,0,0,0.2), 0 4px 6px rgba(0,0,0,0.4) !important;
    animation: dropIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.red-piece {
    background: radial-gradient(circle at 30% 30%, #ff4d4d, #c0392b) !important;
    box-shadow: inset -4px -4px 8px rgba(0,0,0,0.3), 0 4px 6px rgba(0,0,0,0.4) !important;
    animation: dropIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.stats-panel, .tree-panel {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    text-align: left;
}

.stats-panel h3, .tree-panel h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 8px;
}

.stats-panel p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.stats-panel span {
    font-weight: 700;
    color: #e74c3c;
}

.tree-container {
    max-height: 250px;
    overflow-y: auto;
    font-size: 14px;
    background: #f8f9fa;
    padding: 15px;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
}

.tree-node {
    margin-left: 20px;
    border-left: 2px dashed #bdc3c7;
    padding-left: 15px;
    margin-bottom: 8px;
    position: relative;
}

.tree-node::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    width: 10px;
    border-top: 2px dashed #bdc3c7;
}

.pruned {
    color: #e74c3c;
    text-decoration: line-through;
    opacity: 0.7;
}

@media (max-width: 600px) {
    .board {
        grid-template-columns: repeat(7, 45px);
        grid-template-rows: repeat(6, 45px);
        gap: 8px;
        padding: 12px;
    }
    
    .cell {
        width: 45px;
        height: 45px;
    }
}

/* =========================================
   ANIMASI MENANG & KALAH
   ========================================= */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    transform: scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    border: 5px solid #fff;
}

.modal.hidden .modal-content {
    transform: scale(0.5);
}

.modal-content h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: #7f8c8d;
}

.winning-piece {
    animation: pulseGlow 0.8s infinite alternate;
    z-index: 10;
}

@keyframes pulseGlow {
    0% { filter: brightness(1); box-shadow: 0 0 5px rgba(255,255,255,0.5); transform: scale(1); }
    100% { filter: brightness(1.4); box-shadow: 0 0 25px rgba(255, 255, 255, 0.9); transform: scale(1.1); }
}

.shake-board {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
    40%, 60% { transform: translate3d(8px, 0, 0); }
}