@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    background: #0a0a12;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    font-family: 'Press Start 2P', monospace;
    cursor: crosshair;
}

#game-viewport {
    position: fixed;
    inset: 0;
    display: none;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

#game-viewport.visible {
    display: block;
}

#game-stage {
    min-width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#game-canvas {
    display: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: crosshair;
}

#zoom-controls {
    position: fixed;
    right: 14px;
    bottom: 18px;
    z-index: 220;
    display: none;
    gap: 8px;
    align-items: center;
}

#zoom-controls.visible {
    display: flex;
}

#zoom-controls button {
    min-width: 42px;
    height: 42px;
    padding: 0 10px;
    border: 2px solid #6666aa;
    background: rgba(10, 10, 24, 0.9);
    color: #ddddee;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(100, 100, 255, 0.18);
}

#zoom-controls button:hover,
#zoom-controls button:active {
    border-color: #9999ff;
    color: #ffffff;
}

/* Loading screen */
#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8888cc;
    gap: 20px;
}

#loading-text {
    font-size: 10px;
    letter-spacing: 1px;
}

.loading-bar {
    width: 200px;
    height: 8px;
    border: 2px solid #4444aa;
    background: #111;
    position: relative;
    overflow: hidden;
}

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: #6666dd;
    animation: loading-slide 1s ease-in-out infinite;
}

@keyframes loading-slide {
    0% { left: -50%; }
    100% { left: 100%; }
}

/* Building name label - shown on hover */
#building-name {
    position: fixed;
    padding: 5px 10px;
    background: rgba(10, 10, 20, 0.85);
    border: 2px solid #8888cc;
    color: #ddddff;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    pointer-events: none;
    z-index: 90;
    opacity: 0;
    transition: opacity 0.15s;
    transform: translateX(-50%);
    white-space: nowrap;
    text-shadow: 0 0 6px rgba(100, 100, 255, 0.4);
}

#building-name.visible {
    opacity: 1;
}

/* Tooltip - shown when character arrives */
#tooltip {
    position: fixed;
    padding: 8px 12px;
    background: rgba(10, 10, 20, 0.92);
    border: 2px solid #6666aa;
    color: #ccccee;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    line-height: 1.8;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s;
    max-width: 280px;
    box-shadow: 0 0 16px rgba(100, 100, 200, 0.3);
}

#tooltip.visible {
    opacity: 1;
}

#tooltip strong {
    color: #aaaaff;
    font-size: 9px;
}

#tooltip .hint {
    color: #777799;
    font-size: 7px;
}

/* Scroll detail overlay */
#scroll-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#scroll-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#scroll-parchment {
    position: relative;
    width: 700px;
    max-width: 90vw;
    max-height: 85vh;
    background: #2a1a0a;
    border: 3px solid #664422;
    box-shadow: 0 0 40px rgba(100, 70, 30, 0.5), inset 0 0 30px rgba(0, 0, 0, 0.4);
    padding: 30px 35px;
    overflow-y: auto;
    image-rendering: pixelated;
}

#scroll-parchment::-webkit-scrollbar {
    width: 8px;
}

#scroll-parchment::-webkit-scrollbar-track {
    background: #1a0f05;
}

#scroll-parchment::-webkit-scrollbar-thumb {
    background: #664422;
    border: 1px solid #443311;
}

#scroll-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: 2px solid #664422;
    color: #aa8844;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 4px 8px;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s, border-color 0.2s;
}

#scroll-close:hover {
    color: #ffcc66;
    border-color: #aa8844;
}

#scroll-content h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #ffcc66;
    text-align: center;
    margin-bottom: 4px;
    text-shadow: 0 0 10px rgba(255, 200, 80, 0.3);
}

#scroll-content .scroll-subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: #886633;
    text-align: center;
    margin-bottom: 20px;
}

#scroll-content .scroll-section {
    margin-bottom: 16px;
}

#scroll-content .scroll-section h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #cc9944;
    margin-bottom: 6px;
    border-bottom: 1px solid #443311;
    padding-bottom: 4px;
}

#scroll-content .scroll-section p {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: #bbaa88;
    line-height: 2;
    white-space: pre-line;
}

/* Fade overlay for scene transitions */
#fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a12;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 200;
}

#fade-overlay.active {
    opacity: 1;
}

/* Back button in interiors */
#back-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    padding: 8px 16px;
    background: rgba(10, 10, 20, 0.85);
    border: 2px solid #6666aa;
    color: #ccccee;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, background 0.2s;
}

#back-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

#back-btn:hover {
    background: rgba(40, 40, 80, 0.9);
    border-color: #8888cc;
    color: #ffffff;
}

/* Debug hint */
#debug-hint {
    position: fixed;
    bottom: 8px;
    right: 12px;
    color: #222;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    pointer-events: none;
}

@media (max-width: 768px) {
    #game-stage {
        padding: 10px;
    }

    #zoom-controls {
        right: 10px;
        bottom: 12px;
        gap: 6px;
    }

    #zoom-controls button {
        min-width: 38px;
        height: 38px;
        font-size: 9px;
    }

    #zoom-reset {
        min-width: 58px;
    }
}
