* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    --bg-top: #081325;
    --bg-bottom: #17345d;
    --panel: rgba(9, 16, 31, 0.78);
    --panel-strong: rgba(6, 12, 24, 0.9);
    --line: rgba(135, 196, 255, 0.3);
    --text: #eef6ff;
    --muted: #9bb7d3;
    --accent: #78d6ff;
    --accent-strong: #ffb35c;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top, rgba(117, 178, 255, 0.2), transparent 35%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    color: var(--text);
}

body {
    padding: 18px;
}

.back-link {
    display: inline-flex;
    margin-bottom: 16px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    background: rgba(5, 11, 22, 0.55);
    backdrop-filter: blur(10px);
}

.shell {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
}

.intro-panel,
.stage-shell {
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(14px);
}

.intro-panel {
    padding: 28px;
}

.eyebrow {
    margin: 0 0 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    font-size: 0.78rem;
}

.intro-panel h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 0.95;
}

.summary {
    margin: 18px 0 24px;
    color: var(--muted);
    line-height: 1.65;
    max-width: 28rem;
}

.control-list {
    display: grid;
    gap: 12px;
    margin-bottom: 26px;
}

.control-list div {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
}

.control-list span,
.stat-label {
    display: block;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent-strong);
    font-size: 0.72rem;
}

.status-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
}

.stat-card strong {
    font-size: 1rem;
}

.stage-shell {
    position: relative;
    padding: 16px;
    min-height: 72vh;
}

.stage-topbar {
    position: absolute;
    top: 18px;
    left: 18px;
    right: 18px;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    pointer-events: none;
}

.pill {
    padding: 9px 14px;
    border-radius: 999px;
    background: rgba(4, 10, 21, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 0.85rem;
}

#scene {
    width: 100%;
    height: 100%;
    min-height: 72vh;
    display: block;
    border-radius: 22px;
    background: linear-gradient(180deg, #11213f, #09101b);
    touch-action: none;
}

.unsupported {
    position: absolute;
    inset: 56px 16px 92px;
    display: grid;
    place-items: center;
    padding: 28px;
    border-radius: 22px;
    background: var(--panel-strong);
    text-align: center;
}

.unsupported p {
    margin: 12px 0 0;
    max-width: 32rem;
    color: var(--muted);
    line-height: 1.6;
}

.touch-dock {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.touch-dock button {
    border: 0;
    border-radius: 16px;
    min-height: 52px;
    padding: 12px 10px;
    font: inherit;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(126, 190, 255, 0.3), rgba(52, 85, 149, 0.86));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.touch-dock button:active {
    transform: translateY(1px);
}

.hidden {
    display: none;
}

@media (max-width: 980px) {
    body {
        padding: 12px;
    }

    .shell {
        grid-template-columns: 1fr;
    }

    .intro-panel {
        padding: 22px;
    }

    .stage-shell {
        padding: 12px;
        min-height: 68vh;
    }

    #scene {
        min-height: 68vh;
    }
}

@media (max-width: 640px) {
    .status-grid {
        grid-template-columns: 1fr;
    }

    .touch-dock {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }

    .touch-dock button:last-child {
        grid-column: span 2;
    }

    .stage-topbar {
        left: 12px;
        right: 12px;
    }

    .unsupported {
        inset: 56px 12px 136px;
    }
}
