* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f0f0;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

h1 {
    margin-bottom: 30px;
    color: #2c3e50;
}

h2 {
    margin-bottom: 20px;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.player-selection, .grid-size-selection {
    margin-bottom: 20px;
}

#start-game {
    margin-top: 20px;
    padding: 12px 30px;
    font-size: 18px;
}

.hidden {
    display: none !important;
}

/* Game Board Styles */
#cards-grid {
    display: grid;
    grid-gap: 10px;
    margin: 20px auto;
    max-width: 800px;
}

.card {
    background-color: #3498db;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
    height: 100px;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    font-size: 40px;
}

.card-front {
    background-color: white;
    transform: rotateY(180deg);
}

.card-back {
    background-color: #3498db;
    background-image: linear-gradient(45deg, #3498db 25%, #2980b9 25%, #2980b9 50%, #3498db 50%, #3498db 75%, #2980b9 75%, #2980b9 100%);
    background-size: 20px 20px;
}

.flipped {
    transform: rotateY(180deg);
}

.matched {
    transform: rotateY(180deg);
    opacity: 0.4;
    cursor: default;
    filter: grayscale(50%) brightness(1.1);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(46, 204, 113, 0.5);
}

.matched::after {
    content: "✓";
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 16px;
    color: #27ae60;
    background-color: rgba(255, 255, 255, 0.7);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transform: rotateY(180deg);
}

/* Game Info Styles */
.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #ecf0f1;
    border-radius: 5px;
}

#current-player {
    font-weight: bold;
    font-size: 18px;
}

#scores {
    display: flex;
    gap: 15px;
}

.player-score {
    padding: 5px 10px;
    border-radius: 5px;
}

.active-player {
    background-color: #2ecc71;
    color: white;
}

/* Game Over Styles */
#game-over {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#final-scores {
    margin: 20px 0;
}

#winner {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #2ecc71;
}

#play-again {
    background-color: #2ecc71;
    padding: 12px 30px;
    font-size: 18px;
}

#play-again:hover {
    background-color: #27ae60;
}

/* Add styles for selected buttons */
.player-btn.selected, .grid-btn.selected {
    background-color: #2ecc71;
    border: 2px solid #27ae60;
    transform: scale(1.05);
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.5);
}

.player-btn.selected:hover, .grid-btn.selected:hover {
    background-color: #27ae60;
}

/* Player type selection styles */
#player-types {
    margin: 20px 0;
}

.player-type-row {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin: 15px 0;
    gap: 10px;
    position: relative;
}

.player-type-row label {
    font-weight: bold;
    color: #2c3e50;
    min-width: 100px;
    text-align: right;
    flex-shrink: 0;
}

.player-type-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 300px;
}

.player-type-toggle {
    display: flex;
    background-color: #ecf0f1;
    border-radius: 5px;
    overflow: hidden;
    margin: 0;
    width: 220px;
}

.player-type-toggle button {
    margin: 0;
    border-radius: 0;
    padding: 8px 15px;
    flex: 1;
    min-width: 110px;
    text-align: center;
}

.player-type-toggle button.selected {
    background-color: #2ecc71;
    color: white;
}

.computer-difficulty {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 10px;
    min-height: 40px;
}

.computer-difficulty button {
    font-size: 14px;
    padding: 8px 12px;
    margin: 0;
}

/* On small screens, stack the controls vertically */
@media (max-width: 600px) {
    .player-type-row {
        flex-direction: column;
        text-align: center;
    }

    .player-type-row label {
        text-align: center;
        margin-right: 0;
        margin-bottom: 5px;
    }

    .computer-difficulty {
        margin-top: 10px;
        margin-left: 0;
    }
}

/* Add styles for selected difficulty buttons */
.computer-difficulty button.selected {
    background-color: #2ecc71;
    border: 2px solid #27ae60;
    transform: scale(1.05);
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.5);
}

.computer-difficulty button.selected:hover {
    background-color: #27ae60;
}

/* Add visual indicator for computer turns */
.computer-turn .card:not(.flipped):not(.matched):hover {
    cursor: not-allowed;
}

.computer-turn #current-player::before {
    content: "🤖 ";
}

.computer-turn #current-player {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Styles for special options */
.special-options {
    margin: 20px 0;
    text-align: center;
}

.checkbox-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.checkbox-container input {
    margin-right: 8px;
    transform: scale(1.2);
}

.checkbox-text {
    font-size: 16px;
    color: #2c3e50;
}

/* Poop card styles */
.poop-card {
    transform: rotateY(180deg);
    opacity: 0.4;
    cursor: default;
    filter: grayscale(50%) brightness(1.1);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(139, 69, 19, 0.5);
    animation: wiggle 0.5s ease-in-out;
}

.poop-card::after {
    content: "💩";
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 16px;
    background-color: rgba(255, 255, 255, 0.7);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transform: rotateY(180deg) scale(0.7);
}

@keyframes wiggle {
    0%, 100% { transform: rotateY(180deg); }
    25% { transform: rotateY(180deg) rotate(5deg); }
    75% { transform: rotateY(180deg) rotate(-5deg); }
}

.poop-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
    font-size: 24px;
    font-weight: bold;
    color: #e74c3c;
    text-align: center;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Add visual indicator for between turns state */
body.between-turns .card:not(.flipped):not(.matched):hover {
    cursor: not-allowed;
}

body.between-turns #current-player {
    opacity: 0.7;
}
