body {
    background-color: #111;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
}

#main-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
}

#game-container {
    position: relative;
    border: 2px solid #333;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

canvas {
    display: block;
    background-color: black;
}

#sidebar {
    width: 200px;
    background-color: #222;
    padding: 20px;
    border: 2px solid #333;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 90vh;
    overflow-y: auto;
}

#sidebar h2 {
    margin-top: 0;
    color: yellow;
    text-align: center;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.info-item {
    font-size: 18px;
    font-weight: bold;
}

.info-item span {
    color: #0ff;
    float: right;
}

/* Statistics Section */
#statistics-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #444;
}

#statistics-section h3 {
    color: #ff0;
    font-size: 18px;
    margin: 0 0 10px 0;
    text-align: center;
}

.stat-category {
    margin-bottom: 12px;
}

.stat-category h4 {
    color: #0ff;
    font-size: 14px;
    color: #aaa;
    text-align: center;
}

.stat-item {
    font-size: 12px;
    padding: 3px 0;
    color: #aaa;
    display: flex;
    align-items: center;
}

.stat-item span {
    color: #fff;
    margin-left: auto;
    font-weight: bold;
}

canvas.stat-icon {
    background-color: transparent;
    margin-right: 8px;
}

.controls-info {
    margin-top: 20px;
    border-top: 1px solid #444;
    padding-top: 10px;
    font-size: 14px;
    color: #aaa;
    text-align: center;
}

.controls-info h3 {
    color: #fff;
    margin-bottom: 5px;
}

.controls-row {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

#pause-btn {
    background-color: #444;
    color: white;
    border: 1px solid #666;
    padding: 5px 15px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 3px;
}

#pause-btn:hover {
    background-color: #666;
}

#ghost-info-section {
    border-top: 1px solid #444;
    padding-top: 10px;
}

#ghost-info-section h3 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 16px;
}

.interactive-stat-item,
.interactive-heading {
    cursor: pointer;
    border-radius: 3px;
    padding: 3px 5px;
    margin: 0 -5px;
}

.interactive-heading {
    margin-bottom: 5px;
}

.interactive-stat-item:hover,
.interactive-heading:hover {
    background-color: #333;
}

.interactive-stat-item.selected,
.interactive-heading.selected {
    background-color: #444;
    border: 1px solid yellow;
}

#ghost-details {
    background-color: #111;
    padding: 10px;
    border-radius: 3px;
    min-height: 80px;
}

#ghost-name {
    margin: 0 0 5px 0;
    color: #0ff;
    font-size: 16px;
}

#ghost-trivia {
    margin: 0;
    font-size: 12px;
    color: #ccc;
    line-height: 1.4;
}

/* Authentication Section */
#auth-section {
    border-top: 1px solid #444;
    padding-top: 10px;
}

#auth-section h3 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 16px;
}

#auth-section .info-item {
    font-size: 14px;
    margin-bottom: 10px;
}

.small-btn {
    background-color: #444;
    color: white;
    border: 1px solid #666;
    padding: 5px 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 3px;
    font-size: 12px;
    width: 100%;
    margin-bottom: 5px;
}

.small-btn:hover {
    background-color: #666;
}

/* High Scores Section */
#highscores-section {
    border-top: 1px solid #444;
    padding-top: 10px;
}

#highscores-section h3 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 16px;
}

#highscores-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.highscores-list {
    list-style-type: decimal;
    padding-left: 20px;
    margin: 0;
    font-size: 12px;
}

.highscores-list li {
    margin-bottom: 5px;
    color: #ccc;
}

.player-name {
    color: #0ff;
    font-weight: bold;
}

.score-value {
    color: yellow;
    font-weight: bold;
}

.score-date {
    color: #888;
    font-size: 10px;
}

.loading,
.error {
    text-align: center;
    color: #aaa;
    font-size: 12px;
    font-style: italic;
}

.error {
    color: #f55;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: #222;
    margin: 10% auto;
    padding: 20px;
    border: 2px solid #666;
    border-radius: 5px;
    width: 90%;
    max-width: 400px;
    color: white;
}

.modal-content h2 {
    margin-top: 0;
    color: yellow;
    text-align: center;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: white;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-form input {
    padding: 10px;
    background-color: #333;
    border: 1px solid #666;
    color: white;
    font-family: inherit;
    border-radius: 3px;
}

#auth-form input:focus {
    outline: none;
    border-color: #0ff;
}

#auth-form button {
    padding: 10px;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 3px;
    margin-top: 10px;
}

.interactive-heading.selected {
    background-color: #444;
    border: 1px solid yellow;
}

#ghost-details {
    background-color: #111;
    padding: 10px;
    border-radius: 3px;
    min-height: 80px;
}

#ghost-name {
    margin: 0 0 5px 0;
    color: #0ff;
    font-size: 16px;
}

#ghost-trivia {
    margin: 0;
    font-size: 12px;
    color: #ccc;
    line-height: 1.4;
}

/* Authentication Section */
#auth-section {
    border-top: 1px solid #444;
    padding-top: 10px;
}

#auth-section h3 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 16px;
}

#auth-section .info-item {
    font-size: 14px;
    margin-bottom: 10px;
}

.small-btn {
    background-color: #444;
    color: white;
    border: 1px solid #666;
    padding: 5px 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 3px;
    font-size: 12px;
    width: 100%;
    margin-bottom: 5px;
}

.small-btn:hover {
    background-color: #666;
}

/* High Scores Section */
#highscores-section {
    border-top: 1px solid #444;
    padding-top: 10px;
}

#highscores-section h3 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 16px;
}

#highscores-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.highscores-list {
    list-style-type: decimal;
    padding-left: 20px;
    margin: 0;
    font-size: 12px;
}

.highscores-list li {
    margin-bottom: 5px;
    color: #ccc;
}

.player-name {
    color: #0ff;
    font-weight: bold;
}

.score-value {
    color: yellow;
    font-weight: bold;
}

.score-date {
    color: #888;
    font-size: 10px;
}

.loading,
.error {
    text-align: center;
    color: #aaa;
    font-size: 12px;
    font-style: italic;
}

.error {
    color: #f55;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: #222;
    margin: 10% auto;
    padding: 20px;
    border: 2px solid #666;
    border-radius: 5px;
    width: 90%;
    max-width: 400px;
    color: white;
}

.modal-content h2 {
    margin-top: 0;
    color: yellow;
    text-align: center;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: white;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-form input {
    padding: 10px;
    background-color: #333;
    border: 1px solid #666;
    color: white;
    font-family: inherit;
    border-radius: 3px;
}

#auth-form input:focus {
    outline: none;
    border-color: #0ff;
}

#auth-form button {
    padding: 10px;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 3px;
    margin-top: 10px;
}

#auth-form button:hover {
    background-color: #666;
}

.error-message {
    color: #f55;
    font-size: 12px;
    text-align: center;
    min-height: 18px;
}

/* Start Menu Overlay */
#start-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#start-menu-content {
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.game-title {
    font-size: 48px;
    color: yellow;
    margin: 0 0 30px 0;
    text-shadow: 3px 3px 0 #ff6600, 6px 6px 10px rgba(255, 102, 0, 0.5);
    letter-spacing: 4px;
}

#menu-auth-section {
    margin-bottom: 30px;
}

#menu-user-info p {
    color: #0ff;
    font-size: 16px;
    margin: 10px 0;
}

#menu-auth-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#menu-highscores-section {
    margin-bottom: 30px;
    background-color: rgba(34, 34, 34, 0.6);
    padding: 20px;
    border-radius: 5px;
    border: 2px solid #444;
}

#menu-highscores-section h2 {
    color: #fff;
    font-size: 20px;
    margin: 0 0 15px 0;
}

#menu-highscores-list {
    max-height: 200px;
    overflow-y: auto;
}

.menu-highscores-list {
    list-style-type: decimal;
    padding-left: 25px;
    margin: 0;
    font-size: 14px;
    text-align: left;
}

.menu-highscores-list li {
    margin-bottom: 8px;
    color: #ccc;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.menu-player-name {
    color: #0ff;
    font-weight: bold;
}

.menu-score-value {
    color: yellow;
    font-weight: bold;
}

#menu-play-section {
    margin-bottom: 20px;
}

.menu-btn {
    background-color: #444;
    color: white;
    border: 2px solid #666;
    padding: 10px 20px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 5px;
    font-size: 14px;
    min-width: 120px;
    transition: all 0.2s;
}

.menu-btn:hover {
    background-color: #666;
    border-color: #888;
    transform: scale(1.05);
}

.menu-btn-primary {
    background-color: #ff6600;
    border-color: #ff8800;
    color: white;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: #222;
    margin: 10% auto;
    padding: 20px;
    border: 2px solid #666;
    border-radius: 5px;
    width: 90%;
    max-width: 400px;
    color: white;
}

.modal-content h2 {
    margin-top: 0;
    color: yellow;
    text-align: center;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: white;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-form input {
    padding: 10px;
    background-color: #333;
    border: 1px solid #666;
    color: white;
    font-family: inherit;
    border-radius: 3px;
}

#auth-form input:focus {
    outline: none;
    border-color: #0ff;
}

#auth-form button {
    padding: 10px;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 3px;
    margin-top: 10px;
}

#auth-form button:hover {
    background-color: #666;
}

.error-message {
    color: #f55;
    font-size: 12px;
    text-align: center;
    min-height: 18px;
}

/* Start Menu Overlay */
#start-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#start-menu-content {
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.game-title {
    font-size: 48px;
    color: yellow;
    margin: 0 0 30px 0;
    text-shadow: 3px 3px 0 #ff6600, 6px 6px 10px rgba(255, 102, 0, 0.5);
    letter-spacing: 4px;
}

#menu-auth-section {
    margin-bottom: 30px;
}

#menu-user-info p {
    color: #0ff;
    font-size: 16px;
    margin: 10px 0;
}

#menu-auth-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#menu-highscores-section {
    margin-bottom: 30px;
    background-color: rgba(34, 34, 34, 0.6);
    padding: 20px;
    border-radius: 5px;
    border: 2px solid #444;
}

#menu-highscores-section h2 {
    color: #fff;
    font-size: 20px;
    margin: 0 0 15px 0;
}

#menu-highscores-list {
    max-height: 200px;
    overflow-y: auto;
}

.menu-highscores-list {
    list-style-type: decimal;
    padding-left: 25px;
    margin: 0;
    font-size: 14px;
    text-align: left;
}

.menu-highscores-list li {
    margin-bottom: 8px;
    color: #ccc;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.menu-player-name {
    color: #0ff;
    font-weight: bold;
}

.menu-score-value {
    color: yellow;
    font-weight: bold;
}

#menu-play-section {
    margin-bottom: 20px;
}

.menu-btn {
    background-color: #444;
    color: white;
    border: 2px solid #666;
    padding: 10px 20px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    border-radius: 5px;
    font-size: 14px;
    min-width: 120px;
    transition: all 0.2s;
}

.menu-btn:hover {
    background-color: #666;
    border-color: #888;
    transform: scale(1.05);
}

.menu-btn-primary {
    background-color: #ff6600;
    border-color: #ff8800;
    color: white;
    font-size: 18px;
    padding: 15px 40px;
    min-width: 200px;
}

.menu-btn-primary:hover {
    background-color: #ff8800;
    border-color: #ffaa00;
}

.menu-hint {
    color: #aaa;
    font-size: 12px;
    margin: 20px 0 0 0;
}

/* Mobile Controls */
#mobile-controls {
    display: none;
    /* Hidden by default, shown on touch devices via JS or media query */
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    opacity: 0.7;
}

.dpad-row {
    display: flex;
    gap: 5px;
}

.dpad-btn {
    width: 60px;
    height: 60px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    color: white;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dpad-btn:active {
    background-color: rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
}

.dpad-center {
    width: 60px;
    height: 60px;
}

/* Responsive Styles */
@media (max-width: 768px) {
    body {
        height: auto;
        min-height: 100vh;
        padding: 10px;
        align-items: flex-start;
    }

    #main-layout {
        flex-direction: column;
        align-items: center;
        width: 100%;
        padding: 0;
        gap: 10px;
    }

    #game-container {
        width: 100%;
        max-width: 448px;
        /* Maintain aspect ratio */
        aspect-ratio: 448/496;
        height: auto;
    }

    canvas {
        width: 100%;
        height: 100%;
    }

    #sidebar {
        width: 100%;
        max-width: 448px;
        max-height: none;
        box-sizing: border-box;
    }

    /* Show mobile controls on small screens */
    #mobile-controls {
        display: flex;
    }

    /* Adjust start menu for mobile */
    .game-title {
        font-size: 32px;
    }

    .menu-btn {
        padding: 12px 20px;
        min-width: 100px;
    }
}

/* Landscape Mobile Optimization */
@media (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 0;
        height: 100vh;
        align-items: center;
    }

    #main-layout {
        flex-direction: row;
        height: 100%;
        width: 100%;
        justify-content: center;
        align-items: center;
        padding: 10px;
        gap: 20px;
    }

    #game-container {
        height: 95vh;
        width: auto;
        aspect-ratio: 448/496;
    }

    #sidebar {
        width: 250px;
        height: 95vh;
        overflow-y: auto;
    }

    /* Position D-pad differently in landscape */
    #mobile-controls {
        position: fixed;
        bottom: 20px;
        left: 20px;
        transform: none;
        opacity: 0.5;
    }

    /* Maybe add a second set of buttons for action if needed, but for now D-pad is enough */
}