:root {
    --bg-dark: #0a0d14;
    --panel-bg: rgba(16, 22, 34, 0.94);
    --panel-border: rgba(255, 255, 255, 0.12);
    --accent-red: #ef4444;
    --accent-gold: #f59e0b;
    --accent-blue: #51b5ed;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-body: 'Inter', sans-serif;
}

[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow: hidden;
}

.game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #000;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ==========================================================================
   HUD SUPERIOR
   ========================================================================== */
.hud-top {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 50;
    pointer-events: none;
}

.hud-zone, .hud-quest {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 8px 16px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.hud-zone {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    color: var(--accent-blue);
    font-weight: 700;
}

.hud-quest {
    flex: 1;
    max-width: 540px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid var(--accent-gold);
}

.quest-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: 0.08em;
}

#hud-quest-text {
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-badges {
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.badge-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(8px);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.badge-btn.ghost {
    color: var(--text-muted);
}

/* ==========================================================================
   PROMPT DE INTERACCIÓN [E]
   ========================================================================== */
.interact-prompt {
    position: absolute;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--accent-blue);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    z-index: 60;
    box-shadow: 0 0 20px rgba(81, 181, 237, 0.35);
    animation: bounceUp 1.4s infinite ease-in-out;
    pointer-events: none;
}

@keyframes bounceUp {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, -6px); }
}

.key-badge {
    background: var(--accent-blue);
    color: #000;
    font-family: var(--font-mono);
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
}

/* ==========================================================================
   TOAST DE EVIDENCIA
   ========================================================================== */
.evidence-toast {
    position: absolute;
    top: 76px;
    right: 20px;
    background: rgba(17, 24, 39, 0.96);
    border-left: 4px solid var(--accent-red);
    border-top: 1px solid var(--panel-border);
    border-right: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    gap: 14px;
    align-items: center;
    max-width: 380px;
    z-index: 70;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-icon {
    font-size: 28px;
}

.toast-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-red);
    letter-spacing: 0.08em;
}

.toast-content h4 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    margin: 2px 0;
}

.toast-content p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   CUADRO DE DIÁLOGO RPG
   ========================================================================== */
.dialog-box {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: min(840px, calc(100vw - 32px));
    min-height: 160px;
    background: rgba(13, 17, 26, 0.96);
    border: 2px solid var(--panel-border);
    border-radius: 18px;
    padding: 22px 26px;
    display: flex;
    gap: 20px;
    z-index: 80;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255,255,255,0.05);
    backdrop-filter: blur(16px);
    cursor: pointer;
}

.dialog-avatar {
    width: 72px;
    height: 72px;
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    flex-shrink: 0;
}

.dialog-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dialog-speaker {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 800;
    color: var(--accent-blue);
    margin-bottom: 6px;
}

.dialog-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-main);
    flex-grow: 1;
    min-height: 48px;
}

.dialog-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.dialog-choice-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid #334155;
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 8px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dialog-choice-btn:hover {
    background: var(--accent-blue);
    color: #000;
    border-color: var(--accent-blue);
    transform: translateX(4px);
}

.dialog-choice-btn.danger:hover {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.dialog-hint {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

/* ==========================================================================
   MODAL DE INVENTARIO Y EVIDENCIAS
   ========================================================================== */
.inventory-modal {
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 12, 0.88);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    padding: 20px;
}

.inv-shell {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 20px;
    width: min(800px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 28px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8);
}

.inv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.inv-header h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
    color: #fff;
}

.inv-close {
    background: #1e293b;
    border: 1px solid #334155;
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
}

.inv-close:hover {
    color: #fff;
    background: #334155;
}

.inv-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.inv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    overflow-y: auto;
    padding-right: 6px;
}

.inv-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inv-card-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-red);
    text-transform: uppercase;
}

.inv-card h4 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.inv-card p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   PANTALLA DE RESOLUCIÓN FINAL
   ========================================================================== */
.ending-screen {
    position: absolute;
    inset: 0;
    background: rgba(3, 5, 8, 0.94);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.ending-card {
    background: #0d121f;
    border: 2px solid var(--accent-red);
    border-radius: 24px;
    max-width: 680px;
    width: 100%;
    padding: 36px;
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.25);
}

.ending-tag {
    display: inline-block;
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.4);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 12px;
}

.ending-card h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 16px;
}

.ending-content {
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.7;
    margin-bottom: 24px;
}

.ending-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn-action {
    background: #1e293b;
    border: 1px solid #334155;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action.primary {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   HINT DE CONTROLES PC
   ========================================================================== */
.controls-hint {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    z-index: 40;
    pointer-events: none;
}

/* ==========================================================================
   CONTROLES TÁCTILES MÓVILES
   ========================================================================== */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 24px;
    left: 20px;
    right: 20px;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 70;
    pointer-events: none;
}

.dpad {
    position: relative;
    width: 140px;
    height: 140px;
    pointer-events: auto;
}

.d-btn {
    position: absolute;
    width: 44px;
    height: 44px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
}

.d-btn:active {
    background: var(--accent-blue);
    color: #000;
}

.d-up { top: 0; left: 48px; }
.d-down { bottom: 0; left: 48px; }
.d-left { top: 48px; left: 0; }
.d-right { top: 48px; right: 0; }

.action-cluster {
    pointer-events: auto;
}

.act-btn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 3px solid #fff;
    color: #000;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(81, 181, 237, 0.4);
    cursor: pointer;
    touch-action: none;
}

.act-btn small {
    font-size: 9px;
    letter-spacing: 0.05em;
}

.act-btn:active {
    transform: scale(0.92);
}

@media (max-width: 768px) {
    .mobile-controls {
        display: flex;
    }
    .controls-hint {
        display: none;
    }
    .hud-quest {
        max-width: 220px;
    }
    .dialog-box {
        bottom: 110px;
        flex-direction: column;
        padding: 16px;
    }
    .dialog-avatar {
        display: none;
    }
}
