:root {
    color-scheme: dark;
    --bg: #071019;
    --bg-soft: rgba(10, 18, 30, 0.78);
    --panel: rgba(7, 15, 24, 0.78);
    --panel-border: rgba(148, 184, 202, 0.15);
    --text: #eff8ff;
    --muted: #9eb1c1;
    --accent: #67e8f9;
    --accent-2: #86efac;
    --accent-warm: #fb923c;
    --danger: #fca5a5;
    --danger-strong: #fb7185;
    --shadow: 0 28px 88px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

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

body {
    background:
        radial-gradient(circle at top left, rgba(103, 232, 249, 0.12), transparent 30%),
        radial-gradient(circle at top right, rgba(251, 146, 60, 0.12), transparent 28%),
        radial-gradient(circle at bottom left, rgba(134, 239, 172, 0.08), transparent 26%),
        linear-gradient(180deg, #08111c 0%, #02070f 100%);
    color: var(--text);
    font-family: "Sora", sans-serif;
    padding: 28px;
}

button,
input {
    font: inherit;
}

.app-shell {
    max-width: 1500px;
    margin: 0 auto;
}

.hero {
    margin-bottom: 16px;
}

.hero-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px 24px;
    flex-wrap: wrap;
}

.hero-title {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

h1 {
    margin: 0;
    font-size: clamp(2.8rem, 6vw, 5rem);
    line-height: 0.92;
}

.playground-picker {
    position: relative;
}

.playground-heading {
    margin: 0;
    display: inline-flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.playground-btn {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    cursor: pointer;
    line-height: 0.92;
}

.playground-btn:hover .playground-method-label,
.playground-picker.open .playground-method-label {
    color: #94f0ff;
}

.playground-caret {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
    background: linear-gradient(135deg, #7dd3fc 0%, #34d399 100%);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    transform: rotate(0deg);
    transform-origin: center;
    transition: transform 180ms ease, filter 180ms ease;
    filter: drop-shadow(0 0 10px rgba(103, 232, 249, 0.24));
}

.playground-method-label,
.playground-suffix {
    font: inherit;
    line-height: inherit;
}

.playground-method-label {
    color: var(--accent);
    transition: color 180ms ease;
}

.playground-suffix {
    color: var(--text);
    cursor: default;
    user-select: none;
    display: inline-flex;
    align-items: flex-end;
    line-height: 0.92;
}

.playground-menu {
    position: absolute;
    top: calc(100% + 14px);
    left: 0;
    min-width: 260px;
    padding: 10px;
    border: 1px solid rgba(125, 211, 252, 0.22);
    border-radius: 18px;
    background: rgba(8, 14, 26, 0.92);
    backdrop-filter: blur(18px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
    z-index: 20;
}

.playground-picker.open .playground-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.playground-option {
    border: 1px solid transparent;
    background: rgba(15, 23, 42, 0.42);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    text-align: left;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.playground-option:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(148, 163, 184, 0.3);
    background: rgba(30, 41, 59, 0.75);
}

.playground-option.active {
    border-color: rgba(56, 189, 248, 0.42);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(34, 197, 94, 0.12));
}

.playground-option:disabled {
    opacity: 0.55;
    cursor: default;
}

.hero-actions,
.toggle-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.72fr) minmax(300px, 360px);
    gap: 22px;
}

.canvas-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.canvas-card {
    padding: 18px;
}

.canvas-topbar,
.canvas-footer,
.panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.canvas-topbar {
    align-items: flex-start;
    margin-bottom: 16px;
    justify-content: flex-end;
}

.tool-btn,
.panel-badge,
.toggle-chip {
    border-radius: 999px;
}

.tool-btn {
    border: 1px solid rgba(148, 184, 202, 0.18);
    background: rgba(15, 23, 42, 0.68);
    color: var(--text);
    padding: 11px 17px;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.tool-btn:hover,
.tool-btn[aria-pressed="true"] {
    transform: translateY(-1px);
    border-color: rgba(103, 232, 249, 0.35);
    box-shadow: 0 10px 28px rgba(103, 232, 249, 0.08);
}

.tool-btn.accent {
    background: linear-gradient(135deg, rgba(103, 232, 249, 0.18), rgba(134, 239, 172, 0.16));
    border-color: rgba(103, 232, 249, 0.38);
}

#predatorBtn[aria-pressed="true"] {
    border-color: rgba(251, 146, 60, 0.45);
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.24), rgba(251, 113, 133, 0.16));
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid rgba(148, 184, 202, 0.14);
    background: rgba(8, 18, 32, 0.72);
    color: var(--text);
    cursor: pointer;
}

.toggle-chip input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.canvas-stack {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid rgba(148, 184, 202, 0.14);
    background: #030913;
}

#boidCanvas {
    display: block;
    width: 100%;
    aspect-ratio: 11 / 7;
    cursor: crosshair;
}

#boidCanvas.predator-active {
    cursor: none;
}

.canvas-footer {
    margin-top: 16px;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.footer-stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    color: var(--muted);
    font: 500 0.84rem "IBM Plex Mono", monospace;
    font-variant-numeric: tabular-nums;
}

.footer-stat {
    display: inline-grid;
    grid-template-columns: auto 4ch;
    align-items: center;
    column-gap: 0.8ch;
}

.footer-label {
    white-space: nowrap;
}

.footer-value {
    display: inline-block;
    min-width: 4ch;
    text-align: right;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.panel {
    padding: 18px;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.panel h2 {
    margin: 0;
    font-size: 1rem;
}

.panel-badge {
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 184, 202, 0.14);
    color: var(--muted);
    font-size: 0.8rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 14px;
    align-items: center;
}

.control-title {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--text);
}

.control strong {
    font: 500 0.9rem "IBM Plex Mono", monospace;
    color: var(--text);
}

.control input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
    accent-color: var(--accent);
}

.layered-slider {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.layered-slider-bands {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.layer-chip {
    border: 1px solid rgba(148, 184, 202, 0.16);
    background: rgba(15, 23, 42, 0.72);
    color: var(--muted);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.layer-chip.active {
    color: var(--text);
    border-color: rgba(103, 232, 249, 0.3);
    background: rgba(103, 232, 249, 0.12);
}

.layered-slider.schooling .layer-chip.active {
    border-color: rgba(251, 146, 60, 0.34);
    background: rgba(251, 146, 60, 0.14);
}

.schooling-slider {
    accent-color: var(--accent-warm);
}

.info-tip {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
    outline: none;
}

.info-mark {
    display: inline-grid;
    place-items: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 184, 202, 0.24);
    color: var(--accent);
    font: 600 0.72rem/1 "IBM Plex Mono", monospace;
    transform: translateY(-0.2rem);
}

.info-bubble {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    width: 220px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(8, 18, 32, 0.96);
    border: 1px solid rgba(103, 232, 249, 0.18);
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
    transform: translateX(-50%) translateY(-6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease, transform 140ms ease;
    z-index: 10;
}

.info-tip:hover .info-bubble,
.info-tip:focus-within .info-bubble {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

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

.stat-card {
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(148, 184, 202, 0.12);
    background: rgba(8, 18, 32, 0.74);
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat-value {
    margin-top: 8px;
    display: block;
    font: 600 1rem "IBM Plex Mono", monospace;
}

@media (max-width: 1120px) {
    body {
        padding: 18px;
    }

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

@media (max-width: 720px) {
    body {
        padding: 14px;
    }

    .canvas-card,
    .panel {
        border-radius: 24px;
    }

    .canvas-topbar,
    .canvas-footer,
    .panel-heading {
        flex-direction: column;
        align-items: flex-start;
    }

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

@media (max-width: 540px) {
    h1 {
        font-size: 1.72rem;
    }

    .playground-heading {
        gap: 4px 8px;
        flex-wrap: nowrap;
    }

    .playground-btn {
        min-height: 44px;
        align-items: flex-end;
    }

    .playground-suffix {
        cursor: pointer;
    }

    .playground-menu {
        min-width: min(260px, calc(100vw - 28px));
    }

    #boidCanvas {
        aspect-ratio: 1 / 1;
    }
}
