/* Okinawa Puzzle Plugin v1.1.0 - Responsive */

/* ========== WPテーマ干渉リセット ========== */
.entry-content .pzl-wrap,
.wp-block-group .pzl-wrap,
.site-content .pzl-wrap,
.page-content .pzl-wrap,
.post-content .pzl-wrap {
  margin: 0 !important;
  padding: 0 !important;
}
.entry-content > *:has(> .pzl-wrap),
.wp-block-group:has(.pzl-wrap) {
  padding: 0 !important;
  margin: 0 !important;
}
.pzl-wrap p, .pzl-wrap ul, .pzl-wrap ol,
.pzl-wrap li, .pzl-wrap h1, .pzl-wrap h2, .pzl-wrap h3 {
  margin: 0 !important;
  padding: 0 !important;
}
.okinawa-puzzle-wrapper {
  display: block;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 0;
  font-size: 0;
}

/* ========== ルート ========== */
.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;
  --sidebar-w: 130px;

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

/* ========== 左サイドバー（デスクトップ） ========== */
.pzl-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  align-self: stretch;
  background: var(--main);
  border-right: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 12px;
  gap: 8px;
  overflow: hidden;
  position: relative;
}
.pzl-sidebar::after {
  content: '';
  position: absolute; left: 0; top: -100%; width: 100%; height: 200%;
  background: linear-gradient(180deg, transparent, rgba(212,175,55,0.08), transparent);
  animation: sideshine 5s infinite;
}
@keyframes sideshine { 0%{top:-100%} 100%{top:100%} }

.pzl-logo {
  font-size: clamp(20px, 2.5vw, 28px); line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.pzl-title {
  color: #fff; font-weight: 900;
  font-size: clamp(11px, 1.2vw, 13px);
  text-align: center; line-height: 1.4;
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
  border-bottom: 2px solid rgba(212,175,55,0.4);
  padding-bottom: 8px; width: 100%;
}

.pzl-score-list {
  display: flex; flex-direction: column;
  gap: 6px; width: 100%;
}
.pzl-score-box {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(212,175,55,0.35);
  border-radius: 10px; padding: 5px 8px;
  text-align: center;
}
.pzl-score-label { color: var(--accent-light); font-size: 10px; font-weight: 700; }
.pzl-score-value { color: #fff; font-size: clamp(16px, 2vw, 22px); font-weight: 900; line-height: 1; }
.pzl-timer { color: #fff; font-size: clamp(12px, 1.5vw, 15px); font-weight: 900; line-height: 1; }

.pzl-btn-reset {
  margin-top: auto;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: var(--main-dark); border: none; border-radius: 12px;
  padding: 8px 0; width: 100%;
  font-size: clamp(11px, 1.2vw, 13px); font-weight: 900;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(212,175,55,0.3);
}
.pzl-btn-reset:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(212,175,55,0.5); }

.pzl-hint-text {
  color: rgba(255,255,255,0.45); font-size: 9px; font-weight: 400;
  text-align: center; line-height: 1.5;
}
.pzl-credit {
  color: rgba(255,255,255,0.3); font-size: 7px; font-weight: 400;
  text-align: center; line-height: 1.5;
  margin-top: 4px; letter-spacing: 0.3px;
}

/* ========== 右コンテンツ ========== */
.pzl-content {
  flex: 1; min-width: 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;
}
.pzl-map-wrapper.panning { cursor: grabbing; }

#mapContainer {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0; will-change: transform;
}
#mapSvg { display: block; }

.pzl-zoom-btns {
  position: absolute; bottom: 10px; right: 10px;
  display: flex; flex-direction: column; gap: 4px; z-index: 10;
}
.pzl-zoom-btn {
  width: 32px; height: 32px;
  background: var(--main); color: #fff;
  border: 2px solid var(--accent); border-radius: 8px;
  font-size: 18px; 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; user-select: none; line-height: 1;
}
.pzl-zoom-btn:hover { background: var(--main-light); transform: scale(1.1); }
.pzl-zoom-reset-btn {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.92); color: var(--main);
  border: 2px solid var(--border); border-radius: 8px;
  font-size: 9px; 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); }

/* ---- ドロップゾーン ---- */
.drop-zone {
  fill: rgba(210,230,248,0.7);
  stroke: #8aaec8; stroke-width: 1;
  transition: fill 0.15s, stroke 0.15s;
}
.drop-zone.hover-active {
  fill: rgba(244,207,95,0.5);
  stroke: var(--accent); stroke-width: 2;
}
.drop-zone.placed-ok {
  stroke: rgba(255,255,255,0.9) !important;
  stroke-width: 1.5 !important;
}
.drop-zone.placed-ng {
  fill: rgba(231,76,60,0.3);
  stroke: var(--ng); stroke-width: 2;
  animation: ngShake 0.4s ease;
}
@keyframes ngShake {
  0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)}
}

/* ---- ピーストレイ ---- */
.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-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 4px;
  -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.35; cursor: grabbing; }
.pzl-piece svg { display: block; filter: drop-shadow(0 2px 4px rgba(30,58,95,0.2)); }
.pzl-piece-name {
  font-size: 10px; font-weight: 900; color: var(--main);
  white-space: nowrap; margin-top: 2px;
  pointer-events: none; letter-spacing: 0.2px;
}

/* ---- ドラッグゴースト ---- */
#dragGhost {
  position: fixed; pointer-events: none; z-index: 9999;
  opacity: 0.88; display: none;
}

/* ---- クリア画面 ---- */
#clearOverlay {
  position: fixed; inset: 0;
  background: rgba(30,58,95,0.85);
  display: none; align-items: center; justify-content: center;
  z-index: 2000; backdrop-filter: blur(4px);
}
#clearOverlay.show { display: flex; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.pzl-clear-box {
  background: var(--base); border: 3px solid var(--accent);
  border-radius: 24px;
  padding: clamp(20px, 4vw, 36px) clamp(24px, 5vw, 56px);
  text-align: center; box-shadow: 0 20px 60px rgba(212,175,55,0.3);
  max-width: 90vw;
}
.pzl-clear-title { font-size: clamp(28px, 5vw, 44px); font-weight: 900; color: var(--main); }
.pzl-clear-emoji { font-size: clamp(40px, 7vw, 60px); display: block; margin: 8px 0; }
.pzl-clear-time { font-size: clamp(14px, 2vw, 18px); color: var(--text-light); margin-top: 8px; }
.pzl-clear-score { font-size: clamp(16px, 3vw, 24px); font-weight: 900; color: var(--accent-dark); margin-top: 6px; }
.pzl-btn-again {
  background: linear-gradient(135deg, var(--main-light), var(--main));
  color: #fff; border: none; border-radius: 14px;
  padding: 12px 32px; font-size: clamp(14px, 2vw, 17px); font-weight: 900;
  cursor: pointer; margin-top: 18px;
  box-shadow: 0 4px 16px rgba(30,58,95,0.3); transition: all 0.2s;
  display: block; width: 100%;
}
.pzl-btn-again:hover { transform: translateY(-3px); }
.pzl-btn-map {
  background: rgba(255,255,255,0.15);
  color: var(--main); border: 2px solid var(--border); border-radius: 14px;
  padding: 10px 32px; font-size: clamp(12px, 1.8vw, 15px); font-weight: 900;
  cursor: pointer; margin-top: 10px;
  transition: all 0.2s; width: 100%; display: block;
}
.pzl-btn-map:hover { background: var(--base-dark); transform: translateY(-2px); }


/* ==========================================
   タブレット（768px 以下）
   サイドバー → 上部ヘッダーバーに
========================================== */
@media (max-width: 768px) {
  .pzl-wrap {
    flex-direction: column;
  }
  .pzl-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    gap: 8px;
    border-right: none;
    border-bottom: 3px solid var(--accent);
    flex-shrink: 0;
    min-height: 56px;
  }
  .pzl-sidebar::after { display: none; }
  .pzl-logo { font-size: 22px; }
  .pzl-title {
    font-size: 12px;
    border-bottom: none;
    padding-bottom: 0;
    white-space: nowrap;
  }
  .pzl-score-list {
    flex-direction: row;
    gap: 6px; width: auto;
  }
  .pzl-score-box { padding: 3px 8px; min-width: 52px; }
  .pzl-score-value { font-size: 16px; }
  .pzl-timer { font-size: 13px; }
  .pzl-hint-text { display: none; }
  .pzl-credit { display: none; }
  .pzl-btn-reset {
    margin-top: 0; width: auto;
    padding: 6px 12px; font-size: 12px; white-space: nowrap;
  }
  .pzl-content { padding: 6px; gap: 6px; }
}

/* ==========================================
   スマホ（480px 以下）
========================================== */
@media (max-width: 480px) {
  .pzl-sidebar { padding: 4px 8px; min-height: 48px; gap: 4px; }
  .pzl-logo { display: none; }
  .pzl-title { font-size: 11px; }
  .pzl-score-box { padding: 2px 6px; min-width: 44px; }
  .pzl-score-value { font-size: 14px; }
  .pzl-score-label { font-size: 9px; }
  .pzl-timer { font-size: 12px; }
  .pzl-btn-reset { padding: 5px 8px; font-size: 11px; }
  .pzl-tray-panel { padding: 4px 8px 6px; }
  .pzl-tray-label { font-size: 11px; margin-bottom: 3px; }
  .pzl-piece-name { font-size: 9px; }
  .pzl-zoom-btn { width: 28px; height: 28px; font-size: 16px; }
  .pzl-zoom-reset-btn { width: 28px; height: 28px; font-size: 8px; }
}
