/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Game Container */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #000;
}

/* Canvas wrapper keeps the canvas centered with correct aspect ratio (no CSS cropping/letterbox math) */
#canvas-wrap {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: #000;
    /* Available space above UI bar */
    height: calc(100vh - 230px);
    position: relative;
    overflow: hidden;
}

/* Canvas */
#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    cursor: crosshair;
    /* Fill the scene area; JS handles aspect via "cover" transform (hotspots stay correct). */
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    background: #000;
}

/* Fullscreen overlay over the scene (NOT the bottom UI) */
#map-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 5;
}

#map-overlay.hidden {
    display: none;
}

#map-overlay-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#map-overlay-content {
    position: relative;
    display: inline-block;
    width: min(1100px, 86vw);
    max-height: 92%;
}

#map-overlay-links {
    position: absolute;
    inset: 0;
    z-index: 6;
}

.map-overlay-link {
    position: absolute;
    display: block;
    color: transparent;
    font-size: 0;
    text-decoration: none;
    cursor: pointer;
}

.map-overlay-link:focus-visible {
    outline: 2px solid #00ddff;
    outline-offset: 1px;
}

/* Click zones aligned to the four big labels in menu.svg */
.map-overlay-link-pokemon { left: 22%; top: 28%; width: 48%; height: 9%; }
.map-overlay-link-tcg { left: 22%; top: 39%; width: 52%; height: 9%; }
.map-overlay-link-music { left: 22%; top: 50%; width: 40%; height: 9%; }
.map-overlay-link-collectibles { left: 22%; top: 61%; width: 57%; height: 10%; }

@media (max-width: 1200px) {
    #map-overlay-content {
        width: min(980px, 90vw);
    }
}

@media (max-width: 900px) {
    #map-overlay-content {
        width: min(860px, 92vw);
    }
}

#map-overlay-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #00ff00;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 26px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    z-index: 7;
}

#map-overlay-close:hover {
    color: #ffff00;
    border-color: #ffff00;
}

/* UI Overlay - Bottom bar */
#ui-overlay {
    width: 100%;
    height: 230px;
    background: #000;
    display: grid;
    grid-template-columns: 280px 1fr 380px;
    grid-template-rows: 200px 30px;
    gap: 0;
    border-top: 2px solid #00ff00;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Verb Panel */
#verb-panel {
    grid-row: 1;
    grid-column: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(4, 1fr);
    gap: 0;
    padding: 25px 15px;
    background: #000;
}

.verb-btn {
    background: transparent;
    border: none;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 22px;
    font-weight: bold;
    text-align: left;
    padding: 10px 10px;
    cursor: pointer;
    transition: all 0.1s;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.verb-btn:hover {
    color: #00ff88;
    text-shadow: 0 0 5px #00ff00;
}

.verb-btn.active {
    color: #ffff00;
    text-shadow: 0 0 8px #ffff00;
}

/* Message Area - Now combined with shop menu in row 1 column 2-3 */
#message-area {
    grid-row: 1;
    grid-column: 2;
    background: #000;
    border: 2px solid #00ff00;
    padding: 25px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 25px 10px 25px 0;
}

#message-text {
    color: #00ff00;
    font-size: 18px;
    text-align: center;
    line-height: 1.6;
    font-family: 'Courier New', monospace;
}

/* Shop Menu - Positioned to the right of message area */
#shop-menu {
    grid-row: 1;
    grid-column: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    padding: 30px 35px;
    background: #000;
    opacity: 1;
    transition: opacity 0.3s ease-in;
    position: relative;
}

#shop-menu.hidden {
    opacity: 0;
    pointer-events: none;
}

.shop-link {
    color: #00ddff;
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
    text-shadow: 0 0 5px #00ddff;
    transition: all 0.2s;
    display: block;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.3px;
    position: relative;
}

.shop-link:hover {
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
    transform: translateX(5px);
}

/* Footer Links */
#footer-links {
    grid-row: 2;
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid #666;
    position: relative;
    padding: 0 14px;
}

#footer-links a {
    color: #999;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

#footer-links a:hover {
    color: #fff;
}

#footer-links span {
    color: #666;
}

/* Footer: keep links centered, music controller anchored left */
#footer-links-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto;
}

#music-controls {
    position: absolute;
    right: 35px; /* align with the shop menu padding above */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

#music-controls button {
    background: transparent;
    border: none;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    padding: 0 2px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0.5px;
    image-rendering: pixelated;
    line-height: 1;
}

#music-controls button:hover {
    color: #ffff00;
}

/* Pixel icons (SVG) */
.music-ico {
    display: block;
    fill: currentColor;
    shape-rendering: crispEdges;
}

/* Only show one of play/stop based on state */
#music-controls.playing .music-ico-play { display: none; }
#music-controls.playing .music-ico-stop { display: block; }
#music-controls:not(.playing) .music-ico-play { display: block; }
#music-controls:not(.playing) .music-ico-stop { display: none; }

/* Thin progress bar (custom, reliable scrub) */
#music-progress {
    position: relative;
    width: 170px;
    height: 10px;
    cursor: pointer;
    user-select: none;
}

#music-progress:focus {
    outline: none;
}

.music-progress-track,
.music-progress-fill {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
}

.music-progress-track {
    background: rgba(0, 255, 0, 0.25);
}

.music-progress-fill {
    background: rgba(0, 255, 0, 0.85);
    width: 0%;
    right: auto;
}

.music-progress-thumb {
    position: absolute;
    top: 50%;
    width: 6px;
    height: 10px;
    transform: translate(-50%, -50%);
    background: #00ff00;
    left: 0%;
}

#music-controls:hover .music-progress-fill,
#music-controls:hover .music-progress-thumb {
    background: #ffff00;
}

/* Responsive scaling */
@media (max-width: 1400px) {
    #ui-overlay {
        grid-template-columns: 250px 1fr 340px;
        height: 210px;
        grid-template-rows: 180px 30px;
    }
    
    #canvas-wrap { height: calc(100vh - 210px); }
    
    .verb-btn {
        font-size: 19px;
        padding: 6px 10px;
    }
    
    #message-text {
        font-size: 15px;
    }
    
    .shop-link {
        font-size: 21px;
        gap: 15px;
    }
}

@media (max-width: 1024px) {
    #ui-overlay {
        grid-template-columns: 220px 1fr 300px;
        height: 190px;
        grid-template-rows: 160px 30px;
    }
    
    #canvas-wrap { height: calc(100vh - 190px); }
    
    .verb-btn {
        font-size: 17px;
        padding: 5px 8px;
    }
    
    #message-text {
        font-size: 14px;
    }
    
    .shop-link {
        font-size: 19px;
        gap: 12px;
    }
}

/* Mobile-only adjustments: preserve desktop layout, compact controls for touch */
@media (max-width: 768px) {
    #game-container {
        height: 100dvh;
    }

    #ui-overlay {
        height: 250px;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 112px 108px 30px;
    }

    #canvas-wrap {
        height: calc(100dvh - 250px);
        min-height: 220px;
    }

    #message-area {
        grid-row: 1;
        grid-column: 1 / -1;
        margin: 10px 10px 8px;
        padding: 10px 12px;
    }

    #message-text {
        font-size: 13px;
        line-height: 1.35;
    }

    #verb-panel {
        grid-row: 2;
        grid-column: 1;
        padding: 6px 8px;
        gap: 2px;
    }

    .verb-btn {
        font-size: 14px;
        padding: 6px 6px;
        min-height: 34px;
    }

    #shop-menu {
        grid-row: 2;
        grid-column: 2;
        padding: 10px 12px;
        gap: 8px;
        justify-content: flex-start;
    }

    .shop-link {
        font-size: 16px;
    }

    #footer-links {
        grid-row: 3;
        padding: 0 8px;
    }

    #footer-links-center {
        gap: 6px;
    }

    #footer-links a {
        font-size: 11px;
    }

    #music-controls {
        left: 8px;
        right: auto;
        gap: 6px;
    }

    #music-progress {
        display: none;
    }

    #music-progress {
        width: 82px;
    }
}

@media (max-width: 480px) {
    #ui-overlay {
        height: 236px;
        grid-template-rows: 102px 104px 30px;
    }

    #canvas-wrap {
        height: calc(100dvh - 236px);
    }

    #message-area {
        margin: 8px 8px 6px;
        padding: 8px 10px;
    }

    #message-text {
        font-size: 12px;
    }

    .verb-btn {
        font-size: 13px;
        min-height: 30px;
        padding: 4px 5px;
    }

    .shop-link {
        font-size: 15px;
    }

    #footer-links a {
        font-size: 10px;
    }

    #music-progress {
        display: none;
    }
}

