/* 山脈パズル v1.0.0 - 共通デザインシステム準拠 */

/* ========== WPテーマ干渉リセット ========== */
.mtp-root {
  display: block;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 0;
  font-size: 0;
}
.pzl-wrap, .pzl-wrap *,
#clearOverlay, #clearOverlay * {
  box-sizing: border-box;
}
#clearOverlay, #clearOverlay * {
  line-height: normal !important;
  text-decoration: none !important;
  list-style: none !important;
  -webkit-text-fill-color: currentColor !important;
  font-family: 'Noto Sans JP', sans-serif !important;
}
#clearOverlay button { -webkit-appearance: none !important; appearance: none !important; }

.pzl-wrap {
  --base: #FFFFFF;
  --base-light: #FAFAFA;
  --base-dark: #F0F4F8;
  --main: #1e3a5f;
  --main-light: #2d5a8f;
  --main-dark: #0f1e3a;
  --accent: #d4af37;
  --accent-light: #f4cf5f;
  --accent-dark: #b8941f;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --border: #E8E8E8;
  --shadow: 0 4px 20px rgba(30,58,95,0.1);
  --ok: #27ae60;
  --ng: #e74c3c;
  --mc: #6d3a0f;

  font-family: 'Noto Sans JP', sans-serif;
  line-height: 1;
  background: linear-gradient(160deg, #e8f0f8 0%, #f5f0e8 100%);
  display: flex; flex-direction: column;
  width: 100%; height: 100vh; height: 100dvh;
  max-height: 100vh; max-height: 100dvh;
  overflow: hidden !important;
  margin: 0 !important; padding: 0 !important;
  position: relative;
}

/* ========== メインコンテンツ ========== */
.pzl-content { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px; gap: 8px; overflow: hidden; }

/* ---- 地図パネル ---- */
.pzl-map-panel {
  background: var(--base); border: 2px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column;
}
.pzl-map-panel::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
  border-radius: 16px 16px 0 0; z-index: 2;
}
.pzl-map-wrapper {
  flex: 1; min-height: 0; overflow: hidden; position: relative; touch-action: none; cursor: grab;
  /* 修正: 海の色を他アプリと統一 */
  background: linear-gradient(160deg, #bfe0f0 0%, #d7ecf5 55%, #e8f4f8 100%);
}
.pzl-map-wrapper.panning { cursor: grabbing; }
#mapContainer { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
#mapSvg { display: block; overflow: visible; }

/* 都道府県背景（山脈の下敷き） */
.drop-zone {
  fill: rgba(244,238,222,0.92); stroke: #8a7a5c; stroke-width: 1.1;
  transition: fill 0.15s, stroke 0.15s; vector-effect: non-scaling-stroke;
}
.map-label text { font-family: 'Noto Sans JP', sans-serif; }

/* 山脈 */
.mountain-hit { fill: none; stroke: transparent; stroke-linecap: round; stroke-linejoin: round; stroke-width: 28; vector-effect: non-scaling-stroke; }
.mountain-vis {
  fill: none; stroke: #8B4513; stroke-linecap: round; stroke-linejoin: round; stroke-width: 5;
  stroke-dasharray: 8 6; opacity: 0.55; vector-effect: non-scaling-stroke;
  transition: opacity 0.2s, stroke 0.2s, stroke-dasharray 0.2s;
}
.mtn-highlight { stroke: var(--accent) !important; stroke-width: 7 !important; filter: drop-shadow(0 0 5px rgba(212,175,55,0.8)); animation: mtnPulse 1.2s ease-in-out infinite; }
@keyframes mtnPulse { 0%,100%{opacity:1} 50%{opacity:0.5} }
.placed-mtn { fill: none; stroke: var(--mc); stroke-linecap: round; stroke-linejoin: round; stroke-width: 5; vector-effect: non-scaling-stroke; }
@keyframes mtnPlace { 0%{stroke:var(--accent);stroke-width:14} 100%{stroke-width:5} }
.placed-mtn.flash { animation: mtnPlace 0.5s ease-out forwards; }
.mtn-label {
  font-size: 14px; font-weight: 900; font-family: 'Noto Sans JP', sans-serif; fill: #4a1f00;
  paint-order: stroke; stroke: rgba(255,255,255,0.95); stroke-width: 3.5; stroke-linejoin: round; pointer-events: none;
}

/* ========== 左上フロート：スコア・レベル・リセット ========== */
.pzl-float-score {
  position: absolute; top: 10px; left: 10px;
  background: rgba(30, 58, 95, 0.82); border: 1px solid rgba(212, 175, 55, 0.55); border-radius: 12px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; min-width: 100px; z-index: 10;
}
.pzl-score-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pzl-score-lbl { color: rgba(212, 175, 55, 0.85); font-size: 10px; font-weight: 700; }
.pzl-score-val { color: #fff; font-size: 20px; font-weight: 900; line-height: 1; }
.pzl-score-timer { color: #fff; font-size: 14px; font-weight: 900; line-height: 1; }
.pzl-score-divider { width: 100%; height: 0.5px; background: rgba(212, 175, 55, 0.3); }
.pzl-wrap.timer-off .pzl-timer-row { display: none; }

.pzl-level-btns { display: flex; gap: 4px; margin-top: 2px; }
.pzl-level-btn {
  flex: 1; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); border-radius: 8px;
  color: rgba(255,255,255,0.75); font-size: 11px; font-weight: 700; padding: 5px 0; cursor: pointer; transition: all 0.15s;
}
.pzl-level-btn:hover { background: rgba(255,255,255,0.16); }
.pzl-level-btn.active { background: var(--accent); border-color: var(--accent); color: var(--main-dark); }

.pzl-btn-reset {
  margin-top: 2px; background: rgba(212, 175, 55, 0.18); border: 1px solid rgba(212, 175, 55, 0.5); border-radius: 8px;
  color: #f4cf5f; font-size: 11px; font-weight: 700; padding: 6px 0; width: 100%; cursor: pointer; transition: background 0.15s;
}
.pzl-btn-reset:hover { background: rgba(212, 175, 55, 0.32); }
.pzl-btn-reset[data-armed="1"] { background: rgba(231, 76, 60, 0.35); border-color: var(--ng); color: #fff; animation: armedPulse 0.9s infinite; }
@keyframes armedPulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

/* ---- パズル／テスト モード切替（右上の丸アイコンボタン） ---- */
.pzl-mode-icons { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.pzl-mode-icon-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--main); border: 2px solid var(--accent); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(30,58,95,0.3); transition: all 0.15s; padding: 0;
}
.pzl-mode-icon-btn svg { width: 21px; height: 21px; display: block; }
.pzl-mode-icon-btn:hover { background: var(--main-light); transform: scale(1.06); }
.pzl-mode-icon-btn.active { background: var(--accent); border-color: #fff; color: var(--main-dark); box-shadow: 0 4px 12px rgba(212,175,55,0.5); }

/* ========== 右下フロート：ズームボタン ========== */
.pzl-zoom-btns { position: absolute; bottom: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 10; }
.pzl-zoom-btn {
  width: 44px; height: 44px; border-radius: 10px; border: 2px solid var(--accent); background: var(--main); color: #fff;
  font-size: 22px; font-weight: 900; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(30,58,95,0.3); transition: all 0.15s; line-height: 1; user-select: none;
}
.pzl-zoom-btn:hover { background: var(--main-light); transform: scale(1.08); }
.pzl-zoom-reset-btn {
  width: 44px; height: 44px; border-radius: 10px; border: 2px solid var(--border); background: rgba(255,255,255,0.92); color: var(--main);
  font-size: 11px; font-weight: 900; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(30,58,95,0.15); transition: all 0.15s; user-select: none;
}
.pzl-zoom-reset-btn:hover { background: var(--base-dark); }

/* ========== 正解トースト ========== */
.pzl-correct-toast {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%) scale(0.6);
  background: rgba(39, 174, 96, 0.92); color: #fff; font-size: clamp(15px, 3vw, 24px); font-weight: 900;
  padding: 9px 24px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none; z-index: 20; white-space: nowrap;
}
.pzl-correct-toast.show { animation: toastPop 0.7s ease forwards; }
@keyframes toastPop {
  0%{opacity:0;transform:translate(-50%,-50%) scale(0.6)} 20%{opacity:1;transform:translate(-50%,-50%) scale(1.08)}
  35%{transform:translate(-50%,-50%) scale(1)} 80%{opacity:1} 100%{opacity:0;transform:translate(-50%,-60%) scale(1)}
}

/* ========== ピーストレイ ========== */
.pzl-tray-panel {
  background: var(--base); border: 2px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  position: relative; padding: 6px 12px 8px; flex-shrink: 0;
}
.pzl-tray-panel::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent)); border-radius: 16px 16px 0 0;
}
.pzl-credit { color: rgba(30, 58, 95, 0.45); font-size: 9px; margin-bottom: 3px; }
.pzl-tray-label { color: var(--main); font-weight: 900; font-size: 12px; margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.pzl-tray-label::before { content: ''; display: inline-block; width: 4px; height: 14px; background: var(--accent); border-radius: 2px; }
.pzl-tray {
  display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 4px 2px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none;
}
.pzl-tray::-webkit-scrollbar { display: none; }

.pzl-piece {
  display: flex; flex-direction: column; align-items: center; cursor: grab; transition: transform 0.15s;
  flex-shrink: 0; user-select: none;
}
.pzl-piece:hover:not(.dragging) { transform: translateY(-3px) scale(1.06); }
.pzl-piece.dragging { opacity: 0.32; cursor: grabbing; }
.pzl-piece svg { display: block; }
.pzl-piece-name { font-size: 16px; font-weight: 900; color: var(--mc); white-space: nowrap; margin-top: 4px; pointer-events: none; line-height: 1.5; }
.pzl-piece-name ruby { ruby-position: over; }
.pzl-piece-name rt { font-size: 10px; font-weight: 700; color: var(--main-light); letter-spacing: 0.02em; }

#dragGhost { position: fixed; pointer-events: none; z-index: 9999; opacity: 0.9; display: none; }

/* ========== テストモード ========== */
.pzl-test-area { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; }
.pzl-test-question { color: var(--main); font-weight: 900; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.pzl-test-question::before { content: ''; display: inline-block; width: 4px; height: 14px; background: var(--accent); border-radius: 2px; }
.pzl-test-input-row { display: flex; gap: 8px; align-items: center; }
.pzl-test-input {
  flex: 1; border: 2px solid var(--main); border-radius: 8px; padding: 8px 12px; font-size: 15px;
  font-family: 'Noto Sans JP', sans-serif; font-weight: 700; color: var(--text); outline: none; transition: border-color 0.15s;
}
.pzl-test-input:focus { border-color: var(--accent); }
.pzl-test-input.correct { border-color: var(--ok); background: rgba(39,174,96,0.1); }
.pzl-test-input.wrong { border-color: var(--ng); background: rgba(231,76,60,0.1); animation: wrongShake 0.3s ease; }
@keyframes wrongShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.pzl-test-btn {
  background: var(--main); color: #fff; border: none; border-radius: 8px; padding: 9px 18px; font-size: 13px;
  font-weight: 900; cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.pzl-test-btn:hover { background: var(--main-light); }
.pzl-test-progress { color: var(--text-light); font-size: 11px; font-weight: 700; text-align: center; }

/* ========== モーダル共通フェード ========== */
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* ---- クリア画面 ---- */
#clearOverlay { position: fixed; inset: 0; background: rgba(30,58,95,0.85); display: none; align-items: center; justify-content: center; z-index: 2000; }
#clearOverlay.show { display: flex; animation: fadeIn 0.5s ease; }
.pzl-clear-box {
  background: #ffffff !important; border: none !important; border-radius: 28px !important;
  padding: clamp(28px, 4vw, 40px) clamp(24px, 5vw, 44px) clamp(24px, 4vw, 32px) !important;
  text-align: center !important; box-shadow: 0 24px 64px rgba(30,58,95,0.35) !important;
  max-width: 90vw; width: 380px !important; position: relative !important; overflow: visible !important;
}
.pzl-clear-confetti { position: relative !important; height: 36px !important; margin: 0 0 4px !important; padding: 0 !important; }
.pzl-confetti-dot { position: absolute !important; width: 8px; height: 8px; border-radius: 50% !important; top: 50%; left: 50%; opacity: 0; animation: confettiFly 0.7s ease-out forwards; animation-delay: 0.15s; margin: 0 !important; padding: 0 !important; }
.pzl-confetti-dot-1 { background: #e74c3c !important; --tx: -46px; --ty: -18px; }
.pzl-confetti-dot-2 { background: #2980b9 !important; --tx: 44px; --ty: -20px; }
.pzl-confetti-dot-3 { background: #27ae60 !important; --tx: -34px; --ty: 14px; }
.pzl-confetti-dot-4 { background: #d4af37 !important; --tx: 36px; --ty: 16px; }
.pzl-confetti-dot-5 { background: #9b59b6 !important; --tx: -14px; --ty: -28px; }
.pzl-confetti-dot-6 { background: #e67e22 !important; --tx: 16px; --ty: -30px; }
@keyframes confettiFly { 0%{transform:translate(-50%,-50%) scale(0.4);opacity:1} 100%{transform:translate(calc(-50% + var(--tx)),calc(-50% + var(--ty))) scale(1);opacity:0} }
.pzl-clear-title { display: block !important; font-size: clamp(30px, 5vw, 42px) !important; font-weight: 900 !important; color: var(--main-dark) !important; letter-spacing: 0.02em; margin: 0 !important; padding: 0 !important; }
.pzl-clear-subtitle { display: block !important; font-size: clamp(13px, 2vw, 15px) !important; font-weight: 700 !important; color: var(--text-light) !important; margin: 4px 0 0 !important; padding: 0 !important; }
.pzl-clear-divider { display: flex !important; justify-content: center !important; gap: 5px !important; margin: 14px 0 18px !important; padding: 0 !important; }
.pzl-clear-divider span { width: 4px; height: 4px; border-radius: 50% !important; background: var(--accent-light) !important; margin: 0 !important; padding: 0 !important; }
.pzl-clear-stat { display: flex !important; align-items: center !important; gap: 10px !important; background: var(--base-dark) !important; border-radius: 14px !important; padding: 12px 16px !important; margin: 0 0 10px !important; text-align: left !important; }
.pzl-clear-stat-label { display: inline-block !important; font-size: 13px !important; font-weight: 700 !important; color: var(--text) !important; flex: 1; margin: 0 !important; }
.pzl-clear-stat-value { display: inline-block !important; font-size: 19px !important; font-weight: 900 !important; margin: 0 !important; }
.pzl-clear-stat-miss .pzl-clear-stat-value { color: #2980b9 !important; }
.pzl-clear-stat-time .pzl-clear-stat-value { color: #1e8449 !important; }
#clearOverlay .pzl-btn-again {
  border: none !important; border-radius: 14px !important; padding: 13px 32px !important; font-size: 17px !important; font-weight: 900 !important;
  cursor: pointer; margin: 10px 0 0 !important; width: 100% !important; transition: all 0.2s;
  display: flex !important; align-items: center !important; justify-content: center !important; gap: 8px; opacity: 1 !important;
  background: linear-gradient(135deg, var(--main-light), var(--main)) !important; background-color: #1e3a5f !important;
  color: #ffffff !important; -webkit-text-fill-color: #ffffff !important; box-shadow: 0 4px 16px rgba(30,58,95,0.3) !important;
}
#clearOverlay .pzl-btn-again:hover { transform: translateY(-3px); }

/* ==========================================
   タブレット（768px 以下）
========================================== */
@media (max-width: 768px) {
  .pzl-content { padding: 6px; gap: 6px; }
  .pzl-float-score { min-width: 84px; padding: 6px 8px; }
  .pzl-score-val { font-size: 16px; }
  .pzl-score-timer { font-size: 12px; }
  .pzl-btn-reset { font-size: 10px; padding: 5px 0; }
  .pzl-level-btn { font-size: 10px; }
  .pzl-mode-icon-btn { width: 40px; height: 40px; }
  .pzl-mode-icon-btn svg { width: 19px; height: 19px; }
  .pzl-zoom-btn { width: 40px; height: 40px; font-size: 18px; }
  .pzl-zoom-reset-btn { width: 40px; height: 40px; font-size: 9px; }
}

/* ==========================================
   スマホ（480px 以下）
========================================== */
@media (max-width: 480px) {
  .pzl-tray-panel { padding: 4px 8px 6px; }
  .pzl-tray-label { font-size: 11px; margin-bottom: 3px; }
  .pzl-piece-name { font-size: 14px; }
  .pzl-piece-name rt { font-size: 9px; }
  .pzl-float-score { min-width: 76px; }
}
