@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

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

:root {
    --RESULT-DIALOG-WIDTH: min(85vw, 500px);
    --NAMES-DIALOG-WIDTH: min(85vw, 700px);
    --HEADER-WIDTH: min(90vw, 550px);
    --GAMEBOARD-SIDE: min(90vw, 470px);

    --TITLE-FS: clamp(3rem, 13vw, 4.5rem);
    --TURN-MSG-FS: clamp(1.5rem, 10vw, 2.5rem);
    --PLAYER-SYMBOL-FS: clamp(2rem, 15vw, 5rem);
    --FOOTER-FS: clamp(1rem, 5vw, 1.2rem);
    --RESULT-DIALOG-FS: clamp(1.2rem, 8vw, 2.3rem);

    --LIGHT-COLOR: rgb(216, 200, 173);
    --EXTRA-LIGHT-COLOR: rgb(230, 223, 210);
}

html {
    position: relative;
    min-height: 100vh;
}

/* Cross-browser user-select helper applied below */
body {
    font-family: 'Roboto', sans-serif;
    background-color: rgb(211, 162, 88);
    margin-bottom: 100px;

    -webkit-touch-callout: none; /* iOS Safari: disable callout */
    -webkit-user-select: none;   /* Safari, Chrome */
    -moz-user-select: none;      /* Firefox */
    -ms-user-select: none;       /* IE/Edge legacy */
    user-select: none;           /* Standard */
}

/* HEADER */

header {
    padding-top: 30px;
    margin-bottom: 40px;
}

header h1 {
    margin: 0 auto;
    padding: 20px 0;
    width: var(--HEADER-WIDTH);
    text-align: center;
    font-size: var(--TITLE-FS);
    background-color: var(--LIGHT-COLOR);
    color: #333;
    border-radius: 20px;
}

header h1:hover {
    background-color: var(--EXTRA-LIGHT-COLOR);
}

/* MAIN */

main p {
    margin-bottom: 20px;
    text-align: center;
    font-size: var(--TURN-MSG-FS);
}

main .gameboard {
    width: var(--GAMEBOARD-SIDE);
    height: var(--GAMEBOARD-SIDE);
    margin: 0 auto;
    margin-bottom: 30px;
    padding: 20px;
    border-radius: 20px;
    background-color: var(--LIGHT-COLOR);

    display: grid;
    gap: 3px;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.gameboard .gamecell {
    border: 2px solid black;
    font-size: var(--PLAYER-SYMBOL-FS);
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;
}

.gameboard .gamecell:hover {
    background-color: var(--EXTRA-LIGHT-COLOR);
}

main button {
    display: block;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0 auto;
    padding: 20px 70px;
    border: none;
    border-radius: 10px;
    background-color: var(--LIGHT-COLOR);
    cursor: pointer;
}

main button:hover {
    background-color: var(--EXTRA-LIGHT-COLOR);
}

/* DIALOG */

dialog {
    position: fixed;
    border: none;
    border-radius: 20px;

    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

/* --- RESULT DIALOG */

.result-dialog {
    top: 300px;
    left: calc(50% - (var(--RESULT-DIALOG-WIDTH) / 2));
}

.result-dialog h1 {
    padding: 70px 10px;
    width: var(--RESULT-DIALOG-WIDTH);
    text-align: center;
    font-size: var(--RESULT-DIALOG-FS);
    font-weight: 700;
}

/* --- NAMES DIALOG */

.names-dialog {
    top: 200px;
    left: calc(50% - (var(--NAMES-DIALOG-WIDTH) / 2));
}

.names-dialog form {
    padding: 50px 0 70px 0;
    width: var(--NAMES-DIALOG-WIDTH);

    display: grid;
    row-gap: 50px;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    justify-items: center;
}

.names-dialog p.title {
    grid-column: 1 / -1;

   font-size: 2.5rem;
   font-weight: 700;
}

.names-dialog p.player-name {
    display: flex;
    flex-direction: column;
    gap: 10px;

    font-size: 1.3rem;
    font-weight: 500;
    color: #333;
}

.names-dialog input {
    width: 230px;
    padding: 5px;
    border: 2px solid #333;
    border-radius: 5px;
    font-size: 1rem;
}

.names-dialog button {
    grid-column: 1 / -1;

    margin-top: 25px;
    padding: 25px 70px;
    background-color: rgb(116, 233, 116);
    border: 0.5px solid black;
    border-radius: 10px;
    font: inherit;
    font-size: 1.4rem;
    font-weight: 500;
    cursor: pointer;
}

.names-dialog button:hover {
    background-color: rgb(146, 255, 146);
}

@media screen and (max-width: 600px) {
    .names-dialog {
        top: 100px;
    }
    .names-dialog form {
        row-gap: 40px;
        grid-template-columns: 1fr;
    }
    .names-dialog p.title {
        font-size: clamp(1.5rem, 8vw, 2.2rem);
    }
    .names-dialog button {
        padding-inline: 60px;
        font-size: 1.2rem;
    }
}

/* FOOTER */

footer {
    position: absolute;
    bottom: 15px;
    width: 100%;
    text-align: center;
    color: black;
    font-size: var(--FOOTER-FS);
    user-select: text;

    -webkit-touch-callout: auto;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
