* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial Rounded MT Bold', 'Comic Sans MS', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f9c5d1, #c2e9fb);
    padding: 10px;
    overflow-x: hidden;
    touch-action: manipulation;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-width: 900px;
    width: 100%;
}

h1 {
    color: #ff6b93;
    margin-bottom: 10px;
    text-align: center;
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    text-shadow: 2px 2px 0px rgba(255, 107, 147, 0.2);
}

.game-area {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
}

.game-board-container {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
}

.game-board {
    border: 3px solid #ffb6c1;
    border-radius: 10px;
    background-color: #fff9fb;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    max-width: 100%;
    height: auto;
}

.info-panel {
    background: linear-gradient(135deg, #e6f7ff, #fff0f5);
    border-radius: 15px;
    padding: 10px 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.score-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.score, .high-score, .level, .p2-score {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: #5a7d9a;
    background-color: white;
    padding: 5px 10px;
    border-radius: 50px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-width: 80px;
    text-align: center;
}

.p2-score {
    display: none;
}

.theme-selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin: 6px 0;
}

.theme-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.theme-btn.active {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.theme-cute { background: linear-gradient(135deg, #ff9eb5, #ffb6c1); }
.theme-emoji { background: linear-gradient(135deg, #ffd166, #ff9e6d); }
.theme-pixel { background: linear-gradient(135deg, #9d7af5, #7a5af5); }
.theme-forest { background: linear-gradient(135deg, #7ec850, #4caf50); }
.theme-ocean { background: linear-gradient(135deg, #4fc3f7, #29b6f6); }
.theme-space { background: linear-gradient(135deg, #6a1b9a, #8e24aa); }
.theme-candy { background: linear-gradient(135deg, #ff9a9e, #fad0c4); }
.theme-gold { background: linear-gradient(135deg, #ffd700, #ffec8b); }
.theme-rainbow { background: linear-gradient(135deg, #ff9a9e, #fad0c4, #a1c4fd, #c2e9fb); }

.instructions {
    text-align: center;
    color: #5a7d9a;
    margin-top: 8px;
    font-size: clamp(0.75rem, 2vw, 0.85rem);
    line-height: 1.3;
    background: white;
    padding: 8px;
    border-radius: 10px;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffeff3, #ffd6e0);
    padding: 15px 12px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(255, 107, 147, 0.25);
    z-index: 10;
    display: none;
    width: 65%;
    max-width: 260px;
    border: 2px solid #ffb6c1;
    overflow: hidden;
}

.game-over::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 12px solid #ffb6c1;
}

.game-over h2 {
    color: #ff6b93;
    margin-bottom: 8px;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    text-shadow: 1px 1px 3px rgba(255, 107, 147, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.game-over h2::before, .game-over h2::after {
    content: '🐍';
    font-size: 1.2em;
}

.game-over #winnerInfo {
    color: #ff6b93;
    font-weight: bold;
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    margin: 8px 0;
    display: block;
}

.game-over p {
    margin-bottom: 12px;
    color: #5a7d9a;
    font-size: clamp(0.85rem, 3vw, 1rem);
    background: rgba(255, 255, 255, 0.7);
    padding: 5px 10px;
    border-radius: 50px;
    display: inline-block;
}

.game-over p span.score-val {
    color: #ff6b93;
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 4px;
}

#playAgainBtn {
    background: linear-gradient(135deg, #ff9eb5, #ff6b93);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: clamp(0.9rem, 3vw, 1rem);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 0 #ff4d7d, 0 6px 12px rgba(255, 107, 147, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 auto;
}

#playAgainBtn:hover {
    background: linear-gradient(135deg, #ff8aa6, #ff5a8a);
    transform: translateY(-3px);
    box-shadow: 0 7px 0 #ff4d7d, 0 10px 20px rgba(255, 107, 147, 0.3);
}

#playAgainBtn:active {
    transform: translateY(1px);
    box-shadow: 0 3px 0 #ff4d7d, 0 5px 10px rgba(255, 107, 147, 0.2);
}

#playAgainBtn::before {
    content: '🐾';
    font-size: 1.2em;
}

.sound-control {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #ff6b93;
    z-index: 5;
}

.mode-selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
}

.mode-btn {
    background: linear-gradient(135deg, #b3e5fc, #81d4fa);
    color: #0277bd;
    border: none;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 119, 189, 0.2);
    flex: 1;
    min-width: 80px;
    max-width: 120px;
    text-align: center;
}

.mode-btn.active {
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(41, 182, 246, 0.3);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 119, 189, 0.3);
}

.mode-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(0, 119, 189, 0.2);
}

.mobile-controls-wrapper {
    display: none;
    width: 100%;
    justify-content: space-around;
    margin: 10px 0;
    gap: 10px;
}

.mobile-controls {
    display: grid;
    grid-template-areas:
        ". up ."
        "left . right"
        ". down .";
    gap: 6px;
    justify-content: center;
}

.mobile-controls button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ff9eb5;
    color: white;
    border: none;
    box-shadow: 0 3px 0 #ff7a9b;
    transition: all 0.3s;
}

.controls-p2 button {
    background-color: #4fc3f7;
    box-shadow: 0 3px 0 #29b6f6;
}

.control-up { grid-area: up; }
.control-down { grid-area: down; }
.control-left { grid-area: left; }
.control-right { grid-area: right; }

.ai-settings {
    display: none;
    background: white;
    padding: 6px 8px;
    border-radius: 8px;
    margin: 6px 0 10px;
}

.ai-settings label {
    font-size: 0.85rem;
    color: #5a7d9a;
}

.ai-settings select {
    width: 100%;
    padding: 6px;
    border-radius: 5px;
    border: 1px solid #ffb6c1;
    background: #fff9fb;
    font-size: 0.85rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin: 6px 0;
}

.controls button {
    background-color: #ff9eb5;
    color: white;
    border: none;
    padding: 7px 11px;
    border-radius: 50px;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 3px 0 #ff7a9b;
    flex: 1;
    min-width: 75px;
}

.controls button:hover {
    background-color: #ff7a9b;
    transform: translateY(-2px);
}

.controls button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #ff7a9b;
}

.special-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 8px 0;
}

.feature-toggle {
    background: linear-gradient(135deg, #c2e9fb, #a1c4fd);
    color: #0277bd;
    border: none;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 119, 189, 0.2);
    display: flex;
    align-items: center;
    gap: 5px;
}

.feature-toggle.active {
    background: linear-gradient(135deg, #81d4fa, #4fc3f7);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(41, 182, 246, 0.3);
}

.player-speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 50px;
    margin: 8px 0;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
}

.player-speed-control label {
    font-size: 0.85rem;
    color: #5a7d9a;
    white-space: nowrap;
    font-weight: 600;
}

.player-speed-control input {
    flex: 1;
    min-width: 0;
}

.game-area-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 50px;
    margin: 8px 0;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
}

.game-area-control label {
    font-size: 0.85rem;
    color: #5a7d9a;
    white-space: nowrap;
    font-weight: 600;
}

.game-area-control select {
    flex: 1;
    min-width: 80px;
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid #ffb6c1;
    background: #fff9fb;
    font-size: 0.85rem;
}

.target-score-control {
    display: none;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 50px;
    margin: 8px 0;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
}

.target-score-control label {
    font-size: 0.85rem;
    color: #5a7d9a;
    white-space: nowrap;
}

.target-score-control input {
    flex: 1;
    min-width: 50px;
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid #ffb6c1;
    background: #fff9fb;
    font-size: 0.85rem;
    text-align: center;
}

.copyright-section {
    margin-top: 20px;
    text-align: center;
    color: #5a7d9a;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    line-height: 1.6;
    padding: 10px 0;
    width: 100%;
    max-width: 900px;
}

.copyright-section a {
    color: #ff6b93;
    text-decoration: none;
    transition: color 0.3s ease;
}

.copyright-section a:hover {
    color: #ff4d7d;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .mobile-controls-wrapper {
        display: flex;
    }
    
    .game-board {
        max-width: 380px;
    }
    
    .p2-score {
        display: block;
        min-width: 75px;
    }

    .info-panel {
        padding: 8px 10px 15px;
    }
    
    .special-features {
        flex-direction: column;
        align-items: center;
    }
    
    .feature-toggle, .player-speed-control, .game-area-control, .target-score-control {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
    
    .copyright-section {
        margin-top: 15px;
        padding: 8px 0;
    }
}

@media (min-width: 769px) {
    .game-area {
        flex-direction: row;
        align-items: flex-start;
        gap: 15px;
    }
    
    .game-board-container {
        flex: 3;
    }
    
    .info-panel {
        flex: 1;
        min-width: 240px;
        margin-top: 5px;
    }
}