:root {
    color-scheme: dark;
    --soil: #15110d;
    --soil-deep: #080706;
    --amber: #d69b4a;
    --moss: #7f9b5f;
    --clay: #9a5d3c;
    --text: #f0e7d7;
    --muted: #a89d8f;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at 28% 18%, rgba(127, 155, 95, 0.16), transparent 24rem),
        linear-gradient(145deg, var(--soil), var(--soil-deep) 72%);
    color: var(--text);
    overflow: hidden;
    overscroll-behavior: none;
}

.shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.game-frame {
    position: relative;
    width: min(100%, 72rem);
    aspect-ratio: 16 / 9;
    min-height: 28rem;
    border: 1px solid rgba(214, 155, 74, 0.35);
    background:
        linear-gradient(90deg, rgba(154, 93, 60, 0.12), transparent 32%, rgba(127, 155, 95, 0.1)),
        #0d0a08;
    overflow: hidden;
}

.account-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(7, 5, 4, 0.9);
}

.account-modal[hidden],
.account-dialog [hidden] {
    display: none;
}

.account-dialog {
    position: relative;
    width: min(25rem, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding: 1.25rem;
    border: 1px solid rgba(214, 155, 74, 0.54);
    border-radius: 6px;
    background: #100c09;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.46);
}

.account-dialog h2 {
    margin: 0 2.5rem 0.85rem 0;
    color: var(--text);
    font-size: 1.35rem;
    letter-spacing: 0;
}

.account-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    font-size: 1.35rem;
}

.account-status {
    min-height: 2.4rem;
    margin: 0 0 0.75rem;
    color: #d9c7ad;
    font-size: 0.9rem;
    line-height: 1.35;
}

.account-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 1rem;
}

.account-mode button:first-child {
    border-radius: 6px 0 0 6px;
}

.account-mode button:last-child {
    border-left: 0;
    border-radius: 0 6px 6px 0;
}

.account-mode button[aria-selected="true"] {
    background: #49301f;
    color: #fff4df;
}

.account-dialog form,
.account-sync {
    display: grid;
    gap: 0.7rem;
}

.account-dialog label {
    color: var(--muted);
    font-size: 0.84rem;
}

.account-dialog input {
    width: 100%;
    min-height: 2.7rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid rgba(168, 157, 143, 0.46);
    border-radius: 4px;
    background: #090705;
    color: var(--text);
    font: inherit;
}

.account-dialog button {
    min-height: 2.65rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid rgba(214, 155, 74, 0.58);
    border-radius: 6px;
    background: #2d1d14;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.account-dialog button:focus-visible,
.account-dialog input:focus-visible {
    outline: 2px solid var(--moss);
    outline-offset: 2px;
}

.account-dialog button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.account-dialog .account-primary {
    background: #51351f;
    border-color: rgba(240, 195, 106, 0.76);
}

.account-user-line {
    margin: 0 0 1rem;
    color: var(--text);
}

#account-logout {
    width: 100%;
}

@media (orientation: landscape) and (max-height: 32rem) {
    .account-modal {
        padding: 0.5rem;
    }

    .account-dialog {
        max-height: calc(100vh - 1rem);
        padding: 0.75rem;
    }

    .account-dialog h2 {
        margin-bottom: 0.35rem;
        font-size: 1.15rem;
    }

    .account-close {
        top: 0.45rem;
        right: 0.45rem;
        width: 2rem;
        height: 2rem;
        min-height: 2rem;
    }

    .account-status {
        min-height: 1.2rem;
        margin-bottom: 0.35rem;
        font-size: 0.8rem;
    }

    .account-status:empty {
        min-height: 0;
    }

    .account-mode {
        margin-bottom: 0.45rem;
    }

    .account-dialog form,
    .account-sync {
        gap: 0.35rem;
    }

    .account-dialog input,
    .account-dialog button {
        min-height: 2.25rem;
    }

    .account-dialog input {
        padding: 0.4rem 0.55rem;
    }
}

.game-root {
    width: 100%;
    height: 100%;
    position: relative;
    display: grid;
    place-items: center;
    touch-action: none;
    user-select: none;
}

.boot-panel {
    width: min(32rem, calc(100% - 2rem));
    text-align: center;
    padding: 1rem;
    position: relative;
    z-index: 2;
}

.orientation-panel {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 5;
    place-items: center;
    text-align: center;
    padding: 2rem;
    background:
        radial-gradient(circle at 50% 28%, rgba(127, 155, 95, 0.16), transparent 18rem),
        rgba(8, 7, 6, 0.96);
}

.orientation-content {
    display: grid;
    justify-items: center;
    gap: 0.9rem;
    width: min(22rem, 100%);
}

.orientation-title {
    margin: 0;
    color: var(--amber);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0;
}

.orientation-copy {
    max-width: 18rem;
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.45;
}

.orientation-play-button {
    min-width: 9rem;
    min-height: 2.9rem;
    margin: 0.2rem 0 0;
    padding: 0.7rem 1.15rem;
    border: 1px solid rgba(214, 155, 74, 0.78);
    border-radius: 6px;
    background: #2d1d14;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.orientation-play-button:focus-visible {
    outline: 2px solid var(--moss);
    outline-offset: 3px;
}

.orientation-play-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.orientation-status {
    min-height: 1.2rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.35;
}

.is-running {
    display: block;
}

.is-running .boot-panel {
    display: none;
}

.game-root canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.main-menu-dom-actions {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
}

.main-menu-dom-actions[hidden] {
    display: none;
}

.main-menu-dom-action {
    position: absolute;
    padding: 0;
    border: 0;
    background: transparent;
    color: transparent;
    cursor: pointer;
    opacity: 0.001;
    pointer-events: auto;
}

.main-menu-dom-action:focus-visible {
    outline: 2px solid var(--moss);
    outline-offset: 2px;
}

.touch-menu-dom-actions {
    position: absolute;
    inset: 0;
    z-index: 7;
    display: none;
    pointer-events: none;
}

.touch-menu-dom-actions[hidden] {
    display: none;
}

.touch-menu-dom-action {
    position: absolute;
    padding: 0;
    border: 0;
    background: transparent;
    color: transparent;
    cursor: pointer;
    opacity: 0.001;
    pointer-events: auto;
}

.touch-menu-dom-action[hidden] {
    display: none;
}

.touch-menu-dom-action:focus-visible {
    outline: 2px solid var(--moss);
    outline-offset: 2px;
}

.eyebrow {
    margin: 0 0 0.65rem;
    color: var(--amber);
    font-size: 0.85rem;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 4rem;
    line-height: 1;
    letter-spacing: 0;
}

#boot-status {
    margin: 1rem 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.5;
}

.world-recovery-button {
    display: none;
    min-width: 10rem;
    margin: 1rem auto 0;
    padding: 0.7rem 1rem;
    border: 1px solid rgba(214, 155, 74, 0.7);
    border-radius: 6px;
    background: #241710;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.world-recovery-button:focus-visible {
    outline: 2px solid var(--moss);
    outline-offset: 3px;
}

.is-generation-error .boot-panel {
    display: block;
}

.is-generation-error #boot-status {
    color: #e0b18f;
}

.is-generation-error .world-recovery-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.is-generation-error canvas {
    display: none;
}

@media (max-width: 48rem) {
    .shell {
        align-items: start;
        padding: 0;
    }

    .game-frame {
        min-height: 100vh;
        border: 0;
        aspect-ratio: auto;
    }

    h1 {
        font-size: 2.5rem;
    }
}

@media (orientation: landscape) and (max-height: 32rem) {
    html,
    body,
    .shell,
    .game-frame {
        width: 100vw;
        height: 100vh;
        min-height: 0;
    }

    @supports (height: 100dvh) {
        html,
        body,
        .shell,
        .game-frame {
            height: 100dvh;
        }
    }

    .shell {
        padding: 0;
    }

    .game-frame {
        max-width: none;
        border: 0;
        aspect-ratio: auto;
    }
}

@media (pointer: coarse) and (orientation: landscape) {
    html,
    body,
    .shell,
    .game-frame {
        width: 100vw;
        height: 100vh;
        min-height: 100vh;
    }

    @supports (height: 100dvh) {
        html,
        body,
        .shell,
        .game-frame {
            height: 100dvh;
            min-height: 100dvh;
        }
    }

    .shell {
        padding: 0;
    }

    .game-frame {
        max-width: none;
        border: 0;
        aspect-ratio: auto;
    }

    .game-root {
        padding:
            env(safe-area-inset-top)
            env(safe-area-inset-right)
            env(safe-area-inset-bottom)
            env(safe-area-inset-left);
    }
}

@media (pointer: coarse) and (orientation: portrait) {
    .shell {
        padding: 0;
    }

    .game-frame {
        width: 100vw;
        height: 100vh;
        min-height: 100vh;
        max-width: none;
        border: 0;
        aspect-ratio: auto;
    }

    @supports (height: 100dvh) {
        html,
        body,
        .shell,
        .game-frame {
            height: 100dvh;
            min-height: 100dvh;
        }
    }

    .orientation-panel {
        display: grid;
    }

    .game-root canvas {
        opacity: 0.08;
        pointer-events: none;
    }
}

@media (pointer: coarse) and (orientation: landscape) {
    .touch-menu-dom-actions {
        display: block;
    }
}
