/* General elements */

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: black;
    color: #fafafa;
    overflow-x: hidden;
    overflow-y: auto;
}

section {
    clear: both;
}

a {
    color: white;
    font-weight: bold;
    text-decoration: none;
}


/* General animations */

.hoverable {
    opacity: .84;
    -moz-transition: 140ms opacity;
    -o-transition: 140ms opacity;
    -webkit-transition: 140ms opacity;
    transition: 140ms opacity;
}

    .hoverable:hover {
        opacity: 1;
    }


/* Game section */

section#game {
    min-height: 464px;
}

    section#game .EightBitter {
        margin: auto;
    }



/* Control section */

#controls {
    text-align: center;
}

    #controls .control {
        position: relative;
        display: inline-block;
        margin-top: 0;
        height: 35px;
        width: 256px;
        border: 3px solid black;
        border-radius: 7px;
        box-shadow: 0 3px 7px black inset;
        background: black;
        font-family: 'Press Start';
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        overflow: hidden;
        -moz-transition: 70ms all;
        -o-transition: 70ms all;
        -webkit-transition: 70ms all;
        transition: 70ms all;
    }

    #controls.length-4 .control {
        min-width: 25%;
    }

    #controls.length-5 .control {
        min-width: 20%;
    }

    #controls .control:hover {
        margin-top: -322px;
        height: 350px; /* 322px + 28px */
        border-color: #99ffcc;
        background: #009966;
        z-index: 70;
    }

    #controls .control h4 {
        position: absolute;
        right: 0;
        bottom: 7px;
        left: 0;
        margin: 0;
    }

    #controls .control-inner {
        margin-top: 28px;
        padding: 7px 3px;
        opacity: 0;
        -moz-transition: 35ms opacity;
        -o-transition: 35ms opacity;
        -webkit-transition: 35ms opacity;
        transition: 35ms opacity;
    }

    #controls .control:hover .control-inner {
        display: block;
        margin-top: 0;
        opacity: 1;
    }

    #controls .select-options {
        position: relative;
        max-height: 308px; /* 322 - 14*/
        overflow-x: hidden;
        overflow-y: auto;
    }

    #controls .select-option-title {
        padding: 7px;
    }

    #controls .select-option {
        margin: 1px 3px;
        display: inline-block;
        background: #ffcc33;
        border: 3px outset;
        cursor: pointer;
        color: black;
        font-size: 14px;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }

        #controls .select-option.option-enabled {
            background: #ffcc33;
        }

        #controls .select-option.option-disabled {
            background: #ccaa33;
        }

        #controls .select-option.select-option-inset {
            border: 3px inset;
        }

        #controls .select-option.select-option-large {
            padding: 14px 0;
            font-size: 15px;
            line-height: 140%;
        }

    #controls .disabled {
        opacity: .49 !important;
        cursor: default !important;
        -ms-user-select: none !important;
        -moz-user-select: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }


    /* Controls - option buttons */

    #controls .options-button-option {
        position: relative;
        display: block;
        left: 0;
        right: 0;
        padding: 4px 0;
        /* width: 70px; */
    }

    #controls input[type=number] {
        display: inline;
        margin-left: -3px;
        padding-left: 17px;
        /* font-size: 1em; */
        font-family: "Press Start";
    }

    #controls select {
        /* font-size: 1em; */
        font-family: "Press Start";
    }


    /* Controls - options */

    #controls #control-Options .select-options td {
        padding-top: 7px;
        padding-bottom: 7px;
    }


    /* Controls - option keys */

    #controls .options-label-Keys {
        padding-left: 14px;
    }

    #controls .options-cell-Keys {
        padding: 7px 0;
    }

    #controls .options-key-option {
        display: block;
    }

        #controls .options-key-option:not(:last-of-type):after {
            content: ", ";
        }


    /* Controls - tables */

    #controls table {
        width: 100%;
        border-spacing: 1px;
        padding: 0 2px;
    }

        #controls table input {
            max-width: 70px;
        }

    #controls .maps-grid-option {
        display: table-cell;
        padding: 3px;
    }

    #controls .maps-grid-option-extra {
        display: block;
        margin: 7px 2px 3px 1px;
        padding: 14px 3px;
    }

    #controls .maps-grid-input {
        margin: 0 2px 0 1px;
        width: 98%;
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        font-family: 'Press Start';
        text-align: center;
    }


    /* Controls - uploader */

    #controls .select-upload {
        cursor: pointer;
        overflow: hidden;
    }

    #controls .select-upload-input {
        display: none;
    }


    /* Controls - built-in maps */

    #controls .select-options-editor-maps-holder {
        width: 100%;
    }


/* Mobile game shell */

#orientation-overlay,
#mobile-menu-button {
    display: none;
}

html.mobile-game,
body.mobile-game {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #000;
}

.mobile-game #game {
    position: fixed;
    inset: 0;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.mobile-game #game canvas,
.mobile-game #game .EightBitter,
.mobile-game #game .touch-passer-container,
.mobile-game #game .touch-passer-container * {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.mobile-game #controls {
    display: none;
    position: fixed;
    z-index: 1100;
    top: max(52px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: min(360px, calc(100vw - 16px));
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 2px solid #777;
    border-radius: 8px;
    background: rgba(0, 0, 0, .94);
    box-sizing: border-box;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.mobile-game.mobile-menu-open #controls {
    display: block;
}

.mobile-game #controls .control,
.mobile-game #controls .control:hover {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    margin: 0 0 8px;
    overflow: visible;
    border-color: #555;
    background: #111;
    z-index: auto;
}

.mobile-game #controls .control h4 {
    position: static;
    padding: 9px 4px 7px;
}

.mobile-game #controls .control-inner,
.mobile-game #controls .control:hover .control-inner {
    display: block;
    max-height: none;
    margin-top: 0;
    padding: 3px;
    opacity: 1;
}

.mobile-game #controls .select-options {
    max-height: none;
    overflow: visible;
}

.mobile-game #controls .control:first-child .select-options td {
    padding-top: 7px;
    padding-bottom: 7px;
}

.mobile-game #mobile-menu-button {
    display: block;
    position: fixed;
    z-index: 1150;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    min-width: 64px;
    min-height: 38px;
    padding: 7px 12px;
    border: 2px solid #eee;
    border-radius: 7px;
    color: #fff;
    background: rgba(0, 0, 0, .75);
    font: 14px/1.2 sans-serif;
    touch-action: manipulation;
}

.mobile-game #orientation-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    padding:
        max(20px, env(safe-area-inset-top))
        max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));
    align-items: center;
    justify-content: center;
    color: #fff;
    background: #080808;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    text-align: center;
    touch-action: none;
}

.orientation-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.orientation-card strong {
    font-size: clamp(22px, 7vw, 34px);
}

.orientation-card span {
    color: #bbb;
    font-size: 15px;
}

.orientation-phone {
    display: grid;
    place-items: center;
    width: 62px;
    height: 96px;
    border: 4px solid #fff;
    border-radius: 12px;
    font-size: 38px;
    animation: rotate-phone 1.6s ease-in-out infinite;
}

#mobile-start {
    min-width: 148px;
    min-height: 48px;
    margin-top: 6px;
    border: 0;
    border-radius: 8px;
    color: #111;
    background: #fff;
    font: 700 17px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
    touch-action: manipulation;
}

@keyframes rotate-phone {
    0%, 35% { transform: rotate(0deg); }
    65%, 100% { transform: rotate(90deg); }
}

@media (orientation: portrait) {
    .mobile-game #orientation-overlay {
        display: flex;
    }

    .mobile-game #mobile-menu-button {
        display: none;
    }
}


/* Fixed 4:3 player shell */

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    position: fixed;
    inset: 0;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#player-shell {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

#game-frame {
    position: relative;
    flex: none;
    width: 640px;
    height: 480px;
    overflow: hidden;
    background: #000;
}

#player-shell #game {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
}

#player-shell #game .FullScreenMario {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 640px !important;
    height: 480px !important;
    margin: 0;
    transform: scale(var(--game-scale, 1));
    transform-origin: 0 0;
}

#player-shell #game canvas {
    width: 640px !important;
    height: 480px !important;
    image-rendering: pixelated;
    touch-action: none;
}

#video-character-overlay {
    position: absolute;
    z-index: 20;
    top: 0;
    left: 0;
    display: none;
    pointer-events: none;
    transform-origin: 0 0;
    will-change: transform;
}

#video-character-overlay img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    image-rendering: auto;
    transform-origin: center bottom;
}

#birthday-title-overlay {
    position: absolute;
    z-index: 18;
    top: 0;
    left: 0;
    display: none;
    width: 320px;
    height: 136px;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    transform-origin: 0 0;
    will-change: transform;
}

#birthday-title-overlay img {
    display: block;
    width: 320px;
    height: 136px;
    image-rendering: pixelated;
}

#touch-controls-layer {
    position: fixed;
    z-index: 900;
    inset: 0;
    display: none;
    overflow: hidden;
    pointer-events: none;
    touch-action: none;
}

.mobile-game #touch-controls-layer {
    display: block;
}

#touch-controls-layer .touch-passer-container {
    position: absolute !important;
    inset: 0 !important;
    pointer-events: none;
    touch-action: none;
}

#touch-controls-layer .touch-passer-container > *,
#touch-controls-layer .touch-passer-container * {
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#controls {
    display: none;
    position: fixed;
    z-index: 1100;
    top: 52px;
    right: 8px;
    bottom: 8px;
    width: min(360px, calc(100vw - 16px));
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 2px solid #777;
    border-radius: 8px;
    background: rgba(0, 0, 0, .96);
    box-sizing: border-box;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.developer-mode.developer-menu-open #controls {
    display: block;
}

.developer-mode #controls .control,
.developer-mode #controls .control:hover {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    margin: 0 0 8px;
    overflow: visible;
    border-color: #555;
    background: #111;
    z-index: auto;
}

.developer-mode #controls .control h4 {
    position: static;
    padding: 9px 4px 7px;
}

.developer-mode #controls .control-inner,
.developer-mode #controls .control:hover .control-inner {
    display: block;
    max-height: none;
    margin-top: 0;
    padding: 3px;
    opacity: 1;
}

.developer-mode #controls .select-options {
    max-height: none;
    overflow: visible;
}

#developer-menu-button,
#developer-mode-status {
    display: none;
    position: fixed;
    z-index: 1150;
    color: #fff;
    background: rgba(91, 20, 20, .92);
    font: 14px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.developer-mode #developer-menu-button {
    display: block;
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    min-width: 88px;
    min-height: 38px;
    padding: 7px 12px;
    border: 2px solid #f0b0b0;
    border-radius: 7px;
    touch-action: manipulation;
}

.developer-mode #developer-mode-status {
    display: block;
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    padding: 8px 10px;
    border: 1px solid #f0b0b0;
    border-radius: 5px;
    pointer-events: none;
}

.mobile-game #orientation-overlay {
    z-index: 2000;
}

@media (orientation: portrait) {
    .mobile-game #touch-controls-layer,
    .mobile-game #developer-menu-button,
    .mobile-game #developer-mode-status {
        display: none;
    }
}
