:root {
    --bg: #2a2a2f;
    --ink: #f1f1f3;
    --glass: rgba(22, 22, 28, 0.62);
    --hot: #ffd84a;
    --gap: max(16px, env(safe-area-inset-bottom));
}

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--bg);
    color: var(--ink);
    font: 600 13px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    -webkit-user-select: none;
    user-select: none;
}

canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
}

canvas.dragging { cursor: grabbing; }

#badge {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    width: 40px;
    opacity: 0.85;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
    transition: opacity 0.2s, transform 0.2s;
}

#badge:hover { opacity: 1; transform: scale(1.06) rotate(-4deg); }
#badge img { display: block; width: 100%; height: auto; }

#bar, #panel {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-radius: 12px;
}

#bar {
    bottom: var(--gap);
    display: flex;
    gap: 2px;
    padding: 4px;
}

button {
    font: inherit;
    letter-spacing: 0.05em;
    color: var(--ink);
    background: none;
    border: 0;
    padding: 11px 14px;
    border-radius: 9px;
    cursor: pointer;
    min-width: 4.5em;
}

button:hover { color: var(--hot); background: rgba(255, 255, 255, 0.07); }
button:active { transform: translateY(1px); }

#panel {
    bottom: calc(var(--gap) + 56px);
    width: min(340px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#panel[hidden] { display: none; }

.row {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.sw {
    width: 26px;
    height: 26px;
    min-width: 0;
    padding: 0;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.sw:hover { outline-color: rgba(255, 255, 255, 0.35); background-color: initial; }
.sw.on { outline-color: var(--ink); }

.m-plastic { background: radial-gradient(circle at 35% 30%, #fff 0 7%, #e33 22%, #7a0a0a 100%); }
.m-glass { background: radial-gradient(circle at 35% 30%, #fff 0 7%, rgba(190, 220, 255, 0.35) 24%, rgba(90, 120, 160, 0.3) 70%, rgba(235, 245, 255, 0.85) 96%); }
.m-metal { background: radial-gradient(circle at 35% 30%, #fff 0 6%, #9ab 22%, #1c2430 52%, #cfe0ee 72%, #4a5866 100%); }
.m-marble { background: linear-gradient(130deg, #eee 0 30%, #777 33%, #e6e6e6 37% 62%, #888 64%, #eee 68%); }
.m-wood { background: repeating-radial-gradient(circle at 15% 85%, #d0924a 0 3px, #8a5220 4px 6px); }
.m-granite { background: radial-gradient(#333 0.8px, transparent 1.4px) 0 0 / 5px 5px, radial-gradient(#eee 0.6px, transparent 1.2px) 2px 3px / 6px 6px, radial-gradient(circle at 35% 30%, #c9c3bd, #6d6560); }
.m-checker { background: conic-gradient(#e22 25%, #fff 0 50%, #e22 0 75%, #fff 0) 0 0 / 12px 12px; }
.m-matte { background: radial-gradient(circle at 40% 35%, #d25555, #8a2020); }

#del { min-width: 0; }

input[type=range] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 28px;
    background: none;
    margin: 0 4px;
}

input[type=range]::-webkit-slider-runnable-track { height: 2px; background: rgba(255, 255, 255, 0.35); }
input[type=range]::-moz-range-track { height: 2px; background: rgba(255, 255, 255, 0.35); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--ink); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--ink); }

#nogl { display: none; position: fixed; inset: 0; margin: auto; height: 1em; text-align: center; }
.nogl #nogl { display: block; }
.nogl #bar { display: none; }
