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

:root {
  /* Web 版の下部広告バーの高さ。横長バナー実寸 + 余白に合わせ、
     描画領域とUI位置の基準にする。バナーサイズ(.ad-banner)と連動。 */
  --ad-h: 66px; /* モバイル: 320x50 バナー + 余白 */
}

@media (min-width: 480px) {
  :root { --ad-h: 76px; } /* タブレット: 468x60 */
}

@media (min-width: 768px) {
  :root { --ad-h: 106px; } /* デスクトップ: 728x90 */
}

body {
  background: #000;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* 描画領域。Web 版では下部に広告バーの高さ分を空け、その内側だけに
   ブラックホールと文字・画像を収める（広告領域に重ならないようにする）。 */
#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}

body.web-ads #stage {
  bottom: var(--ad-h);
}

#bh-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.text-label {
  position: absolute;
  pointer-events: auto;
  color: rgba(220, 180, 255, 0.85);
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: grab;
  text-shadow: 0 0 12px rgba(160, 80, 255, 0.5);
  touch-action: none;
}

.photo-card {
  position: absolute;
  pointer-events: auto;
  width: 140px;
  height: 100px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.15);
  cursor: grab;
  background-size: cover;
  background-position: center;
  touch-action: none;
}

#add-btn {
  /* iOS Safari はボタンにネイティブ外観を強制適用し、カスタムの背景・
     枠線を上書きしてデフォルトボタンに見せてしまう。appearance を none に
     してネイティブ外観を無効化し、下記のスタイルを確実に反映させる。 */
  appearance: none;
  -webkit-appearance: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(60, 0, 120, 0.55);
  border: 1px solid rgba(120, 60, 200, 0.6);
  color: rgba(200, 150, 255, 0.9);
  font-family: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

#add-btn:hover {
  background: rgba(80, 0, 160, 0.7);
  border-color: rgba(160, 80, 255, 0.8);
}

#hint {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  color: rgba(120, 80, 180, 0.6);
  font-size: 12px;
  font-weight: 300;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.6s;
}

#hint.hidden {
  opacity: 0;
}

#text-input-wrap {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: min(92vw, 380px);
  display: none;
}

#text-input-wrap.visible {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

#text-input {
  flex: 1;
  min-width: 0;
  background: rgba(20, 0, 40, 0.85);
  border: 1px solid rgba(120, 60, 200, 0.7);
  border-radius: 8px;
  color: rgba(220, 180, 255, 0.9);
  font-size: 16px;
  font-weight: 300;
  padding: 10px 16px;
  outline: none;
  letter-spacing: 0.03em;
}

#text-send-btn {
  /* iOS Safari のネイティブボタン外観を無効化する。これがないと角丸・
     グレーのグラデーションが優先され、以下の背景・枠線が反映されず
     「デフォルトのボタン」として表示されてしまう。 */
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(80, 0, 160, 0.7);
  border: 1px solid rgba(160, 80, 255, 0.8);
  color: rgba(220, 180, 255, 0.95);
  font-family: inherit;
  font-size: 15px;
  font-weight: 300;
  letter-spacing: 0.08em;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

#text-send-btn:hover {
  background: rgba(100, 0, 200, 0.85);
  border-color: rgba(180, 110, 255, 0.95);
}

#text-send-btn:active {
  transform: translateY(1px);
}

#text-input::placeholder {
  color: rgba(120, 80, 180, 0.5);
}

#text-input:focus {
  border-color: rgba(160, 80, 255, 0.9);
}

/* ===== 広告（Web 版のみ表示。Electron 版は表示しない） ===== */
/* ads.js が Web 版でのみ #ad-bottom に AdSense を描画し、body へ web-ads を付与する。
   Electron 版では #ad-bottom が空のまま :empty で非表示になる。 */
#ad-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  height: var(--ad-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  background: rgba(10, 0, 25, 0.82);
  border-top: 1px solid rgba(120, 60, 200, 0.5);
  backdrop-filter: blur(6px);
}

#ad-bottom:empty {
  display: none;
}

/* 下部バナーは横長の固定サイズ。auto 形式だと大きな矩形になり画面下半分を
   占有するため、ブレークポイントごとに横長サイズを明示する。 */
.ad-banner {
  width: 320px;
  height: 50px;
}

@media (min-width: 480px) {
  .ad-banner { width: 468px; height: 60px; }
}

@media (min-width: 768px) {
  .ad-banner { width: 728px; height: 90px; }
}

/* 広告表示時は操作 UI を広告バーの上へ持ち上げ、重ならないようにする */
body.web-ads #add-btn { bottom: calc(var(--ad-h) + 14px); }
body.web-ads #hint { bottom: calc(var(--ad-h) + 68px); }
body.web-ads #text-input-wrap { bottom: calc(var(--ad-h) + 68px); }
