/* Cave Descent — page & touch-control styling */

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

html, body {
    height: 100%;
    background: #05080f;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.topbar {
    position: fixed;
    top: 56px; left: 0; right: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: rgba(8, 12, 22, 0.85);
    border-bottom: 1px solid #1e293b;
    z-index: 30;
}

.topbar .leave {
    color: #8fb8e8;
    text-decoration: none;
    font-size: 13px;
    font-weight: bold;
}
.topbar .leave:hover { color: #fde68a; }

.topbar .title {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 3px;
    color: #64748b;
}

.topbar .fs {
    background: none;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #8fb8e8;
    font-size: 14px;
    width: 30px;
    height: 26px;
    cursor: pointer;
}
.topbar .fs:hover { border-color: #8fb8e8; }

.stage {
    position: fixed;
    inset: 96px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #05080f;
}

/* Site navbar above game chrome; hide both in fullscreen */
body.cd-fs,
body:has(#stage:fullscreen),
body:has(#stage:-webkit-full-screen) {
    padding-top: 0 !important;
}
body.cd-fs #mh-navbar,
body.cd-fs .topbar,
body:has(#stage:fullscreen) #mh-navbar,
body:has(#stage:fullscreen) .topbar,
body:has(#stage:-webkit-full-screen) #mh-navbar,
body:has(#stage:-webkit-full-screen) .topbar {
    display: none !important;
}
body.cd-fs .stage,
body:has(#stage:fullscreen) .stage,
body:has(#stage:-webkit-full-screen) .stage {
    inset: 0;
}

@media (max-width: 720px) {
    .topbar { top: 52px; }
    .stage { inset: 92px 0 0 0; }
}

body.mh-phone-mode .topbar { top: 46px; }
body.mh-phone-mode .stage { inset: 86px 0 0 0; }

canvas#game {
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #05080f;
}

/* ---------- touch controls ---------- */
.touch-layer { display: none; }

body.touch-mode .touch-layer { display: block; }

.tc-cluster {
    position: absolute;
    bottom: 18px;
    display: grid;
    gap: 10px;
    z-index: 20;
}

.tc-left {
    left: 14px;
    grid-template-columns: 64px 64px;
    grid-template-areas:
        "up   down"
        "left right";
}
#tc-up { grid-area: up; }
#tc-down { grid-area: down; }
#tc-left { grid-area: left; }
#tc-right { grid-area: right; }

.tc-right {
    right: 14px;
    grid-template-columns: 58px 58px;
    grid-template-areas:
        "dash cast"
        "use  use"
        "attack jump";
}
#tc-dash { grid-area: dash; }
#tc-cast { grid-area: cast; }
#tc-interact { grid-area: use; }
#tc-attack { grid-area: attack; }
#tc-jump { grid-area: jump; }

.tc {
    height: 58px;
    border-radius: 12px;
    border: 1px solid rgba(143, 184, 232, 0.4);
    background: rgba(30, 41, 59, 0.55);
    color: #cbd5e1;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}
.tc:active {
    background: rgba(143, 184, 232, 0.35);
    color: #fff;
}
.tc-small {
    height: 44px;
    font-size: 11px;
    opacity: 0.9;
}

.tc-pause {
    position: absolute;
    top: 10px;
    right: 14px;
    width: 46px;
    height: 40px;
    z-index: 20;
}
