:root {
    --bg-color: #f0f0f0;
    --primary-red: #e60000;
    --primary-purple: #7b297b;
    --secondary-blue: #0055a7;
    --accent-yellow: #ffcc00;
    --text-color: #222;
    /* Colores de partidos */
    --psoe-color: #e60000;
    --pp-color: #0055a7;
    --vox-color: #63be21;
    --podemos-color: #7b297b;
    --neutral-color: #888888;
}

body {
    font-family: "Press Start 2P", cursive;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport para móvil */
    overflow: auto; /* Permitir scroll */
    user-select: none;
}

#news-ticker {
    background: black;
    color: lime;
    padding: 5px;
    white-space: nowrap;
    overflow: hidden;
    border-bottom: 2px solid var(--primary-red);
}

#news-content {
    display: inline-block;
    padding-left: 100%;
    animation: scroll 120s linear infinite;
}

@keyframes scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

main {
    display: flex;
    flex: 1;
}

/* Sección Izquierda: El Mapa y Botón */
#click-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10px;
    background: radial-gradient(circle, #fff 0%, #ddd 100%);
    border-right: 4px solid var(--primary-purple);
    position: relative;
    overflow-y: auto;
}

/* MAPA ESPAÑA */
#map-container {
    width: 80%;
    max-width: 280px;
    margin-bottom: 5px;
}
#map-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(3px 3px 0 rgba(0,0,0,0.2));
}
.region {
    fill: var(--neutral-color);
    stroke: white;
    stroke-width: 0.5;
    transition: fill 0.5s ease;
    cursor: help;
}
.region:hover { opacity: 0.8; }
/* Para grupos SVG (islas), los paths hijos heredan el fill */
.region path {
    fill: inherit;
    stroke: inherit;
    stroke-width: inherit;
}

/* Panel de Ranking */
#ranking-panel {
    width: 90%;
    max-width: 300px;
    background: white;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

#ranking-panel h4 {
    margin: 0 0 8px 0;
    text-align: center;
    font-size: 0.7rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 5px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 0.6rem;
}

.ranking-item.player {
    border: 2px solid var(--psoe-color);
    background: rgba(230, 0, 0, 0.1);
}

.ranking-position {
    font-weight: bold;
    width: 20px;
    text-align: center;
}

.ranking-emoji {
    font-size: 1.2rem;
    margin: 0 5px;
}

.ranking-name {
    flex: 1;
    font-weight: bold;
}

.ranking-votos {
    text-align: right;
    font-size: 0.55rem;
}

.ranking-regiones {
    width: 40px;
    text-align: center;
    font-size: 0.5rem;
    color: #666;
}

/* Barra de progreso hacia 50M */
#progress-bar-container {
    width: 90%;
    max-width: 300px;
    background: #ddd;
    border-radius: 10px;
    height: 20px;
    margin-bottom: 10px;
    overflow: hidden;
    position: relative;
    border: 2px solid #333;
}

#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--psoe-color), #ff6666);
    width: 0%;
    transition: width 0.3s ease;
}

#progress-text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 0.5rem;
    font-weight: bold;
    line-height: 20px;
    color: #333;
    text-shadow: 0 0 3px white;
}

#votos-display {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 5px;
    text-shadow: 2px 2px var(--accent-yellow);
    line-height: 1;
}

#vps-display {
    font-size: 0.7rem;
    color: #666;
    margin-bottom: 10px;
}

#main-button {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 8px solid var(--primary-red);
    background: white;
    font-size: 3.5rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 0 var(--primary-red);
}

#main-button:active {
    transform: translateY(8px);
    box-shadow: 0 0 0 var(--primary-red);
}

/* Sección Derecha: Tienda */
#shop-zone {
    flex: 1;
    background: white;
    padding: 15px;
    overflow-y: auto;
    border-left: 4px solid var(--primary-red);
}

.shop-category {
    margin-bottom: 20px;
}

.shop-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin-bottom: 8px;
    border: 2px solid #ccc;
    cursor: pointer;
    background: #fafafa;
    transition: background 0.2s;
    font-size: 0.7rem;
}

.shop-item:hover { background: #eee; }
.shop-item.disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }

.item-icon { font-size: 2rem; margin-right: 10px; }
.item-info { flex: 1; }
.item-name { font-weight: bold; font-size: 0.8rem; }
.item-cost { color: var(--primary-red); font-weight: bold; font-size: 0.7rem; }
.item-count { font-size: 1.3rem; font-weight: bold; color: var(--primary-purple); margin-left: 10px; }

/* Prestige Button */
#prestige-btn {
    background: var(--primary-purple);
    color: white;
    border: none;
    padding: 8px;
    width: 100%;
    font-size: 0.7rem;
    cursor: pointer;
    margin-top: 15px;
    border-radius: 5px;
}

/* Animación de números al click */
.click-text {
    position: absolute;
    color: var(--primary-red);
    font-weight: bold;
    pointer-events: none;
    animation: float-up 1s forwards;
    z-index: 100;
}

@keyframes float-up {
    to { transform: translateY(-100px); opacity: 0; }
}

/* Tooltip simple */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.55rem;
    pointer-events: none;
    display: none;
    z-index: 200;
    max-width: 200px;
}

/* Overlays de Victoria/Derrota */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#victory-overlay {
    background: rgba(230, 0, 0, 0.95);
    color: white;
}

#defeat-overlay {
    background: rgba(0, 0, 0, 0.95);
    color: white;
}

.overlay-title {
    font-size: 1.8rem;
    margin-bottom: 20px;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.3);
}

.overlay-stats {
    font-size: 0.8rem;
    margin-bottom: 30px;
    text-align: center;
    line-height: 1.8;
}

.overlay-btn {
    padding: 15px 40px;
    font-size: 1rem;
    cursor: pointer;
    border: 4px solid white;
    background: transparent;
    color: white;
    font-family: inherit;
    transition: all 0.2s;
}

.overlay-btn:hover {
    background: white;
    color: #333;
}

/* Responsive */
@media (max-width: 800px) {
    main {
        flex-direction: column;
        flex: 1 1 auto;
        height: auto;
        min-height: auto;
    }
    #click-zone {
        border-right: none;
        border-bottom: 4px solid var(--primary-purple);
        height: auto;
        min-height: auto;
        max-height: none;
        overflow: visible;
        padding-bottom: 20px;
    }
    #shop-zone {
        border-left: none;
        border-top: 4px solid var(--primary-red);
        overflow-y: visible;
        height: auto;
    }
    #map-container { width: 50%; }
    #main-button { width: 120px; height: 120px; font-size: 3rem; }
    #news-ticker {
        position: relative;
        flex-shrink: 0;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    #map-container {
        width: 60%;
        max-width: 180px;
    }
    #main-button {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
        border-width: 6px;
        box-shadow: 0 6px 0 var(--primary-red);
        min-width: 44px;
        min-height: 44px;
    }
    #main-button:active {
        transform: translateY(6px);
        box-shadow: 0 0 0 var(--primary-red);
    }
    #ranking-panel {
        width: 95%;
        max-width: none;
        padding: 8px;
    }
    #ranking-panel h4 {
        font-size: 0.6rem;
    }
    .ranking-item {
        padding: 4px;
        font-size: 0.5rem;
    }
    .ranking-emoji {
        font-size: 1rem;
    }
    #progress-bar-container {
        width: 95%;
        max-width: none;
    }
    #votos-display {
        font-size: 1rem;
    }
    #vps-display {
        font-size: 0.6rem;
    }
    #shop-zone {
        padding: 10px;
        max-height: 50vh;
        overflow-y: auto;
    }
    #shop-zone h3 {
        font-size: 0.7rem;
        margin: 8px 0;
    }
    .shop-item {
        padding: 10px 8px;
        font-size: 0.6rem;
        min-height: 44px;
    }
    .item-icon {
        font-size: 1.5rem;
        margin-right: 8px;
    }
    .item-name {
        font-size: 0.6rem;
    }
    .item-cost {
        font-size: 0.55rem;
    }
    .item-count {
        font-size: 1.1rem;
    }
    .overlay-title {
        font-size: 1.2rem;
    }
    .overlay-stats {
        font-size: 0.65rem;
        padding: 0 15px;
    }
    .overlay-btn {
        padding: 12px 30px;
        font-size: 0.8rem;
        min-width: 44px;
        min-height: 44px;
    }
    /* Tooltips táctiles */
    .tooltip {
        display: none !important;
    }
}

/* Modal de Eventos Aleatorios */
#event-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 900;
    padding: 20px;
    box-sizing: border-box;
}

#event-modal.active {
    display: flex;
}

.event-content {
    background: white;
    border-radius: 12px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.event-title {
    font-size: 0.9rem;
    margin-bottom: 20px;
    color: #333;
    line-height: 1.4;
}

.event-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.event-option {
    padding: 15px 20px;
    border: 2px solid var(--primary-red);
    background: white;
    cursor: pointer;
    font-size: 0.7rem;
    font-family: inherit;
    border-radius: 8px;
    transition: all 0.2s;
    min-height: 44px;
}

.event-option:hover {
    background: var(--primary-red);
    color: white;
}

.event-option:active {
    transform: scale(0.98);
}

.event-effect {
    font-size: 0.55rem;
    color: #666;
    margin-top: 5px;
}

/* Panel de Logros */
#achievements-panel {
    position: fixed;
    top: 50px;
    right: 10px;
    background: white;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 10px;
    max-width: 250px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 500;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}

#achievements-panel.visible {
    display: block;
}

#achievements-toggle {
    position: fixed;
    top: 50px;
    right: 10px;
    background: var(--accent-yellow);
    border: 2px solid #333;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 501;
    display: flex;
    align-items: center;
    justify-content: center;
}

#new-game-toggle {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: var(--primary-red);
    border: 2px solid #333;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 501;
    display: flex;
    align-items: center;
    justify-content: center;
}

#new-game-toggle:hover {
    background: #cc0000;
}

.achievement-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 5px;
    background: #f5f5f5;
    font-size: 0.6rem;
}

.achievement-item.unlocked {
    background: #d4edda;
    border: 1px solid #28a745;
}

.achievement-item.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-icon {
    font-size: 1.5rem;
    margin-right: 10px;
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-weight: bold;
}

.achievement-desc {
    font-size: 0.5rem;
    color: #666;
}

/* Notificación de logro */
.achievement-notification {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #333;
    padding: 15px 25px;
    border-radius: 10px;
    font-weight: bold;
    z-index: 1000;
    animation: achievementPop 3s forwards;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

@keyframes achievementPop {
    0% { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    10% { transform: translateX(-50%) translateY(0); opacity: 1; }
    80% { transform: translateX(-50%) translateY(0); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-20px); opacity: 0; }
}

/* Indicador de guardado */
#save-indicator {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: #0f0;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

#save-indicator.visible {
    opacity: 1;
}

/* Botón Ko-fi de donaciones */
.kofi-btn {
    position: fixed;
    bottom: 10px;
    left: 60px;
    background: linear-gradient(135deg, #ff5f5f, #c41e3a);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.55rem;
    z-index: 501;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.kofi-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(196, 30, 58, 0.4);
}

/* Responsive: ocultar en móviles muy pequeños */
@media (max-width: 480px) {
    .kofi-btn {
        left: 60px;
        padding: 6px 10px;
        font-size: 0.45rem;
    }
}
