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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: linear-gradient(160deg, #e8f0f8 0%, #f5f0e8 100%);
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
}

.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;

  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

/* ========== メインコンテンツ（旧サイドバーなし） ========== */
.pzl-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- 地図パネル ---- */
.pzl-map-panel {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.pzl-map-wrapper {
  width: 100%;
  height: 100%;
  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;
}
#mapSvg { display: block; }

/* ========== 左上フロート：スコア ========== */
.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: 80px;
  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-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: 5px 0;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s;
}
.pzl-btn-reset:hover {
  background: rgba(212, 175, 55, 0.32);
}

/* ========== 右下フロート：ズームボタン ========== */
.pzl-zoom-btns {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}
.pzl-zoom-btn {
  width: 30px;
  height: 30px;
  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: 30px;
  height: 30px;
  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;
  cursor: default;
  vector-effect: non-scaling-stroke;
}
.drop-zone.hover-active {
  fill: rgba(244,207,95,0.5);
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.drop-zone.placed-ok {
  stroke: rgba(255,255,255,0.9) !important;
  stroke-width: 1.5 !important;
  vector-effect: non-scaling-stroke !important;
}
.drop-zone.placed-ng {
  fill: rgba(231,76,60,0.3);
  stroke: var(--ng);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  animation: ngShake 0.4s ease;
}
@keyframes ngShake {
  0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)}
}

/* ========== ピーストレイ（下端フロート） ========== */
.pzl-tray-panel {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.93);
  border-top: 2px solid rgba(212, 175, 55, 0.6);
  padding: 4px 12px 8px;
}
.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 6px;
  -webkit-overflow-scrolling: touch;
}
.pzl-tray::-webkit-scrollbar { height: 4px; }
.pzl-tray::-webkit-scrollbar-track { background: var(--base-dark); border-radius: 4px; }
.pzl-tray::-webkit-scrollbar-thumb { background: var(--main-light); border-radius: 4px; }

/* ---- ピース ---- */
.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; }
.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: 1000;
  opacity: 0.88;
  display: none;
}

/* ---- 地名ラベル ---- */
.map-label text {
  font-family: 'Noto Sans JP', sans-serif;
}

/* ---- クリア画面 ---- */
#clearOverlay {
  position: fixed;
  inset: 0;
  background: rgba(30,58,95,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#clearOverlay.show { display: flex; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.pzl-clear-box {
  background: #ffffff;
  border: 3px solid var(--accent);
  border-radius: 24px;
  padding: 36px 56px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  min-width: min(420px, 90vw);
}
.pzl-clear-title {
  font-size: 44px;
  font-weight: 900;
  color: var(--main);
}
.pzl-clear-emoji {
  display: none;
}
.pzl-clear-time {
  font-size: 18px;
  color: var(--text-light);
  margin-top: 8px;
}
.pzl-clear-score {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent-dark);
  margin-top: 6px;
}
.pzl-btn-again,
.pzl-btn-map {
  border: none;
  border-radius: 14px;
  padding: 12px 32px;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  margin-top: 18px;
  width: 100%;
  transition: all 0.2s;
}
.pzl-btn-again {
  background: linear-gradient(135deg, var(--main-light), var(--main)) !important;
  color: var(--main) !important;
  box-shadow: 0 4px 16px rgba(30,58,95,0.3);
}
.pzl-btn-again:hover { transform: translateY(-3px); }
.pzl-btn-map {
  background: linear-gradient(135deg, var(--accent-light), var(--accent)) !important;
  color: var(--main-dark) !important;
  box-shadow: 0 4px 16px rgba(212,175,55,0.28);
}
.pzl-btn-map:hover { transform: translateY(-3px); }

@media (max-width: 700px) {
  .pzl-clear-box { padding: 28px 20px; }
  .pzl-clear-title { font-size: 34px; }
}

/* ── 日本全国背景 ── */
.bg-pref {
  fill: rgba(180,200,220,0.25);
  stroke: rgba(140,170,200,0.5);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
