:root {
  --bg: #0b0f17;
  --panel: rgba(17, 23, 36, 0.94);
  --panel-solid: #111724;
  --border: rgba(255, 255, 255, 0.12);
  --text: #e8edf6;
  --muted: #9aa6bd;
  --accent: #22d3ee;
  --accent-press: #0891b2;
  --danger: #f87171;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 映像ステージ ===== */
.stage {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
}

.video {
  width: 100%;
  height: 100%;
  object-fit: contain;        /* 既定は全体表示（クロップしない） */
  background: #000;
  display: block;
}
.video.cover { object-fit: cover; }

/* 操作バーを隠した没入状態 */
.stage.immersive .bar,
.stage.immersive .info { opacity: 0; pointer-events: none; }

/* ===== 操作バー ===== */
.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px;
  padding-left: calc(12px + var(--safe-left));
  padding-right: calc(12px + var(--safe-right));
  padding-bottom: calc(12px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
  transition: opacity 0.25s ease;
}

.bar-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.select {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;          /* iOS の自動ズーム防止のため 16px 以上 */
  padding: 12px 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  appearance: none;
}

.btn {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 18px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease;
}
.bar-row:last-child .btn { flex: 1 1 0; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary {
  color: #052028;
  background: var(--accent);
  border-color: transparent;
}
.btn-primary:active { background: var(--accent-press); }

.btn[aria-pressed="true"] {
  background: var(--accent);
  color: #052028;
  border-color: transparent;
}

.btn-lg { font-size: 18px; padding: 16px 28px; }

/* ===== 情報オーバーレイ ===== */
.info {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  font-variant-numeric: tabular-nums;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: opacity 0.25s ease;
  max-width: calc(100vw - 24px);
}
.info-label { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-stats { font-size: 18px; font-weight: 700; letter-spacing: 0.3px; }

/* ===== 起動オーバーレイ ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%, #11203a 0%, var(--bg) 70%);
  z-index: 10;
}
.overlay.hidden { display: none; }

.overlay-card {
  width: min(440px, 100%);
  text-align: center;
}
.overlay-icon { font-size: 56px; line-height: 1; margin-bottom: 8px; }
.overlay-title { margin: 0 0 12px; font-size: 24px; font-weight: 800; }
.overlay-desc { margin: 0 0 24px; color: var(--muted); font-size: 15px; line-height: 1.7; }
.overlay-hint { margin: 16px 0 0; min-height: 1.4em; font-size: 14px; color: var(--danger); }

/* ===== トースト ===== */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(120px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  font-size: 14px;
  text-align: center;
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
}
.toast[hidden] { display: none; }
.toast.error { border-color: var(--danger); color: #fecaca; }
