* { 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;
  --sidebar-w: 130px;

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

/* ========== 左サイドバー ========== */
.pzl-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--main);
  border-right: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 16px;
  gap: 10px;
  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: 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: 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-subtitle {
  color: var(--accent-light);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

/* スコアカード */
.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: 6px 8px;
  text-align: center;
}
.pzl-score-label {
  color: var(--accent-light);
  font-size: 10px;
  font-weight: 700;
}
.pzl-score-value {
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}
.pzl-timer {
  color: #fff;
  font-size: 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: 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-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: 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;
}
.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 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; 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: 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.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: 36px 56px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(212,175,55,0.3);
  min-width: min(420px, 90vw);
}
.pzl-clear-title {
  font-size: 44px;
  font-weight: 900;
  color: var(--main);
}
.pzl-clear-emoji {
  font-size: 60px;
  display: block;
  margin: 8px 0;
}
.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));
  color: #fff;
  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));
  color: var(--main-dark);
  box-shadow: 0 4px 16px rgba(212,175,55,0.28);
}
.pzl-btn-map:hover { transform: translateY(-3px); }

@media (max-width: 700px) {
  .pzl-wrap { --sidebar-w: 118px; }
  .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;
}
/* ── non-scaling-stroke ── */
.drop-zone { vector-effect: non-scaling-stroke; }
.drop-zone.hover-active { vector-effect: non-scaling-stroke; }
.drop-zone.placed-ok { vector-effect: non-scaling-stroke !important; }
.drop-zone.placed-ng { vector-effect: non-scaling-stroke; }
