:root {
  --bg: #121316;
  --panel: rgba(18, 19, 22, 0.94);
  --line: rgba(255,255,255,0.12);
  --text: #f2f3f5;
  --muted: #9aa0a8;
  --accent: #e8792e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; height: 100dvh;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  overflow: hidden; touch-action: none; user-select: none;
}
body { display: flex; flex-direction: column; }
#stage { flex: 1 1 auto; position: relative; min-height: 0; }
#app { width: 100%; height: 100%; display: block; touch-action: none; }
#hint {
  position: absolute; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top));
  text-align: center; font-size: 13px; letter-spacing: 0.06em; color: rgba(255,255,255,0.7);
  pointer-events: none; transition: opacity 0.6s;
}
#hint.is-hide { opacity: 0; }

#panel {
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 0 14px calc(10px + env(safe-area-inset-bottom));
  max-height: 42vh;
  display: flex; flex-direction: column;
  backdrop-filter: blur(16px);
}
#panel.is-collapsed { max-height: none; }
#panel.is-collapsed .tabs,
#panel.is-collapsed .panel-body,
#panel.is-collapsed .panel-foot { display: none; }
.panel-handle {
  height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted); letter-spacing: 0.12em;
  cursor: pointer;
}
.panel-handle::before {
  content: ""; width: 36px; height: 4px; border-radius: 4px;
  background: rgba(255,255,255,0.22); margin-right: 10px;
}
.tabs { display: flex; gap: 6px; padding-bottom: 8px; }
.tab {
  flex: 1; height: 32px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); border-radius: 8px; font-size: 13px; cursor: pointer;
}
.tab.is-on { color: #111; background: #eee; border-color: #eee; }
.panel-body { overflow: auto; min-height: 0; flex: 1 1 auto; padding-bottom: 4px; }
.pane { display: none; }
.pane.is-on { display: block; }
label {
  display: grid; grid-template-columns: 76px 1fr 44px; gap: 8px; align-items: center;
  font-size: 12px; color: var(--muted); margin: 8px 0;
}
label.check { display: flex; gap: 8px; grid-template-columns: none; color: var(--text); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] {
  width: 100%; height: 28px; border: 1px solid var(--line); border-radius: 6px;
  background: transparent; padding: 0;
}
label b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.subhead { margin: 2px 0 10px; font-size: 12px; color: var(--muted); }
.mat-balls { display: flex; gap: 10px; justify-content: space-between; margin-bottom: 10px; }
.mat-ball {
  flex: 1; background: transparent; border: 1px solid transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; padding: 6px 2px; border-radius: 10px; cursor: pointer;
}
.mat-ball.is-on { border-color: var(--accent); color: var(--text); background: rgba(232,121,46,0.1); }
.mat-ball .ball {
  width: 44px; height: 44px; border-radius: 50%;
  box-shadow: inset -6px -8px 12px rgba(0,0,0,0.45), inset 5px 6px 8px rgba(255,255,255,0.28);
}
.panel-foot { padding-top: 6px; }
#btnReset {
  width: 100%; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 12px; cursor: pointer;
}

#rotate {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: #111; color: #eee; align-items: center; justify-content: center;
  font-size: 18px; letter-spacing: 0.08em;
}
@media (orientation: landscape) and (max-height: 520px) {
  #rotate { display: flex; }
}
