body {
  margin: 0;
  padding: 0;
  background-color: #0d0d1a;
  color: #fff;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow-x: hidden;
  user-select: none;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100vh;
  z-index: 10;
  pointer-events: none; /* UIの背景はクリックを透過 */
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100vh;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  pointer-events: auto;
  background: rgba(13, 13, 26, 0.95);
  padding: 50px 0;
  box-sizing: border-box;
}

.screen.active {
  display: flex;
}

/* ヘッダー (所持ダイヤ表示) */
#header {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  font-weight: bold;
  color: #00ffff;
  text-shadow: 0 0 10px #00ffff;
  pointer-events: auto;
  z-index: 20;
}

h1 {
  font-size: 48px;
  color: #ff00ff;
  text-shadow: 0 0 15px #ff00ff;
  margin-bottom: 40px;
}

h2 {
  font-size: 32px;
  color: #00ffff;
  margin-bottom: 20px;
}

/* ボタン */
.btn {
  background: transparent;
  border: 2px solid #00ffff;
  color: #00ffff;
  padding: 15px 40px;
  font-size: 24px;
  font-weight: bold;
  margin: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}
.btn:hover {
  background: #00ffff;
  color: #000;
  box-shadow: 0 0 20px #00ffff;
  transform: scale(1.05);
}

.btn-danger {
  border-color: #ff0055;
  color: #ff0055;
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.3);
}
.btn-danger:hover {
  background: #ff0055;
  color: #fff;
  box-shadow: 0 0 20px #ff0055;
}

.btn-gacha {
  border-color: #ffff00;
  color: #ffff00;
  font-size: 32px;
  padding: 20px 60px;
  box-shadow: 0 0 15px rgba(255, 255, 0, 0.4);
}
.btn-gacha:hover {
  background: #ffff00;
  color: #000;
  box-shadow: 0 0 30px #ffff00;
}

.back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 18px;
  padding: 10px 20px;
}

/* ガチャ結果 */
#gacha-result {
  font-size: 36px;
  font-weight: bold;
  margin: 20px 0;
  height: 50px;
  text-align: center;
}

/* 図鑑グリッド */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 800px;
  padding: 20px;
}
.collection-item {
  border: 1px solid #444;
  background: rgba(255,255,255,0.05);
  padding: 15px;
  text-align: center;
  border-radius: 8px;
}
.collection-item.owned {
  border-color: #00ff00;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.2);
}
.collection-item .name {
  font-weight: bold;
  margin-top: 10px;
  font-size: 18px;
}
.collection-item .count {
  font-size: 14px;
  color: #aaa;
}

/* ステージ選択 */
.stage-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 300px;
  margin-bottom: 20px;
}
.stage-reward {
  font-size: 14px;
  color: #aaa;
  margin-top: 5px;
}

/* ゲーム内UI (3D上) */
#screen-battle {
  pointer-events: none;
  background: transparent !important;
}
#game-info {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 32px;
  font-weight: bold;
  text-shadow: 0 0 10px #fff;
  text-align: center;
}

/* 配置用インベントリ (画面下部) */
#inventory {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 15px;
  pointer-events: auto;
  background: rgba(0,0,0,0.5);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #00ffff;
}
.inv-slot {
  width: 80px;
  height: 80px;
  border: 2px solid #555;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  background: #111;
  transition: all 0.2s;
  position: relative;
}
.inv-slot.active {
  border-color: #00ffff;
  box-shadow: 0 0 15px #00ffff;
  transform: translateY(-10px);
}
.inv-slot .inv-count {
  position: absolute;
  bottom: 2px;
  right: 5px;
  font-size: 16px;
  font-weight: bold;
}
.inv-slot .inv-name {
  font-size: 10px;
  margin-top: 5px;
  text-align: center;
}

#canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 1;
}

/* ガチャ演出エフェクト */
@keyframes flash {
  0% { opacity: 1; background: #fff; }
  100% { opacity: 0; background: transparent; }
}
#flash-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
}
