:root {
    --surface: #fffaf2;
    --surface-strong: #ffffff;
    --border: #eadfce;
    --text: #243041;
    --text-muted: #667085;
    --accent: #0f9f8f;
    --accent-strong: #0b766c;
    --coral: #f9735b;
    --gold: #f4b740;
    --sky: #78b7f2;
    --shadow: 0 18px 45px rgba(90, 67, 42, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(120, 183, 242, 0.22), rgba(255, 250, 242, 0.96)),
        #fffaf2;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
}

.app-loading,
.access-denied {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    text-align: center;
}

.loading-mark {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(15, 159, 143, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.app-shell {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

.app-header {
    position: fixed;
    left: 50%;
    top: max(90px, env(safe-area-inset-top));
    width: min(760px, calc(100vw - 36px));
    z-index: 4;
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: center;
    gap: 16px;
    min-height: 74px;
    padding: 16px 18px;
    border: 1px solid rgba(234, 223, 206, 0.9);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 16px 38px rgba(90, 67, 42, 0.14);
    backdrop-filter: blur(14px);
    transform: translateX(-50%);
}

h1,
p {
    margin-top: 0;
}

h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.15;
    text-align: center;
}

.header-back {
    justify-self: start;
}

.header-reset {
    justify-self: end;
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(90, 67, 42, 0.08);
    text-decoration: none;
    backdrop-filter: blur(8px);
}

.icon-button:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.blob-stage {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 16% 20%, rgba(244, 183, 64, 0.24), transparent 24%),
        radial-gradient(circle at 86% 22%, rgba(249, 115, 91, 0.18), transparent 25%),
        linear-gradient(180deg, #fffdf8 0%, #f6fbff 58%, #fff7df 100%);
    touch-action: none;
    user-select: none;
}

.blob-stage::before,
.blob-stage::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.blob-stage::before {
    inset: 0;
    background-image:
        linear-gradient(rgba(36, 48, 65, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(36, 48, 65, 0.045) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(180deg, transparent 0%, #000 18%, #000 82%, transparent 100%);
}

.blob-stage::after {
    left: 6%;
    right: 6%;
    bottom: 28px;
    height: 18px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(15, 159, 143, 0.2), rgba(244, 183, 64, 0.28), rgba(249, 115, 91, 0.22));
    filter: blur(9px);
}

.blob-friend {
    --squish-x: 1;
    --squish-y: 1;
    --facing-x: 1;
    position: absolute;
    left: 0;
    top: 0;
    width: var(--blob-width);
    height: var(--blob-height);
    cursor: grab;
    transform-origin: 50% 86%;
    transform: translate3d(var(--blob-x), var(--blob-y), 0) scale(var(--squish-x), var(--squish-y)) rotate(var(--blob-rotation));
    will-change: transform;
    z-index: 2;
}

.blob-art {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 18px 18px rgba(90, 67, 42, 0.18));
    transform-origin: 50% 100%;
    transform: scaleX(var(--facing-x));
    will-change: transform;
}

.blob-friend.is-dragging {
    cursor: grabbing;
    z-index: 3;
    filter: saturate(1.08);
}

.blob-friend.is-walking {
    --scoot-reach: 2px;
}

.blob-friend.is-walking .blob-art {
    animation: slimeScoot var(--scoot-duration, 0.74s) ease-in-out infinite;
}

.blob-friend.walk-left {
    --scoot-reach: -2px;
    --facing-x: 1;
}

.blob-friend.walk-right {
    --scoot-reach: 2px;
    --facing-x: -1;
}

.access-denied p {
    color: var(--text-muted);
    line-height: 1.6;
}

.access-denied a {
    color: var(--accent-strong);
    font-weight: 700;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slimeScoot {
    0%,
    100% {
        transform: translateX(0) scaleX(var(--facing-x)) scaleY(1);
    }

    38% {
        transform: translateX(var(--scoot-reach)) scaleX(calc(var(--facing-x) * 1.1)) scaleY(0.9);
    }

    68% {
        transform: translateX(calc(var(--scoot-reach) * -0.35)) scaleX(calc(var(--facing-x) * 0.96)) scaleY(1.04);
    }
}

@media (max-width: 720px) {
    .app-shell {
        inset: 0;
    }

    .app-header {
        left: 50%;
        top: 38px;
        width: calc(100vw - 20px);
        min-height: 70px;
        padding: 14px;
    }

    h1 {
        font-size: 1.65rem;
    }
}
