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

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Arial Rounded MT Bold', sans-serif;
    background-color: #8fe0ff;
    touch-action: none;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Game Container */
#game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    max-height: 900px;
    aspect-ratio: 9/10;
    margin: 0 auto;
    overflow: hidden;
    background-color: #c0f7e9;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Screen Styles */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: #c0f7e9;
    padding: 20px;
    z-index: 10;
}

.screen.active {
    display: flex;
}

/* Typography */
h1 {
    font-size: 3rem;
    color: #2e8b57;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #fff;
}

h2 {
    font-size: 1.6rem;
    color: #2e8b57;
    margin-bottom: 15px;
}

h3 {
    font-size: 1.3rem;
    color: #2e8b57;
    margin-bottom: 10px;
}

p {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #333;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-family: inherit;
    font-weight: bold;
    font-size: 1.2rem;
    transition: transform 0.2s, background-color 0.2s;
}

button:hover, button:active {
    transform: scale(1.05);
}

.large-button {
    background-color: #4caf50;
    color: white;
    padding: 15px 30px;
    font-size: 1.5rem;
    margin: 15px 0;
    min-width: 200px;
    box-shadow: 0 4px 0 #2e8b57;
}

.large-button:hover {
    background-color: #3e8e41;
}

.secondary-button {
    background-color: #f7aa35;
    color: white;
    margin: 10px 0;
    min-width: 180px;
    box-shadow: 0 4px 0 #d68000;
}

.secondary-button:hover {
    background-color: #e09000;
}

.icon-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.7);
    color: #2e8b57;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    z-index: 5;
}

/* Start Screen */
.character-display {
    width: 100px;
    height: 100px;
    background-color: #6cbf84;
    border-radius: 15px;
    margin: 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #2e8b57;
}

.frog-character {
    width: 70px;
    height: 70px;
    background-color: #4caf50;
    border-radius: 50%;
    position: relative;
}

.frog-character:before, .frog-character:after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    background-color: white;
    border-radius: 50%;
    top: 15px;
}

.frog-character:before {
    left: 10px;
}

.frog-character:after {
    right: 10px;
}

.frog-character::before::after, .frog-character::after::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: black;
    border-radius: 50%;
    top: 7px;
    left: 7px;
}

.difficulty-select {
    margin: 20px 0;
}

.difficulty-btn {
    background-color: #7ec0ee;
    color: #333;
    margin: 5px;
    padding: 10px 15px;
    box-shadow: 0 3px 0 #5a99c7;
}

.difficulty-btn:hover {
    background-color: #5a99c7;
    color: white;
}

.difficulty-btn.selected {
    background-color: #5a99c7;
    color: white;
    box-shadow: 0 3px 0 #3b7ead;
    transform: scale(1.05);
}

/* Tutorial Screen */
.tutorial-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.tutorial-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 160px;
}

.tutorial-image {
    width: 100px;
    height: 100px;
    border-radius: 15px;
    background-color: #f0f0f0;
    margin-bottom: 10px;
    border: 3px solid #2e8b57;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tutorial-move {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50 20l15 20H55v20h20v-10l20 15-20 15v-10H55v20h10l-15 20-15-20h10V70H35v10L15 65l20-15v10h20V40h-10z" fill="%234caf50"/></svg>');
    background-size: 60%;
    background-repeat: no-repeat;
    background-position: center;
}

.tutorial-avoid {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="35" width="80" height="30" rx="10" fill="%23f44336"/><circle cx="25" cy="65" r="10" fill="%23333"/><circle cx="75" cy="65" r="10" fill="%23333"/></svg>');
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
}

.tutorial-ride {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="40" width="80" height="20" rx="5" fill="%23795548"/><circle cx="50" cy="40" r="15" fill="%234caf50"/></svg>');
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
}

.tutorial-goal {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="%238bc34a"/><path d="M30 40 L50 30 L70 40 L70 60 L50 70 L30 60 Z" fill="%234caf50"/></svg>');
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
}

.controls-guide {
    margin-top: 20px;
    width: 100%;
    max-width: 600px;
}

.control-methods {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.control-method {
    flex: 1;
    min-width: 150px;
    background-color: #e6f7ff;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 3px 0 #b3e0ff;
}

/* Game Screen */
#game-screen {
    padding: 0;
    justify-content: flex-start;
}

.game-header {
    width: 100%;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(46, 139, 87, 0.8);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.lives, .level, .score, .timer {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
}

.lives-icons {
    display: flex;
    margin-left: 5px;
}

.life-icon {
    width: 20px;
    height: 20px;
    background-color: #4caf50;
    border-radius: 50%;
    margin-right: 5px;
}

#game-board {
    width: 100%;
    flex-grow: 1; /* Make game board fill available vertical space */
    position: relative;
    overflow: hidden;
    /* Removed fixed height calculation */
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.touch-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 3;
}

.direction-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.7);
    color: #2e8b57;
    font-size: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 5px;
    padding: 0;
    user-select: none;
}

.horizontal-controls {
    display: flex;
    gap: 40px;
}

/* Level Complete Screen */
.level-score {
    background-color: #e6f7ff;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    min-width: 250px;
}

/* Game Over Screen */
.game-over-message {
    color: #f44336;
    font-size: 1.5rem;
    margin: 15px 0;
}

.final-score {
    background-color: #e6f7ff;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    min-width: 250px;
}

/* Game Complete Screen */
.game-complete-message {
    color: #4caf50;
    font-size: 1.5rem;
    margin: 15px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }
    
    .large-button {
        font-size: 1.3rem;
        padding: 12px 25px;
    }
    
    .tutorial-item {
        width: 120px;
    }
    
    .tutorial-image {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    p {
        font-size: 1rem;
    }
    
    .difficulty-btn, .secondary-button {
        font-size: 1rem;
        padding: 8px 15px;
    }
    
    .large-button {
        font-size: 1.2rem;
        padding: 10px 20px;
        min-width: 160px;
    }
    
    .direction-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .game-header {
        font-size: 0.9rem;
    }
}

/* Hide touch controls on non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .touch-controls {
        display: none;
    }
    
    #game-board {
        height: calc(100% - 50px);
    }
}

/* Landscape orientation adjustments for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #game-container {
        aspect-ratio: 4/3;
        height: 100vh;
    }
    
    .touch-controls {
        flex-direction: row;
        justify-content: space-between;
        padding: 5px 20px;
    }
    
    .horizontal-controls {
        order: 1;
        gap: 20px;
    }
    
    #up-btn {
        order: 2;
    }
    
    #down-btn {
        order: 3;
    }
    
    .direction-btn {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
        margin: 2px;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .character-display {
        width: 60px;
        height: 60px;
        margin: 10px auto;
    }
    
    .frog-character {
        width: 40px;
        height: 40px;
    }
    
    .frog-character:before, .frog-character:after {
        width: 15px;
        height: 15px;
        top: 8px;
    }
    
    .tutorial-content {
        gap: 10px;
    }
    
    .tutorial-item {
        width: 100px;
    }
    
    .tutorial-image {
        width: 60px;
        height: 60px;
    }
}
