:root {
    --royal-blue: #0052a5; /* A deeper, more instrument-like blue */
    --accent-red: #d9534f;
    --text-white: #f8f9fa;
    --light-gray: #adb5bd;
    --medium-gray: #495057;
    --dark-gray: #212529;
    --background-gray: #343a40;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--dark-gray);
    color: var(--text-white);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

#app-container {
    width: 95%;
    max-width: 550px;
    background-color: var(--background-gray);
    padding: 2rem;
    border-radius: 15px;
    border: 3px solid var(--light-gray);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0,0,0,0.5);
    text-align: center;
    transition: max-width 0.3s ease;
}

h1 {
    color: #ecf0f1;
    border-bottom: 2px solid #e74c3c; /* Red accent for the heading */
    padding-bottom: 10px;
    margin-bottom: 30px;
}

#setup-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

label {
    font-size: 1.1rem;
}

input[type="number"],
select {
    width: 80px;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #7f8c8d;
    background-color: #2c3e50;
    color: #ecf0f1;
    font-size: 1rem;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* --- LANDING SCREEN --- */
#game-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

/* --- BUTTON STYLES --- */
button {
    color: var(--text-white);
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 10px var(--royal-blue);
}

button:disabled {
    background-color: var(--medium-gray);
    color: var(--light-gray);
    cursor: not-allowed;
    border-color: var(--medium-gray);
}

.button-primary {
    background-color: var(--royal-blue);
    padding: 15px 25px;
    font-size: 1.5rem;
}

.button-secondary {
    background-color: var(--medium-gray);
    padding: 12px 20px;
    font-size: 1rem;
}

.button-utility {
    background-color: transparent;
    border: 1px solid var(--light-gray);
    padding: 8px 12px;
    font-size: 0.9rem;
}

#go-button {
    margin-top: 20px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.button-group button {
    flex-grow: 1;
}

.back-to-main-menu-button {
    position: absolute;
    top: 25px;
    left: 25px;
    z-index: 100;
}

#question-counter {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 1.2rem;
    color: #bdc3c7;
}

.screen {
    display: none; /* All screens are hidden by default */
}

#turn-to-heading-game {
    position: relative;
    padding-top: 70px; /* Add space for the back button */
}

/* Game Screen Styles */
#game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    width: 100%; /* Ensure it takes up space */
}

#heading-display-container {
    position: relative;
    width: 300px; /* Increased size */
    height: 300px;
    background-color: var(--dark-gray);
    border-radius: 50%;
    border: 10px solid var(--medium-gray);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.6);
}

#turn-prompt {
    font-size: 2rem;
    color: var(--accent-red);
    font-weight: bold;
    margin-top: 20px;
}

#heading-display {
    font-size: 7rem;
    font-weight: bold;
    color: var(--text-white);
}

#answer-input {
    width: 180px;
    height: 100px;
    font-size: 5rem;
    text-align: center;
    background-color: var(--dark-gray);
    border: 3px solid var(--light-gray);
    color: var(--text-white);
    border-radius: 10px;
}

#compass-rose {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* So it doesn't interfere with clicks */
}

.compass-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: 0 0;
    color: var(--text-white);
}

.compass-marker.cardinal {
    font-size: 1.8rem;
    font-weight: bold;
}

.compass-marker.degree {
    width: 2px;
    height: 10px;
    background-color: var(--light-gray);
}

.compass-marker.degree.major {
    height: 20px;
    width: 3px;
    background-color: var(--text-white);
}

.compass-marker.degree.major span {
    position: absolute;
    top: -25px;
    left: -10px;
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Hide the number input arrows */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

#question-counter, #timer-display {
    font-size: 1.2rem;
    color: #bdc3c7;
}

/* Results Screen Styles */
#results-screen {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    padding: 10px;
    background-color: #2c3e50;
    border-radius: 5px;
}

.result-label {
    font-weight: bold;
}

.result-value {
    color: #007bff; /* Blue for result values */
}

/* High Scores Screen Styles */
#high-scores-screen {
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#high-scores-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; /* Allow tabs to wrap on smaller screens */
    gap: 10px;
    margin-bottom: 20px;
}

.tab-button {
    padding: 10px 15px;
    background-color: #2c3e50;
    border: none;
    color: #ecf0f1;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s;
    flex-grow: 1; /* Allow buttons to grow and fill space */
    min-width: 120px; /* Ensure a minimum width */
}

.tab-button.active {
    background-color: #007bff;
}

#high-scores-list {
    margin-top: 20px;
    width: 100%;
}

#high-scores-list table {
    width: 100%;
    border-collapse: collapse;
}

#high-scores-list th, #high-scores-list td {
    padding: 8px;
    text-align: left;
}

/* Shake animation for practice mode */
@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.shake {
    animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
}

#back-to-menu-button {
    margin-top: 20px;
}

/* Live Scoreboard */
#live-scoreboard {
    background-color: #2c3e50;
    padding: 1rem;
    border-radius: 5px;
    width: 100%;
    margin-top: 20px;
}

.live-score-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #34495e;
}

/* Responsive Layout */
@media (max-width: 600px) {
    #app-container {
        padding: 1rem;
    }
    .form-group {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    .button-group {
        flex-direction: column;
    }
    #heading-display-container {
        width: 250px;
        height: 250px;
    }
    #heading-display {
        font-size: 5rem;
    }
    #answer-input {
        width: 150px;
        height: 80px;
        font-size: 4rem;
    }
}

@media (min-width: 900px) {
    #app-container, #turn-to-heading-game {
        display: flex;
        flex-direction: column;
        align-items: center;
        max-width: 1000px;
        gap: 20px;
    }
    .game-layout {
        display: flex;
        width: 100%;
        gap: 20px;
        align-items: flex-start;
    }
    #game-screen {
        flex: 2; /* Game takes more space */
    }
    #live-scoreboard {
        flex: 1; /* Scoreboard takes less space */
        margin-top: 0;
    }
}
