

.npc-dialog {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: var(--z-dialog);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

body.immersive-camera-mode .npc-dialog {
    bottom: calc(116px + env(safe-area-inset-bottom, 0px));
}

.npc-dialog.hidden {
    display: none !important;
}

.npc-dialog.passive {
    opacity: 0.96;
}

.npc-dialog-portrait {
    width: 58px;
    height: 58px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    flex: 0 0 58px;
    background: linear-gradient(180deg, #14b8a6, #164e63);
    color: #fff;
    font-size: 26px;
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: 0 10px 20px rgba(0,0,0,0.28);
    pointer-events: auto;
}

.npc-dialog[data-speaker="guide"] .npc-dialog-portrait {
    background: linear-gradient(180deg, #38bdf8, #1d4ed8);
}

.npc-dialog[data-speaker="gatekeeper"] .npc-dialog-portrait {
    background: linear-gradient(180deg, #fb7185, #be123c);
}

.npc-dialog[data-speaker="judge"] .npc-dialog-portrait {
    background: linear-gradient(180deg, #67e8f9, #155e75);
}

.npc-dialog[data-speaker="host"] .npc-dialog-portrait {
    background: linear-gradient(180deg, #fbbf24, #d97706);
}

.npc-dialog[data-speaker="rescue"] .npc-dialog-portrait {
    background: linear-gradient(180deg, #fda4af, #e11d48);
}

.npc-dialog[data-speaker="lore"] .npc-dialog-portrait {
    background: linear-gradient(180deg, #86efac, #047857);
}

.npc-dialog[data-speaker="gatekeeper"] .npc-dialog-header strong {
    background: rgba(251, 113, 133, 0.18);
    border-color: rgba(251, 113, 133, 0.38);
}

.npc-dialog[data-speaker="judge"] .npc-dialog-header strong {
    background: rgba(103, 232, 249, 0.18);
    border-color: rgba(103, 232, 249, 0.4);
}

.npc-dialog[data-speaker="host"] .npc-dialog-header strong {
    background: rgba(251, 191, 36, 0.18);
    border-color: rgba(251, 191, 36, 0.42);
}

.npc-dialog[data-speaker="rescue"] .npc-dialog-header strong {
    background: rgba(253, 164, 175, 0.18);
    border-color: rgba(253, 164, 175, 0.42);
}

.npc-dialog[data-speaker="lore"] .npc-dialog-header strong {
    background: rgba(134, 239, 172, 0.18);
    border-color: rgba(134, 239, 172, 0.38);
}

.npc-dialog-card {
    flex: 1;
    min-width: 0;
    border-radius: 18px 18px 10px 18px;
    padding: 11px 13px 11px;
    background:
        linear-gradient(180deg, rgba(7, 12, 20, 0.96), rgba(16, 24, 40, 0.92)),
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 36%);
    border: 1px solid rgba(255,255,255,0.14);
    color: #fff;
    box-shadow: 0 18px 36px rgba(0,0,0,0.38);
    backdrop-filter: blur(12px);
    position: relative;
    pointer-events: auto;
}

.npc-dialog.passive .npc-dialog-card {
    box-shadow: 0 12px 28px rgba(0,0,0,0.28);
    border-color: rgba(255,255,255,0.1);
}

.npc-dialog.passive .npc-dialog-actions {
    display: none;
}

.npc-dialog-card::after {
    content: '';
    position: absolute;
    left: 18px;
    bottom: -10px;
    width: 18px;
    height: 18px;
    background: rgba(16, 24, 40, 0.95);
    border-left: 1px solid rgba(255,255,255,0.14);
    border-bottom: 1px solid rgba(255,255,255,0.14);
    transform: rotate(-45deg);
}

.npc-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.npc-dialog-header strong {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid rgba(125, 211, 252, 0.26);
    font-size: 12px;
    letter-spacing: 0.02em;
}

.npc-dialog-mood {
    font-size: 11px;
    color: rgba(255,255,255,0.72);
}

.npc-dialog-text {
    font-size: 13px;
    line-height: 1.58;
    white-space: pre-wrap;
}

.npc-dialog-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.npc-dialog-btn {
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #38bdf8, #22d3ee);
    color: #082f49;
    font-weight: 800;
    min-height: 40px;
    padding: 8px 16px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(56, 189, 248, 0.28);
}

.npc-dialog-btn::after {
    content: '▶';
    margin-left: 8px;
    font-size: 11px;
    opacity: 0.75;
}

.qp-container {
    position: relative;
    width: 200px;
    height: 120px;
}

.qp-paper {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    padding: 12px 14px;
    box-sizing: border-box;
    transform-origin: center;
    transition: transform 0.6s ease-in-out, opacity 0.6s ease-in-out;
}

.qp-paper-text {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(248, 250, 252, 0.96);
    display: flex;
    align-items: center;
    gap: 6px;
}

.qp-paper-text .qp-dot {
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.9);
    animation: qpDotBounce 1.1s infinite ease-in-out;
}

.qp-paper-text .qp-dot:nth-child(2) {
    animation-delay: 0.12s;
}

.qp-paper-text .qp-dot:nth-child(3) {
    animation-delay: 0.24s;
}

.qp-paper-text .qp-spinner {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid rgba(148, 163, 184, 0.5);
    border-top-color: #e5f3ff;
    animation: qpSpin 0.9s linear infinite;
}

.qp-plane {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.query-transit.sending .qp-paper {
    transform: scale(0.9);
    opacity: 1;
}

.query-transit.sending .qp-plane {
    animation: qpFlyOut 1.5s ease-in forwards;
}

.query-transit.returning .qp-plane {
    animation: qpFlyIn 1.5s ease-out forwards;
}

.query-transit.returning .qp-paper {
    transform: scale(1) rotate(0deg);
    opacity: 1;
}