html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.87);
    background-color: #0f0f0f;
    overscroll-behavior: none;
}

#app {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container,
#game-container canvas {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#game-container {
    width: 100%;
    height: 100%;
}

#game-container canvas {
    display: block;
}

#orientation-message {
    display: none;
}

@media (orientation: portrait) and (pointer: coarse) {
    #game-container {
        display: none;
    }

    #orientation-message {
        display: flex;
        width: 100%;
        height: 100%;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        box-sizing: border-box;
        color: #c4feff;
        font: 700 1.25rem Arial, sans-serif;
        text-align: center;
    }
}

.wg-ui {
    --wg-button-px: 54px;
    position: fixed;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
    color: #f8f3e9;
    font: 600 clamp(13px, 1.8vmin, 20px)/1.35 system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

.wg-ui button, .wg-ui input {
    box-sizing: border-box;
    color: inherit;
    background: #252a30;
    border: 1px solid #93816c;
    border-radius: 6px;
    padding: .5em .85em;
    font: inherit;
    cursor: pointer;
}

.wg-ui button:focus-visible, .wg-ui input:focus-visible { outline: 3px solid #ffce83; }
.wg-ui button:hover { background: #394047; }
.wg-ui button:active { background: #535149; }
.wg-layer {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    pointer-events: auto;
}
.wg-panel {
    box-sizing: border-box;
    display: grid;
    gap: .5em;
    min-width: min(16em, 90%);
    max-width: 94%;
    max-height: 96%;
    overflow-y: auto;
    padding: 1.05em 1.3em;
    background: rgb(14 19 25 / 92%);
    border: 1px solid #806d55;
    border-radius: 9px;
    text-align: center;
}
.wg-panel h1 { font-size: 1.65em; margin: 0 0 .2em; }
.wg-panel p { margin: .3em 0; }
.wg-panel input { max-width: 100%; }
.wg-panel table { border-collapse: collapse; }
.wg-panel th, .wg-panel td { padding: .2em .4em; }
.wg-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    text-shadow: 0 1px 3px black, 0 0 4px black;
    container-type: size;
}
.wg-hud::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: calc(var(--wg-button-px) + 8px);
    background: linear-gradient(#111a, transparent);
}
.wg-hud-item {
    box-sizing: border-box;
    padding: .12em .4em;
    background: rgb(14 19 25 / 88%);
    border: 1px solid #93816c;
    border-radius: 5px;
    font-size: 100%;
    position: absolute;
    top: calc((var(--wg-button-px) + 8px) / 2);
    transform: translateY(-50%);
    white-space: nowrap;
    max-width: 100%;
}
.wg-hearts { left: 2%; }
.wg-time { left: 21.59184%; }
.wg-floor { right: 21.59184%; }
.wg-kills { right: 2%; }
.wg-hearts { color: #ff7493; letter-spacing: .05em; }
.wg-control {
    position: absolute;
    width: calc(var(--wg-button-px) * var(--wg-control-scale, 1));
    height: calc(var(--wg-button-px) * var(--wg-control-scale, 1));
    max-width: 100%;
    max-height: 100%;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.wg-ui .wg-control {
    border-radius: 50%;
    padding: 0;
    background-color: rgb(24 32 41 / 80%);
    color: white;
}
.wg-control svg {
    display: block;
    width: 64%;
    height: 64%;
    margin: auto;
    pointer-events: none;
}
.wg-map {
    position: absolute;
    top: calc(var(--wg-button-px) + 3%);
    right: 2%;
    /* Scale the original map width, not the entire HUD viewport. */
    width: calc(clamp(55px, 9%, 120px) * var(--wg-hud-scale, 1));
    max-width: min(calc(100% - 2px), calc(150cqh - 3px));
    height: auto;
    background: #091322b8;
    border: 1px solid #85939a;
    border-radius: 3px;
}
.wg-paused { filter: blur(3px); }
.wg-editor { position: absolute; inset: 0; background: #10182055; pointer-events: auto; }
.wg-editor .wg-draggable {
    pointer-events: auto;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.wg-editor .wg-draggable:active { cursor: grabbing; }
.wg-editor .wg-editor-selected { outline: 2px solid #ffce83; outline-offset: 2px; }
.wg-editor-tools {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    justify-items: center;
    gap: .35em;
    width: max-content;
    max-width: 94%;
    box-sizing: border-box;
    padding: .5em .75em;
    background: rgb(14 19 25 / 92%);
    border: 1px solid #806d55;
    border-radius: 8px;
    text-align: center;
    pointer-events: auto;
}
.wg-editor-tools[data-dock="top"] { top: 2%; transform: translateX(-50%); }
.wg-editor-tools[data-dock="bottom"] { top: auto; bottom: 2%; transform: translateX(-50%); }
.wg-editor-size label { display: flex; align-items: center; justify-content: center; gap: .6em; flex-wrap: wrap; }
.wg-editor-size input[type="range"] { width: 8em; padding: 0; accent-color: #ffce83; touch-action: none; }
.wg-editor-buttons { display: flex; gap: .35em; flex-wrap: wrap; justify-content: center; }
.wg-editor-buttons button { padding: .3em .6em; }
@media (max-height: 480px) { .wg-ui { --wg-button-px: 44px; } }
@media (orientation: portrait) and (pointer: coarse) { .wg-ui { display: none; } }
.wg-binding { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; gap: .3em; text-align: left; }

/* Lift feedback: progress is part of the movable kills panel. */
.wg-kills { display: grid; gap: .15em; min-width: 7em; text-align: center; }
.wg-kill-track { height: .23em; background: #38414b; border-radius: 99px; overflow: hidden; }
.wg-kill-progress { display: block; width: 0; height: 100%; background: #69dce8; border-radius: inherit; }
.wg-lift-ready { color: #adffd1; background: rgb(15 39 27 / 94%); border-color: #93ff77; animation: wg-lift-pulse 1.8s ease-in-out infinite; }
.wg-lift-ready .wg-kill-progress { background: #93ff77; }
@keyframes wg-lift-pulse {
    0%, 100% { box-shadow: 0 0 3px #93ff7740; }
    50% { box-shadow: 0 0 10px #93ff7799; }
}
.wg-lift-notice {
    position: absolute; z-index: 1; top: 50%; left: 0; right: 0;
    transform: translateY(-50%); display: grid; justify-items: center; gap: .3em;
    padding: .7em .3em; text-align: center; pointer-events: none;
    background: linear-gradient(90deg, transparent, #0e211bf5 25%, #0e211bf5 75%, transparent);
    border-block: 1px solid #93ff7780; color: #adffd1;
    text-shadow: 0 1px 4px #000; animation: wg-lift-notice 2s ease both;
}
.wg-lift-title { font-size: 1.55em; letter-spacing: .12em; font-weight: 750; }
.wg-lift-subtitle { font-size: .7em; letter-spacing: .08em; color: #deeae2; }
@keyframes wg-lift-notice { 0%, 100% { opacity: 0; } 10%, 85% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .wg-lift-ready, .wg-lift-notice { animation: none; }
}

/* Shield is held, with no duration or cooldown ring. */
.wg-ui .wg-shield[data-shield-state="active"] { background-color: rgb(21 57 67 / 90%); color: #bff5ff; border-color: #95edff; box-shadow: 0 0 8px #8defff99; }
