@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    background-color: #0b0c10;
    color: #66fcf1;
    font-family: 'Orbitron', sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    touch-action: none; /* Prevent double-tap zoom on mobile */
}

/* Espacios para Monetización (Ads) */
.ad-container {
    width: 100%;
    background-color: #1f2833;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.ad-top {
    height: 60px;
}

.ad-bottom {
    height: 60px;
    position: fixed;
    bottom: 0;
}

.ad-placeholder {
    color: #c5c6c7;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#game-container {
    position: relative;
    flex-grow: 1;
    width: 100%;
    padding-bottom: 60px;
    /* Separación para ad-bottom sticky */
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 50px rgba(102, 252, 241, 0.05);
    /* Efecto Neón Suave */
}

/* Marcador semi-transparente en fondo */
#score-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 5;
    opacity: 0.2;
}

#current-score {
    font-size: 200px;
    font-weight: 900;
    line-height: 1;
    color: #45a29e;
}

#high-score {
    font-size: 30px;
    color: #66fcf1;
}

/* Capa UI */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#players-info {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(11, 12, 16, 0.7);
    border: 1px solid #45a29e;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    text-shadow: 0 0 5px #45a29e;
    line-height: 1.5;
}

/* Overlay de la Cola/Espectador */
#queue-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(31, 40, 51, 0.95);
    border: 2px solid #66fcf1;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    pointer-events: auto;
    /* IMPORTANTE: Para recivir clics de botón por encima del canvas */
    box-shadow: 0 0 20px rgba(102, 252, 241, 0.5);
    width: 90%;
    max-width: 400px;
}

.hidden {
    display: none !important;
}

#queue-overlay h2 {
    font-size: 22px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

#queue-overlay p {
    font-size: 15px;
    margin-bottom: 20px;
    color: #c5c6c7;
}

#queue-position {
    color: #ff0055;
    font-size: 20px;
}

#reward-ad-btn {
    background-color: transparent;
    color: #66fcf1;
    border: 2px solid #66fcf1;
    padding: 12px 20px;
    font-size: 14px;
    font-family: inherit;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.3s;
    text-transform: uppercase;
}

#reward-ad-btn:hover {
    background-color: #66fcf1;
    color: #0b0c10;
    box-shadow: 0 0 15px #66fcf1;
}


@media (max-width: 1024px) {
    #current-score {
        font-size: 20vw;
    }
    #high-score {
        font-size: 4vw;
    }
}

@media (max-width: 600px) {
    #players-info {
        font-size: 11px;
        padding: 6px 10px;
        top: 10px;
        right: 10px;
    }

    #current-score {
        font-size: 25vw;
    }

    #high-score {
        font-size: 5vw;
    }

    #chat-container {
        width: calc(100% - 80px); /* Deja espacio para el botón del chat */
        max-width: 300px;
        height: 200px;
        left: 10px;
        bottom: 70px; /* Ajusta por si la ad-bottom molesta */
    }

    #mobile-chat-btn {
        display: flex;
        bottom: 70px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

/* Estilos del Chat */
#chat-container {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 300px;
    height: 250px;
    background: rgba(11, 12, 16, 0.85);
    border: 1px solid #45a29e;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 20;
    transition: all 0.3s ease;
}

/* Estado minimizado: transparente pero los mensajes se ven */
#chat-container.minimized {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    color: #ffffff;
}

#chat-container.minimized #chat-messages {
    overflow: hidden;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #45a29e;
    border-radius: 10px;
}

.chat-msg {
    word-wrap: break-word;
    background: rgba(11, 12, 16, 0.4);
    padding: 4px 8px;
    border-radius: 4px;
    animation: fadeIn 0.3s ease;
    width: fit-content;
    max-width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg .sender {
    font-weight: bold;
    margin-right: 5px;
}

#chat-input {
    background: rgba(31, 40, 51, 0.9);
    border: none;
    border-top: 1px solid #45a29e;
    padding: 12px;
    color: #66fcf1;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    border-radius: 0 0 8px 8px;
    pointer-events: auto;
}

#chat-container.minimized #chat-input {
    display: none;
}

/* Botón flotante para móviles */
#mobile-chat-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(11, 12, 16, 0.8);
    border: 1px solid #66fcf1;
    border-radius: 50%;
    color: #66fcf1;
    font-size: 20px;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    pointer-events: auto;
    z-index: 21;
    box-shadow: 0 0 10px rgba(102, 252, 241, 0.3);
}

/* Botón compartir */
#share-url-btn {
    display: block;
    margin-top: 10px;
    background: transparent;
    border: 1px solid #66fcf1;
    color: #66fcf1;
    border-radius: 4px;
    padding: 5px 10px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
    pointer-events: auto;
}

#share-url-btn:hover {
    background: #66fcf1;
    color: #0b0c10;
}

/* Pantalla de Lobby */
#lobby-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #1f2833 0%, #0b0c10 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    pointer-events: auto;
    transition: opacity 0.5s ease;
}

.lobby-content {
    background: rgba(11, 12, 16, 0.9);
    border: 2px solid #66fcf1;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 0 30px rgba(102, 252, 241, 0.3);
    max-width: 450px;
    width: 90%;
    animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.lobby-content h1 {
    font-size: 42px;
    font-weight: 900;
    margin-bottom: 10px;
    color: #66fcf1;
    text-shadow: 0 0 10px #66fcf1;
    letter-spacing: 4px;
}

.lobby-content p {
    color: #c5c6c7;
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 25px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    color: #45a29e;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#player-name {
    width: 100%;
    background: rgba(31, 40, 51, 0.5);
    border: 1px solid #45a29e;
    padding: 15px;
    color: #66fcf1;
    font-family: inherit;
    font-size: 18px;
    border-radius: 8px;
    outline: none;
    transition: 0.3s;
}

#player-name:focus {
    border-color: #66fcf1;
    box-shadow: 0 0 10px rgba(102, 252, 241, 0.2);
}

#color-picker {
    display: flex;
    gap: 15px;
    justify-content: space-between;
}

.color-opt {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
    border: 3px solid transparent;
}

.color-opt.active {
    border-color: #ffffff;
    transform: scale(1.2);
    box-shadow: 0 0 15px currentColor;
}

.color-opt:hover {
    transform: scale(1.1);
}

#join-btn {
    width: 100%;
    background-color: transparent;
    color: #66fcf1;
    border: 2px solid #66fcf1;
    padding: 15px;
    font-size: 20px;
    font-family: inherit;
    font-weight: 900;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 10px;
}

#join-btn:hover {
    background-color: #66fcf1;
    color: #0b0c10;
    box-shadow: 0 0 20px #66fcf1;
}

.lobby-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(197, 198, 199, 0.1);
}

.lobby-footer p {
    font-size: 12px;
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .lobby-content {
        padding: 30px 20px;
    }

    .lobby-content h1 {
        font-size: 28px;
    }

    #color-picker {
        gap: 10px;
    }

    .color-opt {
        width: 30px;
        height: 30px;
    }
}

/* Pantalla Anti-AdBlocker */
#adblock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 12, 16, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Por encima de todo, incluido Lobby */
    pointer-events: auto;
}

.adblock-content {
    background: #1f2833;
    border: 3px solid #ff0055;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 0 40px rgba(255, 0, 85, 0.4);
    max-width: 500px;
    width: 90%;
}

.adblock-content h2 {
    color: #ff0055;
    font-size: 32px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.adblock-content p {
    color: #c5c6c7;
    margin-bottom: 15px;
    font-size: 16px;
    line-height: 1.5;
}

.adblock-content button {
    margin-top: 20px;
    background-color: transparent;
    color: #66fcf1;
    border: 2px solid #66fcf1;
    padding: 12px 25px;
    font-size: 16px;
    font-family: inherit;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.3s;
    text-transform: uppercase;
}

.adblock-content button:hover {
    background-color: #66fcf1;
    color: #0b0c10;
    box-shadow: 0 0 15px #66fcf1;
}