:root {
    box-sizing: border-box;
    --red: #FA1400;
    --blue: #007BFF;
    --dull-blue: #5B95D1;
    --lime: #DEFA15;
    --brown: #512723;
    --inactive: #A9A9A9;
    --offwhite: #F2F0EF;
}
body {
    display: grid;
    grid-template-areas: 
    "header player"
    "game sidebar"
    "footer foobar"
    ;
    grid-template-columns: auto minmax(200px, 25vw);
    grid-template-rows: 4rem auto 3rem;
    gap: 0rem 2rem;
    height: 100dvh;
    font-family: "Indie Flower", cursive;
    font-weight: 400;
    font-style: normal;
    margin: 0;
    padding: 0 3rem;
    background-color: var(--dull-blue);
}

header {
    grid-area: header;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
header h1 {
    height: 3.5rem;
    margin: 0;
    padding: 0;
}
#playername-container {
    grid-area: player;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
#playername-container img {
    height: 20px;
    width: 20px;
    margin-left: 1rem;
    cursor: pointer;
}
#playername-container img:hover {
    transform-origin: center;
    transform: translateY(-2px);
}
#playername {
    font-size: 2rem;
}

select {
    font-family: "Indie Flower", cursive;
    font-size: 1.25rem;
    padding: 0.5rem 1rem;
    border: 2px solid var(--brown);
    border-radius: 999px;
    background-color: var(--blue);
    width: 10rem;
    text-align: center;
    color: white;
    cursor: pointer;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    transition: transform 0.05s ease, box-shadow 0.05s ease;
}

input {
    font-family: "Indie Flower", cursive;
    font-size: 1.25rem;
    padding: 0.25rem .5rem;
    border-radius: 1rem;
    width: 50%;
}

#game-board {
    grid-area: game;
    height: 100%;
    width: 100%;
    margin: 0;
    border: 2px solid var(--lime);
    border-radius: 2rem;
    background-image: url('assets/grass-field.svg');
    background-size: cover;
    position: relative;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
#hero {
    position: absolute;
    width: 50px;
    height: 50px;
    background-size: contain;
    background-repeat: no-repeat;
    transform: translateY(-50%) translateX(-50%);
    transition: transform 0.05s linear;
}
.bubble {
    --bubble-flip: 1;
    --arrow-pos: 35%;
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%) scaleX(var(--bubble-flip));
    transform-origin: center bottom;
    
    background: var(--offwhite);
    color: var(--brown);
    font-family: sans-serif;
    font-size: .75rem;
    padding: .75rem;
    border-radius: 1rem;
    border: 2px solid var(--blue);
    width: 100px;
    text-align: center;
    z-index: 21;
}

.bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: var(--arrow-pos); /* Változó használata */
    width: 1rem;
    height: 1rem;
    margin-left: -10px;     /* Finomhangoltuk, hogy középre essen */
    background-color: var(--offwhite);
    transform: rotate(45deg);
    border-width: 2px;
    border-style: solid;
    border-color: transparent var(--blue) var(--blue) transparent;
    z-index: 20;
}

.sidebar {
    grid-area: sidebar;
    justify-self: right;
    display: flex;
    flex-flow: row wrap;
    justify-content: center;
    align-items: center;
    max-width: max(200px, 20vw);
    border-radius: 2rem;
    border: 2px solid var(--brown);
    padding: 2rem;
    gap: 1rem;
    background-color: var(--offwhite);
}
.score-board {
    display: flex;
    width: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.score-board h2 {
    font-size: 2.5rem;
    margin: 0;
    text-align: center;
}
#score {
    font-size: 3rem;
    color: var(--blue);
}
#scoreChange {
    font-size: 1.5rem;
    height: 1.5rem;
    margin-top: 0.5rem;
    opacity: 0;
}

.animate-score {
    animation: floatFade 1s ease-out forwards;
}

@keyframes floatFade {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

.diff-section {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: center;
    margin-top: 1rem;
}
.diff-section p {
    font-size: 1.5rem;
    margin: 0;
}
#difficultySelect {
    margin-top: .5rem;
}
#life-meter {
    width: 200px;
    height: 20px;
    text-align: center;
    font-size: 1.5rem;
}

.button-wrapper {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: center;
    margin-top: auto;
    gap: 1rem;
}
button {
    font-family: "Indie Flower", cursive;
    font-size: 1.25rem;
    width: 100%;
    min-width: 6rem;
    padding: 0.5rem 1rem;
    border: 2px solid var(--brown);
    border-radius: 50px;
    background-color: var(--blue);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    color: white;
    cursor: pointer;
    transition: transform 0.05s ease, box-shadow 0.05s ease;
}
button:hover:not(.disabled) {
    transform-origin: center;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    color: var(--lime);
}
button:active {
    transform: translateY(0);
    box-shadow: none;
}
button.disabled {
    background-color: var(--inactive);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: white;
    pointer-events: none;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
}
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--offwhite);
    border: 2px solid var(--brown);
    border-radius: 2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    padding: 2rem 4rem;
    z-index: 1000;
    overflow-y: auto;
    scrollbar-gutter: stable;
    min-height: 30dvh;
    max-height: 80dvh;
    width: min(900px, 95vw);
}

.gameover.modal {
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.info.modal {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.info.modal ul {
    list-style-type: none;
    padding-left: 0;
    padding-bottom: 1rem;
    margin: 0;
}
.info.modal li {
    display: flex;
    align-items: first baseline;
    margin-bottom: 0.5rem;
}
.info.modal h2 {
    margin: .5rem;
    padding: 0;
}
.info.modal h3 {
    width: 100%;
    margin-bottom: 1rem;
    text-align: left;
    text-decoration: underline;
}
.info.modal img {
    height: 20px;
    width: 20px;
    margin-right: 0.75rem;
}
.info.modal button {
    width: 50%;
}

.leaderboard.modal {
    width: min(800px, 90%);
    display: grid;
    justify-content: center;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(12, auto);
}

.leaderboard.modal h2 {
    text-align: center;
    margin-top: 0;
    grid-column-start: 1;
    grid-column-end: 4;
}
.leaderboard.modal h3 {
    margin: 0;
    text-align: center;
    grid-row: 2;
    border: 1px solid var(--blue);
}
.leaderboard.modal ol {
    margin: 0;
    grid-row: 3;
    border: 1px solid var(--blue);
}
.leaderboard.modal li {
    padding: 0.25rem .5rem;
}
.leaderboard.modal button {
    width: 50%;
    grid-row: 12;
    grid-column-start: 1;
    grid-column-end: 4;
    margin-top: 2rem;
    place-self: center;
}

footer {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: .5rem 0;
    background-color: var(--dull-blue)
}

@media screen and (max-width: 1024px){
    body {
        grid-template-areas:
        "header player"
        "game game"
        "sidebar sidebar"
        "footer footer"
        ;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto 1fr 1fr auto;
        place-items: center;
        height: fit-content;
        gap: 0;
        padding: 0 1rem;
    }
    .sidebar {
        margin-top: 2rem;
        max-width: 100%;
        justify-self: center;
    };
    #game-board {
        width: 80vw;
        aspect-ratio: 1 / 1;
    }
}

@media screen and (max-width: 768px){
    body {
        padding: 0 .5rem;
    }
    header h1 {
        font-size: 1rem;
        height: 2rem;
    }
    #playername {
        font-size: 1rem;
    }
    #playername-container img {
        height: 16px;
        width: 16px;
    }
    .sidebar {
        margin-top: 2rem;
        max-width: 100%;
        flex: 1 0 100%;
        justify-self: center;
    };
    #game-board {
        width: 80vw;
        aspect-ratio: 1 / 1;
    }
}