:root {
  /* ---- ミルキーポップ（ライトテーマ） ---- */
  --bg: #FFF5FA;
  --card: #FFFFFF;
  --card-soft: #FDEAF3;
  --text: #382B3E;
  --muted: #8B7E91;
  --border: #F1D9E6;

  --accent: #FF6FAE;        /* 華やか（ブランド・アクティブ） */
  --accent-deep: #D83B86;   /* 白文字ボタン用（コントラスト確保） */
  --accent-soft: #FFDCEC;   /* 選択中チップ背景 */

  --ok: #1F9E6E;
  --ok-bg: #D6F5E7;
  --ng: #E4556B;
  --ng-bg: #FCE0E5;
  --hint: #E8890B;

  --map-land: #EAF0F7;
  --map-stroke: #A9B6C8;
  --target: #FFC93C;              /* 出題県ハイライト（ゴールド） */
  --target-glow: rgba(255, 201, 60, 0.65);
  --silhouette-fill: #8A5CD6;     /* シルエット（紫） */

  --radius: 16px;
  --radius-btn: 14px;
  --transition: 150ms ease;
}

* { box-sizing: border-box; }
/* hidden 属性は必ず効かせる（author の display 指定に負けないよう） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Maru Gothic ProN", "Rounded Mplus 1c",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 14px calc(20px + env(safe-area-inset-bottom));
}

.topbar { text-align: center; margin-bottom: 12px; }
.topbar h1 { font-size: 1.45rem; margin: 4px 0; letter-spacing: 0.02em; }
.tagline { color: var(--muted); margin: 0; font-size: 0.88rem; }
/* プレイ中は一言を隠してヘッダーを薄く */
body.playing .tagline { display: none; }
body.playing .topbar { margin-bottom: 8px; }
body.playing .topbar h1 { font-size: 1.15rem; }

.panel {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 3px 14px rgba(216, 59, 134, 0.06);
}

/* ---- 設定 ---- */
.setup-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field-label { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.field select {
  appearance: none;
  background: var(--card-soft);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.9rem;
  width: 100%;
}
.field.checkbox {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: var(--card-soft);
  border-radius: 12px;
  padding: 10px 12px;
}
.field.checkbox input { width: 20px; height: 20px; accent-color: var(--accent-deep); }
.field.checkbox span { font-size: 0.88rem; font-weight: 600; }

/* ---- ボタン ---- */
button { font-family: inherit; cursor: pointer; }
.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  padding: 13px 20px;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 0 rgba(180, 45, 120, 0.32);
}
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(180, 45, 120, 0.32); }
.primary.big { width: 100%; padding: 15px; font-size: 1.08rem; }
.ghost {
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
}
.ghost:disabled { opacity: 0.45; cursor: default; }

/* ---- 設定サマリーバー（プレイ中・モバイル） ---- */
.playbar { display: none; }
body.playing:not(.setup-open) .setup { display: none; }
body.setup-open .setup { display: block; }
body.playing .playbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(216, 59, 134, 0.06);
}
.pb-tags { flex: 1; font-size: 0.82rem; color: var(--text); font-weight: 600; min-width: 0; }
.pb-tags b { color: var(--accent-deep); }
.pb-gear {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ---- ゲーム: モバイルは縦に積んで4択を下端へ ---- */
.game { display: flex; flex-direction: column; }
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.hud-progress { color: var(--muted); font-weight: 600; }
.hud-score { font-weight: 800; color: var(--accent-deep); }

/* ---- 地図（pref47 レイアウト流用・ライト化） ---- */
.map {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 42dvh;       /* スマホで地図が画面を占有しすぎないよう上限 */
  margin: 0 auto 6px;
}
.map .map-main { position: absolute; inset: 0; overflow: hidden; }
.map .map-main svg,
.map .map-okinawa svg,
.map .map-hokkaido svg { width: 100%; height: 100%; display: block; }
.map svg path {
  fill: var(--map-land);
  stroke: var(--map-stroke);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  transition: fill var(--transition), filter var(--transition);
  cursor: default;
}
.map.q-interactive svg path { cursor: pointer; }
.map.q-interactive svg path:hover {
  filter: brightness(0.97) drop-shadow(0 0 4px var(--target-glow));
}
.map .map-hokkaido,
.map .map-okinawa {
  position: absolute;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  background: var(--card);
}
.map .map-hokkaido {
  top: 0; right: 27%;
  width: 37%; min-width: 110px;
  aspect-ratio: 1.3 / 1;
}
.map .map-okinawa {
  right: 4%; bottom: 6%;
  width: 23%; min-width: 88px;
  aspect-ratio: 1.3 / 1;
}
@media (max-width: 520px) {
  .map .map-hokkaido { min-width: 92px; width: 40%; }
  .map .map-okinawa { min-width: 74px; width: 25%; }
}

/* ハイライト状態 */
.map svg path.q-target {
  fill: var(--target);
  stroke: #E8A81E;
  filter: drop-shadow(0 0 6px var(--target-glow));
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 4px var(--target-glow)); }
  50%      { filter: drop-shadow(0 0 10px var(--target-glow)); }
}
.map svg path.q-correct {
  fill: var(--ok);
  stroke: #14724F;
  filter: drop-shadow(0 0 7px rgba(31, 158, 110, 0.6));
}
.map svg path.q-wrong {
  fill: var(--ng);
  stroke: #B83A4C;
  filter: drop-shadow(0 0 6px rgba(228, 85, 107, 0.55));
}
.map svg path.q-region-hint { fill: #F6D9EA; }

/* ---- シルエット ---- */
.silhouette {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 320px;
  max-height: 42dvh;
  margin: 2px auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 45%, #F3ECFB, transparent 72%);
  transition: border-color var(--transition), background var(--transition);
}
.silhouette svg { width: 84%; height: 84%; display: block; }
.silhouette svg path {
  fill: var(--silhouette-fill);
  stroke: #5E3A9E;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 3px 8px rgba(138, 92, 214, 0.35));
}
.silhouette.q-correct { border-color: var(--ok); background: var(--ok-bg); }
.silhouette.q-correct svg path { fill: var(--ok); stroke: #14724F; }
.silhouette.q-wrong { border-color: var(--ng); background: var(--ng-bg); }

/* ---- 出題・選択肢（4択は下端＝親指ゾーン） ---- */
.qa { margin-top: auto; }
.question {
  text-align: center;
  font-size: 1.12rem;
  font-weight: 800;
  margin: 4px 0 10px;
}
.name-prompt { text-align: center; padding: 6px 0 12px; }
.name-prompt .np-name { display: block; font-size: 1.9rem; font-weight: 900; letter-spacing: 0.03em; }
.name-prompt .np-yomi { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 2px; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice {
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 15px 8px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 3px 0 rgba(216, 59, 134, 0.1);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.choice:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(216, 59, 134, 0.1); }
.choice .c-name { font-size: 1.14rem; font-weight: 800; }
.choice .c-yomi { font-size: 0.7rem; color: var(--muted); }
.choice.dimmed { opacity: 0.4; }
.choice.is-correct { background: var(--ok-bg); border-color: var(--ok); }
.choice.is-correct .c-name { color: var(--ok); }
.choice.is-correct .c-name::after { content: " ⭕"; font-size: 0.85em; }
.choice.is-wrong { background: var(--ng-bg); border-color: var(--ng); }
.choice.is-wrong .c-name { color: var(--ng); }
.choice.is-wrong .c-name::after { content: " ✕"; font-size: 0.85em; }
.choice:disabled { cursor: default; }

/* ---- フィードバック ---- */
.feedback {
  min-height: 1.4em;
  text-align: center;
  margin: 12px 0 8px;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.45;
}
.feedback.ok { color: var(--ok); }
.feedback.ng { color: var(--ng); }
.feedback.ng b { color: var(--ng); }
.feedback.hint { color: var(--hint); }

.game-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.game-actions .primary,
.game-actions .ghost { flex: 1 1 auto; min-width: 150px; min-height: 52px; }

/* ---- 結果 ---- */
.result-score { text-align: center; margin-bottom: 14px; }
.result-score .rs-num { display: block; font-size: 2.4rem; font-weight: 900; color: var(--accent-deep); }
.result-score .rs-grade { display: block; color: var(--muted); margin-top: 4px; font-weight: 700; }
.wrong-list h3 { font-size: 1rem; margin: 8px 0; }
.wrong-items { list-style: none; padding: 0; margin: 0; }
.wrong-items li {
  background: var(--card-soft);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.95rem;
}
.wrong-items b { font-size: 1.05rem; }
.wl-yomi { color: var(--muted); font-size: 0.8rem; margin-left: 6px; }
.wl-region {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-radius: 8px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 6px;
}
.wl-picked { color: var(--muted); font-size: 0.8rem; }
.all-correct { text-align: center; color: var(--ok); font-weight: 800; }
.result-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.result-actions button { flex: 1 1 auto; min-width: 150px; min-height: 52px; }

.foot { text-align: center; color: var(--muted); margin-top: 6px; }
.foot small { font-size: 0.72rem; }

/* ---- デスクトップ: 設定を左・ゲームを右の2カラム ---- */
@media (min-width: 768px) {
  .wrap {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-areas:
      "top  top"
      "set  game";
    gap: 8px 18px;
    align-items: start;
    max-width: 1080px;
  }
  .topbar { grid-area: top; }
  .setup { grid-column: 1; align-self: start; position: sticky; top: 14px; }
  /* デスクトップは設定を常時表示、サマリーバーは不要 */
  body.playing:not(.setup-open) .setup { display: block !important; }
  .playbar { display: none !important; }
  #game, #result { grid-column: 2; grid-row: 2; }
  body.playing .topbar h1 { font-size: 1.45rem; }
  body.playing .tagline { display: block; }
  .map { max-height: none; }
  .silhouette { max-height: none; }
  .qa { margin-top: 12px; }
}
