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

body {
  margin: 0;
  min-height: 100dvh;
  background: #1a1a2e;
  color: #c8c8d8;
  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: #7a7a9a;
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

header a:hover {
  color: #c8c8d8;
}

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(22, 22, 44, 0.92);
  --tileui-tile-bg: rgba(40, 40, 70, 0.6);
  --tileui-tile-bg-hover: rgba(60, 60, 100, 0.8);
  --tileui-border: rgba(100, 100, 160, 0.25);
  --tileui-knob-track: rgba(100, 100, 160, 0.25);
  --tileui-text: #c8c8d8;
  --tileui-accent: #e94560;
}

#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(22, 22, 44, 0.92);
    color: #c8c8d8;
    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(40, 40, 70, 0.95);
  }

  /* アイコンの回転アニメーション */
  #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(22, 22, 44, 0.85);
  }
}
