:root {
    --primary-color: #0a1728;
    --secondary-color: #1e3a5f;
    --accent-color: #64ffda;
    --text-color: #e0e0e0;
    --choice-color: #2196f3;
    --meta-color: #ff6b35;
    --glitch-color: #ff0040;
}

/* Enhanced Glitch Effects for Reality Bleed */
.glitch-text {
    position: relative;
    font-family: 'Courier New', monospace;
    color: #ff0040;
    background: rgba(0, 0, 0, 0.8);
    padding: 5px;
    margin: 5px 0;
    border-left: 3px solid #ff0040;
    animation: glitch-flicker 2s infinite;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    z-index: -1;
}

.glitch-text::before {
    animation: glitch-anim-1 0.2s infinite linear alternate-reverse;
    color: #ff0040;
    z-index: -1;
}

.glitch-text::after {
    animation: glitch-anim-2 0.2s infinite linear alternate-reverse;
    color: #00ffff;
    z-index: -2;
}

@keyframes glitch-flicker {
    0%, 100% { opacity: 1; }
    2% { opacity: 0.8; }
    4% { opacity: 1; }
    8% { opacity: 0.9; }
    70% { opacity: 1; }
    72% { opacity: 0.7; }
    74% { opacity: 1; }
}

@keyframes glitch-anim-1 {
    0% { clip-path: inset(40% 0 61% 0); }
    20% { clip-path: inset(92% 0 1% 0); }
    40% { clip-path: inset(43% 0 1% 0); }
    60% { clip-path: inset(25% 0 58% 0); }
    80% { clip-path: inset(54% 0 7% 0); }
    100% { clip-path: inset(58% 0 43% 0); }
}

@keyframes glitch-anim-2 {
    0% { clip-path: inset(25% 0 58% 0); }
    20% { clip-path: inset(54% 0 7% 0); }
    40% { clip-path: inset(58% 0 43% 0); }
    60% { clip-path: inset(40% 0 61% 0); }
    80% { clip-path: inset(92% 0 1% 0); }
    100% { clip-path: inset(43% 0 1% 0); }
}

/* Enhanced System Alerts */
.system-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 0, 64, 0.95);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    z-index: 1000;
    animation: slide-in-alert 0.3s ease-out;
    max-width: 300px;
    word-wrap: break-word;
    box-shadow: 0 0 20px rgba(255, 0, 64, 0.5);
    border: 1px solid #ff0040;
}

@keyframes slide-in-alert {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Data Corruption Effects */
.data-corruption {
    animation: dataCorrupt 0.5s ease-in-out;
    filter: contrast(150%) brightness(120%);
}

@keyframes dataCorrupt {
    0% { transform: translateX(0) scale(1); }
    25% { transform: translateX(-2px) scale(1.02) skew(1deg); }
    50% { transform: translateX(2px) scale(0.98) skew(-1deg); }
    75% { transform: translateX(-1px) scale(1.01) skew(0.5deg); }
    100% { transform: translateX(0) scale(1) skew(0deg); }
}

/* Reality Breach Visual Effects */
.reality-breach {
    animation: realityBreach 1s ease-in-out;
    position: relative;
    overflow: hidden;
}

.reality-breach::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 0, 64, 0.2), transparent);
    animation: scanline 2s linear infinite;
}

@keyframes realityBreach {
    0% { filter: brightness(1) contrast(1); }
    25% { filter: brightness(1.3) contrast(1.5) hue-rotate(180deg); }
    50% { filter: brightness(0.7) contrast(0.8) hue-rotate(90deg) saturate(2); }
    75% { filter: brightness(1.2) contrast(1.3) hue-rotate(270deg); }
    100% { filter: brightness(1) contrast(1); }
}

@keyframes scanline {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Text Scramble Effect */
.scramble-text {
    animation: textScramble 0.6s ease-in-out;
}

@keyframes textScramble {
    0% { transform: translateX(0); }
    10% { transform: translateX(-2px) skew(-1deg); }
    20% { transform: translateX(2px) skew(1deg); }
    30% { transform: translateX(-1px) skew(-0.5deg); }
    40% { transform: translateX(1px) skew(0.5deg); }
    50% { transform: translateX(-0.5px) skew(-0.2deg); }
    60% { transform: translateX(0.5px) skew(0.2deg); }
    70% { transform: translateX(0) skew(0deg); }
    100% { transform: translateX(0) skew(0deg); }
}

/* Screen Distortion Effects */
.screen-distortion {
    animation: screenDistort 1.5s ease-in-out;
}

@keyframes screenDistort {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.01) rotate(0.2deg); }
    50% { transform: scale(0.99) rotate(-0.2deg); }
    75% { transform: scale(1.005) rotate(0.1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Protocol Warning Styles */
.protocol-warning {
    background: rgba(255, 0, 64, 0.1);
    border: 2px solid var(--glitch-color);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    animation: protocolAlert 2s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.protocol-warning::before {
    content: '⚠️ PROTOCOL BREACH DETECTED ⚠️';
    position: absolute;
    top: -30px;
    left: 0;
    right: 0;
    background: var(--glitch-color);
    color: white;
    text-align: center;
    padding: 5px;
    font-size: 0.8em;
    font-weight: bold;
    transform: translateY(0);
    animation: warningBanner 3s ease-in-out infinite;
}

@keyframes protocolAlert {
    0% { box-shadow: 0 0 5px rgba(255, 0, 64, 0.3); }
    50% { box-shadow: 0 0 20px rgba(255, 0, 64, 0.6), inset 0 0 20px rgba(255, 0, 64, 0.1); }
    100% { box-shadow: 0 0 5px rgba(255, 0, 64, 0.3); }
}

@keyframes warningBanner {
    0% { transform: translateY(-100%); }
    10% { transform: translateY(0); }
    90% { transform: translateY(0); }
    100% { transform: translateY(-100%); }
}

/* Mouse Cursor Effects */
.cursor-glitch {
    cursor: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=='), auto;
}

.cursor-interference {
    cursor: crosshair;
    user-select: none;
}

/* Button Visual Corruption */
.choice-button.corrupted {
    background: linear-gradient(45deg, var(--glitch-color), #8b0000);
    animation: buttonCorrupt 0.5s ease-in-out;
    border-left: 4px solid var(--glitch-color);
    box-shadow: 0 0 15px rgba(255, 0, 64, 0.4);
}

@keyframes buttonCorrupt {
    0% { transform: translateX(0) scale(1); }
    25% { transform: translateX(-3px) scale(1.02) skew(-1deg); }
    50% { transform: translateX(3px) scale(0.98) skew(1deg); }
    75% { transform: translateX(-1px) scale(1.01) skew(-0.5deg); }
    100% { transform: translateX(0) scale(1) skew(0deg); }
}

/* Loading Interference */
.loading-interference {
    position: relative;
    overflow: hidden;
}

.loading-interference::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        rgba(255, 0, 64, 0.1) 2px,
        rgba(255, 0, 64, 0.1) 4px
    );
    animation: interference 0.2s linear infinite;
    z-index: 1;
}

@keyframes interference {
    0% { transform: translateX(0); }
    100% { transform: translateX(4px); }
}

/* Fade out animation for system alerts */
.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

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

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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

.story-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 20px;
}

h1 {
    font-size: 2.5em;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color);
    margin-bottom: 10px;
    animation: pulse 2s infinite;
}

.meta-note {
    font-size: 0.9em;
    color: var(--meta-color);
    font-style: italic;
}

#story-content {
    background: rgba(30, 58, 95, 0.3);
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid var(--accent-color);
    font-size: 1.1em;
    line-height: 1.6;
    min-height: 300px;
}

#choices-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.choice-button {
    background: linear-gradient(45deg, var(--choice-color), #1976d2);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
    text-align: left;
    border-left: 4px solid transparent;
}

.choice-button:hover {
    background: linear-gradient(45deg, #1976d2, var(--choice-color));
    border-left: 4px solid var(--accent-color);
    transform: translateX(10px);
    box-shadow: 0 4px 15px rgba(100, 255, 218, 0.3);
}

.meta-panel {
    position: fixed;
    top: 70px;
    right: -300px;
    width: 280px;
    height: auto;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--meta-color);
    border-radius: 10px;
    padding: 20px;
    font-size: 0.9em;
    transition: right 0.3s ease;
    z-index: 1000;
}

.meta-panel.open {
    right: 20px;
}

.meta-panel h3 {
    color: var(--meta-color);
    margin-bottom: 15px;
    text-align: center;
}

.meta-panel div {
    margin-bottom: 10px;
    padding: 5px;
    background: rgba(255, 107, 53, 0.1);
    border-radius: 4px;
}

#meta-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--meta-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    z-index: 1001;
}

#meta-toggle:hover {
    background: #e55a2b;
}

.glitch-text {
    animation: glitch 0.5s infinite;
    color: var(--glitch-color);
}

.fade-in {
    animation: fadeIn 1s ease-in;
}

.reality-shift {
    animation: realityShift 2s ease-in-out;
}

/* Text Distortion Effects */
.reality-word {
    color: var(--accent-color);
    font-weight: bold;
    transition: all 0.3s ease;
}

.reality-word:hover {
    text-shadow: 0 0 10px var(--accent-color);
    cursor: help;
}

.uncertain-text {
    animation: fadeUncertain 3s ease-in-out;
    opacity: 0.7;
}

.distorted-text {
    font-family: 'Times New Roman', serif;
    color: var(--meta-color);
    font-style: italic;
    transition: all 0.5s ease;
}

.scrambled-text {
    animation: scramble 2s ease-in-out;
}

/* Choice Button Effects */
.choice-button.glitched {
    animation: buttonGlitch 0.3s ease-in-out;
    transform: translateX(5px);
}

.choice-button.displaced {
    margin-left: 50px;
    transition: margin-left 1s ease-in-out;
}

.choice-button.multi-click {
    opacity: 0.7;
    transform: scale(0.98);
    transition: all 0.2s ease;
}

/* Mouse Response Effects */
.sticky-cursor {
    cursor: wait !important;
    user-select: none;
}

.strange-selection {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.strange-selection::selection {
    background: var(--glitch-color);
    color: white;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

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

@keyframes glitch {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

@keyframes realityShift {
    0% { filter: brightness(1) contrast(1); }
    25% { filter: brightness(1.2) contrast(1.5); }
    50% { filter: brightness(0.8) contrast(0.5) hue-rotate(90deg); }
    75% { filter: brightness(1.1) contrast(1.2); }
    100% { filter: brightness(1) contrast(1); }
}

@keyframes fadeUncertain {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

@keyframes scramble {
    0% { transform: translateX(0); }
    10% { transform: translateX(-1px) skew(1deg); }
    20% { transform: translateX(1px) skew(-1deg); }
    30% { transform: translateX(-1px) skew(1deg); }
    40% { transform: translateX(1px) skew(-1deg); }
    50% { transform: translateX(0) skew(0deg); }
    100% { transform: translateX(0) skew(0deg); }
}

@keyframes buttonGlitch {
    0% { transform: translateX(0); }
    25% { transform: translateX(-3px) skew(-2deg); }
    50% { transform: translateX(3px) skew(2deg); }
    75% { transform: translateX(-1px) skew(-1deg); }
    100% { transform: translateX(0) skew(0deg); }
}

.agent-note {
    color: var(--meta-color);
    font-style: italic;
    font-size: 0.8em;
    margin: 10px 0;
    padding: 5px;
    background: rgba(255, 107, 53, 0.1);
    border-left: 2px solid var(--meta-color);
}

/* Audio visualizer for sound effects */
.audio-indicator {
    position: fixed;
    top: 50px;
    right: 20px;
    width: 20px;
    height: 20px;
    background: var(--glitch-color);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.audio-indicator.active {
    opacity: 0.7;
    animation: pulse 0.5s infinite;
}

/* Error handling styles */
.system-error {
    background: rgba(255, 0, 64, 0.2);
    border: 2px solid var(--glitch-color);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    color: var(--glitch-color);
    text-align: center;
}

.system-error h2 {
    color: var(--glitch-color);
    margin-bottom: 10px;
}

/* Loading states */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

.loading::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-color);
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1000;
}

/* Better accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #1a1a1a;
        --text-color: #ffffff;
        --accent-color: #00ff00;
    }
}

@media (max-width: 768px) {
    .story-container {
        padding: 10px;
    }
    
    .meta-panel {
        width: 90%;
        right: -90%;
    }
    
    .meta-panel.open {
        right: 5%;
    }
    
    h1 {
        font-size: 2em;
    }
    
    #story-content {
        padding: 20px;
        font-size: 1em;
    }
    
    .choice-button {
        padding: 12px 16px;
        font-size: 0.9em;
    }
}