@import url("https://fonts.googleapis.com/css?family=Press+Start+2P");

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "Press Start 2P", cursive;
    font-size: 16px;
    color: white;
    background: linear-gradient(180deg, #87CEEB 0%, #5BA3C6 100%);
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

canvas {
    display: block;
}

button {
    outline: none;
    cursor: pointer;
    border: none;
    box-shadow: 3px 5px 0px 0px rgba(0, 0, 0, 0.75);
    touch-action: manipulation;
}

#counter {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: clamp(1rem, 4vw, 2rem);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    z-index: 10;
}

#end {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    z-index: 100;
    background: rgba(0,0,0,0.5);
}

#end button {
    background-color: #ff3333;
    padding: 20px 40px;
    font-family: inherit;
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    color: white;
    border-radius: 10px;
    border: 3px solid white;
}

#end button:active {
    transform: scale(0.95);
}

#controlls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    z-index: 10;
}

#controlls div {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto;
    gap: 8px;
}

#controlls button {
    width: clamp(45px, 12vw, 60px);
    height: clamp(45px, 12vw, 60px);
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #333;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#controlls button:active {
    background-color: #ffdd00;
    transform: scale(0.95);
}

#controlls button svg {
    width: 60%;
    height: 60%;
}

#controlls button svg path {
    fill: #333;
}

/* Forward button spans all columns */
#controlls button:first-of-type {
    grid-column: 1 / -1;
    width: 100%;
}

/* Touch instruction overlay */
#touch-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 15px;
    font-size: clamp(0.6rem, 2.5vw, 0.9rem);
    text-align: center;
    z-index: 50;
    border: 2px solid #ffdd00;
    line-height: 1.8;
}

#touch-hint.hidden {
    display: none;
}

/* Landscape adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    #controlls {
        position: absolute;
        right: 10px;
        bottom: 50%;
        transform: translateY(50%);
        left: auto;
        width: auto;
        padding-bottom: 0;
    }

    #controlls div {
        grid-template-columns: repeat(3, 1fr);
    }

    #controlls button {
        width: clamp(35px, 8vh, 50px);
        height: clamp(35px, 8vh, 50px);
    }
}
