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

/* ── PWA install hint ─────────────────────────────────────────────── */
#pwa-hint {
    display: none; /* shown by JS on Safari iOS non-standalone */
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: rgba(80, 40, 160, 0.95);
    color: #ddd;
    font-family: -apple-system, monospace;
    font-size: 13px;
    padding: 10px 40px 10px 14px;
    text-align: center;
    border-bottom: 1px solid rgba(160, 120, 255, 0.5);
}
#pwa-hint-close {
    position: absolute;
    right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: #aaa; font-size: 16px;
    cursor: pointer; padding: 4px 8px;
}

html, body {
    background: #000;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    image-rendering: pixelated;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ── Mobile overlay ─────────────────────────────────────────────────── */
#m-ui {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
}

#m-ui.active { display: block; }

/* Portrait rotation prompt */
#m-rotate {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    color: #ccc;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 18px;
    text-align: center;
    gap: 20px;
    pointer-events: auto;
}

.m-rotate-icon {
    font-size: 60px;
    animation: m-spin 2s linear infinite;
    display: block;
}
@keyframes m-spin { to { transform: rotate(360deg); } }

/* Show/hide based on orientation */
@media (orientation: portrait) {
    #m-rotate { display: flex; }
    #m-left, #m-right { display: none !important; }
}
@media (orientation: landscape) {
    #m-rotate { display: none !important; }
}

/* ── Left D-pad (directional buttons) ─────────────────────────────── */
#m-left {
    position: absolute;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    left: calc(14px + env(safe-area-inset-left, 0px));
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

/* ── Right action cluster ──────────────────────────────────────────── */
#m-right {
    position: absolute;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    right: calc(14px + env(safe-area-inset-right, 0px));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
}

/* Utility row (potion + kiri) above action row */
#m-util {
    display: flex;
    flex-direction: row;
    gap: 8px;
    justify-content: flex-end;
    align-items: flex-end;
}

/* Action row (jump + attack) */
#m-actions {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
}

/* ── Button base ───────────────────────────────────────────────────── */
.mbtn {
    pointer-events: auto;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: rgba(50, 40, 95, 0.68);
    border: 2px solid rgba(160, 140, 230, 0.55);
    color: #eee;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.08s, transform 0.08s;
}

.mbtn-pressed {
    background: rgba(140, 120, 255, 0.82) !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
    transform: scale(0.91);
}

/* Utility buttons (smaller) */
.mbtn-sm {
    width: 50px;
    height: 50px;
    font-size: 19px;
    background: rgba(38, 28, 72, 0.65);
    border-color: rgba(130, 110, 200, 0.45);
}

/* Jump button — blue, larger */
.mbtn-jump {
    width: 70px;
    height: 70px;
    font-size: 28px;
    background: rgba(18, 50, 145, 0.72);
    border-color: rgba(80, 150, 255, 0.65);
}

/* Attack button — red, larger */
.mbtn-attack {
    width: 70px;
    height: 70px;
    font-size: 26px;
    background: rgba(145, 18, 18, 0.72);
    border-color: rgba(255, 80, 80, 0.65);
}

/* Pause button — top-left, out of the way of the HUD */
#m-pause-wrap {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    pointer-events: none;
}
.mbtn-pause {
    pointer-events: auto;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(20, 16, 40, 0.72);
    border: 1px solid rgba(140, 120, 200, 0.5);
    color: #ccc;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
}
