/* === VARIABLES GLOBALES === */
:root { 
    --ui-scale: 1.0; 
    --accent-color: #ffcc00;
    --danger-color: #ff4444;
    --bg-glass: rgba(15, 15, 20, 0.5);
    --blur-strength: 15px;
}
/* === FUENTE CHAU PHILOMENE ONE (títulos, tooltips, menús) === */
:root { --font-display: 'Chau Philomene One', sans-serif; }

/* Opcional: Forzar la carga de la fuente antes de que inicie el juego */
.font-loader {
    font-family: var(--font-display);
    position: absolute;
    visibility: hidden;
}

body { margin: 0; padding: 0; background: #000; overflow: hidden; font-family: var(--font-display); color: white; user-select: none; -webkit-user-select: none; }
canvas { display: block; }
.ui-layer { transform-origin: top left; }

#contenedor-menu-trigger { transform: scale(var(--ui-scale)); transform-origin: top right; position: absolute; top: 20px; right: 20px; z-index: 4700; display: flex; align-items: center; gap: 8px; }
.toolbar-help { border-color: rgba(100, 200, 255, 0.45); font-size: 20px; }
.toolbar-help:hover { border-color: rgba(100, 200, 255, 0.8); }
#btn-menu { width: 48px; height: 48px; background: rgba(0, 0, 0, 0.6); border-radius: 50%; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; cursor: pointer; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
#btn-menu span { width: 22px; height: 2px; background: white; border-radius: 2px; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
#btn-menu.activo { background: rgba(255, 255, 255, 0.1); border-color: var(--accent-color); }
#btn-menu.activo span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#btn-menu.activo span:nth-child(2) { opacity: 0; transform: translateX(10px); }
#btn-menu.activo span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

#menu-lateral {
    position: absolute;
    top: 0;
    right: calc(-280px * var(--ui-scale));
    width: 280px;
    height: calc(100vh / var(--ui-scale));
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-strength));
    border-left: 1px solid rgba(255,255,255,0.15);
    z-index: 4600;
    transform: scale(var(--ui-scale));
    transform-origin: top right;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

#menu-lateral.activo {
    right: 0;
}

/* En dispositivos móviles, el menú ocupa toda la pantalla con animación moderna */
.mobile-device #menu-lateral {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    left: 0;
    right: auto;
    top: 0;
    bottom: 0;
    border-left: none;
    border-right: none;
    transform-origin: unset;
    z-index: 4600;
    background: linear-gradient(165deg, rgba(10, 10, 18, 0.97) 0%, rgba(18, 18, 30, 0.96) 55%, rgba(26, 22, 10, 0.97) 100%);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(34px) scale(0.96);
    transition: opacity 0.38s ease, transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s linear 0.5s;
}

.mobile-device #menu-lateral::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 45% at 50% -10%, rgba(255, 204, 0, 0.12), transparent 60%);
    pointer-events: none;
}

.mobile-device #menu-lateral.activo {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition-delay: 0s;
}

/* Animación escalonada del contenido del menú al abrirse */
.mobile-device #menu-lateral.activo .menu-perfil-header,
.mobile-device #menu-lateral.activo .tabs-nav,
.mobile-device #menu-lateral.activo .menu-footer {
    animation: svMenuStagger 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.mobile-device #menu-lateral.activo .menu-perfil-header { animation-delay: 0.06s; }
.mobile-device #menu-lateral.activo .tabs-nav { animation-delay: 0.14s; }
.mobile-device #menu-lateral.activo .menu-footer { animation-delay: 0.22s; }

@keyframes svMenuStagger {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Ajustes de UI para dispositivos móviles */
.mobile-device #contenedor-menu-trigger {
    top: 10px;
    right: 10px;
}

.mobile-device #btn-menu {
    width: 56px;
    height: 56px;
}

.mobile-device #btn-menu span {
    width: 26px;
    height: 3px;
}

.mobile-device .menu-perfil-header {
    padding: 30px 15px 15px;
}

.mobile-device .avatar-container {
    width: 55px;
    height: 55px;
}

.mobile-device .menu-perfil-header h2 {
    font-size: 16px;
}

.mobile-device .user-badge {
    font-size: 10px;
}

.mobile-device .tab-btn {
    padding: 12px;
    font-size: 16px;
}

.mobile-device .ajuste-item {
    padding: 12px 10px;
    font-size: 14px;
}

/* Móvil: el escalado de UI se eliminó de ajustes (la UI móvil usa una escala fija) */
.mobile-device .ajuste-item--ui-scale {
    display: none;
}

/* Los estilos de chat móvil se definen más abajo en la sección "Chat móvil" */

.mobile-device #chat-input {
    font-size: 14px;
}

/* Ajustes de inventario para móvil */
.mobile-device .inv-slot {
    width: 40px;
    height: 40px;
}

.mobile-device .inv-slot--selected {
    border-width: 3px;
}

/* Ajustes de hotbar para móvil */
.mobile-device #hotbar-container {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale));
    transform-origin: bottom center;
}

/* Ajustes de prompts de interacción para móvil */
.mobile-device #interact-prompt {
    font-size: 14px;
    padding: 8px 12px;
}

/* Ajustes generales de UI para evitar solapamiento en móvil */
.mobile-device .ui-layer {
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
}

.mobile-device #menu-lateral {
    height: 100dvh;
    overflow-y: auto;
}

.mobile-device .tab-pane {
    padding: 10px;
    max-height: calc(100dvh - 200px);
    overflow-y: auto;
    position: static;
}

.mobile-device .ajuste-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
}

.mobile-device .ajuste-item select,
.mobile-device .ajuste-item input[type="range"] {
    max-width: 120px;
}

.mobile-device .switch {
    transform: scale(0.9);
}
.menu-perfil-header { padding: 40px 20px 20px; text-align: center; background: rgba(255,255,255,0.03); }
.avatar-container { width: 65px; height: 65px; margin: 0 auto 10px; border-radius: 50%; border: 2px solid var(--accent-color); overflow: hidden; box-shadow: 0 0 15px rgba(255, 204, 0, 0.2); }
.avatar-container canvas { width: 100%; height: 100%; object-fit: cover; }
.menu-perfil-header h2 { font-size: 18px; margin: 5px 0; letter-spacing: 0.5px; }
.user-badge { color: var(--accent-color); font-size: 11px; font-weight: bold; text-transform: uppercase; margin: 0; }
.user-level { color: #00ff64; font-size: 12px; font-weight: bold; margin: 5px 0 0; }
.tabs-nav { display: flex; background: rgba(0,0,0,0.2); border-bottom: 1px solid rgba(255,255,255,0.1); }
.tab-btn { flex: 1; padding: 15px; border: none; background: none; color: white; cursor: pointer; opacity: 0.4; transition: 0.2s; font-size: 18px; filter: grayscale(1); }
.tab-btn:hover { opacity: 0.8; background: rgba(255,255,255,0.05); }
.tab-btn.activo { opacity: 1; filter: grayscale(0); background: rgba(255,255,255,0.05); border-bottom: 2px solid var(--accent-color); }
.tabs-content { flex: 1; position: relative; overflow: hidden; }
.tab-pane { position: absolute; width: 100%; height: 100%; padding: 20px; box-sizing: border-box; display: none; overflow-y: auto; }
.tab-pane.activo { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* === CONTENIDO DE LAS PESTAÑAS === */
.pane-header { font-size: 11px; color: rgba(255,255,255,0.5); margin-bottom: 15px; display: flex; justify-content: space-between; }
/* === TOP-LEFT TOOLBAR: Mochila + Customize === */
#top-left-toolbar {
    position: fixed; top: 14px; left: 14px; z-index: 3500;
    display: flex; align-items: center; gap: 6px;
    transform: scale(var(--ui-scale)); transform-origin: top left;
}
.toolbar-btn {
    width: 44px; height: 44px; border-radius: 8px;
    background: rgba(12, 12, 18, 0.92); border: 2px solid rgba(255, 204, 0, 0.45);
    color: #ffcc00; font-size: 22px; cursor: pointer; transition: 0.15s;
    display: flex; align-items: center; justify-content: center; padding: 0;
    position: relative;
}
.toolbar-key {
    position: absolute; top: 2px; left: 4px; font-size: 9px; font-weight: bold;
    color: rgba(255,255,255,0.35); pointer-events: none; line-height: 1;
}
.toolbar-btn:hover { background: rgba(255, 204, 0, 0.2); border-color: var(--accent-color); }
.toolbar-mochila { border-color: rgba(255, 204, 0, 0.6); }
.toolbar-customize { border-color: rgba(100, 200, 255, 0.45); font-size: 20px; }
.toolbar-customize:hover { border-color: rgba(100, 200, 255, 0.8); }
/* === BUFFS: indicadores apilados bajo el botón de mochila === */
/* z-index por debajo de los paneles (mochila 3490, customize 3491) para no taparlos */
#buff-indicators {
    position: fixed; top: 70px; left: 14px; z-index: 3489;
    display: flex; flex-direction: column; gap: 4px;
    transform: scale(var(--ui-scale)); transform-origin: top left;
    pointer-events: none;
}
.buff-indicator {
    width: fit-content; min-width: 44px; height: 30px; padding: 0 9px;
    border-radius: 6px;
    background: rgba(12, 12, 18, 0.92); border: 2px solid rgba(255, 204, 0, 0.5);
    color: #ffcc00; font-size: 16px; line-height: 1;
    display: flex; align-items: center; justify-content: center; gap: 5px;
    box-sizing: border-box;
    pointer-events: auto;
}
.buff-indicator .buff-time {
    font-size: 11px; font-weight: bold; color: #ffcc00; line-height: 1;
}
.buff-indicator .buff-count {
    font-size: 13px; font-weight: bold; color: #4ade80; line-height: 1;
}
.inv-slot { aspect-ratio: 1; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; cursor: pointer; transition: 0.15s; display: flex; align-items: center; justify-content: center; position: relative; box-sizing: border-box; }
.inv-slot:hover { border-color: var(--accent-color); background: rgba(255,204,0,0.12); }
.inv-slot-key {
    position: absolute; top: 2px; left: 4px; font-size: 10.8px; font-weight: bold; color: rgba(255,255,255,0.35);
    pointer-events: none; line-height: 1;
}
#backpack-panel {
    position: fixed; top: 68px; left: 14px; z-index: 3490; display: none;
    padding: 10px; border-radius: 10px;
    background: rgba(10, 10, 16, 0.95); border: 1px solid rgba(255, 204, 0, 0.35);
    box-shadow: 0 8px 28px rgba(0,0,0,0.65);
    transform: scale(var(--ui-scale)); transform-origin: top left;
}
#backpack-panel.activo { display: block; }
#customize-panel {
    position: fixed; top: 68px; left: 14px; z-index: 3491; display: none;
    padding: 10px; border-radius: 10px; width: 250px;
    background: rgba(10, 10, 16, 0.95); border: 1px solid rgba(100, 200, 255, 0.35);
    box-shadow: 0 8px 28px rgba(0,0,0,0.65);
    transform: scale(var(--ui-scale)); transform-origin: top left;
    max-height: calc(100vh - 110px); min-height: 50vh; overflow-y: auto;
}
#customize-panel.activo { display: block; }
.customize-section { margin-bottom: 10px; }
.customize-section-title {
    font-size: 13.2px; color: rgba(255,255,255,0.55); margin: 0 0 6px;
}
.customize-select-container { display: flex; flex-direction: column; gap: 4px; }
.custom-select { position: relative; width: 100%; }
.custom-select-trigger {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 10px; border-radius: 6px; cursor: pointer; box-sizing: border-box;
    background: rgba(0,0,0,0.35); border: 2px solid rgba(255,255,255,0.12);
    color: #fff; font-size: 14.4px; font-family: var(--font-display); transition: 0.15s;
}
.custom-select-trigger:hover { border-color: var(--accent-color); background: rgba(255,204,0,0.12); }
.custom-select-value { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-arrow { color: rgba(255,255,255,0.5); font-size: 12px; }
.custom-select-menu {
    display: none; position: absolute; top: calc(100% + 4px); left: 0; width: 100%; z-index: 5000;
    background: rgba(12,12,18,0.97); border: 1px solid rgba(255,204,0,0.4);
    border-radius: 8px; padding: 4px; max-height: 190px; overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.7); box-sizing: border-box;
    scrollbar-width: thin; scrollbar-color: rgba(255,204,0,0.4) rgba(255,255,255,0.06);
}
.custom-select-menu.activo { display: flex; flex-direction: column; gap: 2px; }
.custom-select-menu::-webkit-scrollbar { width: 5px; }
.custom-select-menu::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
.custom-select-menu::-webkit-scrollbar-thumb { background: rgba(255,204,0,0.35); border-radius: 3px; }
.custom-select-menu::-webkit-scrollbar-thumb:hover { background: rgba(255,204,0,0.6); }
#customize-panel::-webkit-scrollbar { width: 5px; }
#customize-panel::-webkit-scrollbar-track { background: transparent; }
#customize-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }
#customize-panel { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }
#customize-close {
    width: 24px; height: 24px; padding: 0; box-sizing: border-box;
    border-radius: 6px; cursor: pointer; line-height: 1;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.65); font-size: 15.6px; font-weight: bold;
    display: flex; align-items: center; justify-content: center; transition: 0.15s;
}
#customize-close:hover { background: rgba(255,80,80,0.25); border-color: rgba(255,120,120,0.7); color: #fff; }
.banner-preview { width: 28px; height: 18px; border-radius: 3px; }
.backpack-header { display: flex; justify-content: space-between; font-size: 13.2px; color: rgba(255,255,255,0.55); margin-bottom: 8px; align-items: center; }
.backpack-page-indicator { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.backpack-page-indicator .page-btn { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: white; padding: 1px 6px; border-radius: 4px; font-size: 12px; cursor: pointer; transition: 0.15s; line-height: 1.4; }
.backpack-page-indicator .page-btn:hover { background: rgba(255,204,0,0.2); border-color: var(--accent-color); }
.backpack-page-indicator .page-btn:disabled { opacity: 0.25; cursor: default; background: none; border-color: transparent; }
.backpack-grid { display: grid; grid-template-columns: repeat(4, calc(40px * var(--ui-scale))); grid-template-rows: repeat(7, calc(40px * var(--ui-scale))); gap: 5px; margin-right: 46px; }
.backpack-grid .inv-slot { width: calc(40px * var(--ui-scale)); height: calc(40px * var(--ui-scale)); }
/* Escritorio: slots especiales (equipaje/aura/basura) en columna vertical a la derecha
   de la cuadrícula, justo bajo el encabezado (el panel fixed es su contenedor). */
.backpack-special {
    position: absolute;
    top: 40px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* === TOP-LEFT HUD: Coins + Minutes (next to toolbar buttons) === */
.top-left-hud {
    display: flex; flex-direction: row; gap: 4px;
    margin-left: 4px;
}
.hud-indicator {
    display: flex; align-items: center; gap: 5px;
    background: rgba(12, 12, 18, 0.88); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px; padding: 4px 10px;
    font-size: 12px; color: rgba(255,255,255,0.8);
}
.hud-icon { font-size: 14px; }
.hud-value { font-weight: bold; font-size: 13px; }
.hud-coins .hud-value { color: #ffcc00; }
.hud-minutes .hud-value { color: #55aaff; }
button.hud-indicator {
    border: 1px solid rgba(255,255,255,0.12);
    font-family: inherit;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
button.hud-minutes:hover {
    border-color: rgba(85,170,255,0.7);
    background: rgba(20, 24, 32, 0.95);
    transform: translateY(-1px);
}
button.hud-minutes.nav-focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* === PANTALLA DE CARGA === */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-box {
    width: 360px;
    max-width: 90vw;
    height: auto;
    padding: 26px 24px;
    background: rgba(15, 15, 20, 0.95);
    border: 2px solid rgba(255, 204, 0, 0.5);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.loading-fede-img {
    width: 106px;
    height: 132px;
    image-rendering: pixelated;
    border-radius: 8px;
}

.loading-fede-label {
    color: #ffcc00;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.loading-fede-tip {
    color: rgba(255, 255, 255, 0.88);
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    font-style: italic;
    margin: 0;
    max-height: 76px;
    overflow-y: auto;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 204, 0, 0.3);
    border-top: 4px solid #ffcc00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
}


.dropdown-option {
    padding: 4px 8px;
    border: 1px solid rgba(255, 204, 0, 0.3);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-size: 13.2px;
    font-weight: 500;
    min-height: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.dropdown-option:hover {
    background: rgba(255, 204, 0, 0.15);
    border-color: rgba(255, 204, 0, 0.6);
}

.dropdown-option.selected {
    background: rgba(255, 204, 0, 0.4) !important;
    border-color: #ffcc00 !important;
    color: #ffcc00 !important;
    box-shadow: 0 0 8px rgba(255, 204, 0, 0.5);
}

.dropdown-option.bloqueado {
    opacity: 0.4;
    cursor: not-allowed;
}

.dropdown-option.bloqueado::after {
    content: '🔒';
    position: absolute;
    right: 8px;
    font-size: 12px;
}

.color-preview {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.banner-preview {
    width: 100%;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.special-slot {
    width: 40px;
    height: 40px;
    background: rgba(128, 128, 128, 0.15);
    border: 1px solid rgba(128, 128, 128, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.special-slot[data-special="titulo"] {
    background: rgba(100, 200, 255, 0.15);
    border: 2px solid rgba(100, 200, 255, 0.7);
    box-shadow: 0 0 8px rgba(100, 200, 255, 0.4);
}

.special-slot[data-special="titulo"] .special-icon {
    filter: none;
    opacity: 1;
}

.special-slot:hover {
    background: rgba(128, 128, 128, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.special-slot[data-special="titulo"]:hover {
    background: rgba(100, 200, 255, 0.25);
    border-color: #64c8ff;
    box-shadow: 0 0 12px rgba(100, 200, 255, 0.6);
}
.special-icon {
    font-size: 18px;
    opacity: 0.4;
    filter: grayscale(50%);
    pointer-events: none;
}
.special-slot[data-special="titulo"] .special-icon { filter: none; opacity: 1; }
.special-slot[data-special="basura"] .special-icon { filter: grayscale(30%); }
.special-slot[data-special="basura"]:hover {
    background: rgba(255, 100, 100, 0.2);
    border-color: rgba(255, 100, 100, 0.4);
}
.special-slot.aura-equipped {
    border: 2px solid #4488ff;
    box-shadow: 0 0 8px rgba(68, 136, 255, 0.5);
    background: rgba(68, 136, 255, 0.12);
}
.special-slot.aura-equipped:hover {
    border-color: #66aaff;
    box-shadow: 0 0 12px rgba(68, 136, 255, 0.7);
}
.inv-slot--drag-src { opacity: 0.35; }

/* === EFECTOS DE PANTALLA (pirotecnia) === */
#screen-fx {
    position: fixed; inset: 0; z-index: 12000; pointer-events: none; opacity: 0;
}
#screen-fx.screen-fx--flash-grande {
    opacity: 1;
    animation: screenFlashGrande 0.38s ease-out forwards;
    background: radial-gradient(ellipse at center, rgba(255, 250, 220, 0.65) 0%, rgba(255, 200, 80, 0.2) 40%, transparent 72%);
}
#screen-fx.screen-fx--boom-wrap {
    opacity: 1;
    position: fixed; inset: 0;
}
#screen-fx.screen-fx--boom-wrap .screen-fx-blur {
    position: absolute; inset: 0;
    animation: screenBlurBoom 0.7s ease-out forwards;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}
#screen-fx.screen-fx--boom-wrap .screen-fx-flash-boom {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.92) 0%, rgba(255, 230, 150, 0.5) 30%, transparent 68%);
    animation: screenFlashBlinkBoom 0.7s ease-out forwards;
}
body.screen-fx-zoom {
    animation: bodyZoomBoom 0.7s ease-out;
    transform-origin: center center;
}
@keyframes screenFlashGrande {
    0% { opacity: 0; }
    18% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes screenBlurBoom {
    0%, 100% { backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
    12%, 38%, 62% { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
}
@keyframes screenFlashBlinkBoom {
    0%, 100% { opacity: 0; }
    8% { opacity: 1; }
    18% { opacity: 0; }
    32% { opacity: 0.92; }
    42% { opacity: 0; }
    55% { opacity: 0.85; }
    65% { opacity: 0; }
}
@keyframes bodyZoomBoom {
    0% { transform: scale(1); }
    10% { transform: scale(1.055); }
    22% { transform: scale(0.985); }
    38% { transform: scale(1.04); }
    52% { transform: scale(0.99); }
    100% { transform: scale(1); }
}
.inv-slot--filled { background: rgba(255,204,0,0.06); }
.inv-slot--small { width: 100%; aspect-ratio: 1; background: rgba(255,255,255,0.08); border-radius: 6px; display: flex; align-items: center; justify-content: center; position: relative; min-height: 48px; }
.inv-slot--filled-inv { background: rgba(255,204,0,0.1); border: 1px solid rgba(255,204,0,0.2); }
.inv-icon { width: 70%; height: 70%; object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.inv-fallback { width: 16px; height: 16px; background: #d13030; border-radius: 3px; }
.inv-stack { position: absolute; right: 4px; bottom: 2px; font-size: 10px; font-weight: bold; color: #fff; background: rgba(0,0,0,0.75); padding: 1px 5px; border-radius: 6px; line-height: 1.2; pointer-events: none; }
.shortcut-list, .info-card { display: flex; flex-direction: column; gap: 12px; }
.shortcut-item { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
kbd { background: #333; padding: 2px 6px; border-radius: 4px; font-family: monospace; border-bottom: 2px solid #111; }
.ajuste-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 13px; }
.menu-footer { padding: 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.btn-moderno { display: block; width: 100%; padding: 12px; border-radius: 8px; background: rgba(255,255,255,0.1); color: white; text-align: center; text-decoration: none; font-size: 13px; border: none; cursor: pointer; transition: 0.2s; box-sizing: border-box; }
.btn-moderno:hover { background: rgba(255,255,255,0.15); transform: translateY(-1px); }
.btn-peligro { background: rgba(255, 68, 68, 0.15); color: #ff8888; border: 1px solid rgba(255, 68, 68, 0.2); }
.btn-peligro:hover { background: rgba(255, 68, 68, 0.3); }

/* GAMIFICACIÓN */
.metricas-container { background: rgba(0,0,0,0.3); border-radius: 8px; padding: 12px; margin-top: 15px; border: 1px solid rgba(255,204,0,0.2); }
.metricas-container h4 { margin: 0 0 10px 0; font-size: 11px; color: var(--accent-color); text-transform: uppercase; text-align: center; letter-spacing: 1px; }
.metrica { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px dashed rgba(255,255,255,0.05); }
.metrica:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.metrica b { color: #00ff00; }

/* === MODALES GLASS (juegos, desafíos, tic-tac-toe, ajedrez) === */
.glass-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 15, 20, 0.95);
    border: 2px solid var(--accent-color);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}
.glass-modal.activo { display: block !important; }
.glass-modal--z6000 { z-index: 6000; }
.glass-modal--z6500 { z-index: 6500; }
.glass-modal--z7000 { z-index: 7000; }

/* === MODAL DE AYUDA === */
#help-modal .card-content { max-height: calc(80vh - 100px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,204,0,0.4) rgba(255,255,255,0.06); }
#help-modal .card-content::-webkit-scrollbar { width: 5px; }
#help-modal .card-content::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
#help-modal .card-content::-webkit-scrollbar-thumb { background: rgba(255,204,0,0.35); border-radius: 3px; }
#help-modal-content { line-height: 1.6; }
#btn-help-entendido,
#btn-break-done,
#btn-estudio-stats-cerrar {
    width: 100%; margin-top: 20px; padding: 12px; box-sizing: border-box;
    background: var(--accent-color, #ffcc00); color: black; border: none; border-radius: 8px;
    font-family: inherit; font-size: 15px; text-transform: uppercase; letter-spacing: 1px;
    cursor: pointer; transition: all 0.2s;
}
#btn-help-entendido:hover,
#btn-break-done:hover,
#btn-estudio-stats-cerrar:hover { transform: scale(1.02); filter: brightness(1.1); }

/* === CHAT === */
#chat-container { position: absolute; bottom: 20px; left: 20px; width: 420px; height: 220px; background: rgba(0, 0, 0, 0.4); border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); transition: 0.3s; overflow: hidden; display: flex; flex-direction: column; transform: scale(var(--ui-scale)); transform-origin: bottom left; }
#chat-container.activo { background: rgba(0,0,0,0.85); border-color: var(--accent-color); height: 260px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
#chat-messages { flex: 1; overflow-y: auto; padding: 15px; font-size: 16.9px; scrollbar-width: none; display: flex; flex-direction: column; }
#chat-messages::-webkit-scrollbar { display: none; }
#chat-messages::before { content: ''; flex: 1; }
#chat-messages div { margin-bottom: 8px; line-height: 1.4; }
#chat-messages .chat-server-msg { color: #ff9999; font-style: italic; }
#chat-hint { height: 40px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: rgba(255,255,255,0.4); cursor: pointer; user-select: none; -webkit-user-select: none; }
#chat-container.activo #chat-hint { display: none; }
.chat-input-row { display: none; width: 100%; border-top: 1px solid var(--accent-color); box-sizing: border-box; }
#chat-container.activo .chat-input-row { display: flex; align-items: stretch; }
#chat-input { flex: 1; min-width: 0; background: rgba(255,255,255,0.05); border: none; padding: 12px 15px; color: white; outline: none; box-sizing: border-box; }
#chat-send-btn { flex: 0 0 auto; width: 42px; margin: 5px 6px 5px 0; border-radius: 8px; border: 1px solid var(--accent-color); background: rgba(255,204,0,0.15); color: var(--accent-color); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; line-height: 1; }
#chat-send-btn:active { transform: scale(0.92); background: rgba(255,204,0,0.3); }
/* === PANEL TAB === */
#panel-tab { position: absolute; top: 80px; left: 50%; width: 380px; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(10px); border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); opacity: 0; pointer-events: none; transition: 0.3s; transform: translateX(-50%) scale(var(--ui-scale)); transform-origin: top center; }
#panel-tab.activo { opacity: 1; pointer-events: auto; top: 100px; }
.tab-header { padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; }
.tab-header h3 { font-size: 12px; letter-spacing: 2px; color: var(--accent-color); margin: 0; }
.tab-stats { font-size: 12px; color: #00ff00; font-weight: bold; }
#lista-jugadores { max-height: 350px; overflow-y: auto; padding: 10px; }
.jugador-item { display: flex; justify-content: space-between; padding: 10px 15px; background: rgba(255,255,255,0.05); margin-bottom: 6px; border-radius: 6px; font-size: 13px; }
.jugador-item .tit { color: var(--accent-color); font-size: 11px; font-style: italic; opacity: 0.8; }

.switch { position: relative; width: 34px; height: 18px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #444; border-radius: 18px; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .4s; }
input:checked + .slider { background: var(--accent-color); }
input:checked + .slider:before { transform: translateX(16px); }
input[type=range] { -webkit-appearance: none; width: 100px; background: transparent; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: #444; border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { height: 14px; width: 14px; border-radius: 50%; background: var(--accent-color); cursor: pointer; -webkit-appearance: none; margin-top: -5px; }

/* === MENÚS CONTEXTUALES FLOTANTES === */
#item-cursor-hud {
    position: fixed; left: 0; top: 0; z-index: 10000; pointer-events: none;
    display: none; align-items: center; gap: 5px; transform: translate(12px, 8px);
}
#item-cursor-icon {
    width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.9)) drop-shadow(0 0 6px rgba(0,0,0,0.5));
}
.item-cursor-qty {
    font-size: 11px; font-weight: bold; color: #fff;
    background: rgba(0,0,0,0.75); padding: 2px 6px; border-radius: 6px; min-width: 14px; text-align: center;
    text-shadow: 0 1px 2px #000;
}
.item-cursor-bad { display: none; font-size: 16px; font-weight: bold; color: #ff4444; text-shadow: 0 0 6px #000, 0 0 10px rgba(255,0,0,0.6); line-height: 1; }
#item-cursor-hud.item-cursor--invalid .item-cursor-bad { display: block; }
#item-cursor-hud.item-cursor--invalid #item-cursor-icon { opacity: 0.45; filter: grayscale(0.4) drop-shadow(0 1px 3px rgba(0,0,0,0.9)); }
.inv-slot--equipped { outline: 2px solid var(--accent-color); outline-offset: -2px; background: rgba(255,204,0,0.15) !important; }
.inv-slot--selected { outline: 2px solid var(--accent-color); outline-offset: -2px; background: rgba(255,204,0,0.08) !important; }

#ranking-mensual-menu, #ranking-general-menu, #ranking-carreras-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6000;
    display: none;
    width: 600px;
    max-height: 400px;
}
#ranking-mensual-menu.activo, #ranking-general-menu.activo, #ranking-carreras-menu.activo {
    display: block;
}

/* === MODAL DE ESTADÍSTICAS DE ESTUDIO (estilo consistente con rankings) === */
#estudio-stats-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6000;
    display: none;
    width: 380px;
    max-width: 92vw;
    background: rgba(15, 15, 20, 0.95);
    border: 2px solid var(--accent-color);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
    overflow: hidden;
}
#estudio-stats-modal.activo {
    display: block;
}
#estudio-stats-modal h4 {
    margin: 0;
    padding: 15px;
    background: rgba(255, 204, 0, 0.1);
    color: var(--accent-color);
    font-size: 14px;
    text-align: center;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.estudio-stats-body {
    padding: 15px 18px;
    box-sizing: border-box;
}
.estudio-stats-divider {
    border-top: 1px dashed rgba(255,255,255,0.1);
    margin: 10px 0;
}
#estudio-stats-modal .metrica b {
    color: var(--accent-color, #ffcc00);
}

/* === MENÚ DE RECOMPENSAS DE CÁPSULA === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default;
}

.rewards-modal {
    background: rgba(15, 15, 20, 0.95);
    border: 2px solid rgba(255, 204, 0, 0.5);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.rewards-modal h2 {
    color: #ffcc00;
    margin-bottom: 20px;
    font-size: 24px;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.reward-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s;
}

.reward-item:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.1);
}

.reward-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    image-rendering: pixelated;
}

.reward-coin-emoji {
    font-size: 44px;
    line-height: 1;
}

.rewards-pomodoro-tipo {
    color: #aaa;
    font-size: 14px;
    margin: -10px 0 20px;
}

.reward-info {
    text-align: center;
}

.reward-name {
    font-size: 12px;
    color: #ffffff;
    margin-bottom: 4px;
    font-weight: 500;
}

.reward-rarity {
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.rewards-btn {
    background: linear-gradient(135deg, #ffcc00, #ff9900);
    border: none;
    border-radius: 8px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.rewards-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 204, 0, 0.4);
}


/* Desenfoque de fondo cuando el ranking está activo */
#ranking-mensual-menu.activo ~ #game-canvas,
#ranking-general-menu.activo ~ #game-canvas {
    filter: blur(5px);
}
.ranking-header {
    display: grid;
    grid-template-columns: 40px 1fr 100px 80px 50px 50px 50px;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 11px;
    font-weight: bold;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
}
.ranking-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 5px 0;
}
.ranking-list::-webkit-scrollbar {
    width: 8px;
}
.ranking-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
.ranking-list::-webkit-scrollbar-thumb {
    background: rgba(255,204,0,0.3);
    border-radius: 4px;
}
.ranking-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255,204,0,0.5);
}
.ranking-item {
    display: grid;
    grid-template-columns: 40px 1fr 100px 80px 50px 50px 50px;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    margin: 3px 0;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
}
.ranking-item:nth-child(1) {
    background: rgba(255,215,0,0.15);
    border-color: #ffd700;
}
.ranking-item:nth-child(2) {
    background: rgba(192,192,192,0.15);
    border-color: #c0c0c0;
}
.ranking-item:nth-child(3) {
    background: rgba(205,127,50,0.15);
    border-color: #cd7f32;
}
.ranking-item.empty {
    background: rgba(0,0,0,0.2);
    border-color: rgba(255,255,255,0.05);
    opacity: 0.5;
}
.ranking-position {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}
.ranking-nickname {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ranking-minutos {
    color: var(--accent-color);
    font-weight: bold;
    text-align: right;
}
.ranking-pomo {
    text-align: center;
    color: rgba(255,255,255,0.6);
}

.hologram-container {
    background: rgba(0, 255, 204, 0.05);
    border: 1px solid rgba(0, 255, 204, 0.3);
    border-radius: 4px;
    padding: 5px;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 0 20px rgba(0, 255, 204, 0.2),
        inset 0 0 20px rgba(0, 255, 204, 0.1);
    animation: hologramFloat 3s ease-in-out infinite;
    position: relative;
    width: 120px;
}
.hologram-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        180deg,
        rgba(0, 255, 204, 0.1) 0%,
        transparent 50%,
        rgba(0, 255, 204, 0.1) 100%
    );
    background-size: 100% 4px;
    pointer-events: none;
    animation: hologramScan 2s linear infinite;
}
@keyframes hologramFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
@keyframes hologramScan {
    0% { background-position: 0 0; }
    100% { background-position: 0 20px; }
}
.hologram-header {
    font-size: 10px;
    font-weight: bold;
    color: #00ffcc;
    text-align: center;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}
.hologram-item {
    display: flex;
    align-items: center;
    padding: 2px 4px;
    margin: 2px 0;
    background: rgba(0, 255, 204, 0.08);
    border-radius: 2px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.9);
}
.hologram-item:nth-child(2) {
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
}
.hologram-item:nth-child(3) {
    background: rgba(192, 192, 192, 0.15);
    border: 1px solid rgba(192, 192, 192, 0.3);
}
.hologram-item:nth-child(4) {
    background: rgba(205, 127, 50, 0.15);
    border: 1px solid rgba(205, 127, 50, 0.3);
}
.hologram-position {
    font-weight: bold;
    color: #00ffcc;
    width: 15px;
    text-align: center;
    margin-right: 4px;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.5);
}
.hologram-nickname {
    flex: 1;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hologram-minutos {
    color: #00ffcc;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.5);
}
body.item-equipado { cursor: none; }
body.item-equipado .ui-layer,
body.item-equipado .inv-slot,
body.item-equipado button,
body.item-equipado a { cursor: pointer; }

.study-popup button kbd {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px; padding: 2px 6px;
    margin-right: 8px; font-size: 11px;
    color: var(--accent-color);
    box-shadow: 0 2px 0 rgba(0,0,0,0.5);
    font-family: monospace;
}

.study-popup { 
    position: absolute; flex-direction: column; 
    background: rgba(15, 15, 20, 0.95); border: 1px solid var(--accent-color); 
    border-radius: 12px; z-index: 4000; box-shadow: 0 10px 30px rgba(0,0,0,0.8); 
    overflow: hidden; backdrop-filter: blur(10px); min-width: 180px; 
    display: flex; opacity: 0; pointer-events: none;
    transform: translate(-50%, -90%) scale(0.9); margin-top: -15px; 
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.study-popup.activo { opacity: 1; pointer-events: auto; transform: translate(-50%, -100%) scale(1); }
.study-popup h4 { margin: 0; padding: 15px; background: rgba(255,204,0,0.1); color: var(--accent-color); font-size: 13px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.05); }
.study-popup button { background: transparent; border: none; color: white; padding: 12px 15px; text-align: left; cursor: pointer; font-size: 13px; transition: 0.2s; border-bottom: 1px solid rgba(255,255,255,0.05); }
.study-popup button:hover { background: rgba(255, 255, 255, 0.05); padding-left: 20px; }

/* Menú de Silla (Rediseñado SIN X) */
.study-popup { 
    position: absolute; flex-direction: column; 
    background: rgba(15, 15, 20, 0.95); border: 1px solid var(--accent-color); 
    border-radius: 12px; z-index: 4000; box-shadow: 0 10px 30px rgba(0,0,0,0.8); 
    overflow: hidden; backdrop-filter: blur(10px); min-width: 180px; 
    display: flex; opacity: 0; pointer-events: none;
    transform: translate(-50%, -90%) scale(0.9); margin-top: -15px; 
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.study-popup.activo { opacity: 1; pointer-events: auto; transform: translate(-50%, -100%) scale(1); }
.study-popup h4 { margin: 0; padding: 15px; background: rgba(255,204,0,0.1); color: var(--accent-color); font-size: 13px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.05); }
.study-popup button { background: transparent; border: none; color: white; padding: 12px 15px; text-align: left; cursor: pointer; font-size: 13px; transition: 0.2s; border-bottom: 1px solid rgba(255,255,255,0.05); }
.study-popup button:hover { background: rgba(255, 255, 255, 0.05); padding-left: 20px; }

/* === CAPA DE CONCENTRACIÓN === */
#study-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 5000; display: none; align-items: center; justify-content: center; }
#study-overlay.foco-off { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(0, 0, 0, 0.15); pointer-events: none; }
#study-overlay.foco-off .study-card { pointer-events: auto; }
#study-overlay.activo { display: flex; animation: fadeStudy 0.5s ease; }
#foco-toggle-wrap { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 16px; }
#foco-toggle-label { font-size: 12px; color: rgba(255,255,255,0.5); letter-spacing: 1px; text-transform: uppercase; }
@keyframes fadeStudy { from { opacity: 0; backdrop-filter: blur(0px); } to { opacity: 1; backdrop-filter: blur(12px); } }
.study-card { background: rgba(20, 20, 25, 0.8); border: 1px solid var(--accent-color); padding: 40px; border-radius: 20px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.9), inset 0 0 30px rgba(255,204,0,0.05); }
.study-card h2 { margin: 0 0 10px 0; color: var(--accent-color); font-size: 18px; letter-spacing: 3px; }
#study-main-timer { font-family: monospace; font-size: 60px; font-weight: bold; color: white; text-shadow: 0 0 15px rgba(255,255,255,0.3); margin-bottom: 5px; }
.study-mining-indicator {
    font-family: 'Chau Philomene One', sans-serif;
    font-size: 15px; font-weight: bold;
    color: #ffd76a;
    background: rgba(12, 12, 18, 0.92);
    border: 2px solid rgba(255, 204, 0, 0.5);
    border-radius: 8px;
    padding: 4px 10px;
    display: inline-flex; align-items: center; gap: 6px;
    white-space: nowrap;
    box-sizing: border-box;
    margin: 0 auto 6px auto;
    line-height: 1;
}

/* === MODAL DE CONFIRMACIÓN === */
#confirm-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.8); z-index: 6000; display: none; align-items: center; justify-content: center; }
#confirm-modal.activo { display: flex; }
.confirm-card { background: #1a1a24; padding: 25px; border-radius: 12px; width: 300px; border: 1px solid rgba(255,50,50,0.3); text-align: center; }
.confirm-card h3 { color: #ff8888; margin-top: 0; }
.confirm-card p { font-size: 13px; color: #ccc; line-height: 1.5; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button { flex: 1; padding: 10px; border-radius: 6px; cursor: pointer; border: none; font-size: 13px; font-weight: bold; }

/* === NAVEGACIÓN TECLADO (NUEVO) === */
.nav-focus {
    outline: 2px solid white !important;
    outline-offset: 2px !important;
    transform: scale(1.05) !important;
    filter: brightness(1.2) !important;
    box-shadow: 0 0 15px rgba(255,255,255,0.4) !important;
    transition: 0.1s;
}
#btn-abandonar-silla.nav-focus, #btn-confirm-yes.nav-focus {
    outline-color: #ff8888 !important;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.6) !important;
}

/* MODAL DE FIN DE DESCANSO: usa .glass-modal (estilo consistente con Ayuda y juegos) */

/* === OBJETOS INTERACTIVOS (modales centrados) === */
.interactive-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 6500;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(8px);
}
.interactive-modal.activo { display: flex; }

.interactive-modal-card {
    background: rgba(15, 15, 20, 0.95);
    border: 1px solid var(--accent-color, #ffcc00);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    position: relative;
}
.interactive-modal-card--wide { max-width: 520px; }
.interactive-modal-card h4 {
    margin: 0 0 8px 0;
    color: var(--accent-color, #ffcc00);
    text-align: center;
}
.interactive-modal-desc {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    text-align: center;
    margin: 0 0 16px 0;
}
.interactive-label {
    display: block;
    font-size: 12px;
    color: #ccc;
    margin-bottom: 6px;
}
.char-count { float: right; opacity: 0.6; }
.interactive-input, .interactive-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    margin-bottom: 14px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 14px;
}
.interactive-textarea { resize: vertical; min-height: 100px; }
.interactive-submit { width: 100%; margin-top: 8px; }

.fede-dialog-text {
    color: #eee;
    font-size: calc(18px * var(--ui-scale));
    font-weight: normal;
    line-height: 1.6;
    text-align: center;
    padding: 20px 10px;
    min-height: 60px;
}

#arcade-canvas {
    display: block;
    width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    image-rendering: pixelated;
}

.store-items-list {
    max-height: 340px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 2px;
}
.store-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 10px;
    text-align: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    transition: border-color 0.2s, background 0.2s;
}
.store-item:hover {
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.08);
}
.store-item--inactivo {
    opacity: 0.45;
    filter: grayscale(0.6);
    border-color: rgba(255,255,255,0.08);
    cursor: default;
}
.store-item--inactivo:hover {
    border-color: rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.05);
}
.store-item--inactivo .store-buy-btn {
    cursor: not-allowed;
}
.store-item-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
    image-rendering: pixelated;
}
.store-item-name { font-size: 13px; font-weight: bold; color: #fff; line-height: 1.25; }
.store-item-meta { font-size: 11px; color: rgba(255,255,255,0.5); }
.store-item-price { font-size: 13px; color: #ffcc00; white-space: nowrap; }
.store-buy-btn {
    width: 100%;
    margin-top: auto;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--accent-color, #ffcc00);
    color: #000;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    transition: filter 0.15s, opacity 0.15s;
}
.store-buy-btn:hover { filter: brightness(1.1); }
.store-buy-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.store-empty { text-align: center; color: rgba(255,255,255,0.5); font-size: 13px; }
.store-toast {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translate(-50%, 10px);
    background: rgba(20, 20, 26, 0.95);
    border: 1px solid var(--accent-color, #ffcc00);
    color: #fff;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10;
    white-space: nowrap;
}
.store-toast.show { opacity: 1; transform: translate(-50%, 0); }
.store-toast.store-toast-error { border-color: #ff5555; }

.ranking-header--carreras {
    grid-template-columns: 40px 1fr 100px 80px;
}
.ranking-item--carreras {
    grid-template-columns: 40px 1fr 100px 80px;
}

/* Community */
.community-post {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.community-post:last-child { border-bottom: none; }
.community-post-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}
.community-avatar-canvas {
    border-radius: 4px;
    background: #333;
}
.community-post-body {
    flex: 1;
    min-width: 0;
}
.community-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.community-post-author {
    font-weight: bold;
    font-size: 13px;
    color: var(--accent-color, #ffcc00);
}
.community-post-time {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}
.community-post-text {
    font-size: 13px;
    color: #ddd;
    word-break: break-word;
}

/* ==========================================
   CONTROLES TÁCTILES PARA MÓVIL
   ========================================== */
#mobile-controls {
    display: none;
    position: fixed;
    z-index: 3001;
    pointer-events: none;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
}

.mobile-device #mobile-controls {
    display: block !important;
}

.mobile-action-btn {
    pointer-events: auto;
    position: absolute;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    line-height: 1;
}

.mobile-action-btn:active {
    transform: scale(0.88);
    background: rgba(255,204,0,0.25);
    border-color: var(--accent-color);
}

#mobile-btn-close {
    top: calc(10px + 56px + 6px);
    right: 10px;
    width: 44px;
    height: 44px;
    font-size: 18px;
    background: rgba(200,50,50,0.3);
    border-color: rgba(255,100,100,0.3);
    display: none;
}

.mobile-device #mobile-btn-close.show {
    display: flex;
}

/* Toolbar superior izquierda en móvil: sin transform (evita que `overflow: hidden`
   de `.ui-layer` corte a los botones al crecer con scale). Tamaños reales. */
.mobile-device #top-left-toolbar {
    top: 14px;
    left: 14px;
    z-index: 3490;
    transform: none;
    gap: 10px;
}

.mobile-device .toolbar-btn {
    width: 56px;
    height: 56px;
    font-size: 28px;
    border-radius: 10px;
    transform: none;
}

.mobile-device .toolbar-key {
    top: 4px;
    left: 5px;
    font-size: 10px;
}

/* HUD monedas/tiempo en móvil: apilado vertical (monedas sobre tiempo) y compacto,
   porque el ancho de pantalla es menor. Sin scale. */
.mobile-device #top-left-hud {
    margin-left: 14px;
    transform: none;
    flex-direction: column;
    gap: 4px;
}

.mobile-device #top-left-hud .hud-indicator {
    padding: 2px 10px;
    font-size: 12px;
}

.mobile-device #top-left-hud .hud-icon {
    font-size: 13px;
}

.mobile-device #top-left-hud .hud-value {
    font-size: 13px;
}

/* Indicadores de buff en móvil: al 120% (antes 150%: -20%), en la esquina superior derecha
   (bajo el botón del menú) para no solaparse con la mochila. Tamaños reales, sin scale. */
.mobile-device #buff-indicators {
    top: 70px;
    right: 10px;
    left: auto;
    z-index: 3491;
    transform: none;
}

.mobile-device .buff-indicator {
    min-width: 52px;
    height: 36px;
    padding: 0 11px;
    font-size: 19px;
}

.mobile-device .buff-indicator .buff-time {
    font-size: 13px;
}

.mobile-device .buff-indicator .buff-count {
    font-size: 16px;
}

/* Mochila en móvil: pegada a la parte superior izquierda (bajo la toolbar),
   para no tapar al sprite del jugador. Personalizar sigue como modal centrado. */
.mobile-device #backpack-panel {
    top: 88px;
    left: 14px;
    right: auto;
    transform: none;
    z-index: 4500;
    width: 480px;
    max-width: calc(100vw - 28px);
    max-height: calc(100vh - 96px);
    box-sizing: border-box;
    overflow-y: auto;
    padding: 16px;
    background: rgba(15, 15, 20, 0.95);
    border: 2px solid var(--accent-color);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}

.mobile-device #customize-panel {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4501;
    width: 480px;
    max-width: 92vw;
    max-height: 82vh;
    overflow-y: auto;
    padding: 16px;
    background: rgba(15, 15, 20, 0.95);
    border: 2px solid var(--accent-color);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}

/* Slots transpuestos en móvil: 7 columnas x 4 filas (en vez de 4x7) */
.mobile-device .backpack-grid {
    grid-template-columns: repeat(7, 44px);
    grid-template-rows: repeat(4, 44px);
    margin-right: 0;
}

.mobile-device .backpack-grid .inv-slot {
    width: 44px !important;
    height: 44px !important;
}

/* Móvil: los slots especiales van en el encabezado (junto a "Mochila"), en horizontal */
.mobile-device .backpack-special {
    position: static;
    top: auto;
    right: auto;
    flex-direction: row;
}

.mobile-device .backpack-special .special-slot {
    width: 40px;
    height: 40px;
}

.mobile-device .backpack-header {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 10px;
    padding: 2px 2px 8px;
}

.mobile-device .customize-section-title {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.65);
}

.mobile-device .custom-select-trigger {
    font-size: 15px;
    padding: 10px 12px;
}

/* Nota: el menú full-screen se define arriba en la sección "En dispositivos móviles" */

/* Botón menú hamburguesa en móvil: esquina superior derecha, al 100% (antes 200%) */
.mobile-device #contenedor-menu-trigger {
    top: 10px;
    right: 10px;
    z-index: 5000;
    transform: scale(1);
    transform-origin: top right;
}

/* HUD indicators en móvil: más compactos */
.mobile-device .hud-indicator {
    padding: 3px 7px;
    font-size: 10px;
}

.mobile-device .hud-icon { font-size: 12px; }
.mobile-device .hud-value { font-size: 11px; }

/* Botón "Sansanos en Línea": en la toolbar (entre Ayuda y monedas) en PC,
   y fijo abajo a la derecha en móvil, con la misma apariencia que mochila/customize */
.toolbar-sansanos {
    border-color: rgba(85, 170, 255, 0.55);
}

.mobile-device #btn-ver-sansanos-online {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 3495;
}

/* Cuando el menú está abierto en móvil, ocultar temporalmente botones de acción para no saturar */
.mobile-device #menu-lateral.activo ~ #mobile-controls .mobile-action-btn,
.mobile-device #menu-lateral.activo ~ #top-left-toolbar #btn-ver-sansanos-online {
    opacity: 0.3;
    pointer-events: none;
}

/* Mobile chat: se abre tocando el hint "Toca aquí para hablar" (sin botón redondo).
   Fijado abajo a la izquierda; al activarse sube y muestra el campo + botón enviar. */
.mobile-device #chat-container {
    bottom: 16px;
    left: 10px;
    width: min(70vw, 300px);
    max-height: min(160px, 30vh);
    height: auto;
    position: fixed;
    transform: none;
    transform-origin: unset;
}

.mobile-device #chat-container.activo {
    max-height: min(200px, 40vh);
    height: auto;
}

.mobile-device #chat-hint {
    height: 44px;
    font-size: 13px;
    color: rgba(255,255,255,0.65);
}

.mobile-device #chat-messages {
    max-height: min(80px, 20vh);
    overflow-y: auto;
}

/* Modales en móvil: más compactos */
.mobile-device .interactive-modal-card {
    max-width: 92vw;
    padding: 16px;
    margin: 10px;
}

.mobile-device .ranking-header {
    grid-template-columns: 30px 1fr 60px 40px 30px 30px 30px;
    gap: 4px;
    font-size: 9px;
}

.mobile-device .ranking-item {
    grid-template-columns: 30px 1fr 60px 40px 30px 30px 30px;
    gap: 4px;
    font-size: 10px;
    padding: 5px 6px;
}

.mobile-device .ranking-header--carreras {
    grid-template-columns: 30px 1fr 60px 50px;
}

.mobile-device .ranking-item--carreras {
    grid-template-columns: 30px 1fr 60px 50px;
}

/* Tabla de jugadores en móvil: más grande para pantalla táctil */
.mobile-device #panel-tab {
    width: 94vw;
    max-width: 460px;
    top: 56px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.mobile-device #panel-tab.activo {
    top: 64px;
}

.mobile-device #panel-tab .tab-header {
    padding: 14px 18px;
}

.mobile-device #panel-tab .tab-header h3 {
    font-size: 14px;
}

.mobile-device #panel-tab .tab-stats {
    font-size: 13px;
}

.mobile-device #lista-jugadores {
    max-height: none;
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.mobile-device .jugador-item {
    padding: 13px 16px;
    font-size: 15px;
    margin-bottom: 8px;
}

.mobile-device .jugador-item .tit {
    font-size: 12px;
}

/* Ajustar chess en móvil */
.mobile-device .chess-board {
    width: min(85vw, 320px) !important;
    height: min(85vw, 320px) !important;
    grid-template-columns: repeat(8, minmax(30px, 1fr)) !important;
    grid-template-rows: repeat(8, minmax(30px, 1fr)) !important;
}

.mobile-device .chess-cell {
    font-size: min(7vw, 28px) !important;
    width: 100% !important;
    height: 100% !important;
}

/* Menú de juegos en móvil */
.mobile-device #games-selection-menu {
    width: min(90vw, 360px) !important;
}

.mobile-device #tictactoe-game {
    width: min(90vw, 360px) !important;
}

.mobile-device .ttt-cell {
    font-size: min(12vw, 36px) !important;
}

/* Solapamiento: cuando la mochila está abierta en móvil, reducir opacidad de botones de acción */
.mobile-device #backpack-panel.activo ~ #mobile-controls .mobile-action-btn {
    opacity: 0.5;
}

/* Base padding-bottom al body en móvil para no cubrir contenido con botones */
.mobile-device body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* === EXCEPCIONES: fuentes que NO deben usar Chau Philomene One === */
#study-main-timer,
kbd,
.chess-cell,
.ttt-cell {
    font-family: monospace;
}
.interactive-input,
.interactive-textarea,
#chat-input,
#inbox-asunto,
#inbox-mensaje,
#community-mensaje {
    font-family: inherit;
}

/* === AVISO DE RECONEXIÓN === */
#reconnect-overlay {
    display: none;
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20000;
    pointer-events: none;
}

#reconnect-overlay.activo {
    display: flex;
}

.reconnect-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(10, 10, 18, 0.92);
    border: 1px solid rgba(255, 204, 0, 0.5);
    color: #fff;
    font-family: 'Chau Philomene One', sans-serif;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.reconnect-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 204, 0, 0.3);
    border-top-color: #ffcc00;
    border-radius: 50%;
    animation: svReconnectSpin 0.8s linear infinite;
}

.reconnect-btn {
    pointer-events: auto;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: #ffcc00;
    color: #111;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.reconnect-btn:hover {
    background: #ffe066;
}

@keyframes svReconnectSpin {
    to { transform: rotate(360deg); }
}