/*
 * Safe-area insets are published as custom properties here because Phaser
 * cannot read env() itself. SafeArea.ts reads these back as numbers and feeds
 * LayoutPolicy. Requires viewport-fit=cover in index.html — without it every
 * env(safe-area-inset-*) resolves to 0 even on a notched device.
 */
:root {
    /*
     * WKWebView normally supplies env(), but iOS 26 can transiently publish
     * zeros during a cold launch. The native shell writes the --native-*
     * values after UIKit has resolved its safe area and dispatches resize so
     * the running Phaser scene relays out. Browsers retain the env() fallback.
     */
    --safe-area-top: var(--native-safe-area-top, env(safe-area-inset-top, 0px));
    --safe-area-right: var(--native-safe-area-right, env(safe-area-inset-right, 0px));
    --safe-area-bottom: var(--native-safe-area-bottom, env(safe-area-inset-bottom, 0px));
    --safe-area-left: var(--native-safe-area-left, env(safe-area-inset-left, 0px));
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.87);
    background-color: #0a0a14;
    /* A puzzle board must not rubber-band or select text under a drag. */
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/*
 * The canvas fills the viewport exactly — no centring, no letterbox. 100dvh
 * (not 100vh) so an iOS browser's collapsing URL bar cannot leave a dead strip
 * at the bottom of the board.
 */
#app {
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}

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

#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/*
 * Semantic companion for VoiceOver and other assistive technology.
 *
 * Do not use the usual 1px/clip visually-hidden pattern here. iOS WKWebView
 * prunes clipped nodes from its native accessibility tree, even though browser
 * DOM accessibility tools still expose them. Real, on-screen layout boxes with
 * transparent paint survive the WKWebView -> UIKit bridge. Pointer events stay
 * disabled so the authored canvas remains the sole touch surface; assistive
 * technology activates the ordinary DOM buttons directly.
 */
#phase-shift-accessibility {
    position: fixed;
    inset: 0;
    z-index: 1;
    padding: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
    color: transparent;
    background: transparent;
    border: 0;
}

/*
 * Normal touch bypasses the transparent companion. When UIKit reports that
 * VoiceOver is running, the native shell adds this class so exploration and
 * activation target the semantic buttons instead of falling through to the
 * canvas. The UI test target enables the identical path explicitly.
 */
.phase-shift-assistive-active #phase-shift-accessibility {
    pointer-events: auto;
}

#phase-shift-accessibility h1,
#phase-shift-accessibility p,
#phase-shift-accessibility button {
    display: block;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: transparent;
    background: transparent;
    border: 0;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
}

#phase-shift-accessibility div {
    display: grid;
    grid-template-columns: repeat(4, 44px);
    width: 176px;
    margin: 0;
    padding: 0;
}
