/* Case-file narrative panels in mission */
.case-file-narrative {
    background: rgba(0, 212, 240, 0.06);
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
}

.case-file-narrative h3 {
    margin: 0 0 0.5rem 0;
    color: var(--accent);
    font-size: 1.1rem;
}

.case-file-narrative p {
    margin: 0;
}

@media (max-width: 900px) {
    .campaign-bar {
        grid-template-columns: 1fr;
    }
}

.mission-body {
    overflow: hidden;
}

.mission-layout {
    display: grid;
    grid-template-columns: 220px 1fr 260px;
    gap: 0.75rem;
    height: calc(100vh - 53px);
    padding: 0.75rem;
    box-sizing: border-box;
}

@media (min-width: 1600px) {
    .mission-layout {
        grid-template-columns: 240px 1fr 280px;
        gap: 1rem;
        padding: 1rem;
    }
}

.sidebar, .workspace, .right-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.sidebar h2 {
    margin-top: 0;
    color: var(--accent);
    font-size: 1.4rem;
}

/* Timeline */
#mission-timeline {
    margin-bottom: 1.25rem;
}

.timeline-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.timeline-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 999px;
    transition: width 0.6s ease;
}

.timeline-label {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: right;
}

/* Phase list */
.phase-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    position: relative;
}

.phase-list::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}

.phase-list li {
    min-height: var(--tap);
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.35rem;
    color: var(--muted);
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: color 0.2s, background 0.2s;
}

.phase-list li .phase-icon {
    flex-shrink: 0;
    image-rendering: pixelated;
    filter: grayscale(0.6);
    transition: filter 0.2s;
}

.phase-list li.active {
    background: rgba(0, 212, 240, 0.12);
    color: var(--accent);
    font-weight: 600;
}

.phase-list li.active .phase-icon {
    filter: grayscale(0);
}

.phase-list li.done {
    color: var(--success);
}

.phase-list li.done .phase-icon {
    filter: grayscale(0);
}

/* Meters */
.meter-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.meter-track {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 999px;
    transition: width 0.6s ease;
}

.meter-fill.entropy-fill {
    background: linear-gradient(90deg, var(--entropy), var(--entropy-dim));
}

.budget-meter {
    margin-top: 1rem;
}

.budget-meter[hidden] {
    display: none;
}

/* Workspace */
.workspace {
    padding: 1.25rem 1.5rem;
    position: relative;
}

.workspace::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 212, 240, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 240, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    border-radius: var(--radius);
    pointer-events: none;
    animation: gridDrift 20s linear infinite;
}

@keyframes gridDrift {
    from { background-position: 0 0, 0 0; }
    to { background-position: 40px 40px, 40px 40px; }
}

.workspace::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 212, 240, 0.04) 50%, transparent 100%);
    background-size: 100% 120px;
    border-radius: var(--radius);
    pointer-events: none;
    animation: scanMove 5s linear infinite;
}

@keyframes scanMove {
    from { background-position: 0 -120px; }
    to { background-position: 0 calc(100% + 120px); }
}

.workspace > * {
    position: relative;
    z-index: 1;
}

.workspace.animating {
    animation: fadeIn 0.35s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.workspace h2 {
    margin-top: 0;
    color: var(--accent);
    font-size: 1.6rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.workspace h3 {
    color: var(--entropy);
    margin-top: 1.5rem;
}

/* Crunch overlay */
.crunch-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    overflow: hidden;
    pointer-events: none;
}

.crunch-overlay.active {
    pointer-events: all;
}

.crunch-backdrop {
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(11, 13, 18, 0.78), rgba(11, 13, 18, 0.92)), url('/static/images/hero.png') center/cover no-repeat;
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.crunch-overlay.active .crunch-backdrop {
    opacity: 1;
}

.crunch-content {
    position: relative;
    text-align: center;
    max-width: 520px;
    padding: 2rem;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.crunch-overlay.active .crunch-content {
    opacity: 1;
    transform: scale(1);
}

.crunch-avatar {
    width: 140px;
    height: 140px;
    margin: 0 auto 1.25rem;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(255, 152, 0, 0.45);
    animation: crunchPulse 1.4s ease-in-out infinite;
    position: relative;
}

.crunch-avatar .sprite {
    margin: 6px auto 0;
    image-rendering: pixelated;
}

.crunch-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.crunch-avatar::after {
    content: '';
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 152, 0, 0.4);
    animation: spin 8s linear infinite;
}

.crunch-desk {
    margin: 0 auto 1rem;
    opacity: 0.9;
}

.crunch-desk .data-bar {
    animation: dataBar 1.2s ease-in-out infinite alternate;
}

.crunch-desk .data-dot {
    animation: dataDot 0.9s ease-in-out infinite alternate;
}

@keyframes dataBar {
    0% { opacity: 0.5; transform: scaleX(0.85); }
    100% { opacity: 1; transform: scaleX(1); }
}

@keyframes dataDot {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

@keyframes crunchPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(255, 152, 0, 0.45); }
    50% { transform: scale(1.06); box-shadow: 0 0 64px rgba(255, 152, 0, 0.65); }
}

.crunch-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1rem;
}

.crunch-title::after {
    content: '';
    display: inline-block;
    width: 0;
    animation: thinkingDots 1.2s steps(4, end) infinite;
}

@keyframes thinkingDots {
    0% { width: 0; }
    100% { width: 2.2em; }
}

.crunch-terminal {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    min-height: 100px;
    max-height: 140px;
    overflow: hidden;
    text-align: left;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.crunch-terminal .line {
    display: block;
    animation: terminalIn 0.25s ease forwards;
}

@keyframes terminalIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.crunch-progress {
    width: 240px;
    height: 6px;
    background: var(--bg);
    border-radius: 999px;
    margin: 0 auto;
    overflow: hidden;
}

.crunch-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 999px;
    transition: width 0.2s linear;
}

/* Phase hero banner */
.phase-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin: -1.25rem -1.5rem 1.25rem;
    background: linear-gradient(90deg, rgba(0, 212, 240, 0.12), transparent);
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.phase-hero svg,
.phase-hero .sprite.phase-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    color: var(--accent);
    filter: drop-shadow(0 0 12px rgba(0, 212, 240, 0.35));
    image-rendering: pixelated;
}

.phase-hero .hero-text h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.5rem;
}

.phase-hero .hero-text p {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Right panel */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.entropy-panel {
    text-align: center;
}

.entropy-avatar {
    width: 120px;
    height: 120px;
    margin: 0 auto 0.75rem;
    position: relative;
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.entropy-avatar.sprite {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    filter: drop-shadow(0 0 16px rgba(255, 152, 0, 0.35));
    transition: filter 0.3s;
    image-rendering: pixelated;
}

.entropy-avatar.thinking {
    animation: float 1.5s ease-in-out infinite, pulse 1.2s ease-in-out infinite;
}

.entropy-avatar.concerned.sprite {
    filter: drop-shadow(0 0 20px rgba(255, 82, 82, 0.5));
}

.entropy-avatar.happy.sprite {
    filter: drop-shadow(0 0 24px rgba(105, 240, 174, 0.45));
}

.entropy-avatar.calm.sprite {
    filter: drop-shadow(0 0 16px rgba(255, 152, 0, 0.35));
}

@keyframes pulse {
    0%, 100% { transform: scale(1) translateY(-8px); }
    50% { transform: scale(1.04) translateY(-8px); }
}

.entropy-panel h3,
.entropy-panel h4 {
    margin: 0 0 0.5rem 0;
    color: var(--entropy);
    font-size: 1.1rem;
}

.entropy-panel .message {
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    min-height: 3.5rem;
}

.stakeholder-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.stakeholder-row:last-child {
    border-bottom: none;
}

.stakeholder-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #000;
    flex-shrink: 0;
    overflow: hidden;
}

.stakeholder-avatar svg {
    width: 60%;
    height: 60%;
}

.stakeholder-avatar.sprite {
    background: var(--panel);
    border: 2px solid;
    overflow: hidden;
}

.stakeholder-avatar.sprite .sprite {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    image-rendering: pixelated;
}

.stakeholder-info {
    flex: 1;
    min-width: 0;
}

.stakeholder-info .name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stakeholder-info .role {
    font-size: 0.75rem;
    color: var(--muted);
}

.stakeholder-pressure {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.log-entry {
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(42, 49, 64, 0.5);
    line-height: 1.4;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry .source {
    font-weight: 600;
    color: var(--accent);
}

.log-entry .source.entropy {
    color: var(--entropy);
}

.log-entry .source.system {
    color: var(--muted);
}

