/* 画面全体を暗い背景で覆い、キャンバスを最背面に敷く。
   UI（オーバーレイ／ツールバー）はその上へ重ねる。 */
:root {
  --bg: #0b0d12;
  --panel: rgba(18, 22, 30, 0.82);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #e7ecf3;
  --text-dim: #9aa4b2;
  --accent: #22d3ee;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* タッチ操作を描画へ回す（スクロール/ズーム抑止） */
}

/* --- 左上のタイトル・ヒント --- */
.overlay {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  padding: 14px 16px;
  pointer-events: none; /* 下のキャンバス操作を妨げない */
}

.overlay__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.overlay__hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* --- 下部の操作パネル --- */
.toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}

.palette {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.palette::-webkit-scrollbar {
  display: none;
}

.palette__item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}

.palette__item:active {
  transform: scale(0.96);
}

.palette__item--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.palette__swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.controls__brush {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.controls__brush input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}

.controls__btn {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.controls__btn:active {
  transform: scale(0.96);
}

/* --- フォールバック（描画非対応時のみ表示） --- */
.fallback {
  display: none;
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
}

.no-webgl #scene,
.no-webgl .overlay,
.no-webgl .toolbar {
  display: none;
}

.no-webgl .fallback {
  display: block;
}
