:root {
    color-scheme: dark;
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    background: #10140f;
    color: #f7f0d9;
}

* {
    box-sizing: border-box;
}

html,
body,
#app,
.lawn-shell {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    min-height: 100svh;
    overflow: hidden;
    overscroll-behavior: none;
    background: #10140f;
}

button {
    border: 0;
    font: inherit;
}

.boot-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #10140f;
    color: #f7f0d9;
}

.player-shell {
    position: relative;
    width: 100%;
    height: 100svh;
    min-height: 0;
    overflow: hidden;
    background: #10140f;
}

.play-stage {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    padding:
        max(12px, env(safe-area-inset-top))
        max(12px, env(safe-area-inset-right))
        max(12px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
    overflow: hidden;
    background: #11170f;
}

.play-stage:fullscreen,
.play-stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    padding: 0;
    background: #000;
}

.game-canvas {
    max-width: 100%;
    max-height: 100%;
    background: #203123;
    border: 1px solid rgba(247, 240, 217, 0.18);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.46);
    image-rendering: pixelated;
    touch-action: none;
    user-select: none;
}

.play-stage:fullscreen .game-canvas,
.play-stage:-webkit-full-screen .game-canvas {
    border: 0;
    box-shadow: none;
}

.game-canvas:focus {
    outline: none;
}

.stage-hud {
    position: absolute;
    inset:
        max(12px, env(safe-area-inset-top))
        max(12px, env(safe-area-inset-right))
        auto
        max(12px, env(safe-area-inset-left));
    z-index: 4;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.status-chip {
    min-width: 120px;
    max-width: min(46vw, 360px);
    padding: 8px 11px;
    border-radius: 8px;
    background: rgba(17, 23, 15, 0.78);
    border: 1px solid rgba(247, 240, 217, 0.16);
    color: #eadfaf;
    font-size: 13px;
    line-height: 1.25;
    overflow-wrap: anywhere;
    transition: opacity 160ms ease;
}

.status-chip.is-hidden {
    opacity: 0;
}

.status-chip.is-waiting {
    color: #f0c867;
}

.status-chip.is-busy {
    color: #8fd4ff;
}

.status-chip.is-ready {
    color: #bfe78a;
}

.stage-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.chrome-button,
.drawer-close {
    min-width: 44px;
    min-height: 40px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(22, 29, 19, 0.84);
    border: 1px solid rgba(247, 240, 217, 0.18);
    color: #fff4c8;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.chrome-button:hover,
.drawer-close:hover {
    background: rgba(41, 52, 31, 0.94);
}

.chrome-button:disabled,
.drawer-close:disabled {
    opacity: 0.48;
    cursor: default;
}

.launch-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    padding: clamp(18px, 4vw, 48px);
    background: rgba(7, 10, 7, 0.72);
    backdrop-filter: blur(4px);
}

.launch-panel {
    width: min(520px, 100%);
    padding: clamp(24px, 5vw, 38px);
    border-radius: 8px;
    background: rgba(25, 32, 21, 0.96);
    border: 1px solid rgba(247, 240, 217, 0.18);
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.52);
}

.launch-panel.has-error {
    border-color: rgba(239, 111, 86, 0.72);
}

.eyebrow {
    margin: 0 0 8px;
    color: #efc766;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
    font-weight: 800;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(34px, 7vw, 56px);
    line-height: 1;
}

h2 {
    font-size: 22px;
    line-height: 1.12;
}

.launch-copy {
    margin: 16px 0 0;
    color: #d8cfaa;
    font-size: 16px;
    line-height: 1.55;
}

.portrait-hint {
    display: none;
    margin: 12px 0 0;
    color: #efc766;
    font-size: 13px;
    font-weight: 700;
}

.launch-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.primary-action,
.secondary-action {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
    text-align: center;
}

.primary-action {
    min-width: 156px;
    padding: 0 18px;
    background: #9fca49;
    color: #17210e;
}

.primary-action:hover {
    background: #b4da5b;
}

.primary-action.is-disabled,
.primary-action:disabled {
    opacity: 0.52;
    cursor: default;
}

.secondary-action {
    width: 100%;
    padding: 0 14px;
    background: #3a4a2b;
    color: #fff0bf;
    border: 1px solid rgba(247, 240, 217, 0.14);
}

.secondary-action:hover {
    background: #4b6036;
}

.secondary-action:disabled {
    opacity: 0.48;
    cursor: default;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.launch-error {
    margin: 18px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(100, 36, 27, 0.68);
    color: #ffd9cb;
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.drawer-scrim {
    position: absolute;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.28);
    cursor: default;
}

.settings-drawer {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 6;
    width: min(376px, calc(100vw - 24px));
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding:
        max(22px, env(safe-area-inset-top))
        max(22px, env(safe-area-inset-right))
        max(22px, env(safe-area-inset-bottom))
        22px;
    background: #1c2219;
    border-left: 1px solid rgba(247, 240, 217, 0.14);
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.38);
    transform: translateX(100%);
    transition: transform 180ms ease;
}

.settings-drawer.is-open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.drawer-close {
    flex: 0 0 auto;
    width: 40px;
    min-width: 40px;
}

.status-list {
    margin: 0;
    display: grid;
    gap: 0;
}

.status-list div {
    display: grid;
    grid-template-columns: 74px 1fr;
    gap: 12px;
    align-items: center;
    min-height: 42px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(247, 240, 217, 0.1);
}

.status-list dt {
    color: #a9b391;
    font-size: 12px;
    font-weight: 700;
}

.status-list dd {
    margin: 0;
    color: #fff3c9;
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.drawer-actions {
    display: grid;
    gap: 10px;
}

.drawer-actions .primary-action {
    width: 100%;
}

.log-panel {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    padding: 10px 12px;
    border-radius: 8px;
    background: #11170f;
    border: 1px solid rgba(247, 240, 217, 0.1);
}

.log-panel p {
    margin: 0 0 9px;
    color: #d1c7a6;
    font-size: 12px;
    line-height: 1.45;
}

.log-panel p:last-child {
    margin-bottom: 0;
}

.empty-state {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    padding: 12px 16px;
    background: #6a2920;
    color: white;
    z-index: 10;
}

#blazor-error-ui .reload,
#blazor-error-ui .dismiss {
    margin-left: 12px;
    color: white;
}

@media (max-width: 720px) {
    .play-stage {
        padding:
            max(8px, env(safe-area-inset-top))
            max(8px, env(safe-area-inset-right))
            max(8px, env(safe-area-inset-bottom))
            max(8px, env(safe-area-inset-left));
    }

    .stage-hud {
        inset:
            max(8px, env(safe-area-inset-top))
            max(8px, env(safe-area-inset-right))
            auto
            max(8px, env(safe-area-inset-left));
    }

    .status-chip {
        max-width: 42vw;
        min-width: 0;
        padding: 7px 9px;
        font-size: 12px;
    }

    .chrome-button {
        min-width: 42px;
        min-height: 38px;
        padding: 0 9px;
        font-size: 12px;
    }

    .launch-panel {
        padding: 22px;
    }

    h1 {
        font-size: 38px;
    }

    .launch-copy {
        font-size: 14px;
    }

    .launch-actions {
        display: grid;
    }

    .primary-action {
        width: 100%;
    }

    .settings-drawer {
        width: min(340px, calc(100vw - 18px));
        gap: 16px;
        padding:
            max(18px, env(safe-area-inset-top))
            max(18px, env(safe-area-inset-right))
            max(18px, env(safe-area-inset-bottom))
            18px;
    }
}

@media (orientation: portrait) {
    .portrait-hint {
        display: block;
    }
}
