@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&display=swap');

:root {
    --bg-dark: #120024; --gold: #d4af37; --gold-dim: rgba(212, 175, 55, 0.3);
    --gold-light: #ffd700; --purple-magic: #8a2be2; --red-alert: #ff4d4d;
}

body { 
    font-family: 'Cinzel', serif; background-color: var(--bg-dark); color: #ffffff; 
    margin: 0; padding: 20px; min-height: 100vh;
    background-image: radial-gradient(circle at top, #1a0033 0%, #05000a 100%);
    text-align: center;
}
h1, h2, h3 { color: var(--gold); text-shadow: 0 0 15px rgba(212, 175, 55, 0.6); }
.container-hex { width: 95%; margin: 0 auto; max-width: 1600px; }

nav, .filter-group { display: flex !important; justify-content: center !important; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; width: 100%; }
button { 
    background: linear-gradient(145deg, #2e004f, #1a0033); color: var(--gold); border: 1px solid var(--gold); 
    padding: 10px 15px; cursor: pointer; font-family: 'Cinzel'; transition: 0.2s ease; 
    border-radius: 4px; font-weight: bold; box-shadow: 0 4px 6px rgba(0,0,0,0.4); 
}
button:hover:not(:disabled) { filter: brightness(1.3); transform: translateY(-2px); }
button:active:not(:disabled) { transform: translateY(1px); }
.btn-active { background: var(--gold) !important; color: var(--bg-dark) !important; border: 2px solid var(--gold-light); }

.catalogo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; max-width: 1000px; margin: 0 auto; }
.char-card { background: rgba(21, 0, 41, 0.8); border: 1px solid var(--gold-dim); border-radius: 8px; padding: 15px; cursor: pointer; transition: 0.3s; }
.char-card:hover { transform: scale(1.05); border-color: var(--gold); box-shadow: 0 0 20px rgba(212, 175, 55, 0.3); }
.char-card img { width: 100px; height: 100px; border-radius: 50%; border: 2px solid var(--gold); object-fit: cover; }
.char-card h3 { margin: 10px 0 5px 0; font-size: 1.2em; text-transform: uppercase; }
.char-card p { margin: 0; font-size: 0.8em; color: #aaa; }

.player-header { display: flex; align-items: center; gap: 20px; background: rgba(30, 0, 60, 0.6); padding: 20px; border: 1px solid var(--gold); border-radius: 8px; margin-bottom: 20px; text-align: left; }
.player-icon { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--gold); object-fit: cover; background: #000; }

.btn-sync-float { position: fixed; bottom: 30px; right: 30px; background: linear-gradient(145deg, #aa0000, #ff4444); color: white; padding: 15px 25px; border-radius: 50px; font-weight: bold; font-size: 1.1em; border: 2px solid #fff; box-shadow: 0 5px 20px rgba(255,0,0,0.6); z-index: 9999; cursor: pointer; animation: pulse 2s infinite; }
.btn-sync-float.oculto { display: none; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* Botones +/- en Tablas OP */
.btn-inline-op { color: white; border: 1px solid var(--gold); padding: 4px 10px; font-size: 1.1em; font-weight: bold; cursor: pointer; border-radius: 4px; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.btn-inline-op.plus { background: #004a00; border-color: #00ff00; margin-left: 8px; }
.btn-inline-op.minus { background: #4a0000; border-color: #ff0000; margin-right: 8px; }
.btn-inline-op:hover { filter: brightness(1.3); transform: scale(1.1); }

/* Tooltips y Resumen Visual */
.hex-tooltip { position: relative; display: inline-block; cursor: help; }
.hex-tooltip .tooltiptext { visibility: hidden; width: 250px; background: rgba(10,0,20,0.98); color: #fff; border: 1px solid var(--gold); text-align: left; border-radius: 6px; padding: 12px; position: absolute; z-index: 100; bottom: 120%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s; font-size: 0.85rem; pointer-events:none; box-shadow: 0 4px 15px rgba(0,0,0,0.9); }
.hex-tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }
.hex-tooltip .tooltiptext span { display: block; color: var(--gold-light); margin-bottom:5px; font-weight:bold; font-size:1.1em; border-bottom: 1px dashed #555; padding-bottom: 5px;}

.resumen-row { display: flex; background: rgba(20,0,40,0.6); border: 1px solid var(--gold-dim); border-radius: 8px; margin-bottom: 15px; padding: 15px; align-items: center; gap: 20px;}
.resumen-left { flex: 0 0 120px; text-align: center; border-right: 1px dashed var(--gold-dim); padding-right: 15px; }
.resumen-right { flex: 1; display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-start; }
.resumen-right img { width: 55px; height: 55px; object-fit: cover; border-radius: 6px; border: 1px solid var(--gold); transition: 0.2s; }
.resumen-right img:hover { transform: scale(1.1); border-color: #fff; }
.img-stack { position: relative; }

/* Contenedor de cantides Normal y OP */
.badge-normal { position: absolute; bottom: -5px; right: -5px; background: var(--gold); color: #000; border-radius: 50%; width: 22px; height: 22px; font-size: 0.75em; font-weight: bold; display: flex; align-items: center; justify-content: center; border: 1px solid #000; }
.badge-op { position: absolute; bottom: -8px; right: -8px; display: flex; align-items: center; background: #000; border: 1px solid var(--gold); border-radius: 4px; z-index: 10; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.8); }
.badge-op button { background: #222; color: #fff; border: none; padding: 2px 6px; font-weight: bold; cursor: pointer; transition: 0.2s; border-radius: 0; box-shadow: none; }
.badge-op button.plus { background: #004a00; }
.badge-op button.minus { background: #4a0000; }
.badge-op button:hover { filter: brightness(1.5); }
.badge-op span { padding: 2px 6px; font-size: 0.85em; font-weight: bold; color: var(--gold); background: #111; }

.top-items-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.top-item-card { background: linear-gradient(180deg, #111, #000); border: 1px solid var(--gold-dim); padding: 8px; text-align: center; border-radius: 6px; overflow: hidden; transition: 0.3s ease; box-shadow: 0 4px 8px rgba(0,0,0,0.6); }
.top-item-card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; opacity: 0.85; transition: 0.4s ease; cursor: pointer; border-radius: 4px; }
.top-item-card img:hover { opacity: 1; filter: brightness(1.2); transform: scale(1.05); }

.rarity-comun { border: 1px solid #777 !important; }
.rarity-raro { border: 2px solid var(--purple-magic) !important; box-shadow: 0 0 15px rgba(138, 43, 226, 0.5), inset 0 0 10px rgba(138, 43, 226, 0.2) !important; }
.rarity-legendario { border: 2px solid var(--gold-light) !important; box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), inset 0 0 15px rgba(212, 175, 55, 0.3) !important; }

.grid-control { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 20px; }
.control-card { background: rgba(30, 0, 60, 0.9); border: 1px solid var(--gold-dim); padding: 15px; border-radius: 8px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.4); transition: 0.2s; }
.control-card:hover { border-color: var(--gold); }
.item-con-stock { background: linear-gradient(145deg, rgba(74, 0, 74, 0.8), rgba(40, 0, 40, 0.9)) !important; border: 2px solid var(--gold) !important; box-shadow: inset 0 0 15px rgba(212,175,55,0.1); }
.item-name { font-size: 0.85em; font-weight: bold; margin-bottom: 5px; display: block; color: var(--gold); text-shadow: 1px 1px 2px #000; }
.control-card img { width: 60px !important; height: 60px !important; min-width: 60px !important; min-height: 60px !important; object-fit: cover; cursor: pointer; border-radius: 8px; transition: 0.2s; margin: 0 auto; display: block; }

.table-responsive { width: 100%; overflow-x: auto; margin-top: 15px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
table { width: 100%; border-collapse: collapse; background: rgba(20, 0, 40, 0.9); border: 1px solid var(--gold); min-width: 650px; }
th { background: linear-gradient(180deg, var(--gold-light), var(--gold-dark)); color: var(--bg-dark); padding: 14px; border: 1px solid #000; text-transform: uppercase; font-weight: bold; letter-spacing: 1px; }
td { padding: 12px; border: 1px solid rgba(212, 175, 55, 0.2); text-align: center; color: #f0f0f0; }
tr:hover td { background: rgba(212, 175, 55, 0.1); }
th:first-child, td:first-child { width: 70px; text-align: center; }

.cat-img { width: 50px !important; height: 50px !important; min-width: 50px !important; max-width: 50px !important; object-fit: cover; border: 1px solid var(--gold); border-radius: 4px; background: #000; display: block; margin: 0 auto; }

.search-bar { width: 85%; max-width: 600px; display: block; margin: 0 auto 20px auto; padding: 15px; border: 1px solid var(--gold); background: rgba(0,0,0,0.5); color: white; text-align: center; border-radius: 6px; font-family: 'Cinzel'; font-size: 1.1em; transition: 0.3s; }
.search-bar:focus { outline: none; box-shadow: 0 0 15px rgba(212, 175, 55, 0.5); background: #000; }

.op-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; max-width: 900px; margin: 30px auto; }
.op-grid button { padding: 20px; font-size: 1.1em; }
.cant-input { width: 55px; float: right; background: #000; color: var(--gold-light); border: 1px dashed var(--gold); text-align: center; font-weight: bold; font-size: 1.1em; border-radius: 4px; padding: 2px; }

.hex-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); display: none; justify-content: center; align-items: center; z-index: 2000; }
.hex-modal img { max-width: 80vw; max-height: 75vh; border: 3px solid var(--gold); box-shadow: 0 0 40px rgba(212, 175, 55, 0.3); background: #000; cursor: grab; position: absolute; border-radius: 8px; }
.hex-modal img:active { cursor: grabbing; }

.pagina { display: none; }
.pagina.activa { display: block; animation: fadeIn 0.4s ease; }

/* Corregir la cuadrícula de la forja múltiple */
#multi-creation-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important; /* Mínimo 320px para que no choquen */ gap: 20px !important; padding: 10px;}

/* Estilo para los nuevos inputs de texto con datalist */
input[list].search-bar {
    width: 100% !important;
    box-sizing: border-box;
    padding: 10px;
    font-size: 0.85em !important;
    text-align: left; /* Mejor alineado a la izquierda para leer tipos largos */
    height: 40px;
    margin: 0;
}

/* Asegurar que las filas de inputs dentro de cada caja de objeto tengan espacio */
.multi-obj-row {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 10px;
    margin-bottom: 10px;
}

.multi-obj-row-triple {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 70px; /* Distribución equilibrada */
    gap: 10px;
    margin-bottom: 10px;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 768px) {
    body { padding-bottom: 90px !important; padding-left: 10px !important; padding-right: 10px !important; }
    nav { position: fixed !important; bottom: 0 !important; left: 0 !important; width: 100% !important; background: rgba(10, 0, 20, 0.98) !important; border-top: 2px solid var(--gold) !important; padding: 10px 5px !important; margin: 0 !important; justify-content: space-around !important; z-index: 9999 !important; box-shadow: 0 -5px 20px rgba(0,0,0,0.9); display: flex !important; flex-wrap: nowrap !important; }
    nav button { font-size: 0.65em !important; padding: 12px 2px !important; flex: 1; margin: 0 2px !important; text-align: center; white-space: pre-wrap; }
    .player-header { flex-direction: column !important; text-align: center !important; gap: 15px !important; }
    .grid-control { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .resumen-row { flex-direction: column; text-align: center; }
    .resumen-left { border-right: none; border-bottom: 1px dashed var(--gold-dim); padding-right: 0; padding-bottom: 15px; margin-bottom: 15px; }
    .resumen-right { justify-content: center; }
}
