/* ブラウザ全体を覆うラッパ */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #333;
  overflow: hidden;
}

/* 
  #wrapper でコンテンツを中央配置し、
  内部の #container を transform: scale() で縮小/拡大します 
*/
#wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  background: #333;
  overflow: hidden;
  background-image: url('background.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* 
  アプリ本体の固定デザインサイズを想定(1080x1920) 
  transform-origin: top left; 等と組み合わせて拡縮 
*/
#container {
  width: 1080px;
  height: 1920px;
  background: black;
  position: relative;
  overflow: hidden;
  transform-origin: center center;
  margin: 0 auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--scale-factor));
}

/* 
  画面を4つに分割: topView / slideView / videoView / resultView 
  それぞれを絶対配置し、必要に応じて表示・非表示を切り替える 
*/
#topView, #slideView, #videoView, #resultView {
  position: absolute;
  top: 0;
  left: 0;
  width: 1080px;
  height: 1920px;
  display: none;
}

/* 0) トップ画面 */
#topView {
  background: black;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  font-family: sans-serif;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

/* タイトル */
#gameTitle {
  font-size: 72px;
  margin-bottom: 100px;
  text-align: center;
  animation: titlePulse 2s infinite;
}

/* タップ案内テキスト */
#tapGuide {
  font-size: 36px;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  animation: fadeInOut 2s infinite;
}

/* アニメーション */
@keyframes titlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.4; }
}

/* 1) スライド画面 (初期表示) */
#slideView {
  background: black;
  display: block;
  text-align: center;
  color: white;
  font-family: sans-serif;
  position: relative;
  overflow: hidden;
}

/* 産道の穴 */
#birthHole {
  position: absolute;
  bottom: 200px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 200px;
  background: white;
  border-radius: 200px 200px 200px 200px;
  z-index: 1;
  border: 5px solid #333;
}

/* 産道の穴のアニメーション */
@keyframes openHole {
  0% { width: 40px; }
  100% { width: 200px; }
}

/* 赤ちゃんのアニメーション */
@keyframes birthAnimation {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(300px) scale(0.8); }
  100% { transform: translateY(500px) scale(0.6); }
}

/* ドラッグ対象の赤ちゃん */
#baby {
  width: 450px;
  position: absolute;
  left: calc(50% - 250px);
  top: 500px;
  touch-action: none;
  transition: top 0.5s ease-out;
  z-index: 2;
  transform-origin: center center;
}

/* 赤ちゃんが産まれる時のアニメーションクラス */
.birthing {
  animation: birthAnimation 1.5s ease-in forwards;
}

/* 点滅する画像 */
#slideBlink {
  width: 300px;
  position: absolute;
  left: calc(50% + 240px);
  top: 500px;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* (スライド画面でガチャ結果を一時的に表示したい場合) */
#resultTextSlide {
  font-size: 48px;
  padding-top: 50px;
}

/* 2) 動画再生画面 */
#videoView {
  background: black;
  display: none;
  width: 100%;
  height: 100%;
}

#videoView.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

#videoContainer {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  background: black;
  overflow: hidden;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  transform: scale(1.1);
}

/* 3) 結果表示画面(白背景) */
#resultView {
  background: black;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 80px;
  font-family: sans-serif;
  width: 100%;
  height: 100%;
  position: relative;
  cursor: pointer;
}

#resultImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  margin-bottom: 20px;
}

/* 詳細表示用のオーバーレイ */
#detailOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 20;
  cursor: pointer;
}

#detailContent {
  width: 80%;
  max-height: 80%;
  overflow-y: auto;
  padding: 20px;
  text-align: center;
  font-size: 24px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* 結果画面のスキップボタン */
#resultSkipButton {
  position: absolute;
  top: -20px;
  right: 5px;
  width: 220px;
  height: 200px;
  z-index: 10;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.3s;
  object-fit: contain;
}

#resultSkipButton:hover {
  opacity: 0.8;
}

/* ============ サイズ警告 ============ */
#warningBox {
  display: none;
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,0,0,0.8);
  color: white;
  font-size: 32px;
  font-family: sans-serif;
  padding: 10px 20px;
  border-radius: 8px;
}

/* スキップボタン */
#skipButton {
  position: absolute;
  top: -20px;
  right: 5px;
  width: 220px;
  height: 200px;
  z-index: 10;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.3s;
  object-fit: contain;
}

#skipButton:hover {
  opacity: 1;
}

/* スケーリング用のスタイル */
@media screen and (max-width: 1080px), screen and (max-height: 1920px) {
  #container {
    transform-origin: center center;
  }
}

/* スマートフォン用のスタイル */
@media (max-width: 768px) {
  #wrapper {
    background-image: none;
    background: linear-gradient(135deg, #1a1a1a 0%, #333333 100%);
  }
  
  #container {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
  }
  
  #slideView, #videoView, #resultView {
    background: rgba(0, 0, 0, 0.8);
  }

  #videoContainer {
    background: black;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    transform: scale(1.1);
  }

  #skipButton {
    width: 120px;
    height: 100px;
    top: 20px;
    right: 20px;
    opacity: 0.8;
  }

  #gameTitle {
    font-size: 48px;
    margin-bottom: 60px;
  }

  #tapGuide {
    font-size: 24px;
  }
}

/* ローディング画面 */
#loadingView {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-spinner {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-size: 24px;
  font-family: sans-serif;
  color: white;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* スマートフォン用のスタイル */
@media (max-width: 768px) {
  .loading-spinner {
    width: 60px;
    height: 60px;
  }
  
  .loading-text {
    font-size: 20px;
  }
}

#closeDetailButton {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 15px 40px;
  font-size: 24px;
  background-color: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#closeDetailButton:hover {
  background-color: rgba(255, 255, 255, 1);
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
  #closeDetailButton {
    top: 15px;
    right: 15px;
    padding: 12px 30px;
    font-size: 20px;
  }
}

#toggleParentButton {
  position: absolute;
  top: 20px;
  left: 20px;
  padding: 15px 40px;
  font-size: 24px;
  background-color: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#toggleParentButton:hover {
  background-color: rgba(255, 255, 255, 1);
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
  #toggleParentButton {
    top: 15px;
    left: 15px;
    padding: 12px 30px;
    font-size: 20px;
  }
}

.heso-no-o-display {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 18px;
  font-family: 'Arial', sans-serif;
  z-index: 1000;
}

.login-bonus-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 20px 40px;
  border-radius: 10px;
  font-size: 24px;
  font-family: 'Arial', sans-serif;
  z-index: 1000;
  animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
  0% { opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; }
}

/* 管理者モードボタン */
.admin-button {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  font-size: 16px;
  color: white;
  background-color: #4CAF50;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  z-index: 100;
}

.admin-button:hover {
  opacity: 0.8;
}

/* コレクション画面のスタイル */
.collection-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.collection-controls {
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.filter-controls {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.filter-controls select {
  padding: 8px 15px;
  border-radius: 5px;
  border: 1px solid #ccc;
  background: white;
  font-size: 14px;
}

.collection-stats {
  display: flex;
  gap: 20px;
  color: #fff;
  font-size: 14px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px;
}

.collection-character {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s;
  cursor: pointer;
}

.collection-character:hover {
  transform: scale(1.05);
}

.character-image-container {
  position: relative;
  width: 100%;
  padding-top: 100%;
}

.character-image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-pulls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  padding: 5px;
  display: flex;
  justify-content: center;
  color: white;
  font-size: 12px;
}

.total-pulls {
  font-weight: bold;
  color: #ffd700;
}

.character-info {
  padding: 10px;
  color: white;
  text-align: center;
}

.stars {
  font-size: 18px;
  font-weight: bold;
  color: #ffd700;
  margin-right: 10px;
}

.obtained-date {
  font-size: 12px;
  color: #ccc;
}

/* タブのスタイル */
.collection-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
}

.tab-button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  transition: background-color 0.2s;
}

.tab-button.active {
  background: #4CAF50;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.parent-details {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1rem;
  max-height: 80vh;
  overflow-y: auto;
}

.parent-section {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.parent-section h3 {
  color: #ffd700;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  text-align: center;
}

.parent-section p {
  color: #fff;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.parent-section pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  margin-top: 1rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 0.5rem;
}
