﻿html, body{
  margin: 0;
  height: 100%;
  background: #111;
  overflow: hidden;
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* 画像ビュー領域 */
#viewer{
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background: #111;
  touch-action: none; /* ← Panzoomがタッチを使うため */
  cursor: grab;
  z-index: 1;
}

#viewer.dragging{
  cursor: grabbing;
}

/* 対象画像 */
#img{
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;

  /* 重要：ボタン問題を避けるため、画像へのクリックを許可してOK
     ただし controls の方が前面に来るので問題なし */
  pointer-events: auto;
}

/* コントロール（必ず最前面＆クリック可能に） */
.controls{
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 999999;  /* 可能な限り前面 */
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;

  /* ===== ② デザイン性UP（ガラス感 + 影） ===== */
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 10px 30px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);

  pointer-events: auto; /* ← 念のため */
  isolation: isolate;   /* ← スタッキングを安定させる */
}

/* ボタン */
.controls button{
  width: 56px;
  height: 46px;
  border: 0;
  border-radius: 12px;

  /* ===== ② デザイン性UP（ボタンの質感） ===== */
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.96),
    rgba(235,235,235,0.92)
  );
  box-shadow:
    0 2px 6px rgba(0,0,0,.22),
    inset 0 1px 0 rgba(255,255,255,.65);
  border: 1px solid rgba(0,0,0,.08);

  color: #111;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* タップの誤動作軽減 */

  /* 押した時の気持ちよさ */
  transition: transform .06s ease, box-shadow .06s ease, filter .12s ease;
}

/* ホバー（PCのみ） */
@media (hover:hover){
  .controls button:hover{
    filter: brightness(1.03);
  }
}

/* 押下 */
.controls button:active{
  transform: translateY(1px);
  box-shadow:
    0 1px 3px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.45);
}

/* フォーカス（キーボード操作でも見失わない） */
.controls button:focus-visible{
  outline: 2px solid rgba(255,255,255,.55);
  outline-offset: 2px;
}

/* RESETボタン */
.controls button.reset{
  width: 86px;
  font-size: 13px;
  letter-spacing: .5px;
  font-weight: 800;
}

.controls, .controls * { touch-action: manipulation; }

/* ステータス表示 */
#badge{
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 999999;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 10px;

  /* バッジも少し高級感 */
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 8px 20px rgba(0,0,0,.30);

  white-space: nowrap;
  opacity: .92;
  pointer-events: none;
}

/* ===== スマホ向け最適化 ===== */
@media (max-width: 768px) {
  .controls {
    gap: 6px;
    padding: 6px;
    border-radius: 12px;
  }

  .controls button {
    width: 40px;
    height: 36px;
    font-size: 16px;
    border-radius: 10px;
  }

  .controls #reset {
    width: 64px;
    font-size: 11px;
    letter-spacing: .3px;
  }
}
