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

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", sans-serif;
  background: linear-gradient(180deg, #bfe7f7 0%, #d8f1fb 60%, #cdeef9 100%);
  color: #33404d;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; cursor: pointer; }

ruby rt { font-size: 0.45em; color: inherit; opacity: 0.85; }

.hidden { display: none !important; }

/* ===== 上部HUD ===== */
#hud-top { flex: 0 0 auto; padding: 10px 12px 4px; }

#home-header { text-align: center; position: relative; }
#home-header h1 {
  font-size: clamp(22px, 4.5vw, 34px);
  color: #1c6ea4;
  text-shadow: 2px 2px 0 #fff;
  letter-spacing: 0.06em;
}
#title-badge {
  margin-top: 4px;
  font-size: clamp(13px, 2.4vw, 17px);
  color: #7a5b17;
  background: #fff7dd;
  border: 2px solid #f2c94c;
  border-radius: 999px;
  display: inline-block;
  padding: 4px 16px;
  cursor: pointer;
}
#title-badge:active { transform: scale(0.96); }
#title-badge::after { content: " 👑"; }

#btn-sound {
  position: absolute; right: 2px; top: 2px;
  font-size: 22px;
  background: #fff; border: 2px solid #9ecbe0; border-radius: 12px;
  width: 44px; height: 44px;
}

#question-banner {
  background: #fff;
  border: 3px solid #1c6ea4;
  border-radius: 16px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 3px 0 rgba(28, 110, 164, 0.25);
}
#btn-quit {
  flex: 0 0 auto;
  background: #eef4f8; border: 2px solid #b9cdd9; border-radius: 10px;
  font-size: 13px; padding: 8px 10px; color: #557;
}
#question-text {
  flex: 1 1 auto;
  font-size: clamp(19px, 3.6vw, 30px);
  font-weight: bold;
  text-align: center;
  line-height: 1.5;
}
#remain-count {
  flex: 0 0 auto;
  font-size: clamp(14px, 2.6vw, 20px);
  font-weight: bold;
  color: #1c6ea4;
  background: #e8f3fa;
  border: 2px solid #9ecbe0;
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
}

#timer {
  flex: 0 0 auto;
  font-size: clamp(18px, 3.2vw, 26px);
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  color: #d84315;
  background: #fff3ec; border: 2px solid #f5b199; border-radius: 10px;
  padding: 4px 10px;
}

#progress {
  height: 10px;
  background: #dcebf3;
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ===== 地図 ===== */
#map-wrap {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  margin: 4px 8px;
}
#map-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

#map-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
}

g.prefecture { transition: opacity 0.3s ease; }
g.prefecture polygon { cursor: pointer; }

g.dimmed { opacity: 0.35; pointer-events: none; }

g.quiz-target {
  fill: #FFD54F;
  animation: pulse 0.9s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { fill: #FFC400; }
  to { fill: #FFE082; }
}

g.flash-correct { fill: #58C25C !important; }
g.flash-wrong { fill: #EF5350 !important; }
g.pressed { fill: #90CAF9 !important; }

/* ステージ選択ボタン(地図上オーバーレイ) */
.stage-btn {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid #888;
  border-radius: 14px;
  padding: 6px 12px;
  text-align: center;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  min-width: 96px;
}
.stage-btn .stage-name {
  display: block;
  font-size: clamp(13px, 2.4vw, 18px);
  font-weight: bold;
}
.stage-btn .stars { display: block; font-size: 15px; color: #f5a800; }
.stage-btn .stars.new { color: #e0533d; font-size: 12px; }
.stage-btn.locked { filter: grayscale(1); opacity: 0.75; }
.stage-btn:active { transform: translate(-50%, -50%) scale(0.94); }

/* 正解/不正解ポップ */
.pop {
  position: absolute;
  left: 50%; top: 38%;
  transform: translate(-50%, -50%);
  font-size: clamp(30px, 6vw, 52px);
  font-weight: bold;
  padding: 12px 28px;
  border-radius: 20px;
  pointer-events: none;
  animation: popin 0.25s ease-out;
  white-space: nowrap;
  z-index: 5;
}
.pop.correct { background: rgba(255,255,255,0.95); color: #2e9e33; border: 4px solid #2e9e33; }
.pop.wrong { background: rgba(255,255,255,0.95); color: #d84343; border: 4px solid #d84343; }
@keyframes popin {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.penalty {
  position: absolute;
  right: 14%; top: 20%;
  font-size: clamp(22px, 4vw, 36px);
  font-weight: bold;
  color: #d84315;
  animation: floatup 1.2s ease-out forwards;
  pointer-events: none;
  z-index: 6;
}
@keyframes floatup {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-60px); opacity: 0; }
}

#pref-label {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #34495e;
  color: #fff;
  font-size: clamp(16px, 3vw, 24px);
  font-weight: bold;
  padding: 6px 14px;
  border-radius: 12px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 6;
}
#pref-label::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -8px;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #34495e;
  border-bottom: none;
}

/* ===== 下部HUD ===== */
#hud-bottom { flex: 0 0 auto; padding: 6px 12px 12px; }

#home-menu {
  display: flex;
  gap: 10px;
  justify-content: center;
}
#home-menu button {
  flex: 1 1 0;
  max-width: 240px;
  font-size: clamp(14px, 2.6vw, 19px);
  font-weight: bold;
  padding: 14px 8px;
  border-radius: 16px;
  border: 3px solid #1c6ea4;
  background: #fff;
  color: #1c6ea4;
  box-shadow: 0 3px 0 rgba(28, 110, 164, 0.3);
}
#home-menu button:active { transform: translateY(2px); box-shadow: none; }
#home-menu button.locked { border-color: #aaa; color: #999; background: #f0f0f0; }

#choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice-btn {
  min-height: 64px;
  font-size: clamp(18px, 3.4vw, 26px);
  font-weight: bold;
  border-radius: 16px;
  border: 3px solid #7fb3d3;
  background: #fff;
  color: #33404d;
  box-shadow: 0 3px 0 rgba(127, 179, 211, 0.5);
  line-height: 1.6;
}
.choice-btn:active { transform: translateY(2px); box-shadow: none; }
.choice-btn.right { background: #d9f4da; border-color: #58C25C; }
.choice-btn.wrong { background: #fddddd; border-color: #EF5350; animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ===== オーバーレイ画面(リザルト・図鑑) ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(20, 50, 80, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}
.overlay-card {
  background: #fffdf7;
  border-radius: 22px;
  border: 4px solid #1c6ea4;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
  text-align: center;
  animation: popin 0.3s ease-out;
  transform: none;
  position: relative;
  left: auto; top: auto;
}
.overlay-card h2 { color: #1c6ea4; font-size: clamp(22px, 4vw, 30px); margin-bottom: 10px; }
.overlay-card h3 { margin: 14px 0 8px; font-size: clamp(16px, 3vw, 20px); }

.result-stars { font-size: clamp(44px, 9vw, 68px); margin: 8px 0; }
.result-stars .star { color: #d9d4c8; display: inline-block; }
.result-stars .star.on {
  color: #f5a800;
  animation: starpop 0.5s cubic-bezier(0.2, 2, 0.4, 1) both;
}
@keyframes starpop {
  from { transform: scale(0) rotate(-90deg); }
  to { transform: scale(1) rotate(0); }
}

.result-time {
  font-size: clamp(40px, 8vw, 60px);
  font-weight: bold;
  color: #d84315;
  font-variant-numeric: tabular-nums;
}
.new-record { font-size: clamp(20px, 4vw, 28px); color: #e0533d; font-weight: bold; margin: 6px 0; }
.hint { color: #777; margin: 6px 0; font-size: clamp(13px, 2.4vw, 16px); }

.title-get {
  margin: 12px auto 0;
  background: #fff7dd;
  border: 3px solid #f2c94c;
  border-radius: 14px;
  padding: 10px 16px;
  font-size: clamp(15px, 2.8vw, 19px);
  max-width: 420px;
}
.title-get small { color: #8a7a4a; }

.result-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.result-buttons button {
  font-size: clamp(16px, 3vw, 20px);
  font-weight: bold;
  padding: 12px 26px;
  border-radius: 14px;
  border: 3px solid #1c6ea4;
  background: #1c6ea4;
  color: #fff;
}
.result-buttons button#btn-retry { background: #fff; color: #1c6ea4; }

/* 図鑑 */
#zukan-body { text-align: left; }
.zukan-count { text-align: center; font-size: clamp(16px, 3vw, 20px); margin-bottom: 6px; }
.zukan-count b { font-size: 1.4em; color: #1c6ea4; }
.stamp-grid, .stamp-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}
.stamp-row { display: flex; flex-wrap: wrap; justify-content: center; }
.stamp {
  background: #fff;
  border: 2px dashed #c9b98a;
  border-radius: 50%;
  aspect-ratio: 1;
  width: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  margin: 0 auto;
}
.stamp svg { width: 46px; height: 40px; }
.stamp span { font-size: 11px; font-weight: bold; text-align: center; line-height: 1.2; }
.stamp.on { border-style: solid; border-color: #b3562e; box-shadow: 0 0 0 2px #f6e3d3 inset; }
.stamp.off { opacity: 0.55; }
.stamp.off span { color: #999; }
.stamp.specialty { cursor: pointer; }
.stamp.specialty:active { transform: scale(0.94); }
.stamp.specialty .stamp-emoji {
  font-size: 34px;
  line-height: 42px;
  height: 42px;
}

/* 特産品説明ポップアップ */
.specialty-card { max-width: 420px; }
.specialty-emoji {
  display: block;
  font-size: 84px;
  line-height: 1.2;
  margin: 4px auto 8px;
}
.specialty-pref {
  display: inline-block;
  margin: 6px 0;
  font-size: clamp(13px, 2.4vw, 16px);
  color: #1c6ea4;
  background: #e8f3fa;
  border-radius: 999px;
  padding: 4px 14px;
}
.specialty-fact {
  font-size: clamp(14px, 2.8vw, 18px);
  line-height: 1.7;
  text-align: left;
  background: #fff;
  border-radius: 12px;
  border: 2px dashed #e5d9b8;
  padding: 10px 14px;
}

#btn-zukan-close { margin-top: 14px; }

/* タイムアタック自己ベスト */
.zukan-best {
  margin-top: 16px;
  text-align: center;
  font-size: clamp(14px, 2.8vw, 18px);
  background: #fff3ec;
  border: 2px solid #f5b199;
  border-radius: 999px;
  padding: 8px 16px;
}
.zukan-best b { color: #d84315; font-size: 1.25em; font-variant-numeric: tabular-nums; }

/* 称号一覧 */
.title-list-head { color: #7a5b17; }
.title-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 2px solid #f2c94c;
  border-radius: 12px;
  padding: 8px 12px;
}
.title-row .title-name {
  font-weight: bold;
  font-size: clamp(14px, 2.6vw, 18px);
  color: #7a5b17;
  white-space: nowrap;
}
.title-row .title-desc {
  font-size: clamp(11px, 2.2vw, 14px);
  color: #999;
  margin-left: auto;
  text-align: right;
}
.title-row.notyet {
  background: #f4f2ee;
  border-color: #d5d0c5;
}
.title-row.notyet .title-name { color: #a9a294; }
