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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Press Start 2P', monospace;
    color: #fff;
    width: 100vw;
    height: 100vh;
}

#start-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

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

#start-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

#start-title {
    font-size: clamp(3rem, 12vw, 8rem);
    letter-spacing: 0.3em;
    animation: titleWarp 3s ease-in-out infinite;
    background: linear-gradient(45deg, #ff0066, #ffff00, #00ff88, #0066ff, #ff0066);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleColor 4s linear infinite, titleWarp 3s ease-in-out infinite;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(255,0,102,0.5));
}

@keyframes titleColor {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes titleWarp {
    0%, 100% { transform: scaleX(1) scaleY(1); }
    25% { transform: scaleX(1.05) scaleY(0.97); }
    50% { transform: scaleX(0.97) scaleY(1.03); }
    75% { transform: scaleX(1.02) scaleY(0.98); }
}

#start-subtitle {
    font-size: clamp(0.6rem, 2.5vw, 1.2rem);
    letter-spacing: 0.5em;
    color: #aaa;
    margin-top: 10px;
}

#start-tagline {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    color: #666;
    margin-top: 15px;
    letter-spacing: 0.1em;
}

#dream-count-display {
    font-size: 0.6rem;
    color: #555;
    margin-top: 20px;
}

#fall-asleep-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(0.6rem, 2vw, 0.9rem);
    padding: 15px 40px;
    margin-top: 40px;
    background: transparent;
    border: 2px solid #ff0066;
    color: #ff0066;
    cursor: pointer;
    transition: all 0.3s;
    animation: btnPulse 2s ease-in-out infinite;
}

#fall-asleep-btn:hover {
    background: #ff0066;
    color: #000;
    box-shadow: 0 0 30px rgba(255,0,102,0.6);
}

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

#game-container {
    width: 100%; height: 100%;
    position: fixed;
    top: 0; left: 0;
}

#scene-container {
    width: 100%; height: 100%;
}

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

#hud {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    padding: 15px 20px;
    z-index: 50;
    pointer-events: none;
}

#day-counter {
    font-size: 0.5rem;
    color: rgba(255,255,255,0.3);
    animation: hudFlicker 4s ease-in-out infinite;
}

@keyframes hudFlicker {
    0%, 90%, 100% { opacity: 0.3; }
    92% { opacity: 0.05; }
    94% { opacity: 0.4; }
    96% { opacity: 0.1; }
}

#dream-timer-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 3px;
    background: rgba(255,255,255,0.1);
    z-index: 50;
    pointer-events: none;
}

#dream-timer-fill {
    height: 100%;
    width: 100%;
    background: rgba(255,255,255,0.25);
    transition: width 1s linear;
}

#vignette {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 40;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.7) 100%);
    animation: vignettePulse 6s ease-in-out infinite;
}

@keyframes vignettePulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

#flash-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(0.8rem, 3vw, 1.5rem);
    color: rgba(255,255,255,0.8);
    z-index: 45;
    pointer-events: none;
    opacity: 0;
    text-align: center;
    text-shadow: 0 0 10px rgba(255,0,0,0.5);
    letter-spacing: 0.3em;
}

#transition-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    background: #000;
}

#crosshair {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: rgba(255,255,255,0.15);
    z-index: 45;
    pointer-events: none;
}

#mobile-controls {
    position: fixed;
    bottom: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 60;
    pointer-events: none;
}

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

#joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.15);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#joystick-stick {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    position: absolute;
}

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

#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;
}

#journal-book {
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    background: #f5e6c8;
    color: #333;
    padding: 30px;
    overflow-y: auto;
    position: relative;
    box-shadow: 5px 5px 30px rgba(0,0,0,0.5);
    border-left: 4px solid #c9a96e;
}

#journal-title {
    font-family: 'Caveat', cursive;
    font-size: 2rem;
    color: #5a3e2b;
    margin-bottom: 20px;
    border-bottom: 2px solid #c9a96e;
    padding-bottom: 10px;
}

.journal-entry {
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    color: #4a3520;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #c9a96e;
    line-height: 1.6;
}

.journal-entry .entry-day {
    font-weight: 700;
    font-size: 1.3rem;
    color: #2a1810;
}

.journal-entry .entry-env {
    color: #8b4513;
    font-size: 0.95rem;
}

.journal-entry .entry-desc {
    font-style: italic;
    margin-top: 5px;
    color: #6b4423;
}

#journal-close, #wakeup-continue, #wakeup-journal, #instructions-ok {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    padding: 10px 20px;
    margin-top: 15px;
    background: transparent;
    border: 2px solid #5a3e2b;
    color: #5a3e2b;
    cursor: pointer;
    transition: all 0.2s;
}

#journal-close:hover {
    background: #5a3e2b;
    color: #f5e6c8;
}

#wakeup-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 150;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#wakeup-content {
    text-align: center;
    max-width: 400px;
    padding: 20px;
}

#wakeup-text {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #888;
}

#wakeup-env {
    font-size: 0.6rem;
    color: #555;
    margin-bottom: 15px;
}

#wakeup-desc {
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: #666;
    margin-bottom: 25px;
    font-style: italic;
    line-height: 1.6;
}

#wakeup-continue, #wakeup-journal {
    border-color: #555;
    color: #555;
    margin: 5px;
}

#wakeup-continue:hover, #wakeup-journal:hover {
    background: #555;
    color: #000;
}

#instructions-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 180;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

#instructions-content {
    text-align: center;
    max-width: 400px;
}

#instructions-content p {
    font-size: 0.55rem;
    color: #888;
    margin-bottom: 12px;
    line-height: 1.8;
}

.mobile-note {
    color: #555 !important;
}

#instructions-ok {
    border-color: #ff0066;
    color: #ff0066;
    margin-top: 20px;
}

#instructions-ok:hover {
    background: #ff0066;
    color: #000;
}

/* Scanline overlay */
#game-container::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0,0,0,0.08) 2px,
        rgba(0,0,0,0.08) 4px
    );
    pointer-events: none;
    z-index: 35;
}

#app-footer {
    position: fixed;
    bottom: 5px;
    right: 10px;
    z-index: 500;
    font-size: 0.4rem;
}

#app-footer a {
    color: rgba(255,255,255,0.15);
    text-decoration: none;
}

#app-footer a:hover {
    color: rgba(255,255,255,0.4);
}

@media (max-width: 768px) {
    #crosshair { display: none; }
    .mobile-note { display: block !important; }
}

@media (min-width: 769px) {
    .mobile-note { display: none; }
    #mobile-controls { display: none !important; }
}