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

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background: #000;
    cursor: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    contain: layout style paint;
}

#room {
    width: 100%;
    height: 100%;
    position: relative;
    background: #1a1a1a;
    overflow: hidden;
    contain: layout style paint;
    will-change: background-color;
}

#flashlight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
        transparent 0%, 
        transparent 150px, 
        rgba(0, 0, 0, 0.95) 200px,
        rgba(0, 0, 0, 0.98) 100%);
    pointer-events: none;
    z-index: 10;
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: background;
}

.clue {
    position: absolute;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 5;
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    contain: layout style paint;
}

.clue:hover {
    transform: scale(1.2) translateZ(0);
}

.clue-icon {
    font-size: 40px;
    text-align: center;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    animation: pulse 2s ease-in-out infinite;
    will-change: filter;
    transform: translateZ(0);
}

@media (prefers-reduced-motion: no-preference) {
    @media (max-width: 768px) {
        .clue-icon {
            animation: none;
            filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.6));
        }
    }
}

.clue.found {
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

@keyframes pulse {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
    }
}

#exit-door {
    position: absolute;
    width: 100px;
    height: 150px;
    cursor: pointer;
    z-index: 5;
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
    contain: layout style paint;
}

.door-icon {
    font-size: 80px;
    text-align: center;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.3));
    will-change: filter;
    transform: translateZ(0);
}

#exit-door.locked {
    opacity: 0.5;
    cursor: not-allowed;
    transition: opacity 0.2s ease;
}

#exit-door.unlocked {
    animation: glow 1s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(255, 255, 255, 0.8));
    }
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 20;
    color: white;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    min-width: 200px;
    backdrop-filter: blur(10px);
    will-change: transform;
    transform: translateZ(0);
    contain: layout style paint;
}

#clues-found h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

#clue-count {
    color: #4CAF50;
    font-weight: bold;
}

#message {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    min-height: 40px;
    display: none;
    will-change: opacity, transform;
    transform: translateZ(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#message.show {
    display: block;
    opacity: 1;
    transform: translateY(0) translateZ(0);
}

#clue-display {
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    min-height: 60px;
    display: none;
    will-change: opacity, transform;
    transform: translateZ(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#clue-display.show {
    display: block;
    opacity: 1;
    transform: translateY(0) translateZ(0);
}

.clue-text {
    font-size: 14px;
    line-height: 1.6;
    color: #fff;
}

#level-info {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

#level-info h2 {
    font-size: 24px;
    color: #FFD700;
}

#level-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
    transition: opacity 0.5s ease;
}

#level-transition.hidden {
    opacity: 0;
    pointer-events: none;
}

#transition-content {
    text-align: center;
    color: white;
}

#transition-title {
    font-size: 48px;
    margin-bottom: 20px;
    color: #FFD700;
    animation: fadeIn 0.5s ease;
    will-change: opacity, transform;
    transform: translateZ(0);
}

#transition-text {
    font-size: 24px;
    animation: fadeIn 0.5s ease 0.3s both;
    will-change: opacity, transform;
    transform: translateZ(0);
}

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

/* Puzzle Modal Styles */
#puzzle-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
    transition: opacity 0.3s ease;
}

#puzzle-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

#puzzle-content {
    background: linear-gradient(160deg, rgba(13, 19, 41, 0.95), rgba(9, 12, 28, 0.98));
    border: 2px solid rgba(110, 231, 255, 0.3);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    transform: translateZ(0);
    position: relative;
}

#puzzle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(110, 231, 255, 0.2);
}

#puzzle-title {
    color: #FFD700;
    font-size: 1.8rem;
    margin: 0;
}

#puzzle-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
}

#puzzle-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

#puzzle-body {
    color: white;
}

#puzzle-question {
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
}

#puzzle-input-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

#puzzle-answer {
    flex: 1;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(110, 231, 255, 0.3);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

#puzzle-answer:focus {
    border-color: rgba(110, 231, 255, 0.6);
}

#puzzle-answer::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#puzzle-submit {
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, rgba(190, 242, 100, 0.9), rgba(56, 189, 248, 0.9));
    border: none;
    border-radius: 8px;
    color: rgba(15, 23, 42, 0.92);
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#puzzle-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(56, 189, 248, 0.4);
}

#puzzle-submit:active {
    transform: translateY(0);
}

#puzzle-hint-container {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid rgba(255, 215, 0, 0.5);
    border-radius: 5px;
}

#puzzle-hint {
    color: rgba(255, 215, 0, 0.9);
    font-style: italic;
    margin: 0;
}

#puzzle-feedback {
    margin-top: 1rem;
    padding: 0.8rem;
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#puzzle-feedback.success {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.4);
}

#puzzle-feedback.error {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.4);
}

@media (max-width: 768px) {
    #puzzle-content {
        padding: 1.5rem;
        width: 95%;
    }
    
    #puzzle-title {
        font-size: 1.5rem;
    }
    
    #puzzle-question {
        font-size: 1rem;
    }
    
    #puzzle-input-container {
        flex-direction: column;
    }
    
    #puzzle-submit {
        width: 100%;
    }
}

/* Custom cursor - only on desktop */
@media (hover: hover) and (pointer: fine) {
    body {
        cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="none" stroke="white" stroke-width="2"/><circle cx="12" cy="12" r="2" fill="white"/></svg>') 12 12, auto;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .clue-icon {
        animation-duration: 3s;
    }
    
    #transition-title {
        font-size: 32px;
    }
    
    #transition-text {
        font-size: 18px;
    }
    
    #ui {
        font-size: 14px;
        padding: 12px;
        min-width: 160px;
    }
    
    #flashlight-overlay {
        background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
            transparent 0%, 
            transparent 120px, 
            rgba(0, 0, 0, 0.95) 160px,
            rgba(0, 0, 0, 0.98) 100%);
    }
}

/* Performance optimizations for low-end devices */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Reduce animations on slower devices */
@media (prefers-reduced-motion: no-preference) {
    @media (max-width: 768px) {
        .clue-icon {
            animation: none;
            filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.6));
        }
    }
}


