/* ===================================================
   index.css  -  PLプレイヤー画面のスタイルシート
   =================================================== */

/* --- 全要素のリセット --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* --- ページ全体のベーススタイル --- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  background: #000;
}

/* ===== アプリストア風インストール画面 ===== */
#install-screen {
  position: fixed;
  inset: 0;
  background: #f2f2f7;
  z-index: 10;
  overflow-y: auto;
}

/* --- アプリ情報ヘッダー --- */
.store-header {
  background: #fff;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 0.5px solid #c7c7cc;
}

/* --- アプリアイコン（グラデーション背景） --- */
.app-icon {
  width: 100px;
  height: 100px;
  border-radius: 22px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
}

/* --- アプリ名・開発者情報エリア --- */
.app-info {
  flex: 1;
  min-width: 0;
}

.app-name {
  font-size: 22px;
  font-weight: 700;
  color: #000;
  margin-bottom: 3px;
}

.app-developer {
  font-size: 14px;
  color: #0071e3;
  margin-bottom: 8px;
}

/* --- アプリカテゴリタグ --- */
.app-tag {
  display: inline-block;
  font-size: 11px;
  color: #8e8e93;
  background: #f2f2f7;
  border-radius: 4px;
  padding: 2px 6px;
  margin-bottom: 12px;
}

/* --- インストールボタン --- */
.install-btn {
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: 0.02em;
}
.install-btn:active { opacity: 0.7; }

/* --- 評価・インストール数などの統計行 --- */
.app-stats {
  display: flex;
  background: #fff;
  margin-top: 12px;
  padding: 14px 20px;
  border-top: 0.5px solid #c7c7cc;
  border-bottom: 0.5px solid #c7c7cc;
}

.stat-item {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

/* --- 統計アイテム間の区切り線 --- */
.stat-item + .stat-item {
  border-left: 0.5px solid #c7c7cc;
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
  color: #3c3c43;
}

.stat-label {
  font-size: 10px;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- 星評価の色 --- */
.star-display {
  color: #ff9f0a;
  font-size: 12px;
  letter-spacing: 1px;
}

/* ===== スクリーンショットプレビューセクション ===== */
.screenshots-section {
  margin-top: 12px;
  padding: 16px 0 16px 20px;
  background: #fff;
  border-top: 0.5px solid #c7c7cc;
  border-bottom: 0.5px solid #c7c7cc;
}

.screenshots-label {
  font-size: 12px;
  font-weight: 600;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* --- 横スクロールコンテナ --- */
.screenshots-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-right: 20px;
  -webkit-overflow-scrolling: touch;
}
.screenshots-scroll::-webkit-scrollbar { display: none; }

/* --- 個別スクリーンショットカード --- */
.screenshot {
  width: 130px;
  height: 232px;
  border-radius: 14px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.screenshot-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,0.9);
}

.screenshot-emoji {
  font-size: 36px;
}

.screenshot-text {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 0 8px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== アプリ説明セクション ===== */
.description-section {
  margin-top: 12px;
  padding: 16px 20px;
  background: #fff;
  border-top: 0.5px solid #c7c7cc;
  border-bottom: 0.5px solid #c7c7cc;
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  color: #000;
  margin-bottom: 10px;
}

.description-section p {
  font-size: 14px;
  color: #3c3c43;
  line-height: 1.7;
}

/* ===== 機能一覧セクション ===== */
.features-section {
  margin-top: 12px;
  padding: 16px 20px 24px;
  background: #fff;
  border-top: 0.5px solid #c7c7cc;
}

.feature-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid #f2f2f7;
}

.feature-row:last-child { border-bottom: none; }

.feature-icon {
  font-size: 24px;
  width: 32px;
  text-align: center;
}

.feature-text {
  flex: 1;
}

.feature-title {
  font-size: 14px;
  font-weight: 600;
  color: #000;
}

.feature-desc {
  font-size: 12px;
  color: #8e8e93;
  margin-top: 2px;
}

/* ===== インストールコマンド入力モーダル ===== */
#command-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,0.45);
  align-items: flex-end;
  justify-content: center;
}

/* open クラスが付いたときに表示 */
#command-modal.open {
  display: flex;
}

/* --- モーダルシート（下から登場するパネル） --- */
.modal-sheet {
  background: #f2f2f7;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 12px 20px 48px;
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

/* --- シートが下からスライドインするアニメーション --- */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* --- モーダル上部のハンドルバー --- */
.modal-handle {
  width: 36px;
  height: 4px;
  background: #c7c7cc;
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-app-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

/* --- モーダル内のアプリアイコン（小） --- */
.modal-app-icon {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.modal-app-info .modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #000;
  text-align: left;
}

.modal-app-info .modal-subtitle {
  font-size: 12px;
  color: #8e8e93;
  text-align: left;
  margin-top: 2px;
}

.command-label {
  font-size: 13px;
  font-weight: 600;
  color: #3c3c43;
  margin-bottom: 8px;
}

/* --- ルームコード入力フィールド --- */
#install-command-input {
  width: 100%;
  font-size: 22px;
  font-family: 'SF Mono', 'Fira Mono', 'Courier New', monospace;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  padding: 14px 16px;
  text-align: center;
  border: 1.5px solid #c7c7cc;
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: #000;
  transition: border-color 0.2s;
}

/* フォーカス時に枠線を青くハイライト */
#install-command-input:focus {
  border-color: #0071e3;
}

/* --- エラーメッセージ表示エリア --- */
#command-error {
  color: #ff3b30;
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
  min-height: 20px;
}

/* --- モーダル内のインストールボタン --- */
.modal-install-btn {
  width: 100%;
  margin-top: 12px;
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: 0.02em;
}
.modal-install-btn:active { opacity: 0.7; }

/* --- キャンセルボタン --- */
.modal-cancel-btn {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  color: #0071e3;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

/* ===== インストール進捗画面 ===== */
#installing-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: #f2f2f7;
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

/* --- 大型アプリアイコン（脈打つアニメーション） --- */
.installing-icon {
  width: 110px;
  height: 110px;
  border-radius: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
  animation: iconPulse 2s ease-in-out infinite;
}

/* --- アイコンの影が膨らむパルスアニメーション --- */
@keyframes iconPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5); }
  50% { box-shadow: 0 8px 36px rgba(102, 126, 234, 0.8); }
}

.installing-name {
  font-size: 22px;
  font-weight: 700;
  color: #000;
}

/* --- インストール中のステータスメッセージ --- */
.installing-status {
  font-size: 14px;
  color: #8e8e93;
  letter-spacing: 0.02em;
  min-height: 20px;
}

/* --- プログレスバーの外枠 --- */
.progress-container {
  width: 260px;
}

.progress-bar-bg {
  background: #e5e5ea;
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
}

/* --- プログレスバーの塗り部分（グラデーション） --- */
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 6px;
  width: 0%;
  transition: width 0.25s ease;
}

/* --- 進捗率テキスト表示 --- */
.progress-pct {
  font-size: 12px;
  color: #8e8e93;
  text-align: center;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* --- ステップインジケーターのドット列 --- */
.installing-step-indicators {
  display: flex;
  gap: 6px;
}

/* 未完了ドット */
.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c7c7cc;
  transition: background 0.3s;
}

/* 現在のステップ（紫） */
.step-dot.active {
  background: #764ba2;
}

/* 完了済みステップ（青紫） */
.step-dot.done {
  background: #667eea;
}

/* ===== 遷移ブランク（スプラッシュ前の黒画面） ===== */
#black-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 45;
  display: none;
}

/* ===== スプラッシュ画面（アプリ起動時・更新時） ===== */
#splash-screen {
  position: fixed;
  inset: 0;
  background: #050c18;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
}

/* --- ロゴ本体（スケールアニメーションはJSで付与） --- */
.splash-logo {
  font-size: 64px;
  font-weight: 800;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: 0.02em;
  opacity: 0;
  user-select: none;
}

/* --- ロゴ登場アニメーション（バウンス感） --- */
.splash-logo.animate {
  animation: splashLogoIn 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes splashLogoIn {
  from {
    opacity: 0;
    transform: scale(0.65);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- 文字色分け --- */
.splash-br { color: rgba(255, 255, 255, 0.92); }
.splash-n  { color: rgba(255, 255, 255, 0.92); }

/* AI 部分にグラデーション --- */
.splash-ai {
  background: linear-gradient(135deg, #667eea, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== HUDオーバーレイ（左上・テック系ステータス表示） ===== */
#hud-overlay {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 5;
  font-family: 'Courier New', 'SF Mono', monospace;
  font-size: 12px;
  color: rgba(80, 255, 190, 0.85);
  line-height: 2;
  pointer-events: none;   /* クリックイベントを透過させる */
  text-transform: uppercase;
  letter-spacing: 0.12em;
  user-select: none;
  text-shadow: 0 0 8px rgba(80, 255, 190, 0.5);
}

.hud-line {
  margin-bottom: 2px;
}

/* --- 点滅アニメーション（遅め） --- */
.hud-blink {
  animation: hudBlink 2.8s step-end infinite;
}

/* --- 点滅アニメーション（さらに遅め・位相ずれ） --- */
.hud-blink2 {
  animation: hudBlink 4.2s step-end infinite 1.5s;
}

/* HUD 点滅キーフレーム */
@keyframes hudBlink {
  0%, 100% { opacity: 0.85; }
  45%, 55% { opacity: 0.22; }
}

/* ===== HUDコーナー表示（右下） ===== */
#hud-corner {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 5;
  font-family: 'Courier New', 'SF Mono', monospace;
  font-size: 10px;
  color: rgba(80, 255, 190, 0.6);
  line-height: 1.8;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: right;
  user-select: none;
  text-shadow: 0 0 6px rgba(80, 255, 190, 0.35);
  animation: hudBlink 5s step-end infinite 0.8s;
}

/* ===== コンパイルストリーム（左下・擬似ログ流れ） ===== */
#compile-stream {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 5;
  font-family: 'Courier New', 'SF Mono', monospace;
  font-size: 11px;
  line-height: 1.75;
  pointer-events: none;
  letter-spacing: 0.05em;
  user-select: none;
  max-width: 460px;
}

/* --- 各ログ行（古くなるほど透明になる） --- */
.cs-line {
  display: block;
  transition: opacity 0.4s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ログの種別ごとの色分け */
.cs-line.cs-ok    { color: rgba(80, 255, 190, 0.9); }   /* 成功: 緑 */
.cs-line.cs-warn  { color: rgba(255, 220, 80, 0.75); }  /* 警告: 黄 */
.cs-line.cs-info  { color: rgba(100, 200, 255, 0.75); } /* 情報: 青 */

/* ===================================================
   コネクションアウト演出スタイル
   =================================================== */

/* --- ブラックアウトオーバーレイ（オーバーロードより前面 z-index:300） --- */
#co-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #000;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#co-overlay.active {
  display: flex;
}

/* --- CRT電源オフ：中央に一瞬現れる白い水平線 --- */
#co-scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  top: 50%;
  transform: translateY(-50%) scaleX(0);
  opacity: 0;
  /* グラデーションで端を滑らかにフェード */
  background: linear-gradient(
    to right,
    transparent,
    rgba(255, 255, 255, 0.7) 15%,
    #fff 50%,
    rgba(255, 255, 255, 0.7) 85%,
    transparent
  );
  pointer-events: none;
}

/* --- CONNECTION LOST テキスト --- */
#co-text {
  color: #fff;
  font-family: 'Courier New', 'SF Mono', monospace;
  font-size: clamp(16px, 3.5vw, 28px);
  font-weight: bold;
  letter-spacing: 0.22em;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
  opacity: 0;
  /* 幅を固定して文字が出るたびにレイアウトがずれないようにする */
  min-width: 16ch;
  text-align: left;
}

/* ===================================================
   オーバーロード演出スタイル（全効果はJavaScriptで段階的に制御）
   =================================================== */

/* --- オーバーロードオーバーレイコンテナ（全画面・VRM描画の上） --- */
#overload-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
  overflow: hidden;
}

/* active クラスが付いたときに表示 */
#overload-overlay.active {
  display: block;
}

/* --- RGB分離：赤チャンネル。transform/opacity はJS制御 --- */
#ol-rgb-r {
  position: absolute;
  inset: 0;
  background: rgba(255, 0, 0, 0.18);
  mix-blend-mode: screen;
  opacity: 0;
}

/* --- RGB分離：青チャンネル。transform/opacity はJS制御 --- */
#ol-rgb-b {
  position: absolute;
  inset: 0;
  background: rgba(0, 80, 255, 0.18);
  mix-blend-mode: screen;
  opacity: 0;
}

/* --- グリッチノイズキャンバス（JavaScript で動的描画） --- */
#ol-glitch-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* --- スキャンライン。opacity はJS制御 --- */
#ol-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.14) 2px,
    rgba(0, 0, 0, 0.14) 4px
  );
  pointer-events: none;
  opacity: 0;
}
