:root {
    --bg-color: #050505;
    --phosphor-green: #33FF00;
    --phosphor-dim: #1a8000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--phosphor-green);
    font-family: 'VT323', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden; /* Permite scroll vertical en móviles, bloquea horizontal */
    overflow-y: auto;
    /* Efecto Glow Global */
    text-shadow: 0 0 5px var(--phosphor-green), 0 0 10px var(--phosphor-green);
}

/* CRT Overlay Effect */
.crt-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 100;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% { opacity: 0.95; }
    50% { opacity: 1; }
    100% { opacity: 0.95; }
}

/* Selector de Idioma */
.lang-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 200;
}

.lang-btn {
    background: var(--bg-color);
    border: 1px solid var(--phosphor-dim);
    color: var(--phosphor-dim);
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover, .lang-btn.active {
    border-color: var(--phosphor-green);
    color: var(--bg-color);
    background: var(--phosphor-green);
    text-shadow: none;
}

.main-container {
    display: flex;
    flex-direction: row;
    gap: 40px;
    padding: 20px;
    max-width: 1500px;
    width: 100%;
}

/* ZONA DE JUEGO */
.game-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

h1 { font-size: 2.5rem; letter-spacing: 3px; }
h2 { font-size: 1.8rem; color: #a3ff85; font-family: 'Courier New', monospace; font-weight: normal; margin-top: 5px; }
.score-display { font-size: 2rem; margin-top: 10px; }

.game-board {
    font-size: 1.5rem;
    line-height: 1.1;
    white-space: pre;
    border: 2px solid var(--phosphor-dim);
    padding: 10px;
    background-color: #000;
    box-shadow: inset 0 0 15px rgba(51, 255, 0, 0.2);
}

.mobile-controls {
    display: none;
    margin-top: 20px;
    gap: 10px;
}

.btn-ctrl {
    background: transparent;
    border: 2px solid var(--phosphor-green);
    color: var(--phosphor-green);
    font-family: 'VT323', monospace;
    font-size: 2rem;
    padding: 15px 25px;
    cursor: pointer;
    text-shadow: inherit;
    box-shadow: 0 0 5px var(--phosphor-green);
}

.btn-ctrl:active {
    background: var(--phosphor-green);
    color: var(--bg-color);
}

/* ZONA AFILIADOS */
.shop-section {
    width: 400px;
    border-left: 2px dashed var(--phosphor-dim);
    padding-left: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.shop-section h2, .leaderboard-section h2 {
    font-size: 1.2rem;
}

.blink {
    animation: blinker 1s linear infinite;
    font-size: 2rem;
    margin-bottom: 10px;
}

@keyframes blinker {
    50% { opacity: 0; }
}

.shop-section p {
    font-size: 1.3rem;
    margin-bottom: 30px;
    color: #a3ff85;
}

.affiliate-links {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.retro-btn {
    text-decoration: none;
    color: var(--bg-color);
    background-color: var(--phosphor-green);
    padding: 10px;
    font-size: 1.2rem;
    text-align: center;
    border: 2px solid var(--phosphor-green);
    transition: all 0.2s;
    text-shadow: none;
    font-weight: bold;
}

.retro-btn:hover {
    background-color: transparent;
    color: var(--phosphor-green);
    text-shadow: 0 0 5px var(--phosphor-green);
}

.footer-info {
    margin-top: 30px;
    font-size: 1.0rem;
    color: #a3ff85;
    font-family: 'Courier New', monospace;
}

/* RESPONSIVE (MOBILE) */
@media (max-width: 800px) {
    .main-container {
        flex-direction: column;
        gap: 20px;
    }
    .shop-section {
        border-left: none;
        border-top: 2px dashed var(--phosphor-dim);
        padding-left: 0;
        padding-top: 20px;
    }
    .mobile-controls {
        display: flex;
    }
    .game-board {
        font-size: 1.2rem;
    }
    h1 {
        font-size: 2rem;
        letter-spacing: 2px;
    }
}

/* RANKING GLOBAL Y MODAL ARCADE */

.leaderboard-section {
    background-color: transparent;
    border-right: 2px dashed var(--phosphor-dim);
    padding-right: 20px;
    width: 400px;
    display: flex;
    flex-direction: column;
}

.ranking-filters {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 5px;
}

.rank-btn {
    background-color: transparent;
    color: #a3ff85;
    border: 1px solid #a3ff85;
    padding: 5px 10px;
    font-family: 'VT323', monospace;
    font-size: 0.9rem;
    cursor: pointer;
    flex: 1 1 45%;
    transition: all 0.2s;
}

.rank-btn.active, .rank-btn:hover {
    background-color: #a3ff85;
    color: #000;
}

.leaderboard-list {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 500px;
}

#score-table {
    width: 100%;
    border-collapse: collapse;
}

#score-table th, #score-table td {
    padding: 12px 5px;
    text-align: left;
    border-bottom: 1px dashed var(--phosphor-dim);
    font-size: 1.4rem;
    font-weight: normal;
    text-shadow: 0 0 2px currentColor;
    letter-spacing: 1px;
}

#score-table th {
    color: #fff;
}

#score-table tr:nth-child(1) {
    color: #ffff00; /* Gold */
}
#score-table tr:nth-child(2) {
    color: #c0c0c0; /* Silver */
}
#score-table tr:nth-child(3) {
    color: #cd7f32; /* Bronze */
}

/* Modal Arcade */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.arcade-box {
    background-color: #000;
    border: 4px solid #a3ff85;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 30px #a3ff85;
    max-width: 90%;
}

.initials-input-container {
    position: relative;
    margin: 20px auto;
    width: 250px;
    height: 60px;
}

#initials-display {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    font-size: 3rem;
    letter-spacing: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

#initials-input {
    width: 100%;
    height: 100%;
    opacity: 0;
    position: absolute;
    top: 0; left: 0;
    font-size: 3rem;
    cursor: text;
}

.submit-btn {
    background-color: #a3ff85;
    color: #000;
    border: none;
    padding: 10px 20px;
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    cursor: pointer;
    margin-top: 20px;
}

.submit-btn:disabled {
    background-color: #555;
    color: #888;
    cursor: not-allowed;
}

/* Global Flex Orders */
.game-section {
    order: 1;
}

.shop-section {
    order: 2;
}

.leaderboard-section {
    order: 3;
    border-right: none;
    border-left: 2px dashed var(--phosphor-dim);
    padding-right: 0;
    padding-left: 20px;
}

@media (max-width: 1100px) {
    .main-container {
        flex-direction: column;
        align-items: center;
    }
    .leaderboard-section {
        width: 100%;
        max-width: 500px;
        margin-top: 20px;
        border-left: none;
        border-top: 2px dashed var(--phosphor-dim);
        padding-left: 0;
        padding-top: 20px;
    }
    .shop-section {
        border-left: none;
        border-top: 2px dashed var(--phosphor-dim);
        padding-left: 0;
        padding-top: 20px;
        width: 100%;
        max-width: 500px;
        margin-top: 20px;
    }
}

#gameCanvas {
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
}
