
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    background-color: #24b838;
    color: #161515;
    font-family: Arial, sans-serif;
    text-align: center;
}

main {
    height: 100vh;
    height: 100dvh;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

h1 {
    color: #c8ff9a;
    font-size: clamp(20px, 4vw, 36px);
    margin: 0;
}

.puntos {
    font-size: 20px;
    font-weight: bold;
    margin: 0;
}

.zona-juego {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contenedor-tablero {
    position: relative;
    width: min(90vw, 400px, 100%);
    max-height: 100%;
    aspect-ratio: 1 / 1;
    flex-shrink: 1;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #263e2d;
    border: 4px solid white;
    touch-action: none;
}

#mensaje {
    position: absolute;
    inset: 4px;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    font-size: clamp(18px, 4vw, 28px);
    font-weight: bold;
}

button {
    background-color: green;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    touch-action: manipulation;
}

#iniciar {
    padding: 10px 20px;
    font-size: 17px;
    flex-shrink: 0;
}

button:active {
    background-color: #005500;
}

.controles {
    display: grid;
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(2, 42px);
    gap: 5px;
    flex-shrink: 0;
}

.flecha {
    font-size: 23px;
    font-weight: bold;
    background-color: #176b2a;
}

.arriba {
    grid-column: 2;
    grid-row: 1;
}

.izquierda {
    grid-column: 1;
    grid-row: 2;
}

.abajo {
    grid-column: 2;
    grid-row: 2;
}

.derecha {
    grid-column: 3;
    grid-row: 2;
}

.ayuda {
    font-size: 12px;
    margin: 0;
    flex-shrink: 0;
}

/* Ajustes para pantallas pequeñas */
@media (max-width: 600px) {
    h1 {
        font-size: 23px;
    }

    .puntos {
        font-size: 17px;
    }

    .flecha {
        font-size: 22px;
    }
}

/* Ajustes para pantallas bajas */
@media (max-height: 550px) {
    main {
        gap: 3px;
        padding: 4px;
    }

    h1 {
        font-size: 18px;
    }

    .controles {
        grid-template-columns: repeat(3, 34px);
        grid-template-rows: repeat(2, 30px);
    }

    #iniciar {
        padding: 6px 14px;
        font-size: 14px;
    }

    .ayuda {
        display: none;
    }
}
