/* ============================================================================
   Heritage Chrono Lens — Glassmorphism Cinematic UI Stylesheet
   Web Quality Guidelines Compliant (100dvh, Safe Area, 320px〜1440px, Touch 44px+)
   ============================================================================ */

:root {
  color-scheme: dark;
  --bg-deep: #060911;
  --glass-bg: rgba(12, 17, 29, 0.72);
  --glass-surface: rgba(20, 27, 44, 0.68);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.24);
  --text-primary: #f3f5fa;
  --text-secondary: #b6c0d4;
  --text-muted: #7f8ca6;
  --accent-gold: #e6b85c;
  --accent-gold-bright: #ffd479;
  --accent-amber: #f08c3a;
  --accent-cyan: #58b8f0;
  --font-sans: 'Inter', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --font-serif: 'Cormorant Garamond', 'Shippori Mincho', Georgia, serif;
}

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

html, body {
  width: 100%;
  height: 100%;
}

body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* ==================== 3D WebGL キャンバス背景 & ファインダー ==================== */
#canvas-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#webgl-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.shutter-flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 4;
}

.shutter-flash.active {
  opacity: 0.92;
  transition: none;
}

.viewfinder-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.28;
  transition: opacity 0.3s ease;
}

.vf-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.14);
}
.vf-h1 { top: 33.333%; left: 0; right: 0; height: 1px; }
.vf-h2 { top: 66.666%; left: 0; right: 0; height: 1px; }
.vf-v1 { left: 33.333%; top: 0; bottom: 0; width: 1px; }
.vf-v2 { left: 66.666%; top: 0; bottom: 0; width: 1px; }

.vf-center-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(230, 184, 92, 0.45);
  border-radius: 50%;
}

/* ==================== アプリケーション UI ルート ==================== */
#app {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen[hidden],
[hidden] {
  display: none !important;
}

/* ==================== グラスモーフィズム共通クラス ==================== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.glass-surface {
  background: var(--glass-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
}

/* ==================== 1. タイトル画面 ==================== */
.title-screen {
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: auto;
  background: radial-gradient(circle at center, rgba(6, 10, 20, 0.25) 0%, rgba(4, 7, 15, 0.72) 100%);
}

.title-card {
  width: min(100%, 600px);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(1.25rem, 4vw, 2.4rem);
  border-radius: 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.title-badge {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent-gold);
  background: rgba(230, 184, 92, 0.12);
  border: 1px solid rgba(230, 184, 92, 0.35);
}

.title-heading {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 6vw, 3.3rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 0%, #f5dfb0 55%, #d69e42 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-sub {
  font-family: var(--font-serif);
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  color: var(--text-secondary);
  letter-spacing: 0.08em;
}

.title-lead {
  font-size: clamp(0.8rem, 2vw, 0.92rem);
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 52ch;
}

.heritage-preview-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.preview-pill {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.title-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 0.25rem;
}

.title-controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* ==================== 共通ボタン ==================== */
button, a.btn {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
}

.btn {
  min-height: 48px;
  min-width: 180px;
  padding: 0.65rem 1.5rem;
  border-radius: 14px;
  border: 1px solid transparent;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #d8a242 0%, #b8771d 100%);
  color: #0b0e17;
  border-color: rgba(255, 232, 179, 0.45);
  box-shadow: 0 10px 28px rgba(216, 162, 66, 0.32);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #e5b354 0%, #c98527 100%);
  box-shadow: 0 12px 34px rgba(230, 184, 92, 0.45);
}

.btn-secondary {
  background: rgba(34, 43, 66, 0.85);
  color: var(--text-primary);
  border-color: var(--glass-border);
}

.btn-main {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.btn-caption {
  font-size: 0.72rem;
  opacity: 0.85;
  font-weight: 500;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover,
.icon-pill:hover {
  border-color: var(--glass-highlight);
}

.icon-pill {
  min-height: 44px;
  padding: 0 0.85rem;
  border-radius: 12px;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.icon-pill[aria-pressed="true"] {
  border-color: rgba(230, 184, 92, 0.55);
  color: var(--accent-gold-bright);
}

/* ==================== 2. プレイ（鑑賞・撮影）画面 ==================== */
.play-screen {
  justify-content: space-between;
  pointer-events: none;
}

/* 上部ナビゲーションバー */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  pointer-events: auto;
  z-index: 5;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.site-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem;
  border-radius: 14px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.site-tabs::-webkit-scrollbar {
  display: none;
}

.site-tab {
  min-height: 40px;
  padding: 0.3rem 0.75rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.site-tab.active {
  background: rgba(230, 184, 92, 0.18);
  border-color: rgba(230, 184, 92, 0.55);
  color: var(--text-primary);
}

.site-tab-en {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.site-tab-jp {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.site-tab.active .site-tab-jp {
  color: var(--accent-gold);
}

/* 没入モード復帰ボタン */
.restore-ui-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  pointer-events: auto;
  z-index: 8;
}

/* 右側コントロールパネル（Control Dock） */
.control-dock {
  position: absolute;
  top: 4.2rem;
  right: 0.75rem;
  width: min(330px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 10.2rem);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  z-index: 5;
  transition: max-height 0.28s ease;
}

.control-dock.collapsed .dock-body {
  display: none;
}

.dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.dock-tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.dock-tab {
  flex: 1;
  min-height: 38px;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.dock-tab.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--accent-gold-bright);
}

.dock-collapse-btn {
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1rem;
  margin-left: 0.25rem;
}

.dock-body {
  padding: 0.75rem 0.85rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.control-label-row small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

.control-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent-gold-bright);
  font-size: 0.8rem;
}

.control-subhint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* スライダー */
.chrono-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}

.chrono-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.chrono-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gold-bright);
  border: 2px solid #0b0f1c;
  margin-top: -7px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* クイックチップ＆セグメントボタン */
.quick-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}

.chip-btn {
  min-height: 30px;
  padding: 0.2rem 0.25rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.66rem;
  font-weight: 500;
}

.chip-btn:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

.mini-action-btn {
  min-height: 28px;
  padding: 0.15rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(230, 184, 92, 0.4);
  background: rgba(230, 184, 92, 0.14);
  color: var(--accent-gold-bright);
  font-size: 0.68rem;
  font-weight: 600;
}

.segmented-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 0.3rem;
}

.seg-btn {
  min-height: 36px;
  padding: 0.3rem 0.45rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
}

.seg-btn.active {
  background: rgba(230, 184, 92, 0.22);
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

/* 絶景プリセットボタン */
.preset-grid {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.preset-btn {
  min-height: 36px;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-align: left;
  font-size: 0.75rem;
}

.preset-btn.active {
  background: rgba(230, 184, 92, 0.2);
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

.preset-num {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--accent-gold);
  font-size: 0.85rem;
}

/* 長時間露光トグルスイッチ */
.toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.toggle-title {
  font-size: 0.78rem;
  font-weight: 600;
}
.toggle-title small {
  color: var(--text-muted);
  font-weight: 400;
}

.toggle-desc {
  font-size: 0.67rem;
  color: var(--text-muted);
}

.switch-btn {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  padding: 2px;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.switch-btn[aria-checked="true"] {
  background: rgba(230, 184, 92, 0.38);
  border-color: var(--accent-gold);
}

.switch-knob {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
}

.switch-btn[aria-checked="true"] .switch-knob {
  transform: translateX(20px);
  background: var(--accent-gold-bright);
}

/* ==================== 下部シャッターバー ==================== */
.bottom-shutter-bar {
  margin-top: auto;
  padding: 0.5rem 0.75rem 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
  z-index: 4;
}

.Telemetry-readout {
  padding: 0.28rem 0.85rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  pointer-events: auto;
}

.Telemetry-readout .sep {
  color: var(--accent-gold);
}

.shutter-btn {
  pointer-events: auto;
  background: transparent;
  border: 0;
  padding: 0;
  min-width: 68px;
  min-height: 68px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.shutter-outer-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  padding: 4px;
  border: 2px solid var(--accent-gold-bright);
  background: rgba(10, 14, 24, 0.65);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.65), 0 0 20px rgba(230, 184, 92, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.shutter-btn:hover .shutter-outer-ring {
  transform: scale(1.05);
  box-shadow: 0 10px 32px rgba(230, 184, 92, 0.45);
}

.shutter-btn:active .shutter-outer-ring {
  transform: scale(0.94);
}

.shutter-inner-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6df 0%, #e6b85c 65%, #b57b22 100%);
  color: #0b0e17;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.shutter-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.shutter-label {
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

/* ==================== モーダル（ポラロイド・確認・一時停止） ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 1rem;
  background: rgba(4, 7, 14, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  width: min(100%, 380px);
  max-height: 100%;
  overflow-y: auto;
  padding: 1.5rem;
  border-radius: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-gold);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-desc {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.modal-actions .btn {
  width: 100%;
}

/* ポラロイドプレビューモーダル */
.polaroid-dialog {
  width: min(100%, 540px);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.15rem;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.polaroid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.polaroid-heading {
  font-family: var(--font-serif);
  font-size: 1.35rem;
}

.polaroid-frame-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 0.5rem;
}

.captured-preview-img {
  display: block;
  max-width: 100%;
  max-height: 54vh;
  max-height: 54dvh;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
}

.polaroid-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

/* ==================== レスポンシブ対応（Small 320px / Landscape / Tablet） ==================== */
@media (max-width: 680px) {
  .top-bar {
    padding: 0.35rem 0.45rem;
    gap: 0.3rem;
  }

  .pill-text {
    display: none;
  }

  .icon-pill {
    padding: 0 0.55rem;
    min-width: 44px;
    justify-content: center;
  }

  .site-tab {
    padding: 0.22rem 0.5rem;
  }

  .site-tab-en {
    font-size: 0.72rem;
  }

  .site-tab-jp {
    font-size: 0.56rem;
  }

  .Telemetry-readout {
    display: none;
  }

  .control-dock {
    top: auto;
    bottom: 4.55rem;
    left: 0.45rem;
    right: 0.45rem;
    width: auto;
    max-height: calc(100dvh - 8.6rem);
  }

  .dock-body {
    padding: 0.55rem 0.65rem;
  }

  .tab-pane {
    gap: 0.5rem;
  }

  .bottom-shutter-bar {
    padding: 0.25rem 0.5rem 0.4rem;
  }

  .shutter-outer-ring {
    width: 54px;
    height: 54px;
  }

  .shutter-btn {
    min-width: 54px;
    min-height: 54px;
  }
}

/* 横画面（iphone-landscape: max-height 450px）対応 */
@media (max-height: 460px) {
  .title-card {
    padding: 0.85rem 1.25rem;
    gap: 0.45rem;
  }

  .title-lead {
    font-size: 0.76rem;
    line-height: 1.4;
  }

  .top-bar {
    padding: 0.3rem 0.5rem;
  }

  .control-dock {
    top: 3.4rem;
    bottom: 0.4rem;
    right: 0.5rem;
    left: auto;
    width: 280px;
    max-height: calc(100dvh - 3.9rem);
  }

  .bottom-shutter-bar {
    position: absolute;
    left: 0.75rem;
    bottom: 0.4rem;
    align-items: flex-start;
    padding: 0;
  }

  .Telemetry-readout {
    display: none;
  }
}
