:root {
    --bg: #050816;
    --bg-soft: #0b1123;
    --panel: rgba(9, 14, 29, 0.82);
    --panel-strong: rgba(14, 20, 39, 0.94);
    --line: rgba(255, 255, 255, 0.09);
    --text: #f4efe8;
    --muted: #9da6bf;
    --cyan: #8fe9ff;
    --cyan-soft: rgba(143, 233, 255, 0.18);
    --peach: #ffc98b;
    --peach-soft: rgba(255, 201, 139, 0.16);
    --rose: #ff8e7d;
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
    --radius-xl: 34px;
    --radius-lg: 24px;
    --radius-md: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    min-width: 320px;
    font-family: "Noto Sans SC", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 142, 125, 0.14), transparent 24%),
        radial-gradient(circle at 82% 14%, rgba(143, 233, 255, 0.16), transparent 24%),
        radial-gradient(circle at 48% 82%, rgba(255, 201, 139, 0.08), transparent 26%),
        linear-gradient(180deg, #04070f 0%, #07101f 44%, #04070f 100%);
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 80px 80px;
    mask-image: radial-gradient(circle at center, black 48%, transparent 88%);
    opacity: 0.28;
}

.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.08;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.5) 0 0.6px, transparent 0.8px),
        radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.32) 0 0.6px, transparent 0.8px),
        radial-gradient(circle at 60% 70%, rgba(255, 255, 255, 0.38) 0 0.6px, transparent 0.8px);
    background-size: 180px 180px;
}

button,
input {
    font: inherit;
}

h1,
h2,
.eyebrow,
.stage-label,
.control-field strong,
.stat-card strong,
.ghost-button {
    font-family: "Space Grotesk", sans-serif;
}

p,
h1,
h2 {
    margin-top: 0;
}

.layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: 18px;
    width: min(1380px, calc(100% - 24px));
    height: calc(100dvh - 24px);
    margin: 0 auto;
    padding: 12px 0;
}

.info-panel,
.stage-panel {
    border: 1px solid var(--line);
    background: var(--panel);
    backdrop-filter: blur(22px);
    box-shadow: var(--shadow);
}

.info-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px;
    border-radius: var(--radius-xl);
}

.eyebrow,
.stage-label {
    margin-bottom: 10px;
    color: var(--cyan);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.74rem;
    font-weight: 700;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(2.4rem, 3.6vw, 3.8rem);
    line-height: 0.9;
    letter-spacing: -0.05em;
}

h2 {
    margin-bottom: 0;
    font-size: clamp(1.5rem, 2.2vw, 2.2rem);
    line-height: 0.96;
    letter-spacing: -0.04em;
}

.intro,
.footnote,
.legend,
.control-field span,
.canvas-overlay {
    color: var(--muted);
    line-height: 1.55;
}

.intro {
    font-size: 0.96rem;
}

.control-panel {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.03);
}

.control-field {
    display: grid;
    gap: 8px;
}

.control-field strong {
    font-size: 1.05rem;
    color: var(--text);
}

input[type="range"] {
    width: 100%;
    appearance: none;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(143, 233, 255, 0.28), rgba(255, 201, 139, 0.34));
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, var(--peach), var(--rose));
    box-shadow: 0 0 0 4px rgba(255, 201, 139, 0.15);
    cursor: pointer;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ghost-button {
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    transition: transform 0.24s ease, background 0.24s ease, border-color 0.24s ease;
    cursor: pointer;
}

.ghost-button:hover,
.ghost-button:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(143, 233, 255, 0.3);
    background: rgba(143, 233, 255, 0.08);
}

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

.stat-card {
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.stat-card span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.8rem;
}

.stat-card strong {
    display: block;
    font-size: clamp(1rem, 1.6vw, 1.45rem);
}

.footnote {
    margin-bottom: 0;
    font-size: 0.84rem;
}

.stage-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 18px;
    border-radius: calc(var(--radius-xl) + 6px);
    overflow: hidden;
}

.stage-header {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    font-size: 0.82rem;
}

.legend span {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-path {
    background: rgba(255, 255, 255, 0.42);
}

.dot-trace {
    background: var(--peach);
}

.dot-circle {
    background: var(--cyan);
}

.canvas-shell {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: calc(var(--radius-lg) + 4px);
    overflow: hidden;
    background:
        radial-gradient(circle at 30% 24%, rgba(143, 233, 255, 0.13), transparent 18%),
        radial-gradient(circle at 72% 72%, rgba(255, 201, 139, 0.12), transparent 22%),
        linear-gradient(180deg, rgba(11, 17, 35, 0.96), rgba(4, 8, 22, 0.96));
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.canvas-overlay {
    position: absolute;
    left: 20px;
    bottom: 16px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(8, 12, 24, 0.74);
    backdrop-filter: blur(18px);
    font-size: 0.88rem;
}

@media (max-width: 1080px) {
    body {
        overflow: auto;
    }

    .layout {
        grid-template-columns: 1fr;
        height: auto;
        padding: 10px 0 18px;
    }

    .canvas-shell {
        min-height: 520px;
    }
}

@media (max-width: 720px) {
    .layout {
        width: min(100% - 20px, 1380px);
        padding: 10px 0 20px;
    }

    .info-panel,
    .stage-panel {
        padding: 18px;
    }

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

    .stage-header {
        flex-direction: column;
    }

    .legend {
        justify-content: flex-start;
        gap: 12px;
    }

    .canvas-shell {
        min-height: 420px;
    }
}
