:root {
    --bg-color: #282A36; /* Dracula background */
    --primary-color: #BD93F9; /* Dracula purple */
    --secondary-color: #FF79C6; /* Dracula pink */
    --text-color: #F8F8F2; /* Dracula foreground */
    --cell-bg-color: #44475A; /* Dracula current line */
    --shadow-color: #21222C; /* Darker Dracula background */

    /* Color options */
    --red: #FF5555;
    --blue: #8BE9FD;
    --green: #50FA7B;
    --yellow: #F1FA8C;
    --purple: #BD93F9;
    --orange: #FFB86C;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow-y: auto; /* Allow vertical scrolling for main content */
}

.game-container {
    background-color: var(--cell-bg-color);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 500px;
    width: 90%;
}

h1 {
    color: var(--primary-color);
    margin-top: 0;
    font-size: 2.5rem;
}

.instructions {
    color: #BDC3C7;
    margin-bottom: 1.5rem;
}

.secret-code-display {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.secret-code-display.hidden {
    display: none;
}

.secret-code-display .color-peg {
    width: min(30px, 7vw);
    height: min(30px, 7vw);
    border-radius: 50%;
    background-color: var(--shadow-color); /* Placeholder for hidden color */
    border: 2px solid var(--primary-color);
}

.guess-history {
    /* Removed max-height, overflow-y, padding-right for scrollbar */
    margin-bottom: 1.5rem;
}
/* Removed Webkit scrollbar styles */

.guess-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background-color: var(--shadow-color); /* Default for empty/inactive */
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.guess-row.active {
    background-color: var(--cell-bg-color); /* Highlight active row */
}

.guess-row.empty .guess-peg,
.guess-row.empty .feedback-peg {
    background-color: transparent;
    border: 1px dashed var(--text-color);
}

.guess-row .guess-pegs {
    display: flex;
    gap: 0.5rem;
}

.guess-row .guess-peg {
    width: min(25px, 6vw);
    height: min(25px, 6vw);
    border-radius: 50%;
    border: 1px solid var(--text-color);
}

.guess-row .feedback-pegs {
    display: flex;
    gap: 0.2rem;
    margin-left: 1rem;
}

.feedback-peg {
    width: min(15px, 4vw); /* Slightly larger */
    height: min(15px, 4vw); /* Slightly larger */
    border-radius: 50%;
    border: 1px solid var(--text-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3); /* Add some depth */
}

.black-peg { background-color: black; }
.white-peg { background-color: white; border: 1px solid var(--shadow-color); } /* Add a subtle border for white peg */

.current-guess {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.guess-slot {
    width: min(40px, 9vw);
    height: min(40px, 9vw);
    border-radius: 50%;
    border: 2px dashed var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.guess-slot.filled {
    border: 2px solid var(--primary-color);
}

.color-palette {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.color-option {
    width: min(45px, 10vw);
    height: min(45px, 10vw);
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: var(--text-color);
}

/* Specific color styles */
.color-option.red { background-color: var(--red); }
.color-option.blue { background-color: var(--blue); }
.color-option.green { background-color: var(--green); }
.color-option.yellow { background-color: var(--yellow); }
.color-option.purple { background-color: var(--purple); }
.color-option.orange { background-color: var(--orange); }

.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.game-controls button, .game-controls a {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s;
    box-shadow: 0 4px 0 var(--shadow-color);
    background-color: var(--primary-color);
    color: var(--bg-color);
}

.game-controls button:hover, .game-controls a:hover {
    background-color: #a970f0; /* Lighter purple */
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-box {
    background: var(--cell-bg-color);
    padding: 2rem 3rem;
    border-radius: 15px;
    text-align: left;
    position: relative;
    box-shadow: 0 10px 0 var(--shadow-color);
    transform: scale(1);
    transition: transform 0.5s ease;
    max-width: 500px;
    width: 90%;
    color: var(--text-color);
}

.modal-overlay.hidden .modal-box {
    transform: scale(0.7);
}

.modal-box h2 {
    text-align: center;
    margin-top: 0;
    color: var(--primary-color);
}

.modal-box ul {
    list-style: none;
    padding: 0;
    margin-bottom: 2rem;
}

.modal-box ul li {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.modal-box ul li::before {
    content: '›';
    color: var(--primary-color);
    margin-right: 0.5rem;
    font-weight: bold;
}

#close-rules-button, #play-again-button {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s;
    box-shadow: 0 4px 0 var(--shadow-color);
    background-color: var(--primary-color);
    color: var(--bg-color);
    margin-top: 1rem;
}

#close-rules-button:hover, #play-again-button:hover {
    background-color: #a970f0;
}

/* --- Confetti Styles --- */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks to pass through */
    overflow: hidden;
    z-index: 99; /* Below modals */
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--primary-color); /* Default color, will be randomized */
    opacity: 0;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotateZ(720deg);
        opacity: 0;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 1rem;
        gap: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .instructions {
        font-size: 0.9rem;
    }

    .secret-code-display .color-peg {
        width: min(25px, 6vw);
        height: min(25px, 6vw);
    }

    .guess-row {
        gap: 0.3rem;
        padding: 0.3rem;
    }

    .guess-row .guess-pegs {
        gap: 0.3rem;
    }

    .guess-row .feedback-pegs {
        margin-left: 0.5rem;
        gap: 0.1rem;
    }

    .guess-row .guess-peg {
        width: min(20px, 5vw);
        height: min(20px, 5vw);
    }

    .feedback-peg {
        width: min(12px, 3vw);
        height: min(12px, 3vw);
    }

    .current-guess {
        gap: 0.3rem;
    }

    .guess-slot {
        width: min(35px, 8vw);
        height: min(35px, 8vw);
    }

    .color-palette {
        gap: 0.4rem; /* Further reduced gap */
        margin-bottom: 1.5rem;
    }

    .color-option {
        width: min(35px, 8vw); /* Further reduced width */
        height: min(35px, 8vw);
    }

    .game-controls {
        gap: 0.5rem;
    }

    .game-controls button, .game-controls a, #close-rules-button, #play-again-button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .modal-box {
        padding: 1.5rem 2rem;
    }

    .modal-box h2 {
        font-size: 1.8rem;
    }

    #game-end-message {
        font-size: 1.8rem;
    }
}