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

body {
    overflow: hidden;
    background: #1a1008;
    font-family: 'Press Start 2P', monospace;
    cursor: none;
}

#scene-container {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

#scene-container canvas {
    display: block;
}

#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.6);
    font-size: 20px;
    font-family: monospace;
    pointer-events: none;
    z-index: 10;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    mix-blend-mode: difference;
}

#hud-coords {
    position: fixed;
    top: 12px;
    left: 12px;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
    z-index: 20;
    pointer-events: none;
    line-height: 1.6;
}

#search-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    font-size: 24px;
    cursor: pointer;
    z-index: 25;
    filter: grayscale(0.3);
    transition: transform 0.2s;
    text-shadow: 2px 2px 0 #000;
}
#search-toggle:hover {
    transform: scale(1.2);
}

#search-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 6, 2, 0.85);
    z-index: 100;
    justify-content: center;
    align-items: center;
}
#search-panel.active {
    display: flex;
}

#search-inner {
    background: #2a1f10;
    border: 3px solid #5a4020;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    position: relative;
    text-align: center;
    image-rendering: pixelated;
    box-shadow: 0 0 40px rgba(180,120,40,0.3), inset 0 0 20px rgba(0,0,0,0.5);
}

#search-title {
    color: #d4a030;
    font-size: 14px;
    margin-bottom: 8px;
}
#search-desc {
    color: #8a7050;
    font-size: 7px;
    margin-bottom: 20px;
}

#search-input {
    width: 100%;
    padding: 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    background: #1a1208;
    border: 2px solid #5a4020;
    color: #d4a030;
    outline: none;
    margin-bottom: 12px;
}
#search-input:focus {
    border-color: #d4a030;
}

#search-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 10px 20px;
    background: #5a4020;
    color: #d4a030;
    border: 2px solid #8a6030;
    cursor: pointer;
    transition: background 0.2s;
}
#search-btn:hover {
    background: #7a5030;
}

#search-result {
    color: #8a7050;
    font-size: 7px;
    margin-top: 12px;
    line-height: 1.8;
}

#search-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #8a6030;
    font-size: 16px;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
}

/* Book overlay */
#book-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 6, 2, 0.8);
    z-index: 90;
    justify-content: center;
    align-items: center;
}
#book-overlay.active {
    display: flex;
}

#book-panel {
    background: #f4e4c1;
    border: 4px solid #8a6830;
    max-width: 650px;
    width: 92%;
    max-height: 85vh;
    padding: 28px 24px 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 60px rgba(180,120,40,0.4),
                8px 8px 0 rgba(0,0,0,0.3);
    overflow: hidden;
}

#book-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 28px,
            rgba(139,109,56,0.06) 28px,
            rgba(139,109,56,0.06) 29px
        );
    pointer-events: none;
}

#book-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: none;
    border: none;
    color: #6a4820;
    font-size: 18px;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    z-index: 5;
}

#book-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #3b2a1a;
    margin-bottom: 4px;
    text-align: center;
    word-break: break-all;
}

#book-location {
    font-family: 'Press Start 2P', monospace;
    font-size: 6px;
    color: #8a7050;
    margin-bottom: 14px;
    text-align: center;
}

#book-content {
    flex: 1;
    overflow-y: auto;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: #3b2a1a;
    line-height: 2;
    word-break: break-all;
    white-space: pre-wrap;
    padding: 10px;
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(139,109,56,0.15);
    min-height: 200px;
    max-height: 50vh;
}

#book-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 2px solid rgba(139,109,56,0.2);
}

#book-nav button {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 8px 14px;
    background: #5a4020;
    color: #f4e4c1;
    border: 2px solid #8a6030;
    cursor: pointer;
}
#book-nav button:hover {
    background: #7a5030;
}

#book-page {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: #6a4820;
}

/* Controls tooltip */
#controls-tooltip {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    text-align: center;
    text-shadow: 1px 1px 0 #000;
    z-index: 20;
    transition: opacity 1s;
    line-height: 2;
    pointer-events: auto;
}
#controls-tooltip.faded {
    opacity: 0;
    pointer-events: none;
}
#controls-tooltip:hover {
    opacity: 1 !important;
    pointer-events: auto;
}

/* Lock screen */
#lock-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0604;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}
#lock-prompt.hidden {
    display: none;
}

#lock-inner {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

#lock-title {
    color: #d4a030;
    font-size: 18px;
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(212,160,48,0.5);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { text-shadow: 0 0 20px rgba(212,160,48,0.3); }
    50% { text-shadow: 0 0 40px rgba(212,160,48,0.7); }
}

#lock-subtitle {
    color: #8a7050;
    font-size: 8px;
    margin-bottom: 30px;
    letter-spacing: 2px;
}

#lock-desc {
    color: #6a5530;
    font-size: 8px;
    line-height: 2.2;
    margin-bottom: 40px;
}

#lock-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 16px 32px;
    background: #3a2810;
    color: #d4a030;
    border: 3px solid #5a4020;
    cursor: pointer;
    transition: all 0.3s;
    animation: btnGlow 2s ease-in-out infinite;
}
#lock-btn:hover {
    background: #5a3818;
    border-color: #d4a030;
    box-shadow: 0 0 30px rgba(212,160,48,0.4);
}

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(212,160,48,0.1); }
    50% { box-shadow: 0 0 20px rgba(212,160,48,0.3); }
}

/* Scrollbar */
#book-content::-webkit-scrollbar { width: 8px; }
#book-content::-webkit-scrollbar-track { background: rgba(139,109,56,0.1); }
#book-content::-webkit-scrollbar-thumb { background: #8a6830; }