:root {
    --bg-color: #0b0e14;
    --accent-color: #72ffb6;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --surface: #161b22;
    --glow: 0 0 20px rgba(114, 255, 182, 0.2);
    --book-font: 'Georgia', serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
    box-shadow: var(--glow);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#observer-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #111827 0%, #0b0e14 100%);
    z-index: -1;
}

#app-container {
    width: 96%;
    max-width: 1400px;
    height: 90vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    padding: 20px 40px 10px 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.inline-actions {
    display: flex;
    gap: 15px;
    margin-top: 40px;
    padding: 20px 0;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 20px;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: 4px;
    font-size: 0.9rem;
    color: var(--accent-color);
    text-shadow: var(--glow);
}

.status-bar {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    gap: 20px;
}

#story-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 0 40px;
    margin-bottom: 10px;
    /* Reduced margin */
}

#narrative-content {
    font-size: 1.2rem;
    font-weight: 400;
    font-family: var(--book-font);
    line-height: 2;
    color: #cbd5e0;
}

#narrative-content h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.2rem;
    margin-bottom: 3rem;
    color: #fff;
    text-align: center;
}

.scene-header {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
    text-align: center;
    font-weight: 600;
    opacity: 0.9;
}

.system-msg {
    color: #f6ad55;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    display: block;
    text-align: center;
    margin: 20px 0;
    font-style: italic;
}

.content-body {
    max-width: 650px;
    margin: 0 auto;
}

#controls {
    display: flex;
    justify-content: center;
}

#action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

button,
.primary-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 12px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    display: inline-block;
}

button:hover,
.primary-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: var(--glow);
    transform: translateY(-2px);
}

.secondary-btn {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
    font-size: 0.7rem;
    opacity: 0.5;
}

.secondary-btn:hover {
    border-color: #fff;
    color: #fff;
    background: transparent;
    opacity: 1;
}

.fade-in {
    animation: fadeIn 1.2s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
        filter: blur(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* --- Archive / Memory Constellation Styles --- */
#diary-list {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    perspective: 1000px;
}

.memory-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
}

.memory-dot:hover {
    background: var(--accent-color);
    box-shadow: var(--glow), 0 0 30px var(--accent-color);
    transform: scale(1.5);
    z-index: 100;
}

.memory-dot.is-read {
    background: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-color);
}

.memory-dot.is-read::after {
    content: "";
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 1px solid var(--accent-color);
    border-radius: 50%;
    opacity: 0.3;
    animation: orbit 4s linear infinite;
}

@keyframes orbit {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.memory-tag {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(11, 14, 20, 0.98);
    backdrop-filter: blur(30px);
    border: 1px solid var(--accent-color);
    padding: clamp(20px, 5vw, 40px);
    border-radius: 24px;
    width: min(90%, 420px);
    max-height: 80vh;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.9), var(--glow);
    z-index: 2000;
    text-align: center;
}

.memory-tag.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.tag-close-hint {
    display: block;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.65rem;
    opacity: 0.5;
    font-style: italic;
    letter-spacing: 1px;
}

.memory-tag h3 {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1rem, 4vw, 1.3rem);
    color: var(--accent-color);
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.tag-summary-content {
    font-size: clamp(0.85rem, 3vw, 1.05rem);
    color: var(--text-primary);
    line-height: 1.8;
    margin-bottom: 30px;
    text-align: left;
    font-family: var(--book-font);
}

.tag-btn {
    width: 100%;
}

/* --- Content Overrides for Wide Screen --- */
.content-body {
    max-width: 750px;
    /* Slightly wider for better e-book feel on wide screen */
    margin: 0 auto;
}

/* --- Graph Styles --- */
#graph-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 14, 20, 0.95);
    backdrop-filter: blur(40px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#graph-overlay.hidden {
    display: none;
}

#observation-logs {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 24px;
    width: 90%;
    max-width: 800px;
    text-align: center;
    box-shadow: var(--glow);
}

.log-header {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    letter-spacing: 5px;
    color: var(--accent-color);
    margin-bottom: 30px;
}

#github-graph-container {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    grid-auto-flow: column;
    gap: 4px;
    margin-bottom: 20px;
}

.square {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: #161b22;
    transition: all 0.2s ease;
}

.square[style*="cursor: pointer"]:hover {
    transform: scale(1.3);
    z-index: 10;
    filter: brightness(1.5);
    box-shadow: 0 0 10px currentColor;
}

.square.level-0 {
    background: rgba(255, 255, 255, 0.03);
}

.square.level-1 {
    background: rgba(114, 255, 182, 0.1);
}

.square.level-2 {
    background: rgba(114, 255, 182, 0.3);
}

.square.level-3 {
    background: rgba(114, 255, 182, 0.6);
}

.square.level-4 {
    background: var(--accent-color);
    box-shadow: var(--glow);
}

.graph-legend {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* Modal Styles */
#observer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#observer-modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), var(--glow);
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 5px;
    color: var(--accent-color);
    margin-bottom: 20px;
    text-transform: uppercase;
}

.modal-content p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    color: #fff;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.danger-btn {
    background: rgba(255, 0, 80, 0.1);
    border: 1px solid #ff0050;
    color: #ff0050;
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.danger-btn:hover {
    background: #ff0050;
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 0, 80, 0.5);
    transform: translateY(-2px);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

footer {
    display: flex;
    flex-direction: row !important;
    gap: clamp(5px, 2vw, 15px);
    margin-top: auto;
    padding: 20px clamp(10px, 5vw, 40px);
    align-items: center;
    flex-wrap: nowrap;
    justify-content: space-between;
}

footer button {
    flex: 1;
    min-width: 0;
    padding: 10px 5px;
    font-size: clamp(0.6rem, 1.5vw, 0.8rem);
}

.footer-copyright {
    font-size: 0.65rem;
    color: var(--text-secondary);
    opacity: 0.5;
    font-family: 'Inter', sans-serif;
    letter-spacing: 1px;
    margin-left: auto;
}

@media (max-width: 768px) {
    #app-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        padding: 15px 10px 5px 10px;
        border: none;
    }

    #story-viewport {
        padding: 0 10px;
        margin-bottom: 5px;
    }

    #narrative-content {
        font-size: 1.1rem;
        line-height: 1.8;
    }

    #narrative-content h1 {
        font-size: 1.8rem;
    }

    footer {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 5px;
        justify-content: center;
    }

    .footer-copyright {
        width: 100%;
        text-align: center;
        margin: 5px 0 0 0;
        opacity: 0.4;
    }
}