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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Press Start 2P', monospace;
    cursor: none;
    -webkit-user-select: none;
    user-select: none;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#scene-container canvas {
    image-rendering: pixelated;
}

/* CRT Overlay */
#crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0,0,0,0.15) 0px,
        rgba(0,0,0,0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    mix-blend-mode: multiply;
}

#crt-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.4) 100%);
}

/* Link Flash */
#link-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 40;
    pointer-events: none;
    opacity: 0;
    background: #fff;
    transition: none;
}

#link-flash.active {
    opacity: 1;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.3) 2px, rgba(0,0,0,0.3) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 4px, rgba(100,100,100,0.2) 4px, rgba(100,100,100,0.2) 8px);
    animation: staticNoise 0.1s steps(3) infinite;
}

@keyframes staticNoise {
    0% { background-position: 0 0, 0 0; }
    33% { background-position: -3px 2px, 5px -1px; }
    66% { background-position: 2px -4px, -2px 3px; }
    100% { background-position: -1px 1px, 3px -2px; }
}

/* Glitch Overlay */
#glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 45;
    pointer-events: none;
    opacity: 0;
}

#glitch-overlay.color-invert {
    opacity: 1;
    background: #fff;
    mix-blend-mode: difference;
}

#glitch-overlay.chromatic {
    opacity: 1;
    backdrop-filter: blur(0px);
    box-shadow: 
        inset 5px 0 20px rgba(255,0,0,0.3),
        inset -5px 0 20px rgba(0,0,255,0.3);
}

/* Title Screen */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#title-bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#title-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

#title-text {
    font-family: 'VT323', monospace;
    font-size: clamp(60px, 15vw, 160px);
    color: #fff;
    text-shadow: 
        0 0 20px #ff00ff,
        0 0 40px #00ffff,
        0 0 60px #ffff00,
        4px 4px 0 #ff0066;
    animation: titleWobble 3s ease-in-out infinite, titleColor 5s linear infinite;
    letter-spacing: 20px;
}

#subtitle-text {
    font-family: 'VT323', monospace;
    font-size: clamp(16px, 4vw, 36px);
    color: #aaa;
    letter-spacing: 8px;
    margin-top: 10px;
    text-shadow: 0 0 10px #666;
    animation: subtitlePulse 2s ease-in-out infinite;
}

@keyframes titleWobble {
    0%, 100% { transform: rotate(-1deg) scale(1); }
    25% { transform: rotate(0.5deg) scale(1.02); }
    50% { transform: rotate(1deg) scale(1); }
    75% { transform: rotate(-0.5deg) scale(0.98); }
}

@keyframes titleColor {
    0% { text-shadow: 0 0 20px #ff00ff, 0 0 40px #00ffff, 0 0 60px #ffff00, 4px 4px 0 #ff0066; }
    33% { text-shadow: 0 0 20px #00ffff, 0 0 40px #ffff00, 0 0 60px #ff00ff, 4px 4px 0 #00ff66; }
    66% { text-shadow: 0 0 20px #ffff00, 0 0 40px #ff00ff, 0 0 60px #00ffff, 4px 4px 0 #6600ff; }
    100% { text-shadow: 0 0 20px #ff00ff, 0 0 40px #00ffff, 0 0 60px #ffff00, 4px 4px 0 #ff0066; }
}

@keyframes subtitlePulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

#enter-dream-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 2.5vw, 20px);
    color: #fff;
    background: transparent;
    border: 2px solid #fff;
    padding: 15px 40px;
    margin-top: 50px;
    cursor: pointer;
    animation: btnPulse 1.5s ease-in-out infinite;
    transition: all 0.2s;
    text-transform: uppercase;
}

#enter-dream-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: #ff00ff;
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
    transform: scale(1.05);
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255,255,255,0.3); }
    50% { box-shadow: 0 0 20px rgba(255,0,255,0.5), 0 0 40px rgba(0,255,255,0.2); }
}

#title-hint {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: #555;
    margin-top: 30px;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 60;
    pointer-events: none;
    padding: 15px;
}

#dream-day {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(10px, 2vw, 14px);
    color: rgba(255,255,255,0.7);
    text-shadow: 1px 1px 0 #000, 0 0 8px rgba(255,255,255,0.3);
    position: absolute;
    top: 15px;
    left: 15px;
}

#dream-type {
    font-family: 'VT323', monospace;
    font-size: clamp(14px, 2.5vw, 20px);
    color: rgba(255,255,255,0.5);
    text-shadow: 1px 1px 0 #000;
    position: absolute;
    top: 15px;
    right: 15px;
    letter-spacing: 3px;
}

#hud-bottom {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    pointer-events: all;
}

#hud-bottom button {
    width: 44px;
    height: 44px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#hud-bottom button:hover {
    background: rgba(255,255,255,0.15);
    border-color: #fff;
}

#wake-btn {
    animation: wakePulse 2s ease-in-out infinite;
}

@keyframes wakePulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Crosshair */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 55;
    color: rgba(255,255,255,0.4);
    font-family: 'VT323', monospace;
    font-size: 24px;
    pointer-events: none;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    z-index: 70;
    pointer-events: none;
}

#joystick-zone {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    pointer-events: all;
}

#joystick-base {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    position: relative;
}

#joystick-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    border: 2px solid rgba(255,255,255,0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
}

#look-zone {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 50%;
    height: 100%;
    pointer-events: all;
}

/* Journal Overlay */
#journal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

#journal-panel {
    width: min(90vw, 500px);
    max-height: 80vh;
    background: rgba(30,25,20,0.95);
    border: 2px solid rgba(200,180,140,0.4);
    border-radius: 4px;
    padding: 20px;
    overflow-y: auto;
    color: #c8b48c;
    box-shadow: 0 0 40px rgba(200,180,140,0.1);
}

#journal-panel h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    text-align: center;
    margin-bottom: 15px;
    color: #e8d8b0;
}

#journal-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.journal-tab {
    flex: 1;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 8px;
    background: rgba(200,180,140,0.1);
    border: 1px solid rgba(200,180,140,0.2);
    color: #c8b48c;
    cursor: pointer;
    transition: all 0.2s;
}

.journal-tab.active {
    background: rgba(200,180,140,0.25);
    border-color: rgba(200,180,140,0.5);
}

.journal-entry {
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(0,0,0,0.3);
    border-left: 3px solid rgba(200,180,140,0.3);
}

.journal-entry .je-day {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #e8d8b0;
    margin-bottom: 5px;
}

.journal-entry .je-type {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: #999;
    margin-bottom: 5px;
}

.journal-entry .je-envs {
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: #b8a87c;
    margin-bottom: 8px;
}

.journal-entry .je-desc {
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: #887858;
    line-height: 1.4;
    font-style: italic;
}

#journal-graph {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

#graph-canvas {
    border: 1px solid rgba(200,180,140,0.3);
    background: rgba(0,0,0,0.4);
}

#graph-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    font-family: 'VT323', monospace;
    font-size: 12px;
    color: rgba(200,180,140,0.5);
}

.gl-top { position: absolute; top: 5px; left: 50%; transform: translateX(-50%); }
.gl-bottom { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); }
.gl-left { position: absolute; left: 5px; top: 50%; transform: translateY(-50%); }
.gl-right { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }

.no-entries {
    font-family: 'VT323', monospace;
    font-size: 18px;
    color: #666;
    text-align: center;
    padding: 30px;
}

#close-journal {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: rgba(200,180,140,0.1);
    border: 1px solid rgba(200,180,140,0.3);
    color: #c8b48c;
    cursor: pointer;
    transition: all 0.2s;
}

#close-journal:hover {
    background: rgba(200,180,140,0.2);
}

/* Dream End Screen */
#dream-end {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInBlack 2s ease-in;
}

@keyframes fadeInBlack {
    from { opacity: 0; }
    to { opacity: 1; }
}

#dream-summary {
    text-align: center;
    color: #888;
    padding: 20px;
}

#dream-summary h2 {
    font-family: 'VT323', monospace;
    font-size: 36px;
    color: #aaa;
    margin-bottom: 20px;
    letter-spacing: 5px;
}

#summary-content {
    font-family: 'VT323', monospace;
    font-size: 18px;
    line-height: 1.8;
    max-width: 400px;
    margin: 0 auto 30px;
}

#summary-content .sum-day { color: #e8d8b0; font-size: 22px; }
#summary-content .sum-type { color: #999; }
#summary-content .sum-links { color: #777; }
#summary-content .sum-desc { color: #887858; font-style: italic; margin-top: 15px; }

#dream-again-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: #fff;
    background: transparent;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 12px 30px;
    cursor: pointer;
    transition: all 0.2s;
}

#dream-again-btn:hover {
    border-color: #fff;
    text-shadow: 0 0 10px #fff;
}

/* Footer */
#footer {
    position: fixed;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    font-family: 'VT323', monospace;
    font-size: 12px;
}

#footer a {
    color: rgba(255,255,255,0.15);
    text-decoration: none;
    animation: glitchText 4s steps(1) infinite;
}

@keyframes glitchText {
    0%, 90% { opacity: 0.15; transform: none; }
    91% { opacity: 0.5; transform: skewX(5deg); color: #ff0066; }
    92% { opacity: 0.15; transform: skewX(-3deg); color: #00ffff; }
    93%, 100% { opacity: 0.15; transform: none; color: rgba(255,255,255,0.15); }
}

/* Scrollbar */
#journal-panel::-webkit-scrollbar { width: 6px; }
#journal-panel::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
#journal-panel::-webkit-scrollbar-thumb { background: rgba(200,180,140,0.3); border-radius: 3px; }