/* ============================================================
   VARIABLES DE TEMA — CLARO Y OSCURO
============================================================ */
:root {
    --bg-color:        #e8edf2;
    --text-color:      #1a1a2e;
    --text-muted:      #5a6a7a;
    --screen-bg:       #f5f7fa;
    --surface-bg:      #dde3ea;
    --surface-border:  rgba(0, 0, 0, 0.10);
    --surface-shadow:  rgba(0, 0, 0, 0.08);
    --input-bg:        #c8d0da;

    --board-bg:        #1a1a1a;
    --quadrant-bg:     #2e2e2e;
    --cell-bg:         #ffffff;
    --cell-hover:      #eeeeee;

    --active-rgb: 76, 175, 80;
}

body.dark-mode {
    --bg-color:        #0f0f13;
    --text-color:      #e8e8f0;
    --text-muted:      #8888aa;
    --screen-bg:       #1a1a24;
    --surface-bg:      #24242f;
    --surface-border:  rgba(255, 255, 255, 0.08);
    --surface-shadow:  rgba(0, 0, 0, 0.50);
    --input-bg:        #2e2e3e;
    --cell-bg:         #2c2c2c;
    --cell-hover:      #3d3d3d;
}


/* ============================================================
   BASE — body, app-container, screen, tipografía
============================================================ */
body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
    min-height: 100dvh;
    transition: background-color 0.3s, color 0.3s;
}

.app-container {
    text-align: center;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    min-height: calc(100vh - 20px);
}

.screen {
    background: var(--screen-bg);
    padding: clamp(10px, 3vw, 20px);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--surface-shadow);
    border: 1px solid var(--surface-border);
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
    box-sizing: border-box;
}

.hidden { display: none !important; }

h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-top: 0;
    color: var(--text-color);
}
h2, h3, h4 { color: var(--text-color); margin-top: 0; }
p, label    { color: var(--text-color); }


/* ============================================================
   APP-HEADER
============================================================ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.icon-btn {
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    color: var(--text-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 5px var(--surface-shadow);
    padding: 0;
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.icon-btn:hover { background: var(--input-bg); }

.currency-pill {
    background: var(--surface-bg);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    color: var(--text-color);
    box-shadow: 0 2px 5px var(--surface-shadow);
    border: 1px solid rgba(255, 215, 0, 0.5);
    transition: background 0.3s, color 0.3s;
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-bg);
    padding: 5px 15px 5px 5px;
    border-radius: 30px;
    box-shadow: 0 2px 5px var(--surface-shadow);
    border: 1px solid var(--surface-border);
    transition: background 0.3s, border-color 0.3s;
}

.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgb(var(--active-rgb));
}

.profile-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#user-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-color);
    transition: color 0.3s;
}

.logout-text {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 0.7rem;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-decoration: underline;
    width: auto;
}
.logout-text:hover { color: #ff4d4d; background: none; }


/* ============================================================
   MENÚ PRINCIPAL — botones
============================================================ */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

button {
    padding: clamp(10px, 2vw, 15px) 20px;
    font-size: clamp(1rem, 3vw, 1.1rem);
    cursor: pointer;
    background-color: var(--surface-bg);
    color: var(--text-color);
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    transition: transform 0.1s, background-color 0.2s, color 0.2s, border-color 0.2s;
    touch-action: manipulation;
    width: 100%;
    font-weight: 500;
}
button:hover  { background-color: var(--input-bg); }
button:active { transform: scale(0.98); }

body:not(.dark-mode) button {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-color: var(--surface-border);
}
body:not(.dark-mode) button:hover { background-color: var(--input-bg); }

body.dark-mode button {
    background-color: var(--surface-bg);
    color: var(--text-color);
    border-color: var(--surface-border);
}
body.dark-mode button:hover { background-color: var(--input-bg); }

.disabled-btn {
    background-color: var(--input-bg) !important;
    color: var(--text-muted) !important;
    border-color: var(--surface-border) !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.back-btn {
    background-color: #dc3545 !important;
    color: white !important;
    border: none !important;
    font-size: 0.9rem;
    padding: 8px 15px;
    width: auto;
}
.back-btn:hover { background-color: #c82333 !important; }

.store-btn { background-color: #9c27b0 !important; color: white !important; border: none !important; }
.store-btn:hover { background-color: #7b1fa2 !important; }

#ai-options {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--surface-border);
}
.ai-symbol-selection {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.nemesis-hint {
    display: block;
    font-size: 0.78rem;
    margin-top: -5px;
    margin-bottom: 5px;
    padding: 0 5px;
    line-height: 1.4;
}


/* ============================================================
   HEADER DE JUEGO
============================================================ */
.header-game {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    width: 100%;
}

#mode-title {
    margin: 0;
    font-size: clamp(1rem, 4vw, 1.2rem);
    text-align: right;
    color: var(--text-color);
}

#status {
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    margin-bottom: 15px;
    color: var(--text-color);
}

#reset-btn { margin-top: 15px; }


/* ============================================================
   STATS-PANEL — HUD con timers individuales
============================================================ */
.stats-panel {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    background-color: var(--board-bg);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    gap: 10px;
    color: white;
}

.stat-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 8px 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    opacity: 0.8;
    color: white;
}

.stat-value {
    font-size: clamp(0.8rem, 3vw, 1rem);
    margin: 2px 0;
    color: white;
}

.player-x .stat-label, .player-x .stat-value span { color: #2196F3; font-weight: bold; }
.player-o .stat-label, .player-o .stat-value span { color: #f44336; font-weight: bold; }

.timer-box {
    flex: 0.8;
    background-color: rgba(var(--active-rgb), 0.15);
    border-color: rgba(var(--active-rgb), 0.4);
}
.timer-box .stat-label { color: rgb(var(--active-rgb)); }

.timer-display {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: bold;
    font-family: monospace;
    color: white;
}

.player-timer {
    font-size: clamp(0.85rem, 3vw, 1rem) !important;
    margin-top: 4px;
    opacity: 0.85;
}

.player-x .player-timer { color: #2196F3; }
.player-o .player-timer { color: #f44336; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

.timer-urgent {
    animation: pulse 0.5s infinite !important;
    color: #ff4444 !important;
    opacity: 1;
}

@media (max-width: 400px) {
    .stats-panel { gap: 5px; padding: 5px; }
    .stat-box    { padding: 5px 2px; }
}


/* ============================================================
   TABLERO GLOBAL
============================================================ */
#board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-grow: 1;
    margin: 10px 0;
}

.global-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(2px, 1.5vw, 8px);
    background-color: var(--board-bg);
    padding: clamp(3px, 1.5vw, 8px);
    border-radius: 8px;
    width: 100%;
    max-width: min(100%, 65dvh);
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    transition: background-color 0.3s;
}

.quadrant {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    aspect-ratio: 1 / 1;
    gap: clamp(1px, 0.5vw, 2px);
    background-color: rgba(var(--active-rgb), 0.05);
    padding: clamp(1px, 0.8vw, 3px);
    position: relative;
    border: clamp(1px, 0.5vw, 3px) solid rgba(var(--active-rgb), 0.1);
    border-radius: 4px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.quadrant.active {
    border-color: rgba(var(--active-rgb), 0.8);
    background-color: rgba(var(--active-rgb), 0.25);
    transform: scale(1.02);
    z-index: 5;
    box-shadow: 0 0 12px rgba(var(--active-rgb), 0.3);
}

.cell {
    background-color: var(--cell-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(0.8rem, 4vmin, 2.5rem);
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    border-radius: 2px;
    aspect-ratio: 1 / 1;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-color 0.2s;
}
.cell:hover { background-color: var(--cell-hover); }


/* ============================================================
   ANIMACIÓN POP-IN
============================================================ */
@keyframes pop-in {
    0%   { transform: scale(0);   opacity: 0; }
    80%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}

.victory-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 4px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(2.5rem, 12vmin, 8rem);
    font-weight: bold;
    background-size: 80%;
    background-position: center;
    background-repeat: no-repeat;
    animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}


/* ============================================================
   TIENDA Y SKINS
============================================================ */
.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.store-item {
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-bg);
    transition: background 0.3s, border-color 0.3s;
    text-align: center;
    color: var(--text-color);
}

.store-item .preview {
    width: clamp(40px, 10vw, 60px);
    height: clamp(40px, 10vw, 60px);
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    background: #222;
    border-radius: 5px;
}

.item-action-btn  { width: 100%; font-size: 0.9rem; padding: 10px; margin-top: auto; }
.btn-buy          { background-color: #4CAF50 !important; color: white !important; border: none !important; }
.btn-equip        { background-color: #2196F3 !important; color: white !important; border: none !important; }
.btn-equipped     { background-color: #4caf50 !important; border: 2px solid #333 !important; color: white !important; }


/* ============================================================
   RANKING
============================================================ */
.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    width: 100%;
}

.ranking-tab {
    background-color: var(--surface-bg);
    border: 1px solid var(--surface-border);
    padding: 10px 15px;
    color: var(--text-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    width: auto;
    transition: background-color 0.2s, transform 0.1s, color 0.2s;
}

.ranking-tab.active {
    background-color: #ff9800;
    color: #fff;
    font-weight: bold;
    transform: scale(1.05);
    border-color: #ff9800;
}

.ranking-container {
    background: var(--surface-bg);
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--surface-border);
    transition: background 0.3s, border-color 0.3s;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-color);
    font-size: clamp(0.85rem, 3vw, 1rem);
}

.ranking-table th,
.ranking-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid var(--surface-border);
}

.ranking-table th {
    text-transform: uppercase;
    font-size: 0.8em;
    opacity: 0.7;
    color: var(--text-muted);
}

.ranking-table tr:hover { background-color: rgba(255, 152, 0, 0.1); }

.ranking-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    vertical-align: middle;
    border: 2px solid rgba(var(--active-rgb), 0.5);
    object-fit: cover;
}

.ranking-table th:nth-child(3),
.ranking-table td:nth-child(3) { text-align: left; }


/* ============================================================
   PERFIL IA — HEATMAP
============================================================ */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
    gap: 5px;
    background-color: var(--board-bg);
    padding: 10px;
    border-radius: 8px;
    border: 2px solid rgba(var(--active-rgb), 0.5);
}

.heatmap-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    border-radius: 4px;
    font-size: 1.2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    transition: transform 0.2s;
}
.heatmap-cell:hover { transform: scale(1.05); }


/* ============================================================
   MULTIJUGADOR — selección de modo online
============================================================ */
#multiplayer-screen .menu-buttons button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: white !important;
    border: none !important;
}

.mode-desc {
    font-size: 0.75rem;
    font-weight: normal;
    opacity: 0.85;
}

.matchmaking-status {
    text-align: center;
    margin-top: 25px;
    padding: 20px;
    background: var(--surface-bg);
    border-radius: 10px;
    border: 1px solid var(--surface-border);
}

.matchmaking-status p {
    font-size: 1.1rem;
    margin: 0 0 10px 0;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}
.dots { animation: blink 1.2s infinite; }


/* ============================================================
   TUTORIAL
============================================================ */
.tutorial-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
    overflow-y: auto;
}

.tutorial-step {
    animation: pop-in 0.3s ease forwards;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 0;
}

.tutorial-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.tutorial-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
    text-align: left;
    display: inline-block;
}

.tutorial-list li {
    padding: 6px 0;
    color: var(--text-color);
    border-bottom: 1px solid var(--surface-border);
}

.tutorial-list li::before {
    content: '• ';
    color: rgb(var(--active-rgb));
    font-weight: bold;
}

.tutorial-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--surface-border);
    width: 100%;
}

.tut-nav-btn {
    padding: 10px 20px !important;
    width: auto !important;
    font-size: 0.95rem !important;
}

.tut-indicator {
    font-size: 0.9rem;
    color: var(--text-muted);
}


/* ============================================================
   REGLAS
============================================================ */
.rules-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    text-align: left;
}

.rules-content h3 {
    margin-top: 15px;
    margin-bottom: 5px;
    font-size: 1rem;
    color: rgb(var(--active-rgb));
}

.rules-content p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 5px 0;
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 5px;
}

.rules-table tr {
    border-bottom: 1px solid var(--surface-border);
}

.rules-table td {
    padding: 8px 6px;
    font-size: 0.88rem;
    color: var(--text-color);
}

.rules-table td:last-child {
    font-weight: bold;
    color: rgb(var(--active-rgb));
    text-align: right;
    white-space: nowrap;
}


/* 🚀 NUEVO: ============================================================
   GLASSMORPHISM — skin de fondo global (ADAPTATIVO DÍA/NOCHE)
============================================================ */
body.has-global-skin::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -1;
    transition: background 0.3s ease;
}

/* Modo Noche (Oscuro) */
body.dark-mode.has-global-skin::before { 
    background: rgba(0, 0, 0, 0.75); 
}
body.dark-mode.has-global-skin .screen {
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: #fff;
}
body.dark-mode.has-global-skin h1, 
body.dark-mode.has-global-skin h2, 
body.dark-mode.has-global-skin h3, 
body.dark-mode.has-global-skin h4, 
body.dark-mode.has-global-skin p, 
body.dark-mode.has-global-skin label {
    color: #fff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
body.dark-mode.has-global-skin .quadrant {
    background-color: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Modo Día (Claro) */
body:not(.dark-mode).has-global-skin::before { 
    background: rgba(255, 255, 255, 0.5); 
}
body:not(.dark-mode).has-global-skin .screen {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    color: #1a1a2e;
}
body:not(.dark-mode).has-global-skin h1, 
body:not(.dark-mode).has-global-skin h2, 
body:not(.dark-mode).has-global-skin h3, 
body:not(.dark-mode).has-global-skin h4, 
body:not(.dark-mode).has-global-skin p, 
body:not(.dark-mode).has-global-skin label {
    color: #1a1a2e !important;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.9);
}
body:not(.dark-mode).has-global-skin .quadrant {
    background-color: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Común para ambos temas con Tablero Activo */
body.has-global-skin .global-board {
    background-color: transparent;
    border: 2px solid rgba(var(--active-rgb), 0.5);
    box-shadow: 0 0 20px rgba(var(--active-rgb), 0.2);
}
body.has-global-skin .quadrant.active {
    background-color: rgba(var(--active-rgb), 0.35);
    border-color: rgba(var(--active-rgb), 0.9);
    box-shadow: 0 0 15px rgba(var(--active-rgb), 0.5);
}
body.has-global-skin .cell { background-color: rgba(128, 128, 128, 0.15); }
body.has-global-skin .cell:hover { background-color: rgba(128, 128, 128, 0.35); }
body.has-global-skin .stats-panel, body.has-global-skin .store-item {
    background: rgba(128, 128, 128, 0.2);
    backdrop-filter: blur(5px);
}


/* ============================================================
   COOKIE BANNER
============================================================ */
#cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--board-bg);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    border: 1px solid rgba(var(--active-rgb), 0.5);
    width: 90%;
    max-width: 400px;
}

#cookie-banner p { color: white; }

#cookie-banner .btn-group {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

#cookie-banner .btn-group button {
    width: auto;
    color: white !important;
    border: none !important;
}


/* ============================================================
   MEDIA QUERIES — pantallas muy pequeñas ≤400px
============================================================ */
@media (max-width: 400px) {
    .store-grid   { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .store-item   { padding: 10px 5px; }
    .header-game  { flex-direction: column; align-items: flex-start; gap: 10px; }
    #mode-title   { text-align: left; width: 100%; }
    .heatmap-grid {
        grid-template-columns: repeat(3, 20vw);
        grid-template-rows: repeat(3, 20vw);
    }
    .tutorial-navigation { gap: 5px; }
}

/* ============================================================
   UPDATE BANNER — notificación de nueva versión
============================================================ */
#update-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1565c0;
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.95rem;
    max-width: 90%;
    animation: pop-in 0.3s ease forwards;
}

#update-apply-btn {
    background: white !important;
    color: #1565c0 !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    font-weight: bold !important;
    width: auto !important;
    font-size: 0.85rem !important;
    cursor: pointer !important;
    white-space: nowrap;
}
#update-apply-btn:hover {
    background: #e3f2fd !important;
}

/* ============================================================
   LAYOUT TOGGLE — modo grid de iconos
============================================================ */
#layout-btn.grid-active {
    background: rgb(var(--active-rgb));
    color: white;
    border-color: rgb(var(--active-rgb));
}

.menu-buttons.grid-mode {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 20px;
}

.menu-buttons.grid-mode button {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 14px 6px !important;
    min-height: 80px;
    border-radius: 12px !important;
    font-size: 0.7rem !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-align: center !important;
    width: 100% !important;
    color: transparent !important;
    position: relative;
    overflow: hidden;
}

.menu-buttons.grid-mode button::before {
    content: attr(data-icon);
    font-size: 1.9rem;
    line-height: 1;
    display: block;
    color: white;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

.menu-buttons.grid-mode button::after {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    display: block;
    letter-spacing: 0.02em;
}

.menu-buttons.grid-mode button:not([data-color=""]):not([style*="background"]) {
    background-color: rgba(var(--active-rgb), 0.85) !important;
}

.menu-buttons.grid-mode button:hover {
    transform: translateY(-2px) scale(1.03) !important;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25) !important;
    filter: brightness(1.1);
}
.menu-buttons.grid-mode button:active {
    transform: scale(0.96) !important;
}

.menu-buttons.grid-mode small {
    display: none !important;
}

.menu-buttons.grid-mode button.back-btn {
    grid-column: 1 / -1;
    min-height: 48px !important;
    flex-direction: row !important;
    gap: 8px !important;
    color: transparent !important;
}
.menu-buttons.grid-mode button.back-btn::before { font-size: 1.2rem; }
.menu-buttons.grid-mode button.back-btn::after  { font-size: 0.85rem; }

.menu-buttons.grid-mode button .mode-desc {
    display: none !important;
}

body.has-global-skin .menu-buttons.grid-mode button {
    background: rgba(255,255,255,0.12) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.2) !important;
}
body.has-global-skin .menu-buttons.grid-mode button[data-color]:not([data-color=""]) {
    background: rgba(255,255,255,0.15) !important;
    border-color: rgba(255,255,255,0.3) !important;
}

@keyframes grid-pop {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}
.menu-buttons.grid-mode button {
    animation: grid-pop 0.2s ease forwards;
}
.menu-buttons.grid-mode button:nth-child(1) { animation-delay: 0.00s; }
.menu-buttons.grid-mode button:nth-child(2) { animation-delay: 0.03s; }
.menu-buttons.grid-mode button:nth-child(3) { animation-delay: 0.06s; }
.menu-buttons.grid-mode button:nth-child(4) { animation-delay: 0.09s; }
.menu-buttons.grid-mode button:nth-child(5) { animation-delay: 0.12s; }
.menu-buttons.grid-mode button:nth-child(6) { animation-delay: 0.15s; }
.menu-buttons.grid-mode button:nth-child(7) { animation-delay: 0.18s; }

@media (max-width: 360px) {
    .menu-buttons.grid-mode {
        grid-template-columns: repeat(2, 1fr);
    }
    .menu-buttons.grid-mode button.back-btn {
        grid-column: 1 / -1;
    }
}


/* ============================================================
   RANKING — temporada, ELO y rangos
============================================================ */
.season-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(var(--active-rgb), 0.15), rgba(var(--active-rgb), 0.05));
    border: 1px solid rgba(var(--active-rgb), 0.3);
    border-radius: 8px;
    padding: 10px 16px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-color);
}

.season-countdown {
    font-size: 0.8rem;
    opacity: 0.8;
    color: rgb(var(--active-rgb));
}

.rank-badge-small {
    font-size: 0.7rem;
    font-weight: bold;
    display: block;
    margin-top: 1px;
    letter-spacing: 0.02em;
}

.rank-badge-table {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 2px;
    opacity: 0.9;
}

.season-header-row td {
    border-bottom: none !important;
}

.ranking-table th:nth-child(3),
.ranking-table td:nth-child(3) {
    text-align: left;
    min-width: 100px;
}

/* ============================================================
   BANNER VS (JUEGO ONLINE)
============================================================ */
.vs-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-bg);
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid var(--surface-border);
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.vs-side {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.vs-side span { font-weight: 900; font-size: 1.1rem; }
.vs-side small { font-size: 0.8rem; opacity: 0.8; }

.blue-side { background: linear-gradient(90deg, rgba(33,150,243,0.3) 0%, transparent 100%); text-align: left; border-left: 4px solid #2196F3; }
.red-side { background: linear-gradient(270deg, rgba(244,67,54,0.3) 0%, transparent 100%); text-align: right; border-right: 4px solid #f44336; }

.vs-center {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0 15px;
    color: #ff9800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* ============================================================
   MODALES (PERFIL)
============================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
    animation: pop-in 0.2s ease-out forwards;
}

.modal-content {
    background: var(--screen-bg);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 20px;
    width: 90%; max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
}

.close-modal {
    position: absolute; top: 10px; right: 10px;
    background: none !important; border: none !important;
    color: var(--text-muted) !important; font-size: 1.2rem;
    width: auto; padding: 5px; cursor: pointer;
}

.modal-header { text-align: center; margin-bottom: 20px; }
.large-avatar { width: 64px; height: 64px; border-width: 3px; margin-bottom: 10px; }

.profile-tabs { display: flex; gap: 5px; margin-bottom: 15px; }
.profile-tab-btn { 
    background: var(--surface-bg) !important; color: var(--text-color) !important; 
    border-radius: 20px !important; padding: 8px !important; font-size: 0.85rem !important;
}
.profile-tab-btn.active { background: rgb(var(--active-rgb)) !important; color: white !important; font-weight: bold !important; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card {
    background: var(--surface-bg); padding: 15px 10px; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; border: 1px solid var(--surface-border);
}
.stat-card span { font-size: 0.8rem; opacity: 0.8; margin-bottom: 5px; text-transform: uppercase; }
.stat-card strong { font-size: 1.4rem; }

.add-friend-box { display: flex; gap: 5px; margin-bottom: 15px; }
.add-friend-box input { flex: 1; padding: 10px; border-radius: 6px; border: 1px solid var(--surface-border); background: var(--input-bg); color: var(--text-color); }
.add-friend-box button { width: auto; padding: 10px 15px; }

.friends-list { list-style: none; padding: 0; margin: 0; max-height: 200px; overflow-y: auto; }
.friend-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; background: var(--surface-bg); border-radius: 6px; margin-bottom: 5px;
}
.friend-info { display: flex; align-items: center; gap: 10px; color: var(--text-color); }
.friend-status { width: 10px; height: 10px; border-radius: 50%; background: #555; }
.friend-status.online { background: #4CAF50; box-shadow: 0 0 5px #4CAF50; }
.challenge-btn { background: #f44336 !important; padding: 5px 10px !important; font-size: 0.8rem !important; width: auto !important; }

.id-copy-box {
    display: inline-block;
    background: var(--input-bg);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-color);
    margin-top: 10px;
    cursor: pointer;
    border: 1px solid var(--surface-border);
    transition: all 0.2s;
}
.id-copy-box:hover {
    background: rgba(var(--active-rgb), 0.2);
    border-color: rgb(var(--active-rgb));
    transform: scale(1.05);
}

/* ============================================================
   CONTENEDORES DE ANUNCIOS (AdSense)
============================================================ */
.ad-container {
    width: 100%;
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0;
    overflow: hidden;
    border-radius: 8px;
}

#game-over-modal .ad-container {
    min-height: 250px; 
}

/* ============================================================
   FOOTER (Legal y Contacto)
============================================================ */
.app-footer {
    margin-top: auto;
    padding: 20px 0 10px 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 100%;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 8px;
}

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
    font-weight: 600;
}

.footer-links a:hover {
    color: rgb(var(--active-rgb));
    text-decoration: underline;
}