* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow: hidden;
  display: flex;
}

/* 広告スペース */
.ad-space {
  flex: 1;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.ad-placeholder {
  width: 100%;
  height: 600px;
  max-width: 300px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#game-container {
  position: relative;
  flex: 8;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at top, #333 0, #000 60%);
  min-width: 0;
}

/* 背景動画 */
#video-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
  background: #000;
}

#video-layers {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
}

.video-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s linear; /* クロスフェード時間 */
}

/* 表示中のレイヤー */
.video-layer.visible {
  opacity: 1;
}

/* 画面共通 */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 1;
}

.screen.active {
  display: flex;
}

#loading-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999; /* 他の画面より前面 */
}

/* 全画面表示時の調整 */
body:fullscreen .ad-space,
body:-webkit-full-screen .ad-space,
body:-moz-full-screen .ad-space,
body:-ms-fullscreen .ad-space {
  display: none;
}

body:fullscreen #game-container,
body:-webkit-full-screen #game-container,
body:-moz-full-screen #game-container,
body:-ms-fullscreen #game-container {
  flex: 1;
  width: 100vw;
}

body:fullscreen #video-player,
body:-webkit-full-screen #video-player,
body:-moz-full-screen #video-player,
body:-ms-fullscreen #video-player {
  object-fit: cover;
}

body:fullscreen .video-layer,
body:-webkit-full-screen .video-layer,
body:-moz-full-screen .video-layer,
body:-ms-fullscreen .video-layer {
  object-fit: cover;
}

/* タイトル画面 */
#title-screen {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.6);
  text-align: center;
  cursor: pointer;
}

.title-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.title-image {
  max-width: 90%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#title-screen .hint {
  font-size: 1.1rem;
  opacity: 0.8;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* ゲーム画面 */
#game-screen {
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  pointer-events: none; /* クリックしても何も起こさない（スペースのみ） */
}

#timer {
  margin-left: auto;
  font-size: 1.4rem;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

#game-message-wrapper {
  width: 100%;
  text-align: center;
  margin-bottom: 10vh;
}

#game-message {
  font-size: 1.1rem;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
  animation: fadeInOut 3s ease-in-out infinite;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* リザルト画面 */
#result-screen {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.65);
  text-align: center;
  padding: 20px;
}

.result-container {
  max-width: 90%;
  width: 600px;
}

#result-screen .result-text {
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.video-history-wrapper {
  margin: 1.5rem 0;
}

.video-history-title {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  text-align: left;
  opacity: 0.9;
}

#video-history {
  width: 100%;
  height: 200px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  resize: none;
  overflow-y: auto;
  text-align: left;
}

#video-history::-webkit-scrollbar {
  width: 8px;
}

#video-history::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

#video-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

#video-history::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

#result-screen .result-sub {
  font-size: 1rem;
  opacity: 0.8;
  margin-top: 1rem;
}

/* 右下のコントロール（全画面 & ボリューム） */
#controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 2;
  pointer-events: auto;
}

.control-button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.2s, transform 0.1s, border-color 0.2s;
  user-select: none;
}

.control-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
  transform: translateY(-1px);
}

.control-button:active {
  transform: translateY(1px) scale(0.97);
}

/* ボリュームスライダー */
.volume-wrapper {
  position: relative;
}

.volume-slider-wrapper {
  position: absolute;
  bottom: calc(100% + 48px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px;
  display: none;
}

/* クリックで開閉しているので :hover はあっても大勢に影響なし（inline style が優先される） */
.volume-wrapper:hover .volume-slider-wrapper {
  display: block;
}

.volume-slider {
  width: 120px;
  transform: rotate(-90deg); /* 縦スライダー風 */
  transform-origin: center;
}

input[type="range"] {
  accent-color: #ffffff;
}

/* 小さい画面向け */
@media (max-width: 600px) {
  #title-screen h1 {
    font-size: 2.2rem;
  }
  #game-message {
    font-size: 0.9rem;
  }
  #timer {
    font-size: 1.1rem;
  }
  .control-button {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }
}
