/*
 * The page the game is drawn into — everything outside the canvas and outside the panel.
 *
 * `manipulation` drops the gestures a game has no use for, double-tap to zoom above all, whose
 * 300ms wait for a second tap would otherwise sit between every tap and the control it lands on.
 * This, not the viewport meta, is what turns it off: iOS Safari has ignored `user-scalable=no`
 * since iOS 10.
 */
html {
    -ms-touch-action: manipulation;
    touch-action: manipulation;
    overflow: hidden;
}

/*
 * **And the document itself does not scroll.**
 *
 * There is nothing here to scroll to: the game is one canvas cut to the window with a fixed sheet
 * of controls over it. What a scrollable document would give a phone instead is a game that can be
 * *dragged* — a flick that misses a control carries the whole canvas up under the panel, and on iOS
 * it takes the browser's toolbars with it, resizing the page halfway through the gesture. `dvh` is
 * what keeps the body from standing a toolbar's height taller than the window.
 */
body {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #1d2126;
    -webkit-text-size-adjust: 100%;
}

/*
 * Nothing here is text to be selected and nothing here is an object to be dragged. Not tidiness: a
 * press that begins on the canvas or on a control and then travels — a drag across the board, a
 * scrub of a volume bar — is a *selection* gesture as far as the browser is concerned, and it makes
 * one, during the manipulation it interrupts. iOS adds its Copy / Look Up callout on a long hold.
 *
 * On `*` rather than on the root alone: `user-select` inherits, but the UA sheet *declares* its own
 * value on a few elements — images, form controls — and a declared value beats an inherited one.
 * The bet field is the one exception, three rules below: a number the player is editing is text.
 */
* {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

.mpl-bet__input {
    user-select: text;
    -webkit-user-select: text;
}

/* The backstop, for a selection made without a gesture: ⌘A, or a script that sets a range. */
::selection {
    background: transparent;
}

#pixi-container {
    position: absolute;
    inset: 0;
}

#pixi-container canvas {
    display: block;
}

/*
 * The launch screen — banners, the bar, and the arrows — is `index.html`'s, ported from
 * `slot-reel-of-the-dead`, whose `main.css` explains each rule.
 *
 * `--loading-line` is the start disc's centre (`.mpl-start` in `@magic/plinko`: 32px off the
 * safe area plus half its 88px), restated because the bar is up before the disc exists.
 */
:root {
    --loading-accent: #5cc4ff;
    --loading-line: calc(100dvh - env(safe-area-inset-bottom, 0px) - 76px);
    --splash-reel-half: min(46dvw, 300px);
    --splash-safe-bottom: calc(var(--loading-line) - 44px - 12px);
}

#splash-safe-bottom {
    position: fixed;
    top: var(--splash-safe-bottom);
    left: 0;
    visibility: hidden;
}

.splash {
    position: fixed;
    inset: 0;
    z-index: 4;
    overflow: hidden;
        background: #000;
    opacity: 1;
    transition:
        opacity 400ms ease-out,
        background-color 400ms ease-out;
        touch-action: pan-y;
}

.splash--ready {
    background: transparent;
}

.splash.is-leaving {
    opacity: 0;
    pointer-events: none;
}

.splash__track {
    position: absolute;
    inset: 0;
}

.splash__slide {
    position: absolute;
    inset: 0;
    overflow: hidden;
    transition: transform 320ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.splash__lockup {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%) scale(var(--splash-fit, 1));
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1.2em;
    box-sizing: border-box;
}

.splash__lockup picture {
    display: flex;
    justify-content: center;
    align-items: center;
}

.splash__image {
    display: block;
    max-width: min(100%, 95dvw);
    max-height: min(100%, 90dvh, 560px);
}

.splash__arrow {
    --splash-arrow-height: 3.6em;
        --splash-arrow-width: calc(var(--splash-arrow-height) * 12 / 21);
        --splash-arrow-gap: 0.6em;
    position: absolute;
    top: var(--loading-line);
    transform: translateY(-50%);
    display: block;
    width: var(--splash-arrow-width);
    height: var(--splash-arrow-height);
    padding: 0;
    border: 0;
    background: none;
    color: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 14px rgba(0, 0, 0, 0.45));
    font-size: clamp(13px, 3.6dvw, 16px);
    transition: opacity 0.18s ease-out;
}

.splash__arrow[hidden] {
    display: none;
}

.splash__arrow svg {
    display: block;
    width: 100%;
    height: 100%;
}

.splash__arrow--prev {
    left: max(
        calc(var(--splash-arrow-gap) + env(safe-area-inset-left, 0px)),
        calc(50% - var(--splash-reel-half) - var(--splash-arrow-gap) - var(--splash-arrow-width))
    );
}

.splash__arrow--next {
    right: max(
        calc(var(--splash-arrow-gap) + env(safe-area-inset-right, 0px)),
        calc(50% - var(--splash-reel-half) - var(--splash-arrow-gap) - var(--splash-arrow-width))
    );
}

.splash__arrow::before {
    content: '';
    position: absolute;
    inset: -0.5em -0.8em;
}

.splash__arrow:active {
    opacity: 0.6;
}

.splash__arrow:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 3px;
}

#loading {
    position: fixed;
    inset: 0;
        z-index: 30;
        pointer-events: none;
    opacity: 1;
    transition: opacity 400ms ease-out;
}

#loading.is-leaving {
    opacity: 0;
}

.loading__bar {
    position: absolute;
    left: 50%;
    top: var(--loading-line);
    translate: -50% -50%;
    width: min(76dvw, 440px);
    height: 4px;
    border-radius: 999px;
        background: rgba(255, 255, 255, 0.13);
    overflow: hidden;
}

.loading__fill {
    width: 100%;
    height: 100%;
    background: var(--loading-accent);
    box-shadow: 0 0 10px var(--loading-accent);
    transform: scaleX(0);
    transform-origin: left center;
        transition: transform 260ms ease-out;
}

.loading__bar--disc {
    box-shadow: 0 0 34px var(--loading-accent);
}

.loading__bar--waiting::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    animation: loading-wait 1.3s ease-in-out infinite;
}

@keyframes loading-wait {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .loading__bar--waiting::after {
        animation: none;
    }

    #loading,
    .splash,
    .splash__slide,
    .loading__fill {
        transition: none;
    }
}
