/* Reset y Estilos Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background-color: #000;
    font-family: 'Cinzel', serif; 
    color: #e0e0e0;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* Pantalla de Inicio "Entrada al Castillo" */
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.9)), url('https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/castle_brick.jpg'); /* Textura fallback o color sólido si falla */
    background-color: #050505;
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 2s ease-in-out;
}

/* Vignette para efecto atmosfera */
#start-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 200px rgba(0,0,0,0.9);
    pointer-events: none;
}

#start-content {
    text-align: center;
    z-index: 101;
    color: #d4af37;
}

#game-title {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 4px 10px rgba(0,0,0,1);
    letter-spacing: 5px;
    font-weight: normal;
}

#game-subtitle {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    color: #888;
    letter-spacing: 3px;
    text-transform: uppercase;
}

#start-btn {
    background: transparent;
    border: 2px solid #d4af37;
    color: #d4af37;
    padding: 15px 40px;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

#start-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    transform: scale(1.05);
}

/* Utilitario para ocultar con fade */
.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Interfaz de Usuario "Abadía" */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Alinear al fondo */
}

#ui-footer {
    position: relative;
    width: 100%;
    height: 124px;
    background: 
        radial-gradient(ellipse at 50% 0%, rgba(65, 45, 25, 0.45) 0%, transparent 75%),
        linear-gradient(to bottom, #1d140d 0%, #130d07 40%, #0a0704 100%);
    border-top: 3px solid #7d5e23;
    box-shadow: 0 -12px 35px rgba(0,0,0,0.92), inset 0 2px 4px rgba(255, 215, 0, 0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 30px;
    pointer-events: auto;
    z-index: 20;
    transition: opacity 0.3s ease, filter 0.3s ease;
}

/* Transparencia adaptativa del HUD cuando el personaje se desplaza por la zona inferior */
#ui-layer.player-near-hud #ui-footer {
    opacity: 0.30;
    pointer-events: none;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
}

#ui-layer.player-near-hud #game-tips {
    opacity: 0.15;
    pointer-events: none;
}

/* Crestería Gótica Calada Superior */
.hud-gothic-frieze {
    position: absolute;
    top: -16px;
    left: 0;
    width: 100%;
    height: 16px;
    background-repeat: repeat-x;
    background-size: 32px 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 16' width='32' height='16'%3E%3Cpath d='M0 16 L0 8 Q8 0 16 0 Q24 0 32 8 L32 16 Z' fill='%231d140d' stroke='%237d5e23' stroke-width='1.2'/%3E%3Ccircle cx='16' cy='7' r='2' fill='%23ffd700'/%3E%3C/svg%3E");
    filter: drop-shadow(0 -3px 3px rgba(0,0,0,0.85));
    pointer-events: none;
    z-index: 25;
}

/* Remaches y herrajes de forja medieval */
.rivet {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffd700, #7d5e23 60%, #1d140d 100%);
    box-shadow: 1px 1px 2px rgba(0,0,0,0.9), inset 0 0 1px rgba(255,255,255,0.7);
    pointer-events: none;
}
.rivet.top-left { top: 5px; left: 5px; }
.rivet.top-right { top: 5px; right: 5px; }
.rivet.bottom-left { bottom: 5px; left: 5px; }
.rivet.bottom-right { bottom: 5px; right: 5px; }

.medieval-frame {
    position: relative;
    background: linear-gradient(145deg, #18120b 0%, #0d0905 100%);
    border: 2px solid #8b6b23;
    border-radius: 4px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.95), 0 4px 10px rgba(0,0,0,0.7);
    outline: 1px solid rgba(212, 175, 55, 0.25);
    outline-offset: -5px;
}

/* Panel Izquierdo: Tiempo Litúrgico / Códice */
#time-panel {
    width: 175px;
    height: 104px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    text-align: center;
}

.time-header-label {
    font-size: 0.68rem;
    color: #9f824c;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
}

#time-day {
    font-size: 0.85rem;
    color: #d8c292;
    letter-spacing: 2px;
    font-weight: 700;
    margin-top: 3px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

#time-hour {
    font-size: 1.25rem;
    color: #ffd700;
    font-family: 'MedievalSharp', 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 3px;
    margin-top: 2px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.65), 0 2px 4px #000;
}

.time-footer-ornament {
    font-size: 0.75rem;
    color: #b89742;
    margin-top: 2px;
    opacity: 0.8;
}

/* Panel Central: Diálogos estilo Abadía + Inventario medieval */
#hud-center-panel {
    flex: 1;
    max-width: 820px;
    height: 104px;
    margin: 0 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

/* Franja Superior: Cartela de Diálogos estilo Abadía (Hueco entre dos túneles) */
#hud-dialogue-area {
    position: relative;
    width: 100%;
    height: 44px;
    background: linear-gradient(to right, #0d0805, #19110a 20%, #19110a 80%, #0d0805);
    border: 1px solid #7d5e23;
    border-radius: 4px;
    box-shadow: inset 0 0 14px rgba(0,0,0,0.98), 0 2px 6px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    padding: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    user-select: none;
}

#hud-dialogue-area.has-dialogue {
    border-color: #d4af37;
    box-shadow: inset 0 0 16px rgba(0,0,0,0.95), 0 0 14px rgba(212, 175, 55, 0.35);
    cursor: pointer;
}

/* Túneles a los extremos (Bocas de túnel góticas que ocultan el texto) */
.tunnel-portal {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 55px;
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.tunnel-portal.tunnel-left {
    left: 0;
    background: linear-gradient(to right, #0a0603 0%, #100a06 40%, rgba(16, 10, 6, 0.8) 75%, transparent 100%);
    border-right: 2px solid #5a421b;
    border-radius: 4px 0 0 4px;
    box-shadow: inset 10px 0 15px rgba(0,0,0,0.95);
    justify-content: flex-start;
    padding-left: 8px;
}

.tunnel-portal.tunnel-right {
    right: 0;
    background: linear-gradient(to left, #0a0603 0%, #100a06 40%, rgba(16, 10, 6, 0.8) 75%, transparent 100%);
    border-left: 2px solid #5a421b;
    border-radius: 0 4px 4px 0;
    box-shadow: inset -10px 0 15px rgba(0,0,0,0.95);
    justify-content: flex-end;
    padding-right: 8px;
}

.tunnel-mark {
    font-size: 0.75rem;
    color: #8c734b;
    text-shadow: 0 0 4px rgba(0,0,0,0.9);
    opacity: 0.7;
}

/* Pista interior entre los dos túneles */
#dialogue-track {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
}

/* Lema de reposo cuando no hay conversación */
.dialogue-idle-state {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #8c734b;
    font-size: 0.78rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    transition: opacity 0.3s ease;
    user-select: none;
}

#hud-dialogue-area.has-dialogue .dialogue-idle-state {
    display: none;
    opacity: 0;
}

/* El 'Tren' de conversación que avanza de derecha a izquierda */
.dialogue-train-content {
    position: absolute;
    left: 0;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    will-change: transform;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#hud-dialogue-area.has-dialogue .dialogue-train-content {
    opacity: 1;
    pointer-events: auto;
}

.dialogue-wagon {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    margin-right: 80px;
}

.train-speaker {
    color: #ffd700;
    font-weight: 700;
    font-family: 'Cinzel', serif;
    font-size: 0.98rem;
    letter-spacing: 1.5px;
    margin-right: 8px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.65);
}

.train-text {
    color: #fff6db;
    font-family: 'MedievalSharp', 'Cinzel', serif;
    font-size: 1.05rem;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.95);
}

.train-heraldry {
    color: #ffd700;
    font-size: 0.85rem;
    margin-left: 12px;
    opacity: 0.8;
}

/* Franja Inferior: 6 Ranuras de Inventario en Hornacinas Góticas */
#inventory-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.inv-slot {
    position: relative;
    width: 48px;
    height: 48px;
    background: radial-gradient(circle at 50% 40%, #1a140e 0%, #0c0805 100%);
    border: 2px solid #5a421b;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.95), 0 2px 5px rgba(0,0,0,0.6);
    transition: all 0.25s ease;
    cursor: pointer;
}

.inv-slot::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 10px;
    border-top: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 3px 3px 0 0;
    pointer-events: none;
}

.inv-slot:hover {
    border-color: #d4af37;
    transform: translateY(-2px);
    box-shadow: inset 0 0 8px rgba(0,0,0,0.9), 0 0 12px rgba(212, 175, 55, 0.5);
}

.slot-num {
    font-family: 'Cinzel', serif;
    font-size: 0.72rem;
    color: rgba(184, 151, 66, 0.35);
    font-weight: 700;
    pointer-events: none;
    transition: color 0.2s;
}

.inv-slot:hover .slot-num {
    color: rgba(255, 215, 0, 0.85);
}

.slot-item {
    font-size: 1.75rem;
    line-height: 1;
    pointer-events: none;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.85));
    display: inline-block;
    transition: transform 0.15s ease-out;
}

.inv-slot:hover .slot-item {
    transform: scale(1.12);
}

.inv-slot.has-item { border-color: #b8973f; }
.inv-slot.item-active { border-color: #ffb855; box-shadow: inset 0 0 10px rgba(0,0,0,0.9), 0 0 14px rgba(255,160,60,0.7); }
.inv-slot.item-active .slot-item { filter: none; }

/* Panel Derecho: Obsequium / Sospecha del Alcaide */
#status-panel {
    width: 220px;
    height: 104px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    text-align: center;
}

.status-header-label {
    font-size: 0.68rem;
    color: #9f824c;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 5px;
}

.status-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}

#suspicion-eye-frame {
    width: 32px;
    height: 32px;
    border: 1px solid #7d5e23;
    border-radius: 50%;
    background: radial-gradient(circle, #2a0b0b 0%, #0d0404 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(180, 20, 20, 0.4), inset 0 0 4px #000;
}

#suspicion-eye {
    font-size: 1.25rem;
    filter: drop-shadow(0 0 6px #ff2200);
    transition: transform 0.3s, opacity 0.3s;
}

#suspicion-bar-container {
    flex-grow: 1;
    height: 14px;
    background: #080504;
    border: 1.5px solid #6b4e1b;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.95);
}

.bar-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(90deg, transparent 0px, transparent 15px, rgba(0,0,0,0.6) 15px, rgba(0,0,0,0.6) 17px);
    pointer-events: none;
    z-index: 2;
}

#suspicion-fill {
    height: 100%;
    background: linear-gradient(to right, #6d1010, #b21e07 60%, #ff4500 100%);
    box-shadow: 0 0 10px #ff3300;
    transition: width 0.4s ease;
}

.status-footer-sub {
    font-size: 0.62rem;
    color: #7d653f;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 5px;
}

/* Music Control Button */
#music-control {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #d4af37;
    color: #d4af37;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 200;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#music-control:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    transform: scale(1.1);
}
