/* 3D market page (Assets/market3d/page.php). Mobile first: full-screen view, compact top bar,
   shop details in a bottom sheet (side panel on wide screens), map + list as a sheet. */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #cfe6ff;
    font-family: system-ui, "Segoe UI", Tahoma, sans-serif;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}
* { box-sizing: border-box; }
#stage canvas { display: block; width: 100vw; height: 100vh; height: 100dvh; touch-action: none; cursor: grab; }
#stage canvas:active { cursor: grabbing; }

#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
    background: linear-gradient(#00000055, #0000);
    pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-title { color: #fff; font-size: 15px; text-shadow: 0 1px 3px #0008; margin-inline-end: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 20px;
    background: #ffffffe6;
    color: #1f4e79;
    font-size: 18px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 2px 8px #0003;
    cursor: pointer;
}
.hud-lang { font-size: 13px; }
#btnMusic.on { background: #1f4e79; color: #fff; }
#compass {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 0;
    background: #ffffffe6;
    box-shadow: 0 2px 8px #0003;
    padding: 0;
    cursor: pointer;
}
#compassNeedle { display: block; width: 100%; height: 100%; position: relative; transition: transform .05s linear; }
#compassNeedle::before {   /* red half points north */
    content: "";
    position: absolute;
    left: 50%;
    top: 5px;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom: 13px solid #d6336c;
}
#compassNeedle b { position: absolute; left: 0; right: 0; bottom: 4px; font-size: 10px; color: #333; }

/* turn buttons: bottom corners, above the safe area; always left = turn left, whatever the language */
.turn-btn { position: fixed; bottom: max(18px, env(safe-area-inset-bottom)); width: 52px; height: 52px; font-size: 24px; }
#turnL { left: 14px; }
#turnR { right: 14px; }

#status, #hint {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    background: #fffffff0;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 4px 20px #0003;
    max-width: calc(100% - 32px);
    text-align: center;
}
#status { top: 45%; }
#hint { bottom: max(20px, env(safe-area-inset-bottom)); font-size: 14px; pointer-events: none; }
#status[hidden], #hint[hidden], #shopPanel[hidden], #mapSheet[hidden] { display: none; }
#fade { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .2s; }
#fade.on { opacity: 1; }

/* Shop sheet: bottom sheet on phones, side panel on wide screens. */
#shopPanel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 62vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 14px 14px max(14px, env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px #0003;
    animation: sheet-up .25s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40%); opacity: 0; } }
@media (min-width: 760px) {
    #shopPanel { left: auto; right: 12px; bottom: auto; top: 64px; width: 360px; max-height: calc(100% - 80px); border-radius: 12px; }
    [dir="rtl"] #shopPanel { right: auto; left: 12px; }
}
.shop-head { display: flex; align-items: center; gap: 10px; }
.shop-head h2 { margin: 0; font-size: 18px; flex: 1; }
.shop-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; background: #f3f5f7; }
.sheet-close { border: 0; background: #eef1f4; width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; }
.shop-about { font-size: 13px; color: #444; }
.shop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.btn-wa, .shop-visit {
    flex: 1 1 140px;
    text-align: center;
    border-radius: 10px;
    padding: 11px 10px;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
}
.btn-wa { background: #25d366; color: #fff; }
.shop-visit { background: #1f4e79; color: #fff; }
.shop-products { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shop-empty { grid-column: 1 / -1; color: #666; font-size: 13px; }
.product { display: flex; flex-direction: column; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; font-size: 12px; }
.product-link { display: flex; flex-direction: column; gap: 2px; padding: 6px; text-decoration: none; color: inherit; flex: 1; }
.product img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.product-name { font-weight: bold; }
.product-price s { color: #888; }
.product-price em { color: #a05a00; font-style: normal; }
.product-wa { background: #e9f9ef; color: #128c4b; text-align: center; padding: 6px; text-decoration: none; font-weight: bold; }

/* Map + list sheet */
#mapSheet {
    position: fixed;
    inset: 0;
    background: #f7f9fb;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
}
.map-head { display: flex; gap: 8px; padding: 10px; }
#mapSearch { flex: 1; height: 40px; border: 1px solid #ccd5df; border-radius: 20px; padding: 0 14px; font-size: 15px; }
.map-body { flex: 1; overflow-y: auto; padding: 0 10px 20px; display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 900px) { .map-body { flex-direction: row; } #mapList { width: 320px; flex: none; } .map-canvas-wrap { flex: 1; } }
.map-canvas-wrap { overflow: auto; text-align: center; }
#mapCanvas { border-radius: 8px; box-shadow: 0 1px 6px #0002; cursor: pointer; }
#mapList { display: flex; flex-direction: column; gap: 6px; }
.map-item { display: flex; align-items: center; gap: 8px; text-align: start; border: 1px solid #e2e8f0; background: #fff; border-radius: 10px; padding: 10px 12px; font-size: 14px; cursor: pointer; }
.map-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
