:root {
    --phasmo-bg: #050505;
    --phasmo-panel: rgba(20, 20, 20, 0.85);
    --phasmo-panel-border: #333;
    --phasmo-text: #e0e0e0;
    --phasmo-text-dim: #888;

    --phasmo-accent: #5c8a8a;
    --phasmo-accent-glow: rgba(92, 138, 138, 0.4);

    --phasmo-highlight: #85e0e0;
    --phasmo-danger: #ff4d4d;
    --phasmo-success: #4dff4d;

    --font-display: 'Creepster', cursive;
    --font-ui: 'Jura', sans-serif;
}

html {
    overflow-y: scroll;
}

body {
    background-color: var(--phasmo-bg);
    color: var(--phasmo-text);
    font-family: var(--font-ui);
    margin: 0;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- ATMOSPHERIC EFFECTS --- */

/* Vignette: Darkens the corners */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 50%, rgba(0,0,0,0.8) 100%);
    pointer-events: none;
    z-index: 998;
}

/* Scanlines: Horizontal lines like an old monitor */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.2) 50%,
        rgba(0,0,0,0.2)
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.3;
}

/* Noise: Canvas-based animated static grain */
#noise-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    opacity: 0.06;
}

/* Flicker Animation for text/elements */
@keyframes flicker {
    0% { opacity: 1; }
    3% { opacity: 0.4; }
    6% { opacity: 1; }
    7% { opacity: 0.4; }
    8% { opacity: 1; }
    9% { opacity: 1; }
    10% { opacity: 0.1; }
    11% { opacity: 1; }
    100% { opacity: 1; }
}

.phasmo-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Header */
.phasmo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--phasmo-panel-border);
    background: linear-gradient(90deg, rgba(21,21,21,0) 0%, rgba(92,138,138,0.05) 50%, rgba(21,21,21,0) 100%);
    flex-shrink: 0;
}

.phasmo-header h1 {
    font-family: var(--font-display);
    font-size: 3.5rem;
    color: var(--phasmo-highlight);
    margin: 0;
    text-shadow: 0 0 15px var(--phasmo-accent-glow);
    letter-spacing: 2px;
    animation: flicker 10s infinite; /* Subtle flicker on title */
}

.phasmo-header .subtitle {
    font-family: var(--font-ui);
    font-size: 1.2rem;
    color: var(--phasmo-text-dim);
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-left: 15px;
}

/* Layout */
.phasmo-grid {
    display: grid;
    grid-template-columns: 300px 250px 1fr;
    gap: 25px;
    margin-bottom: 25px;
    flex-grow: 1;
    min-height: 0; /* Allows grid to shrink inside flex container */
}

@media (max-width: 1200px) {
    .phasmo-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        height: auto;
        min-height: 800px;
    }
    .details-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .phasmo-container {
        height: auto;
        display: block;
    }
    .phasmo-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        height: auto;
        min-height: 0;
    }
    .phasmo-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    .phasmo-header .subtitle {
        display: block;
        margin: 5px 0 0 0;
    }
    .panel {
        min-height: 400px;
    }
}

/* Panels */
.panel {
    background-color: var(--phasmo-panel);
    border: 1px solid var(--phasmo-panel-border);
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px); /* Glass effect */
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--phasmo-accent), transparent);
    opacity: 0.5;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    flex-shrink: 0;
}

h2 {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--phasmo-highlight);
    margin: 0;
    display: flex;
    align-items: center;
}

h2::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--phasmo-accent);
    margin-right: 10px;
    box-shadow: 0 0 8px var(--phasmo-accent);
}

/* Evidence Grid */
.evidence-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 20px;
    flex-grow: 1;
    overflow-y: auto;
}

.evidence-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 12px 15px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
    min-height: 45px;
}

.evidence-item:hover {
    background: rgba(255,255,255,0.08);
    transform: translateX(5px);
    box-shadow: -5px 0 10px rgba(0,0,0,0.5);
}

.evidence-item::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #444;
    transition: all 0.2s;
}

/* Selected State */
.evidence-item.selected {
    background: rgba(77, 255, 77, 0.1);
    border-color: var(--phasmo-success);
    color: var(--phasmo-success);
    box-shadow: 0 0 10px rgba(77, 255, 77, 0.1) inset;
}

.evidence-item.selected::after {
    background-color: var(--phasmo-success);
    border-color: var(--phasmo-success);
    box-shadow: 0 0 8px var(--phasmo-success);
}

/* Excluded State */
.evidence-item.excluded {
    background: rgba(255, 77, 77, 0.05);
    border-color: var(--phasmo-danger);
    color: var(--phasmo-text-dim);
    text-decoration: line-through;
    opacity: 0.6;
}

.evidence-item.excluded::after {
    border-color: var(--phasmo-danger);
    background: transparent;
    position: relative;
}

.evidence-item.disabled {
    opacity: 0.2;
    pointer-events: none;
    filter: grayscale(100%);
}

/* Ghost List */
.ghost-list-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
    margin-right: -5px;
}

.ghost-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ghost-item {
    padding: 10px 15px;
    background: rgba(255,255,255,0.03);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.ghost-item:hover {
    background: rgba(255,255,255,0.08);
    padding-left: 20px;
}

.ghost-item.active-selection {
    background: linear-gradient(90deg, rgba(92,138,138,0.3), transparent);
    border-left-color: var(--phasmo-highlight);
    color: var(--phasmo-highlight);
    text-shadow: 0 0 8px rgba(133, 224, 224, 0.4);
}

.ghost-item.impossible {
    opacity: 0.15;
    order: 100;
    font-size: 0.9rem;
}

/* Ghost Details */
.ghost-details-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--phasmo-text-dim);
    opacity: 0.5;
}

.empty-state .ghost-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.ghost-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--phasmo-panel-border);
    padding-bottom: 15px;
    flex-shrink: 0;
}

.ghost-name {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--phasmo-highlight);
    letter-spacing: 2px;
}

.ghost-evidences {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-shrink: 0;
}

.ghost-evidence-tag {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--phasmo-accent);
    color: var(--phasmo-highlight);
    padding: 6px 12px;
    border-radius: 2px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ghost-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.ghost-info-box {
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 4px;
    border-left: 2px solid var(--phasmo-panel-border);
}

.ghost-info-box.full-width {
    grid-column: 1 / -1;
}

.ghost-info-label {
    display: block;
    color: var(--phasmo-text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.ghost-info-value {
    font-size: 1.1rem;
    line-height: 1.5;
}

.ghost-info-box.strength { border-left-color: var(--phasmo-success); }
.ghost-info-box.weakness { border-left-color: var(--phasmo-danger); }

/* Buttons */
.phasmo-btn {
    background: var(--phasmo-accent);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 2px;
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.phasmo-btn:hover {
    background: #6ba3a3;
    box-shadow: 0 0 15px var(--phasmo-accent-glow);
}

.phasmo-btn.outline {
    background: transparent;
    border: 1px solid var(--phasmo-accent);
    color: var(--phasmo-highlight);
}

.phasmo-btn.outline:hover {
    background: rgba(92, 138, 138, 0.1);
}

.phasmo-btn.reset {
    background: #2a2a2a;
    color: #888;
    width: 100%;
    margin-top: auto;
    flex-shrink: 0;
}

.phasmo-btn.reset:hover {
    background: #333;
    color: #fff;
}

.phasmo-btn.danger {
    background: rgba(255, 77, 77, 0.2);
    color: var(--phasmo-danger);
    border: 1px solid rgba(255, 77, 77, 0.3);
}

.phasmo-btn.danger:hover {
    background: rgba(255, 77, 77, 0.3);
}

.phasmo-btn.small {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.phasmo-btn.icon-only {
    padding: 8px;
    width: 36px;
}

/* Session Controls */
.session-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    background: rgba(0,0,0,0.3);
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid #333;
}

#session-code-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid #444;
    color: #fff;
    padding: 8px;
    width: 80px;
    text-align: center;
    font-family: monospace;
    font-size: 1.1rem;
    text-transform: uppercase;
}

#session-code-input:focus {
    outline: none;
    border-color: var(--phasmo-highlight);
}

.session-label {
    color: var(--phasmo-text-dim);
    font-size: 0.8rem;
    font-weight: 700;
}

.code-display {
    font-family: monospace;
    font-size: 1.4rem;
    color: var(--phasmo-highlight);
    font-weight: 700;
    letter-spacing: 2px;
    margin: 0 10px;
    text-shadow: 0 0 10px var(--phasmo-accent-glow);
}

/* Extra Panel */
.extra-panel {
    flex-direction: row;
    gap: 40px;
    flex-shrink: 0;
}

.timer-section, .sanity-section {
    flex: 1;
}

.timer-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(0,0,0,0.2);
    padding: 20px;
    border-radius: 4px;
}

#timer-display {
    font-family: monospace;
    font-size: 3rem;
    color: var(--phasmo-highlight);
    text-shadow: 0 0 10px var(--phasmo-accent-glow);
}

#sanity-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

#sanity-list li {
    background: rgba(255,255,255,0.03);
    padding: 10px;
    border-radius: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 2px solid #444;
}

#sanity-list li span:first-child {
    font-weight: 700;
    color: var(--phasmo-highlight);
    font-size: 1.2rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* --- Tooltips (JS Based) --- */
.phasmo-tooltip {
    position: fixed;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--phasmo-accent);
    color: var(--phasmo-text);
    padding: 6px 10px;
    border-radius: 2px;
    font-size: 0.8rem;
    font-family: var(--font-ui);
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.1s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    max-width: 250px;
    line-height: 1.4;
}

.phasmo-tooltip.visible {
    opacity: 1;
}
