:root {
    --bg: #12161c;
    --panel: #1c232d;
    --ink: #e6edf3;
    --muted: #8b98a5;
    --accent: #4a9eff;
}
/* Scrollbars, thin */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ink);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100%;
}

#stage {
    position: relative;
    flex: 1;
    min-width: 0;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    image-rendering: pixelated;
}

canvas.dragging {
    cursor: grabbing;
}

#panel {
    width: 280px;
    background: var(--panel);
    padding: 16px;
    overflow-y: auto;
    border-left: 1px solid #000;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: absolute;
    top: 10px;
    bottom: 10px;
    right: 10px;
    border-radius: 12px;
}

h1 {
    font-size: 15px;
    margin: 0 0 4px;
}

.sub {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

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

label {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
}

input[type=range] {
    width: 100%;
}

input[type=number],
input[type=text] {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    color: var(--ink);
    border-radius: 6px;
    padding: 6px;
    font-family: inherit;
    font-size: 12px;
}

button {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 9px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}

button.sec {
    background: #30363d;
}

button:hover {
    filter: brightness(1.1);
}

.toggles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.toggles label {
    font-size: 11px;
    color: var(--ink);
    display: flex;
    gap: 6px;
    align-items: center;
    background: #0d1117;
    padding: 5px 7px;
    border-radius: 6px;
    cursor: pointer;
}

.row {
    display: flex;
    gap: 8px;
}

.legend {
    font-size: 11px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    align-items: center;
}

.sw {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

#tip {
    position: absolute;
    left: 10px;
    top: 10px;
    background: rgba(0, 0, 0, .6);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    pointer-events: none;
    white-space: pre;
    line-height: 1.4;
}

#stat {
    color: var(--muted);
    font-size: 11px;
}

hr {
    border: 0;
    border-top: 1px solid #30363d;
    margin: 2px 0;
}

.accordion {
    border: 1px solid #30363d;
    border-radius: 8px;
    background: #0d1117;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.accordion-grow[open] {
    flex: 1 1 auto;
}

.accordion>summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    flex: 0 0 auto;
}

.accordion>summary::-webkit-details-marker {
    display: none;
}

.accordion>summary::after {
    content: "▸";
    color: var(--muted);
    transition: transform .15s ease;
}

.accordion[open]>summary::after {
    transform: rotate(90deg);
}

.accordion>summary:hover {
    background: #161c24;
}

.accordion-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px;
    border-top: 1px solid #30363d;
    overflow-y: auto;
    min-height: 0;
}

/* Panel toggle button (hidden on desktop, shown on small screens) */
#panelToggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid #30363d;
    padding: 8px 12px;
    font-size: 12px;
    display: none;
}

/* Mobile advisory modal */
#mobileNotice {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, .7);
}

#mobileNotice[hidden] {
    display: none;
}

.mobile-notice-card {
    background: var(--panel);
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 20px;
    max-width: 340px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-notice-card h2 {
    margin: 0;
    font-size: 16px;
}

.mobile-notice-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

/* Small screens: panel becomes a collapsible bottom sheet */
@media (max-width: 720px) {
    #panelToggle {
        display: block;
    }

    #panel {
        top: auto;
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        max-height: 70vh;
        transform: translateY(calc(100% + 20px));
        transition: transform .25s ease;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .5);
    }

    #panel.open {
        transform: translateY(0);
    }
}