:root {
  color-scheme: dark;
  --bg: #1e1e1e;
  --panel: #2a2a2a;
  --text: #f2f2f2;
  --accent: #ff2d2d;
  --btn-bg: #3a3a3a;
  --btn-bg-active: #4a4a4a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  overscroll-behavior-y: contain;
  /* 横に広いコンテンツ(相性マトリクス等)がページ全体を横スクロールさせないようにする。
     個別の横スクロールは各コンテナ側の overflow-x: auto に任せる。 */
  overflow-x: hidden;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel);
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid #000;
}

.toolbar h1 {
  font-size: 16px;
  margin: 0 0 8px;
  font-weight: 600;
}

.buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  background: var(--btn-bg);
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.btn:active {
  background: var(--btn-bg-active);
}

.btn:disabled {
  opacity: 0.4;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-accent:active {
  background: #d61f1f;
}

main {
  padding: 12px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.status {
  min-height: 20px;
  color: #ffd23f;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  margin: 4px 0 10px;
}

.hint {
  color: #aaa;
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
}

#canvasWrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

#canvas {
  max-width: 100%;
  border-radius: 6px;
  /* ハンドルをつかんだ時だけ JS 側で preventDefault してドラッグを乗っ取る。
     それ以外の場所は縦スクロールできるようにしておく（画像が縦長で全体が
     画面に収まらない場合に、右下のハンドルまでスクロールして到達するため）。*/
  touch-action: pan-y;
}
