/* フォントはローカル common/fonts から読み込み(SIL OFL 1.1) */
@import url('../../common/fonts/cormorant-garamond.css');
@import url('../../common/fonts/shippori-mincho.css');

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Shippori Mincho', 'Cormorant Garamond', serif;
  color: #b8a89a;
  touch-action: none;
}

#game { position: fixed; inset: 0; }
canvas { display: block; }

.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 5;
  background-image:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.12) 0px, rgba(0,0,0,0.12) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
  opacity: 0.5;
}
.vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 6;
  background: radial-gradient(ellipse at center,
    transparent 50%,
    rgba(0,0,0,0.3) 85%,
    rgba(0,0,0,0.7) 100%);
}

.flash {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 20;
  background: #fff;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.flash.show { opacity: 1; }
.flash.tint-red { background: #2a0000; }
.flash.tint-blue { background: #000a2a; }
.flash.tint-green { background: #002a0a; }
.flash.tint-violet { background: #1a002a; }
.flash.tint-white { background: #fff; }
.flash.tint-black { background: #000; }
.flash.tint-yellow { background: #2a2200; }
.flash.tint-cyan { background: #002a2a; }
.flash.tint-pink { background: #2a0a1a; }
.flash.tint-amber { background: #2a1500; }

/* 開始ベール — 中心はうっすら世界が透ける */
#veil {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at center,
      rgba(0,0,0,0.42) 0%,
      rgba(0,0,0,0.72) 55%,
      rgba(0,0,0,0.92) 100%);
  z-index: 100;
  display: flex;
  justify-content: center; align-items: center;
  cursor: pointer;
  transition: opacity 1.5s ease;
}
#veil.fading { opacity: 0; pointer-events: none; }
.veil-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 38px;
  text-align: center;
}
.veil-title {
  font-family: 'Cormorant Garamond', 'Shippori Mincho', serif;
  font-weight: 300;
  font-size: clamp(28px, 7vw, 52px);
  letter-spacing: 0.55em;
  padding-left: 0.55em; /* letter-spacingの最後の文字の位置補正 */
  color: rgba(232, 218, 200, 0.88);
  text-shadow: 0 0 24px rgba(0,0,0,0.85), 0 0 6px rgba(0,0,0,0.9);
}
.veil-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(11px, 2vw, 13px);
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  color: rgba(220, 208, 196, 0.5);
  text-shadow: 0 0 12px rgba(0,0,0,0.85);
  margin-top: -22px; /* タイトルとの距離を詰める */
}
.veil-text {
  font-family: 'Shippori Mincho', serif;
  font-size: 13px;
  letter-spacing: 0.7em;
  padding-left: 0.7em;
  color: rgba(200, 184, 170, 0.55);
  font-weight: 400;
  text-shadow: 0 0 8px rgba(0,0,0,0.9);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.9; }
}

/* モバイル操作 */
.controls {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 9;
  pointer-events: none;
  padding: 20px;
  display: flex; justify-content: space-between; align-items: flex-end;
}
.joystick {
  width: 110px; height: 110px;
  border-radius: 50%;
  background: rgba(20, 16, 30, 0.3);
  border: 1px solid rgba(184, 168, 200, 0.18);
  position: relative;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}
.joystick-knob {
  position: absolute; top: 50%; left: 50%;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(184, 168, 200, 0.25);
  border: 1px solid rgba(184, 168, 200, 0.45);
  transform: translate(-50%, -50%);
  transition: background 0.1s;
}
.joystick.active .joystick-knob { background: rgba(184, 90, 160, 0.45); }
.look-pad {
  flex: 1;
  height: 110px;
  margin: 0 16px;
  pointer-events: auto;
}

@media (hover: none) and (pointer: coarse) {
  .desktop-only { display: none !important; }
}
@media (hover: hover) and (pointer: fine) {
  .mobile-only { display: none !important; }
}

/* 補助ナビ: 開始前のトップ画面下部にだけ薄く存在する
   padding で当たり判定を広げ、リンクを狙って少し外しても veil の start が走らないようにする。
   見た目の位置はほぼ変えないため bottom を詰めて padding 分を吸収。 */
.meta-nav {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110; /* veilより上 */
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  letter-spacing: 0.45em;
  /* 上下左右に透明な当たり判定を確保。letter-spacing 末尾文字の位置補正は right 側で */
  padding: 18px 28px 18px calc(28px + 0.45em);
  color: rgba(184, 168, 154, 0.55);
  pointer-events: auto;
  text-shadow: 0 0 10px rgba(0,0,0,0.95);
  transition: opacity 1.4s ease;
  white-space: nowrap;
}
.meta-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(184, 168, 154, 0.22);
  padding-bottom: 1px;
  transition: color 0.4s ease, border-color 0.4s ease;
}
.meta-nav a:hover {
  color: rgba(232, 218, 200, 0.95);
  border-color: rgba(232, 218, 200, 0.7);
}
.meta-nav .sep {
  margin: 0 10px;
  opacity: 0.45;
}
.meta-nav .meta-toggle {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  padding: 0;
  letter-spacing: inherit;
  cursor: pointer;
  border-bottom: 1px solid rgba(184, 168, 154, 0.22);
  padding-bottom: 1px;
  transition: color 0.4s ease, border-color 0.4s ease;
  font-family: inherit;
}
.meta-nav .meta-toggle:hover {
  color: rgba(232, 218, 200, 0.95);
  border-color: rgba(232, 218, 200, 0.7);
}
.meta-nav .meta-toggle .meta-toggle-state {
  margin-left: 0.2em;
  font-style: italic;
  opacity: 0.85;
}
.meta-nav .meta-toggle[aria-pressed="false"] .meta-toggle-state {
  color: rgba(184, 90, 160, 0.85);
}
/* 開始後はフェードアウトして消える */
body.started .meta-nav {
  opacity: 0;
  pointer-events: none;
}

/* sound on/off トグル(右上、開始前のみ表示)
   ・meta-nav の下線スタイルを継承
   ・開始後は他の補助 UI と同様にフェードアウト */
.meta-toggle-corner {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 11;
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: rgba(184, 168, 154, 0.78);
  background: transparent;
  border: none;
  padding: 4px 2px 5px;
  cursor: pointer;
  border-bottom: 1px solid rgba(184, 168, 154, 0.28);
  transition: color 0.3s ease, border-color 0.3s ease, opacity 0.5s ease;
}
.meta-toggle-corner:hover {
  color: rgba(232, 218, 200, 0.96);
  border-color: rgba(232, 218, 200, 0.7);
}
.meta-toggle-corner .meta-toggle-state {
  margin-left: 0.25em;
  font-style: italic;
  opacity: 0.85;
}
.meta-toggle-corner[aria-pressed="false"] .meta-toggle-state {
  color: rgba(184, 90, 160, 0.85);
}
/* 開始後は隠す */
body.started .meta-toggle-corner {
  opacity: 0;
  pointer-events: none;
}

/* ──────────────────────────────────────────────
   フォトモード
   ────────────────────────────────────────────── */

/* 起動ボタン (右下、いつでも表示) */
.photo-trigger {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(232, 218, 200, 0.28);
  background: rgba(20, 16, 28, 0.45);
  color: rgba(232, 218, 200, 0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 13;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.6s ease, background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
  opacity: 0;          /* 開始前は隠れる */
  pointer-events: none;
}
body.started .photo-trigger {
  opacity: 0.9;
  pointer-events: auto;
}
.photo-trigger:hover {
  background: rgba(40, 32, 56, 0.55);
  border-color: rgba(232, 218, 200, 0.55);
  transform: scale(1.04);
}
.photo-trigger svg { display: block; }
.photo-trigger .x-icon { display: none; }
body.photo-mode .photo-trigger svg:first-of-type { display: none; }
body.photo-mode .photo-trigger .x-icon { display: block; }

/* ワープ柱(ポータル)非表示トグル(左下、フォトモード時のみ表示) */
.photo-hide-portal {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(232, 218, 200, 0.28);
  background: rgba(20, 16, 28, 0.45);
  color: rgba(232, 218, 200, 0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 13;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.2s ease, color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
body.photo-mode .photo-hide-portal {
  opacity: 1;
  pointer-events: auto;
}
.photo-hide-portal:hover {
  border-color: rgba(232, 218, 200, 0.55);
  background: rgba(40, 32, 56, 0.55);
}
/* ON 状態: 押下されているニュアンス(crouch と同系統) */
.photo-hide-portal[aria-pressed="true"] {
  background: rgba(184, 90, 160, 0.30);
  border-color: rgba(232, 200, 220, 0.65);
  color: rgba(255, 232, 244, 0.96);
}
.photo-hide-portal svg { display: block; }
/* idle フェード(panel-idle に追従、撮影スタックと同じ薄さ) */
body.photo-mode.panel-idle .photo-hide-portal {
  opacity: 0.55;
  transition: opacity 0.6s ease;
}
body.photo-mode.panel-idle .photo-hide-portal:hover {
  opacity: 1;
  transition: opacity 0.25s ease;
}
/* プレビュー中は隠す(他の photo UI と同様) */
body.photo-preview-open .photo-hide-portal {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* 広角レンズ トグル(左下、HidePortal の上に縦積み)
   ・HidePortal が bottom: 24px / 高さ 50px → 上に 12px ギャップを取って bottom: 86px
   ・フォトモード時のみ表示 */
.photo-fisheye {
  position: fixed;
  left: 24px;
  bottom: 86px;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(232, 218, 200, 0.28);
  background: rgba(20, 16, 28, 0.45);
  color: rgba(232, 218, 200, 0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 13;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.2s ease, color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
body.photo-mode .photo-fisheye {
  opacity: 1;
  pointer-events: auto;
}
.photo-fisheye:hover {
  border-color: rgba(232, 218, 200, 0.55);
  background: rgba(40, 32, 56, 0.55);
}
/* ON 段階別の濃淡(1=広角 / 2=超広角) */
.photo-fisheye[data-mode="1"] {
  background: rgba(184, 90, 160, 0.30);
  border-color: rgba(232, 200, 220, 0.65);
  color: rgba(255, 232, 244, 0.96);
}
.photo-fisheye[data-mode="2"] {
  background: rgba(220, 110, 130, 0.45);
  border-color: rgba(255, 220, 220, 0.85);
  color: rgba(255, 240, 244, 1);
}
.photo-fisheye svg { display: block; }
body.photo-mode.panel-idle .photo-fisheye {
  opacity: 0.55;
  transition: opacity 0.6s ease;
}
body.photo-mode.panel-idle .photo-fisheye:hover {
  opacity: 1;
  transition: opacity 0.25s ease;
}
body.photo-preview-open .photo-fisheye {
  opacity: 0 !important;
  pointer-events: none !important;
}


/* フォトモード: 右下のアクションを縦に積むスタック
   ・撮影(大) → しゃがむ(小) → 終了(.photo-trigger 流用)が下に並ぶ
   ・画面中央のパネルを高さで圧迫しないための分離 */
.photo-side-stack {
  position: fixed;
  right: 24px;
  bottom: 86px; /* photo-trigger (24px + 50px height + 12px gap) の上に積む */
  z-index: 13;
  display: flex;
  flex-direction: column; /* DOM 順 capture → crouch がそのまま 上 → 下 */
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
  transform: translateY(8px);
}
body.photo-mode .photo-side-stack {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
/* idle フェード:撮影ボタンだけは少し見える(押せる場所が分かるよう) */
body.photo-mode.panel-idle .photo-side-stack {
  opacity: 0.55;
  transition: opacity 0.6s ease;
}
body.photo-mode.panel-idle .photo-side-stack:hover {
  opacity: 1;
  transition: opacity 0.25s ease;
}

/* 三角アイコンのしゃがむボタン(小型・トグル) */
.photo-crouch {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(232, 218, 200, 0.28);
  background: rgba(20, 16, 28, 0.45);
  color: rgba(232, 218, 200, 0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.photo-crouch:hover {
  background: rgba(40, 32, 56, 0.55);
  border-color: rgba(232, 218, 200, 0.55);
}
/* しゃがみ 1 段階目(通常しゃがみ) */
.photo-crouch[data-mode="1"] {
  background: rgba(184, 90, 160, 0.32);
  border-color: rgba(232, 200, 220, 0.7);
  color: rgba(255, 232, 244, 0.96);
  transform: translateY(2px);
}
/* しゃがみ 2 段階目(深くしゃがむ)— 色味を一段強く */
.photo-crouch[data-mode="2"] {
  background: rgba(220, 110, 130, 0.45);
  border-color: rgba(255, 220, 220, 0.85);
  color: rgba(255, 240, 244, 1);
  transform: translateY(4px);
}
.photo-crouch svg { display: block; }

/* フォトモード時のクロップ枠 + 半透明マスク
   ・box-shadow を使い、内側を抜いた状態で外周を塗りつぶす
   ・比率変更時は top/left/width/height のトランジションで滑らかに変形 */
.photo-crop-mask {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
body.photo-mode .photo-crop-mask {
  opacity: 1;
}
.photo-crop-mask .crop-frame {
  position: absolute;
  /* JS が top/left/width/height を毎回セット */
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.42);
  transition:
    top    0.36s cubic-bezier(.2,.85,.2,1),
    left   0.36s cubic-bezier(.2,.85,.2,1),
    width  0.36s cubic-bezier(.2,.85,.2,1),
    height 0.36s cubic-bezier(.2,.85,.2,1);
}
.photo-crop-mask.free .crop-frame {
  box-shadow: none;
}
.photo-crop-mask .corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(255, 255, 255, 0.55);
  border-style: solid;
  pointer-events: none;
}
.photo-crop-mask.free .corner { opacity: 0; }
.photo-crop-mask .corner.tl { top: 0;    left: 0;    border-width: 1px 0 0 1px; }
.photo-crop-mask .corner.tr { top: 0;    right: 0;   border-width: 1px 1px 0 0; }
.photo-crop-mask .corner.bl { bottom: 0; left: 0;    border-width: 0 0 1px 1px; }
.photo-crop-mask .corner.br { bottom: 0; right: 0;   border-width: 0 1px 1px 0; }

/* 比率切替バー(画面上部中央、フォトモード時のみ表示) */
.photo-aspect-bar {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(14, 12, 20, 0.55);
  border: 1px solid rgba(232, 218, 200, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  max-width: calc(100vw - 32px);
}
body.photo-mode .photo-aspect-bar {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
/* idle 時のフェード(共通の body.panel-idle が付いたとき) */
body.photo-mode.panel-idle .photo-aspect-bar {
  opacity: 0.20;
  transition: opacity 0.6s ease;
}
body.photo-mode.panel-idle .photo-aspect-bar:hover {
  opacity: 1;
  transition: opacity 0.25s ease;
}

/* (旧)パネル内の比率行 — 互換のため残すが実際には使わない */
.photo-aspects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.aspect-btn {
  font-family: 'Shippori Mincho', serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  padding: 5px 10px;
  background: rgba(20, 16, 28, 0.45);
  color: rgba(220, 208, 196, 0.7);
  border: 1px solid rgba(232, 218, 200, 0.22);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.aspect-btn:hover {
  border-color: rgba(232, 218, 200, 0.5);
  color: rgba(232, 218, 200, 0.95);
}
.aspect-btn[aria-pressed="true"] {
  background: rgba(184, 90, 160, 0.25);
  border-color: rgba(232, 200, 220, 0.6);
  color: rgba(255, 232, 244, 0.96);
}

/* コントロールパネル (下部中央) */
.photo-panel {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 18px);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 12px 18px 10px;
  border-radius: 16px;
  background: rgba(14, 12, 20, 0.55);
  border: 1px solid rgba(232, 218, 200, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(220, 208, 196, 0.92);
  font-family: 'Shippori Mincho', serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
  /* 右下のスタックや左下のジョイスティック領域とぶつからない幅 */
  max-width: calc(100vw - 32px);
}
@media (min-width: 521px) {
  /* 余裕のある画面では右下スタックの分だけ余白を取る */
  .photo-panel { max-width: calc(100vw - 180px); }
}
body.photo-mode .photo-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
/* 操作なしでしばらく経ったらパネル群を薄くする(構図確認の邪魔にならないように)
   ・body.panel-idle が付いたとき、各 UI が薄くフェード
   ・hover で復活、JS が活動を検知すると body から panel-idle を外して即復帰 */
body.photo-mode.panel-idle .photo-panel {
  opacity: 0.20;
  transition: opacity 0.6s ease, transform 0.45s ease;
}
body.photo-mode.panel-idle .photo-panel:hover,
body.photo-mode.panel-idle .photo-panel:focus-within {
  opacity: 1;
  transition: opacity 0.25s ease, transform 0.45s ease;
}

.photo-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
}
.photo-slider {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 130px;
}
.photo-label {
  font-size: 10px;
  letter-spacing: 0.35em;
  padding-left: 0.35em;
  color: rgba(200, 184, 168, 0.7);
  text-transform: lowercase;
  margin-bottom: 4px;
}
.photo-value {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(220, 208, 196, 0.7);
  text-align: right;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.photo-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: rgba(232, 218, 200, 0.25);
  outline: none;
  border-radius: 2px;
  cursor: pointer;
}
.photo-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(232, 218, 200, 0.92);
  border: 1px solid rgba(184, 90, 160, 0.6);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}
.photo-slider input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(232, 218, 200, 0.92);
  border: 1px solid rgba(184, 90, 160, 0.6);
  cursor: pointer;
}

/* シャッター + しゃがむ などのアクション群 */
.photo-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 2px;
}

/* しゃがむなどのトグルボタン(撮影パネル内) */
.photo-toggle {
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  letter-spacing: 0.32em;
  padding: 9px 16px 9px calc(16px + 0.32em);
  background: rgba(20, 16, 28, 0.45);
  color: rgba(220, 208, 196, 0.78);
  border: 1px solid rgba(232, 218, 200, 0.28);
  border-radius: 4px;
  cursor: pointer;
  text-transform: lowercase;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.photo-toggle:hover {
  border-color: rgba(232, 218, 200, 0.55);
  color: rgba(232, 218, 200, 0.95);
}
.photo-toggle[aria-pressed="true"] {
  background: rgba(184, 90, 160, 0.28);
  border-color: rgba(232, 200, 220, 0.65);
  color: rgba(255, 232, 244, 0.96);
}

/* シャッターボタン */
.photo-capture {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: transparent;
  border: none;
  position: relative;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
}
.capture-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(232, 218, 200, 0.85);
  transition: border-color 0.2s ease;
}
.capture-dot {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(232, 218, 200, 0.92);
  transition: background 0.15s ease, transform 0.12s ease;
}
.photo-capture:hover .capture-dot { background: #fff; }
.photo-capture:active .capture-dot { transform: scale(0.85); }
.photo-capture.flash .capture-dot { background: #fff; }

/* フォトモード時に隠す既存UI
   ・モバイルのジョイスティック / ルックパッドはフォトモード中は完全に隠す
     (フォトモードはスクリーン全域 swipe でアングル可、移動はロックされるため
      重複・無効な操作領域になる)。
   ・visibility:hidden を併用して、稀に opacity 0 のままタッチを拾う環境でも
     完全に無効化する。 */
body.photo-mode .controls,
body.photo-mode .grain,
body.photo-mode .vignette {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden;
  transition: opacity 0.4s ease;
}
/* タップ位置に出る AF 風のリング(フォトモード時のみ) */
.focus-indicator {
  position: fixed;
  width: 60px;
  height: 60px;
  border: 1.5px solid rgba(232, 218, 200, 0);
  border-radius: 50%;
  pointer-events: none;
  z-index: 14;
  transform: translate(-50%, -50%);
  opacity: 0;
}
.focus-indicator.show {
  animation: focusPulse 0.75s ease-out;
}
.focus-indicator .focus-distance {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: rgba(232, 218, 200, 0.92);
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(0, 0, 0, 1), 0 0 4px rgba(0,0,0,0.95);
  opacity: 0;
}
.focus-indicator.show .focus-distance {
  animation: focusLabel 0.9s ease-out;
}
@keyframes focusPulse {
  0%   { width: 90px; height: 90px; border-color: rgba(232, 218, 200, 0); opacity: 0; }
  25%  { width: 60px; height: 60px; border-color: rgba(232, 218, 200, 0.95); opacity: 1; }
  60%  { width: 42px; height: 42px; border-color: rgba(232, 218, 200, 0.6); opacity: 0.85; }
  100% { width: 38px; height: 38px; border-color: rgba(232, 218, 200, 0); opacity: 0; }
}
@keyframes focusLabel {
  0%   { opacity: 0; transform: translate(-50%, -4px); }
  35%  { opacity: 1; transform: translate(-50%, 0); }
  85%  { opacity: 0.9; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 4px); }
}

/* シャッター用フラッシュ */
.shutter-flash {
  position: fixed; inset: 0;
  background: #fff;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
}
.shutter-flash.show {
  animation: shutter 0.45s ease-out;
}
@keyframes shutter {
  0%   { opacity: 0; }
  18%  { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ──────────────────────────────────────────────
   撮影プレビュー(長押しで保存)
   ────────────────────────────────────────────── */
.photo-preview {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.photo-preview.show {
  display: flex;
  animation: previewIn 0.35s ease;
}
@keyframes previewIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.preview-content {
  position: relative;
  max-width: 96vw;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.preview-content img {
  max-width: 100%;
  max-height: 72vh;
  border: 1px solid rgba(232, 218, 200, 0.18);
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7);
  /* 長押し保存を有効に保つ */
  -webkit-touch-callout: default;
  touch-action: manipulation;
  user-select: none;
}
.preview-hint {
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  letter-spacing: 0.4em;
  padding-left: 0.4em;
  color: rgba(220, 208, 196, 0.65);
  text-align: center;
}
.preview-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;          /* 折り返さず必ず一列 */
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  max-width: 100%;
}
/* コンパクトな横並び。ボタンは中身ぶんの幅(伸縮しない) */
.preview-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: rgba(20, 16, 28, 0.55);
  border: 1px solid rgba(232, 218, 200, 0.45);
  color: rgba(232, 218, 200, 0.92);
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  padding-left: calc(14px + 0.18em);
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.preview-btn:hover {
  background: rgba(40, 32, 56, 0.7);
  border-color: rgba(232, 218, 200, 0.7);
}
.preview-btn-secondary {
  background: transparent;
  color: rgba(184, 168, 154, 0.75);
  border-color: rgba(184, 168, 154, 0.3);
}
.preview-btn-secondary:hover {
  color: rgba(232, 218, 200, 0.95);
  border-color: rgba(232, 218, 200, 0.5);
  background: transparent;
}
/* スマホでは更に小さく(横幅 360 でも 4 ボタン入るように) */
@media (max-width: 520px) {
  .preview-btn {
    padding: 7px 10px;
    padding-left: calc(10px + 0.16em);
    font-size: 10px;
    letter-spacing: 0.14em;
  }
  .preview-actions { gap: 6px; }
}

/* プレビュー表示中はフォトモード UI を消して、写真に集中
   ・上部のアスペクトバーや右の撮影スタックも隠す */
body.photo-preview-open .photo-panel,
body.photo-preview-open .photo-trigger,
body.photo-preview-open .photo-aspect-bar,
body.photo-preview-open .photo-side-stack,
body.photo-preview-open .focus-indicator { opacity: 0 !important; pointer-events: none !important; }

/* ===== 現像 (Develop) UI ===== */

/* 現像中ローディングオーバーレイ */
.develop-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(8, 6, 12, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 5;
  border-radius: inherit;
}
.develop-loading.show { display: flex; }
.develop-spinner {
  width: 28px; height: 28px;
  border: 2px solid rgba(232, 218, 200, 0.18);
  border-top-color: rgba(232, 218, 200, 0.85);
  border-radius: 50%;
  animation: develop-spin 0.9s linear infinite;
}
@keyframes develop-spin { to { transform: rotate(360deg); } }
.develop-loading-text {
  font-family: 'Shippori Mincho', serif;
  font-size: 13px;
  letter-spacing: 0.4em;
  color: rgba(232, 218, 200, 0.85);
}

/* スタイル選択シート(モーダル)
   ふわっとフェード+カードがわずかに浮かび上がる演出 */
.develop-style-sheet {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.develop-style-sheet.show {
  opacity: 1;
  pointer-events: auto;
}
.develop-style-sheet.show .develop-style-card {
  transform: translateY(0);
}
.develop-style-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.develop-style-card {
  position: relative;
  z-index: 1;
  min-width: 240px;
  padding: 22px 28px 18px;
  border-radius: 14px;
  background: rgba(20, 16, 28, 0.85);
  border: 1px solid rgba(232, 218, 200, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  font-family: 'Shippori Mincho', serif;
  color: rgba(232, 218, 200, 0.92);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  transform: translateY(8px);
  transition: transform 0.32s cubic-bezier(.2,.85,.2,1);
}
.develop-style-title {
  font-size: 13px;
  letter-spacing: 0.36em;
  text-align: center;
  color: rgba(220, 208, 196, 0.78);
  padding-left: 0.36em;
}
.develop-style-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.develop-style-btn {
  font-family: 'Shippori Mincho', serif;
  font-size: 14px;
  letter-spacing: 0.32em;
  padding: 11px 18px 11px calc(18px + 0.32em);
  background: rgba(20, 16, 28, 0.55);
  color: rgba(232, 218, 200, 0.92);
  border: 1px solid rgba(232, 218, 200, 0.28);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
/* シートが開いた直後はカーソルが動くまで :hover を抑制
   (フラッシュ等カーソル直下のボタンが勝手にハイライトされる現象を防ぐ)
   さらに hover 機能のないデバイス(スマホ等)では :hover 自体を無効化
   (タップした要素に張り付くスティッキーホバー対策) */
@media (hover: hover) {
  .develop-style-sheet.mouse-active .develop-style-btn:hover {
    background: rgba(40, 32, 56, 0.65);
    border-color: rgba(232, 218, 200, 0.55);
  }
}
.develop-style-cancel {
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  letter-spacing: 0.28em;
  padding: 6px;
  background: transparent;
  color: rgba(184, 168, 154, 0.65);
  border: none;
  cursor: pointer;
}
@media (hover: hover) {
  .develop-style-cancel:hover { color: rgba(232, 218, 200, 0.9); }
}

/* スマホで panel が画面端ぎりぎりにならないように */
@media (max-width: 520px) {
  .photo-row { gap: 10px; }
  .photo-slider { min-width: 96px; }
  .photo-panel { padding: 12px 14px 10px; bottom: 22px; }
  .photo-trigger { right: 18px; bottom: 18px; width: 46px; height: 46px; }
}

/* 静的ページ用 (about / license) — body の overflow:hidden を上書きしてスクロール可能に */
html:has(.page),
body:has(.page),
body.static-page,
html.static-page {
  overflow: auto !important;
  height: auto !important;
  min-height: 100%;
  touch-action: auto;
}
.page {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, #18141a 0%, #050407 70%, #000 100%);
  color: #c8b8a8;
  font-family: 'Shippori Mincho', 'Cormorant Garamond', serif;
  padding: 80px 24px 120px;
  touch-action: auto;
  user-select: text;
  -webkit-overflow-scrolling: touch;
}
.page-inner {
  max-width: 720px;
  margin: 0 auto;
  line-height: 2.0;
  letter-spacing: 0.08em;
}
.page h1 {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 500;
  letter-spacing: 0.5em;
  text-align: center;
  margin-bottom: 0.4em;
  color: rgba(232, 218, 200, 0.92);
}
.page .page-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 12px;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  text-align: center;
  color: rgba(184, 168, 154, 0.6);
  margin: 0 0 2.6em;
}
.page h2 {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.3em;
  margin: 2.2em 0 0.8em;
  color: rgba(208, 192, 168, 0.9);
  border-left: 2px solid rgba(184, 90, 160, 0.5);
  padding-left: 0.8em;
}
.page p, .page li {
  font-size: 14px;
  color: rgba(200, 184, 168, 0.88);
}
.page ul { padding-left: 1.4em; margin: 0.4em 0 0.8em; }
.page a {
  color: rgba(232, 200, 220, 0.9);
  text-decoration: none;
  border-bottom: 1px solid rgba(184, 90, 160, 0.5);
}
.page a:hover { color: #fff; }
.page .small {
  font-size: 12px;
  color: rgba(160, 144, 130, 0.7);
  letter-spacing: 0.15em;
}
.page .back {
  display: inline-block;
  margin-top: 2.4em;
  font-size: 12px;
  letter-spacing: 0.4em;
  color: rgba(184, 168, 154, 0.7);
  border: none;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(184, 168, 154, 0.3);
}

/* ページ上部の SAMPO ロゴ → トップに戻るリンク
   下線なしで色は親(h1 / page-subtitle)から継承、hover でわずかに明るく */
.page .home-link {
  color: inherit;
  text-decoration: none;
  border: none;
  transition: color 0.3s ease, opacity 0.3s ease;
}
.page .home-link:hover {
  color: rgba(255, 240, 224, 0.95);
}

/* ページ最下部の控えめなクレジットリンク */
.page .page-credits {
  margin-top: 5em;
  padding-top: 2em;
  border-top: 1px solid rgba(184, 168, 154, 0.12);
  text-align: center;
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  color: rgba(160, 144, 130, 0.55);
}
.page .page-credits a {
  color: rgba(184, 168, 154, 0.78);
  text-decoration: none;
  border-bottom: 1px solid rgba(184, 168, 154, 0.2);
  padding-bottom: 1px;
  margin: 0 0.15em;
  transition: color 0.4s ease, border-color 0.4s ease;
}
.page .page-credits a:hover {
  color: rgba(232, 218, 200, 0.95);
  border-color: rgba(232, 218, 200, 0.55);
}
.page .page-credits .sep {
  margin: 0 0.4em;
  opacity: 0.45;
}
/* about のフォトモード説明: 2 × 3 のカードグリッド */
.page .photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 1.5em 0 0.6em;
}
.page .photo-card {
  position: relative;
  padding: 22px 20px 18px;
  background: linear-gradient(
    180deg,
    rgba(40, 28, 56, 0.22) 0%,
    rgba(20, 16, 28, 0.10) 100%
  );
  border: 1px solid rgba(184, 168, 154, 0.18);
  border-radius: 6px;
  transition: border-color 0.4s ease, transform 0.4s ease;
}
.page .photo-card::before {
  /* 左上の小さな装飾(SAMPO のアクセントカラー) */
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 1px;
  background: rgba(184, 90, 160, 0.6);
}
.page .photo-card:hover {
  border-color: rgba(232, 218, 200, 0.32);
}
.page .photo-card-num {
  position: absolute;
  top: 12px;
  right: 16px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: rgba(184, 90, 160, 0.7);
}
.page .photo-card-label {
  font-family: 'Shippori Mincho', serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  padding-bottom: 0.65em;
  margin-bottom: 0.75em;
  border-bottom: 1px solid rgba(184, 168, 154, 0.14);
  color: rgba(232, 218, 200, 0.92);
}
.page .photo-card-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.85;
  color: rgba(200, 184, 168, 0.85);
}
/* スマホは 1 カラムに */
@media (max-width: 520px) {
  .page .photo-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .page .photo-card {
    padding: 18px 16px 14px;
  }
}

.page pre {
  font-family: 'Cormorant Garamond', serif;
  white-space: pre-wrap;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(184, 168, 154, 0.12);
  padding: 14px 18px;
  margin: 1.2em 0 1.6em;
  font-size: 12px;
  line-height: 1.7;
  color: rgba(184, 168, 154, 0.85);
  overflow-x: auto;
}
/* license: ライセンス本文ボックスの直前にある段落と<pre>の間に空気を */
.page p + pre,
.page .small + pre {
  margin-top: 1.4em;
}

/* ===== Gallery ページ =====
   ・正方形サムネイルのグリッド
   ・タップで全画面モーダル(ふわっとフェード)
   ・モバイル長押しで保存可能(img の標準挙動) */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 1.6em 0 0.8em;
}
.gallery-item {
  aspect-ratio: 1 / 1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: #0a0a0e;
  border: 1px solid rgba(232, 218, 200, 0.16);
  border-radius: 4px;
  padding: 0;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.gallery-item:hover {
  border-color: rgba(232, 218, 200, 0.45);
  transform: translateY(-2px);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s cubic-bezier(.2,.85,.2,1);
}
.gallery-item:hover img {
  transform: scale(1.04);
}
.gallery-empty {
  text-align: center;
  padding: 2em 0;
  color: rgba(184, 168, 154, 0.55);
}
@media (max-width: 520px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

/* モーダル */
.gallery-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.40s ease;
}
.gallery-modal[hidden] { display: none; }
.gallery-modal.show {
  opacity: 1;
  pointer-events: auto;
}
.gallery-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.gallery-modal img {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  max-height: 92vh;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.75);
  -webkit-touch-callout: default;
  /* 長押し保存を許可 */
  user-select: none;
}
.gallery-modal-close {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(232, 218, 200, 0.32);
  background: rgba(20, 16, 28, 0.55);
  color: rgba(232, 218, 200, 0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.gallery-modal-close:hover {
  background: rgba(40, 32, 56, 0.7);
  border-color: rgba(232, 218, 200, 0.6);
}
