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

html, body {
    height: 100%;
    font-family: 'Segoe UI', 'Lucida Sans', Geneva, Verdana, sans-serif;
    background-color: #121213;
}

#boks {
    display: flex;
    background-color: #121213;
    min-height: 100%;
    align-items: center;
    flex-direction: column;
}

header {
    margin-top: 100px;
    border-bottom: 1px solid #3a3a3c;
    width: 100%;
}

#spil {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.titel {
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: bold;
    margin: 0.4rem 0;
    text-align: center;
    letter-spacing: 0.1em;
}

#besked-container {
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#besked {
    background-color: #ffffff;
    color: #121213;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
}

#besked.vis {
    opacity: 1;
}

#brætboks {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
}

#bræt {
    display: grid;
    grid-template-columns: repeat(5, 62px);
    grid-template-rows: repeat(6, 62px);
    grid-gap: 5px;
    padding: 10px;
}

.square {
    border: 2px solid #3a3a3c;
    color: #ffffff;
    width: 62px;
    height: 62px;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s;
}

.square.filled {
    border-color: #565758;
    animation: pop 0.1s;
}

.square.flip {
    animation: flip 0.5s ease forwards;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes flip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.square.correct {
    background-color: #538d4e;
    border-color: #538d4e;
}

.square.present {
    background-color: #b59f3b;
    border-color: #b59f3b;
}

.square.absent {
    background-color: #3a3a3c;
    border-color: #3a3a3c;
}

.square.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

#tastaturboks {
    padding: 10px 8px 20px;
}

.tastaturrække {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 0 auto 8px;
    touch-action: manipulation;
}

.tastaturrække button {
    font-family: inherit;
    font-weight: bold;
    font-size: 0.85rem;
    border: 0;
    padding: 0;
    height: 58px;
    min-width: 30px;
    cursor: pointer;
    background-color: #818384;
    color: #ffffff;
    flex: 1;
    text-transform: uppercase;
    margin-right: 6px;
    border-radius: 4px;
    user-select: none;
    transition: background-color 0.1s;
}

.tastaturrække button:last-child {
    margin-right: 0;
}

.tastaturrække button:active {
    transform: scale(0.95);
}

.tastaturrække button.storknap {
    flex: 1.5;
    font-size: 0.75rem;
}

.tastaturrække button.correct {
    background-color: #538d4e;
}

.tastaturrække button.present {
    background-color: #b59f3b;
}

.tastaturrække button.absent {
    background-color: #3a3a3c;
}

.spacerhalv {
    flex: 0.5;
}

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#modal-overlay.vis {
    display: flex;
}

#modal {
    background-color: #121213;
    border: 1px solid #3a3a3c;
    border-radius: 8px;
    padding: 30px 40px;
    text-align: center;
    max-width: 90%;
    width: 350px;
    animation: modalPop 0.3s ease;
}

@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-titel {
    color: #ffffff;
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.modal-tekst {
    color: #818384;
    font-size: 1.1rem;
    margin-bottom: 25px;
}

#modal-titel {
    color: #ffffff;
    font-size: 1.8rem;
    margin-bottom: 15px;
}

#modal-tekst {
    color: #818384;
    font-size: 1.1rem;
    margin-bottom: 25px;
}

#btn-tilbage {
    background-color: #538d4e;
    color: #ffffff;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.2s;
}

#btn-tilbage:hover {
    background-color: #6aaa5e;
}

#btn-spil-igen {
    background-color: #ffeb99;
    color: #000000;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.2s;
}

#btn-spil-igen :hover {
    background-color: #fde06f;
}

.modal-knapper {
    display: flex;
    justify-content: center; 
    gap: 15px;          
    margin-top: 20px;
}

#spil-dato {


    font-size: 0.5em; display: block; color: #ffeb99; font-weight: normal;
}

@media (max-width: 400px) {
    #bræt {
        grid-template-columns: repeat(5, 52px);
        grid-template-rows: repeat(6, 52px);
    }
    
    .square {
        width: 52px;
        height: 52px;
        font-size: 1.6rem;
    }
    
    .tastaturrække button {
        height: 50px;
        font-size: 0.8rem;
    }
}


@media (max-height: 850px) {

    .tastaturrække button {
        height: 45px; 
        font-size: 0.75rem;
    }

    .titel {
        font-size: 1.5rem;
        margin-top: 10px; 
    }
    
    header {
        margin-top: 70px; 
    }

    #bræt {
        grid-template-columns: repeat(5, 45px);
        grid-template-rows: repeat(6, 45px);
        grid-gap: 20px; 
        padding: 5px;
    }

    .square {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        border-width: 2px;
    }
}

@media (max-height: 750px) {

    .tastaturrække button {
        height: 30px; 
        font-size: 0.75rem;
    }

    .titel {
        font-size: 1.3rem;
        margin-top: 10px; 
    }
    
    header {
        margin-top: 70px; 
    }

    #bræt {
        grid-template-columns: repeat(5, 45px);
        grid-template-rows: repeat(6, 45px);
        grid-gap: 10px; 
        padding: 5px;
    }

    .square {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
        border-width: 2px;
    }
}

@media (max-height: 650px) {

    .tastaturrække button {
        height: 30px; 
        font-size: 0.75rem;
    }

    .titel {
        font-size: 1.3rem;
        margin-top: 10px; 
    }
    
    header {
        margin-top: 70px; 
    }

    #bræt {
        grid-template-columns: repeat(5, 45px);
        grid-template-rows: repeat(6, 45px);
        grid-gap: 0px; 
        padding: 5px;
    }

    .square {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
        border-width: 2px;
    }
}

#login-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none; justify-content: center; align-items: center; z-index: 2000;
}
#login-modal-overlay.vis { display: flex; }

#login-modal {
    background-color: #121213; border: 1px solid #3a3a3c;
    padding: 30px; text-align: center; border-radius: 8px; width: 350px;
}

.input-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

#login-modal input {
    background: #3a3a3c; border: 1px solid #565758; color: white;
    padding: 12px; font-size: 1rem; border-radius: 4px; outline: none;
}
#login-modal input:focus { border-color: #538d4e; }

.primary-btn {
    background-color: #538d4e; color: white; border: none; padding: 12px;
    width: 100%; font-weight: bold; cursor: pointer; border-radius: 4px; text-transform: uppercase;
}
.secondary-btn {
    background-color: transparent; color: #818384; border: none; padding: 10px;
    width: 100%; margin-top: 5px; cursor: pointer; text-decoration: underline;
}

/* Leaderboard Styling */
#leaderboard-container {
    margin-top: 20px; text-align: left; background: #1a1a1b; 
    padding: 15px; border-radius: 8px; max-height: 300px; overflow-y: auto;
}

#leaderboard-list {
    color: #c8c8c8;             /* Skift farve her */
    font-size: 0.9rem;
}

#leaderboard-container h3 { color: #ffeb99; margin-bottom: 10px; text-align: center; text-transform: uppercase; font-size: 0.9rem; }

.lb-row {
    display: flex; justify-content: space-between; padding: 5px 0;
    border-bottom: 1px solid #3a3a3c; font-size: 0.9rem; color: #fff;
}
.lb-row.me { color: #538d4e; font-weight: bold; } /* Highlight brugeren */
.lb-rank { width: 30px; color: #818384; }
.lb-name { flex-grow: 1; }
.lb-score { width: 50px; text-align: right; }

.link-btn {
    background: none; border: none; color: #818384; width: 100%;
    padding: 10px; cursor: pointer; font-size: 0.8rem;
}

/* Styling til de nye kontrol-knapper */
#game-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 5px;
}

.kontrol-knap {
    background-color: #3a3a3c;
    color: #ffffff;
    border: 1px solid #565758;
    padding: 8px 15px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    transition: background-color 0.2s;
}

.kontrol-knap:hover {
    background-color: #565758;
}


@media (max-height: 570px) {

    .tastaturrække button {
        height: 20px; 
        font-size: 0.65rem;
    }

    .titel {
        font-size: 1rem;
        margin-top: 10px; 
    }
    
    header {
        margin-top: 70px; 
    }

    #bræt {
        grid-template-columns: repeat(5, 45px);
        grid-template-rows: repeat(6, 45px);
        grid-gap: 0px; 
        padding: 5px;
    }

    .square {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
        border-width: 2px;
    }
}