/* ============================================
   ELONMANIA - FULLSCREEN UI
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    touch-action: manipulation;
}

body,
html {
    width: 100%;
    height: 100%;
    margin: 0;
    background: #000;
    font-family: 'Press Start 2P', cursive;
    color: #fff;
    overflow: hidden;
}

.app-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 2px;
    z-index: 1000;
}

/* Overlays - Top */
.ui-overlay-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    z-index: 50;
    text-align: center;
    pointer-events: none;
}

.ui-overlay-top h1 {
    font-size: 1em;
    color: #ff6600;
    margin-bottom: 5px;
    text-shadow: 0 0 10px #ff6600;
}

.ca-section {
    font-size: 0.35em;
    color: #00ff00;
    margin-top: 5px;
    display: inline-block;
    letter-spacing: 0.5px;
    word-break: break-all;
    /* Ensure it wraps if still too long */
    max-width: 90%;
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px 0;
    font-size: 0.45em;
}

.badge {
    color: #ffff00;
}

.online-indicator {
    color: #00ff00;
}

.music-control {
    pointer-events: auto;
    display: flex;
    gap: 10px;
    align-items: center;
}

#musicToggle,
#sfxToggle {
    background: rgba(255, 102, 0, 0.2);
    border: 2px solid #ff6600;
    color: #fff;
    cursor: pointer;
    font-size: 1em;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#musicToggle:hover,
#sfxToggle:hover {
    background: rgba(255, 102, 0, 0.4);
}

#musicToggle.muted,
#sfxToggle.muted {
    border-color: #555;
    color: #888;
    background: rgba(85, 85, 85, 0.2);
}

/* Game World */
.game-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Marquee Leaderboard */
.marquee-container {
    width: 100%;
    background: rgba(255, 102, 0, 0.15);
    border-top: 1px solid #ff6600;
    border-bottom: 1px solid #ff6600;
    overflow: hidden;
    white-space: nowrap;
    padding: 5px 0;
    margin-top: 5px;
    pointer-events: none;
}

.marquee-content {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 20s linear infinite;
    font-size: 0.55em;
    color: #ffff00;
    text-shadow: 0 0 5px #ff6600;
}

@keyframes marquee {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(-100%, 0);
    }
}

/* Side Info Removed */


/* Overlays - Bottom */
.ui-overlay-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    border-top: 1px solid #333;
    padding-bottom: env(safe-area-inset-bottom);
    /* Fix for iPhone notched area */
}

.chat-area {
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.chat-log {
    display: none;
    /* Messages will appear over characters */
    height: 80px;
    overflow-y: auto;
    font-size: 0.5em;
    /* Slightly larger on mobile/desktop */
    color: #ccc;
    margin-bottom: 8px;
    line-height: 1.5;
    padding: 5px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

/* Ensure touch scrolling works */
.chat-log::-webkit-scrollbar {
    width: 4px;
}

.chat-log::-webkit-scrollbar-thumb {
    background: #444;
}

.chat-item .author {
    color: #ff6600;
    font-weight: bold;
}

.input-bar {
    display: flex;
    gap: 5px;
}

#messageInput {
    flex: 1;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #ff6600;
    color: #fff;
    font-family: 'Press Start 2P';
    font-size: 0.6em;
    padding: 12px;
    outline: none;
    border-radius: 4px;
}

#sendBtn {
    background: #ff6600;
    border: none;
    color: #fff;
    font-family: 'Press Start 2P';
    font-size: 0.5em;
    padding: 0 15px;
    cursor: pointer;
}

.connection-info {
    text-align: center;
    font-size: 0.35em;
    color: #444;
    padding: 5px 0;
    border-top: 1px solid #222;
}

#statusText {
    color: #ff6600;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal-box {
    text-align: center;
    border: 4px solid #ff6600;
    padding: 30px;
    background: #000;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 20px rgba(255, 102, 0, 0.5);
}

.modal-box h2 {
    font-size: 1.5em;
    color: #ff6600;
    margin-bottom: 15px;
    text-shadow: 0 0 10px #ff6600;
}

.modal-box p {
    font-size: 0.6em;
    color: #ccc;
    margin-bottom: 20px;
    line-height: 1.6;
}

#nicknameInput {
    width: 100%;
    padding: 12px;
    background: #111;
    border: 2px solid #333;
    color: #fff;
    font-family: 'Press Start 2P';
    font-size: 0.8em;
    text-align: center;
    outline: none;
    margin-bottom: 20px;
}

#nicknameInput:focus {
    border-color: #ff6600;
}

/* Character Selector */
.choose-elon {
    margin: 20px 0;
}

.choose-elon p {
    font-size: 0.6em;
    color: #ffcc00;
    margin-bottom: 15px;
}

.elon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-height: 250px;
    overflow-y: auto;
    padding: 15px;
    background: #0a0a0a;
    border: 2px solid #222;
}

.elon-item {
    width: 100%;
    aspect-ratio: 1;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    border: 2px solid #444;
    cursor: pointer;
    image-rendering: pixelated;
    padding: 2px;
}

.elon-item:hover {
    border-color: #888;
}

.elon-item.selected {
    border-color: #ff6600;
    background-color: rgba(255, 102, 0, 0.2);
}

#joinGameBtn {
    display: block;
    width: 100%;
    padding: 18px;
    font-family: 'Press Start 2P';
    background: #ff6600;
    border: none;
    color: #fff;
    cursor: pointer;
    margin-top: 20px;
    font-size: 1em;
    transition: transform 0.1s;
}

#joinGameBtn:active {
    transform: scale(0.98);
}

/* Pulse animation */
.pulse {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #0f0;
    border-radius: 50%;
    animation: blink 1s infinite;
    margin-right: 4px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@media (max-width: 480px) {
    .ui-overlay-top h1 {
        font-size: 0.9em;
    }

    .chat-log {
        height: 100px;
        /* More space for chat on mobile since keyboard might cover it */
        font-size: 0.55em;
    }

    .modal-box {
        padding: 20px;
        width: 95%;
    }

    .elon-grid {
        grid-template-columns: repeat(3, 1fr);
        max-height: 200px;
    }

    .ca-section {
        font-size: 0.25em;
        /* Very small for long CA on mobile */
    }
}