/* Grunnleggende oppsett */
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #f0f4f8;
    color: #333;
    padding: 1rem;
}

h1 {
    margin-bottom: 0.5rem;
}

/* --- NY: Brukernavn-modal --- */
#username-modal-overlay {
    position: fixed; /* Ligger over alt */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none; /* Skjult som standard */
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#username-modal {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    width: 90%;
    max-width: 400px;
}

#username-modal h2 {
    margin-bottom: 1rem;
}

#username-modal p {
    margin-bottom: 1.5rem;
}

#username-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-bottom: 1rem;
}

#username-save-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    background-color: #28a745; /* Grønn */
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#username-save-btn:hover {
    background-color: #218838;
}

#username-error {
    color: #dc3545; /* Rød */
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 0.9rem;
    min-height: 1em;
}
/* --- Slutt på NY --- */


/* NY: Velkomstmelding */
#welcome-message {
    font-size: 1.25rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}
/* ... (Resten av h2, #timer, .game-controls, etc. er som før) ... */

#timer {
    color: #007bff;
    min-width: 80px;
    display: inline-block;
    text-align: left;
}
.game-controls {
    display: flex;
    flex-wrap: wrap; 
    gap: 1rem 2rem; 
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}
.game-controls label {
    font-size: 1rem;
    font-weight: 500;
    margin-right: 0.5rem;
}
#level-select {
    padding: 0.5rem;
    font-size: 1rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: white;
}
#reset-button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    background-color: #007bff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
#reset-button:hover {
    background-color: #0056b3;
}
.memory-game {
    width: 90%;
    max-width: 640px;
    margin: auto;
    display: grid;
    gap: 1rem;
    perspective: 1000px; 
}
.memory-card {
    background-color: #f8f9fa;
    aspect-ratio: 1 / 1; 
    transform-style: preserve-3d;
    transition: transform 0.5s;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.memory-card.flip {
    transform: rotateY(180deg);
}
.front-face,
.back-face {
    width: 100%;
    height: 100%;
    padding: 10px;
    position: absolute;
    border-radius: 8px;
    backface-visibility: hidden; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
}
.front-face {
    background: #f8f9fa;
    color: #333;
    transform: rotateY(180deg); 
}
.back-face {
    background: #007bff;
    color: white;
    font-size: 4rem; 
}

/* --- OPPDATERT: Highscore-styling --- */
.highscore-container {
    margin-top: 2rem;
    padding: 1rem 1.5rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    width: 90%;
    max-width: 400px;
}

.highscore-container h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #333;
}

.highscore-container h4 {
    font-size: 1.1rem;
    color: #007bff;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* Selve listene */
.highscore-container ol {
    list-style-type: decimal; /* 1. 2. 3. */
    padding-left: 2rem;
    margin: 0;
}

.highscore-container ol li {
    font-size: 1rem;
    padding: 0.4rem 0;
    display: flex;
    justify-content: space-between;
    font-weight: 500;
}

/* Viser "Ingen tider" uten nummer */
.highscore-container ol li.no-score {
    list-style-type: none;
    font-style: italic;
    color: #888;
    justify-content: center;
    padding-left: 0;
    margin-left: -2rem;
}

/* --- Slutt på OPPDATERT --- */

@media (max-width: 600px) {
    .front-face {
        font-size: 2.5rem;
    }
    .back-face {
        font-size: 3rem;
    }
    .memory-game {
        gap: 0.5rem;
    }
}