*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: #f5f1e6;
  color: #5a4a4a;
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
}

header a {
  color: #b08a8a;
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

header a:hover {
  color: #5a4a4a;
}

main {
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- GUI ラッパー（デスクトップ） --- */

#gui-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#gui-toggle {
  display: none;
}

#gui-container {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0.5rem;
  pointer-events: none;
}

#gui-container > * {
  pointer-events: auto;
  width: 100%;
}

/* tileui テーマ調整（タイルパレット系） */
#gui-container {
  --tileui-bg: rgba(245, 241, 230, 0.92);
  --tileui-text: #333;
  --tileui-tile-bg: rgba(167, 216, 242, 0.25);
  --tileui-tile-bg-hover: rgba(168, 230, 225, 0.4);
  --tileui-border: rgba(167, 216, 242, 0.3);
  --tileui-knob-track: rgba(255, 154, 162, 0.3);
}

#gui-container .tileui-panel {
  justify-content: center;
}

/* --- モバイル: オーバーレイ + トグル --- */

@media (max-width: 48rem) {
  #gui-wrapper {
    transition: transform 0.3s ease;
  }

  /* 閉じた状態: コンテナを画面外に押し下げ、トグルだけ見える */
  #gui-wrapper.collapsed {
    transform: translateY(calc(100% - 2.5rem));
  }

  #gui-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 2.5rem;
    border: none;
    background: rgba(245, 241, 230, 0.92);
    color: #5a4a4a;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 0.5rem 0.5rem 0 0;
    pointer-events: auto;
    transition: background 0.2s;
  }

  #gui-toggle:hover {
    background: rgba(167, 216, 242, 0.6);
  }

  /* アイコンの回転アニメーション */
  #gui-toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
  }

  #gui-wrapper.collapsed #gui-toggle-icon {
    transform: rotate(180deg);
  }

  #gui-container {
    --tileui-bg: rgba(245, 241, 230, 0.82);
  }
}
