/* --- FUENTES --- */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700&family=Roboto+Mono:wght@400;700&display=swap');

:root {
    --bg-dark: #0a0b10;
    --panel-bg: rgba(20, 25, 35, 0.95);
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-green: #00ff9d;
    --neon-yellow: #ffea00;
    --text-main: #e0e6ed;
    --border-color: #2a3b55;
}

/* --- Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Fondo (CENTRADO DEL LOBBY AQUÍ) --- */
.casino-bg {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 🟢 CLAVE: Centra el contenido verticalmente si hay espacio */
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at center, #1a2a3a 0%, #000000 100%);
    position: relative;
}

.city-lights-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(rgba(0, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

/* --- LAYOUT PRINCIPAL (JUEGO + CHAT) --- */
#game-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
    max-width: 1600px;
    position: relative;
    z-index: 1;
    /* Cuando el juego está visible, lo empujamos un poco hacia arriba para que no quede tan centrado si es muy alto */
    margin-top: 0;
}

/* --- PANELES --- */
.cyber-panel,
.game-display {
    background-color: var(--panel-bg);
    border: 1px solid var(--neon-blue);
    box-shadow: 0 0 20px rgba(0, 188, 212, 0.2);
    border-radius: 12px;
    padding: 30px;
    position: relative;
}

/* Panel del Juego */
.game-display {
    flex: 3;
    display: grid;
    grid-template-areas:
        "info"
        "dealer"
        "players"
        "controls";
    gap: 20px;
    min-width: 0;
}

/* Panel del Chat */
.chat-panel {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    height: 800px;
    display: flex;
    flex-direction: column;
}

/* Esquinas decorativas */
.cyber-panel::before,
.game-display::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 20px;
    height: 20px;
    border-top: 2px solid var(--neon-blue);
    border-left: 2px solid var(--neon-blue);
}

.cyber-panel::after,
.game-display::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    border-bottom: 2px solid var(--neon-blue);
    border-right: 2px solid var(--neon-blue);
}

/* --- CHAT INTERNO --- */
.chat-history {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    overflow-y: auto;
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: #111;
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--neon-blue);
    border-radius: 3px;
}

.chat-msg {
    word-wrap: break-word;
}

.chat-msg strong {
    color: var(--neon-green);
}

.chat-input-area {
    display: flex;
    gap: 5px;
}

.chat-field {
    text-align: left;
    padding: 8px;
    font-size: 0.9rem;
}

/* --- TIPOGRAFÍA --- */
.neon-title,
.game-title {
    font-family: 'Orbitron', sans-serif;
    color: var(--neon-blue);
    text-align: center;
    font-size: 2rem;
    letter-spacing: 2px;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

.neon-value {
    color: var(--neon-yellow);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 234, 0, 0.4);
}

.system-message,
.status-message {
    color: var(--neon-pink);
    text-align: center;
    font-weight: bold;
    min-height: 1.5em;
    text-shadow: 0 0 5px rgba(255, 0, 255, 0.4);
}

.system-message.large-message {
    font-size: 1.5em;
    padding: 10px;
    margin-bottom: 10px;
}

/* --- INPUTS --- */
.cyber-input {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--neon-green);
    font-family: 'Roboto Mono', monospace;
    font-size: 1.1rem;
    text-align: center;
}

.cyber-input:focus {
    outline: none;
    border-color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 157, 0.2);
}

.input-group {
    margin-bottom: 20px;
    text-align: center;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #aaa;
    font-weight: bold;
}

/* --- BOTONES --- */
.cyber-btn {
    padding: 14px 28px;
    border: none;
    border-radius: 6px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s;
    color: #fff;
    font-weight: bold;
    text-transform: uppercase;
    margin: 5px;
}

.primary-btn {
    background-color: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 10px rgba(0, 188, 212, 0.4);
}

.primary-btn:hover:not(:disabled) {
    background-color: #fff;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.8);
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--neon-blue);
    color: var(--neon-blue);
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

/* Botones de Acción */
.action-btn {
    background-color: #000;
    color: var(--text-main);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 5px rgba(0, 243, 255, 0.3);
    min-width: 100px;
}

.action-btn:hover:not(:disabled) {
    background-color: #111;
    box-shadow: 0 0 15px var(--neon-blue);
    color: var(--neon-blue);
}

.bonus-btn {
    background-color: #000;
    color: var(--neon-yellow);
    border: 2px solid var(--neon-yellow);
}

.bonus-btn:hover:not(:disabled) {
    background-color: #111;
    box-shadow: 0 0 15px var(--neon-yellow);
}

.cyber-btn:disabled {
    background-color: #222;
    border-color: #444;
    color: #666;
    cursor: not-allowed;
    box-shadow: none;
}

.large-btn {
    width: 100%;
    max-width: 400px;
    font-size: 1.4em;
    padding: 18px;
    margin: 10px auto;
    display: block;
}

/* --- LOBBY (CENTRADO PERFECTO) --- */
#lobby-container {
    width: 90%;
    max-width: 500px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 2;
    /* 🟢 ESTO LO CENTRA: */
    margin: auto;
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.join-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.join-group input {
    flex: 1;
}

.separator {
    color: #555;
    font-weight: bold;
    margin: 5px 0;
}

/* --- MESA DE JUEGO --- */
.game-info-bar {
    grid-area: info;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.data-display {
    font-size: 1.4em;
    font-weight: bold;
}

.player-grid {
    grid-area: players;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 30px;
}

.player-terminal {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    position: relative;
    min-height: 250px;
}

.dealer-terminal {
    grid-area: dealer;
    border-color: var(--neon-red);
    margin-bottom: 30px;
    background: rgba(40, 0, 0, 0.3);
}

.human-terminal {
    border-color: var(--neon-green);
    box-shadow: inset 0 0 15px rgba(0, 255, 157, 0.05);
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.terminal-header h3,
.terminal-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    margin: 0;
    color: var(--text-main);
}

.score-badge {
    background: #333;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Orbitron', sans-serif;
    color: var(--neon-yellow);
    font-size: 1.2em;
}

.terminal-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 10px;
}

.money-val,
.bet-val {
    color: var(--neon-green);
    font-weight: bold;
}

/* --- CARTAS --- */
.card-rack {
    display: flex;
    justify-content: center;
    gap: 12px;
    min-height: 130px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.card {
    width: 90px;
    height: 130px;
    background-color: #2a2a4a;
    color: var(--text-light);
    border: 2px solid var(--neon-blue);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    font-family: 'Michroma', sans-serif;
    font-size: 1.6em;
    box-shadow: 0 0 10px rgba(0, 188, 212, 0.4);
    padding: 8px;
}

.card .main-value {
    font-size: 1.5em;
    color: var(--text-light);
    margin-top: 20px;
}

.card.red-suit {
    border-color: var(--neon-pink);
}

.card.red-suit .main-value {
    color: var(--neon-pink);
    text-shadow: 0 0 5px rgba(218, 44, 123, 0.4);
}

.card.hidden-card {
    background: repeating-linear-gradient(45deg, #3a0050, #3a0050 15px, #0f0020 15px, #0f0020 30px);
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
    justify-content: center;
    font-size: 2.5em;
}

/* --- CONTROLES DE JUEGO --- */
.central-panel {
    grid-area: controls;
    background-color: rgba(0, 0, 0, 0.8);
    border-color: var(--neon-blue);
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.control-dock {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.game-action {
    min-width: 140px;
    font-size: 1.1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.control-label {
    color: var(--neon-yellow);
    font-family: 'Orbitron', sans-serif;
    font-size: 1em;
}

.input-btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.input-btn-group .cyber-input {
    max-width: 120px;
}

/* --- BETTING CONTROLS --- */
.bet-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.bet-input {
    max-width: 120px;
    font-size: 1.2em;
    padding: 10px;
}

/* --- RESPONSIVE --- */
@media (max-width: 1000px) {
    #game-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .game-display {
        width: 100%;
    }

    .chat-panel {
        width: 100%;
        height: 350px;
        margin-top: 10px;
    }

    .player-grid {
        grid-template-columns: 1fr;
    }

    .card {
        width: 65px;
        height: 95px;
        font-size: 1.2em;
    }

    .cyber-btn {
        padding: 12px 20px;
        font-size: 1em;
    }
}