/* 1. Limpieza total y Fondo Fijo al Monitor */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: #1a1305;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative; /* Necesario para la magia del fondo */
    
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 🔥 LA CAPA FANTASMA (TRUCO GEOMÉTRICO) 🔥 */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/background_table_draw.jpg');
    
    /* 🚀 ELIMINA EL ZOOM BESTIAL: */
    /* En vez de "cover" (que recorta y agranda), usamos "100% 100%". 
       Esto obliga a la imagen de la mesa a entrar perfecta en el marco, 
       sin importar si el celular está vertical u horizontal. */
    background-size: 100% 100%; 
    
    background-position: center;
    background-repeat: no-repeat;
    z-index: -100;
    pointer-events: none;
}

.tavern-scene {
    width: 100%;
    min-height: 100vh; 
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10px;
    background: transparent; 
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.interface-frame {
    width: 98%;
    max-width: 1600px;
    height: auto; 
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

/* 3. HEADER Y ESTRUCTURA - LÓGICA FLEXIBLE */
.top-header {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px 40px;
    display: flex;
    justify-content: center; 
    align-items: center;
    position: relative; 
    height: 80px;       
}

.header-left, .header-right {
    display: flex;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 0; 
}

.main-logo-img {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 900px;   
    height: 80px;   
    object-fit: fill; 
    z-index: 9999;
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.5));
}

.content-layout { 
    display: grid; 
    grid-template-columns: 1fr 320px; 
    gap: 20px; 
    flex-grow: 1; 
    padding: 0 40px 40px 40px; 
}

/* 4. LOGO Y BOTONES */
.logo-area h1 { 
    font-family: 'Cinzel', serif; 
    font-size: 1.8rem; 
    color: #ffcc00 !important;
    text-shadow: 2px 2px 4px #000;
    transform: translateX(-36vw) translateY(-13px); 
}

/* 5. PERGAMINO */
.parchment-scroll {
    background-image: url('assets/parchment_scroll.jpg');
    background-size: 100% 100%;
    padding: 90px 70px;
    display: flex; 
    flex-direction: column;
    filter: drop-shadow(0 15px 30px rgba(0,0,0,0.6));
    height: auto; 
    min-height: 750px;
    width: 105%; 
    margin-left: 3%; 
    margin-top: -53px;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.parchment-scroll h2, .parchment-scroll p { 
    color: #000000 !important; 
}

.titles-row, .banners-row, .ranking-bar, .ranking-container, .period-info-row, .search-filter-row {
    position: relative;
    margin-top: -15px;
    z-index: 2000 !important;
}

/* TITLES */
.titles-row {
    width: 82%;
    height: 105px; 
    margin-top: -6.4%; 
    margin-bottom: 2%; 
    margin-left: 11%; 
    background-image: url('assets/barra2.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    position: relative;
    z-index: 50;
    display: flex;
    justify-content: space-between;
}

.title-item {
    width: 20%;
    height: 120%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: 'Special Elite', cursive;
    font-weight: 900;
    font-size: 1.05rem;
    color: #f3cf02;
    text-transform: uppercase;
    padding-right: 10px; 
    transition: all 0.3s ease;
    cursor: pointer;
}

.title-item:hover {
    color: #ffffff !important;
    text-shadow: 0 0 10px #f3cf02, 0 0 20px #ffcc00;
    transform: scale(1.1);
}

/* BANNERS */
.banners-row {
    display: flex; 
    justify-content: space-between; 
    position: relative; 
    z-index: 20;
    margin-bottom: 10px;
    margin-top: -10px; 
    background-image: url('assets/barra.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    height: 112px; 
    width: 90%;
    transform: translateX(100px);
}

.stat-banner {
    width: 20%; 
    height: 117%;
    display: flex; 
    flex-direction: column; 
    justify-content: center;
    align-items: flex-start; 
    padding-left: 20px; 
    padding-right: 0;
    padding-bottom: 20px;
    color: #f7b758 !important; 
    text-shadow: 1px 1px 3px #000;
    transition: all 0.3s ease;
    cursor: pointer;
    transform: translateX(0); 
}

.stat-banner:hover {
    filter: brightness(1.2);
    transform: translateX(0) translateY(-5px);
}

.stat-banner .value {
    font-size: 2.1rem !important; 
    font-family: 'Cinzel', serif !important;
    line-height: 1;
    color: #ffcc00 !important; 
    display: block;
}

.stat-banner .label {
    font-size: 1.3rem !important; 
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: block;
}

.stat-banner .sub {
    font-size: 0.85rem;
    opacity: 0.8;
    display: block;
}

/* PERIOD */
.period-info-row {
    width: 87%;
    height: 45px;
    margin: 0 0 0 10%;
    background-image: url('assets/barraperiod.png');
    background-size: 100% 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.period-cell {
    font-family: 'Special Elite', cursive;
    font-size: 1.1rem;
    color: #f5ad14;
    font-weight: bold;
}

/* SEARCH */
.search-filter-row {
    width: 87%;
    height: 45px;
    margin: 5px 0 10px 10%;
    background-image: url('assets/barrasearch.png');
    background-size: 100% 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
}

.search-cell, .filter-cell {
    width: 45%;
}

.search-cell input, .filter-cell select {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Special Elite', cursive;
    font-size: 1.1rem;
    color: #f5ad14;
    font-weight: bold;
}

/* RANKING */
.ranking-bar {
    width: 88%;
    margin: -11px 0 0 10%;
    display: block;
}

.ranking-container {
    width: 90%; 
    margin-left: 9%; 
    margin-top: 1px;
    height: 420px; 
    overflow-y: auto; 
    overflow-x: hidden;
    padding-right: 15px; 
    font-weight: bold;
    position: relative; 
    z-index: 10;        
    background: rgba(255, 255, 255, 0); 
    border-radius: 5px;
    -webkit-overflow-scrolling: touch;
}

#ranking-data {
    height: auto;
    overflow: visible; 
    padding-bottom: 80px; 
}

.ranking-header, .ranking-row {
    display: grid;
    grid-template-columns: 40px 1.2fr 96px 195px 91px 70px 120px;
    align-items: center;
    gap: 15px;
    padding: 3px 15px;
    z-index: 2000 !important;
    min-width: 0;
}

.ranking-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid rgba(0,0,0,0.4);
    font-family: 'Cinzel', serif; 
    font-weight: 900;
    color: #2b1d0e;
    font-size: 0.95rem;
}

.ranking-row {
    border-bottom: 1px solid rgba(0,0,0,0.2);
    font-size: 0.95rem;
    color: #181306
}

.ranking-row .r-col-name {
    font-weight: bold;
    font-size: 1.05rem;
    color: #181306;
}

.r-col-points { text-align: center; }
.r-col-percent, .r-col-status, .r-col-breakdown { text-align: center; position: relative; right: 20px; }

/* BARRA DE PROGRESO */
.r-bar-bg {
    background: rgba(0, 0, 0, 0.2);
    height: 14px; 
    border-radius: 10px;
    position: relative;
    overflow: visible; 
}

.r-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #1e3c72, #2a5298, #3fa9f5); 
    border-radius: 10px;
    position: relative;
    transition: width 1.5s ease-in-out;
}

.r-bar-fill::after {
    content: "";
    position: absolute;
    z-index: 999; 
    width: 55px;  
    height: 55px;
    background-image: url('assets/barquito.png');
    background-size: contain;
    background-repeat: no-repeat;
    display: block !important;
    top: -28px;  
    right: -15px; 
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.5));
}

/* SIDEBAR Y COMPONENTES */
.sidebar { display: flex; flex-direction: column; gap: 20px; padding-top: 15px; }
.side-widget { border: 2px solid #000; padding: 20px; text-align: center; background: rgba(0,0,0,0.03); }

/* SCROLLBARS */
.ranking-container::-webkit-scrollbar { width: 10px; }
.ranking-container::-webkit-scrollbar-track { background: rgba(43, 29, 14, 0.1); border-radius: 10px; }
.ranking-container::-webkit-scrollbar-thumb { background: #2b1d0e; border: 2px solid #f7b758; border-radius: 10px; }
.ranking-container::-webkit-scrollbar-thumb:hover { background: #f7b758; cursor: pointer; }
.ranking-container { scrollbar-width: thin; scrollbar-color: #2b1d0e rgba(43, 29, 14, 0.1); }

/* CLAN ID */
#clan-id-input {
    background: transparent !important; 
    border: 1px solid rgba(245, 173, 20, 0.5) !important; 
    color: #f5ad14 !important; 
    font-family: 'Special Elite', cursive;
    font-size: 1.1rem;
    padding: 5px;
    outline: none;
    border-radius: 5px;
}

#clan-id-input:focus, #clan-id-input:active {
    background: rgba(0, 0, 0, 0.3) !important; 
}

#clan-id-input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px #2b1d0e inset !important; 
    -webkit-text-fill-color: #f5ad14 !important;
}

/* DIAL Y FECHAS */
.history-container {
    position: relative;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    margin-left: 0px;  
    margin-top: 10px;    
}

.dial-img {
    width: 90%;
    height: auto;
    display: block;
    filter: drop-shadow(2px 4px 5px rgba(0,0,0,0.5));
}

.dial-dates-overlay {
    position: absolute;
    top: 70%;                
    left: 45%;
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
    font-family: 'Special Elite', cursive;
    font-size: 15px;          
    color: #271b03;
    font-weight: bold;
    line-height: 1.4;
    z-index: 10;
}

.dial-dates-overlay div { margin: 4px 0; }
.r-dial-container { font-size: 0.85rem; line-height: 1.4; color: #1a1305; font-weight: bold; }
.r-update-text { font-size: 0.85rem; opacity: 3.9; }

/* ETIQUETAS DE ESTADO */
.status-tag-active { color: #27ae60; font-weight: bold; }
.status-tag-expired { color: #c0392b; font-weight: bold; text-transform: uppercase; }

/* SELECTOR PIRATA */
.custom-period-select {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0; 
    cursor: pointer;
    z-index: 10;
}

#period-selector-container { position: relative; }

#period-selector {
    display: block;
    width: 100%;
    max-width: 260px; 
    margin: 10px 0;
    background-color: #2b1a0a; 
    color: #f5ad14;            
    border: 2px solid #c0c0c0; 
    font-family: 'Special Elite', cursive;
    font-size: 1rem;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23f5ad14%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 12px auto;
    padding-right: 35px;
}

#period-selector:hover {
    border-color: #e0e0e0;
    background-color: #3d2610;
    box-shadow: 0 0 10px rgba(245, 173, 20, 0.3);
}

#period-selector option {
    background-color: #2b1a0a;
    color: #c0c0c0; 
    padding: 10px;
}

/* EL PIANO DEL RINCÓN */
.taberna-piano {
    position: fixed;   
    bottom: 210px;      
    right: 210px;       
    width: 300px;      
    height: auto;      
    z-index: 5;        
}
/* 📜 Estirar papiro CONTROLADO en dispositivos táctiles (Celulares) */
@media (pointer: coarse) {
    
    /* 1. Le damos un tamaño más largo que en PC, pero fijo para que no se deforme la madera */
    .parchment-scroll {
        height: 1200px !important; 
        min-height: 1200px !important;
        background-size: 100% 100%;
    }

    /* 2. El contenedor crece bastante más que en PC, pero tiene tope */
    .ranking-container {
        height: 850px !important;     /* Más del doble que en PC (que era 420px) */
        max-height: 850px !important;
        
        /* 🔥 VUELVE EL SCROLL INTERNO: Si hay más jugadores, scrollean acá adentro */
        overflow-y: auto !important; 
        overflow-x: hidden !important;
    }

    /* 3. Colchón final */
    #ranking-data {
        padding-bottom: 80px !important;
    }
}