/* ============ base ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0a0e1a;
  --panel: rgba(15, 21, 38, 0.92);
  --panel-border: rgba(90, 120, 180, 0.18);
  --text: #dce4f2;
  --text-dim: #7686a3;
  --accent: #4dc3ff;
  --ok: #4ade80;
  --ng: #f87171;
  --card: rgba(18, 25, 44, 0.96);
}
body.light {
  --bg: #e9eef6;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(70, 100, 150, 0.22);
  --text: #1e293b;
  --text-dim: #64748b;
  --accent: #0284c7;
  --ok: #16a34a;
  --ng: #dc2626;
  --card: rgba(255, 255, 255, 0.96);
}
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

/* ============ map ============ */
#map-container { position: fixed; inset: 0; }
#map-container canvas { display: block; cursor: grab; }
#map-container canvas:active { cursor: grabbing; }
.label-layer { pointer-events: none; }

#zoom-controls {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%);
  z-index: 18; display: flex; flex-direction: column; gap: 6px;
}
#zoom-controls button, #zoom-controls a {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--panel-border);
  color: var(--text); font-size: 20px; font-weight: 600; line-height: 1;
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
#zoom-controls button:hover, #zoom-controls a:hover { color: var(--accent); border-color: var(--accent); }
#zoom-controls button:active, #zoom-controls a:active { transform: scale(0.94); }
#home-btn { font-size: 18px; }
#zoom-controls .ctrl-divider {
  height: 1px; margin: 2px 6px;
  background: var(--panel-border);
}
#tilt-up, #tilt-down { font-size: 13px; }
#rotate-left, #rotate-right { font-size: 19px; }
#support-btn { font-size: 18px; }
#support-btn:hover { border-color: var(--accent); }

/* ============ header ============ */
#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  pointer-events: none;
}
#header > * { pointer-events: auto; }
#title h1 {
  font-size: 22px; letter-spacing: 0.35em; font-weight: 800; color: #f0f4fc;
}
#title h1 span { color: var(--accent); }
#subtitle { font-size: 11px; letter-spacing: 0.15em; color: var(--text-dim); margin-top: 2px; }
#panel-toggle {
  width: 42px; height: 38px; flex-shrink: 0;
  border: 1px solid var(--panel-border); border-radius: 8px;
  background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 0;
}
#panel-toggle span {
  display: block; width: 16px; height: 2px; border-radius: 1px;
  background: var(--text-dim);
  transition: transform 0.25s ease, opacity 0.2s ease, background 0.15s;
}
#panel-toggle:hover span { background: var(--accent); }
#panel-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
#panel-toggle.open span:nth-child(2) { opacity: 0; }
#panel-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
#mode-switch {
  margin-left: auto; display: flex; gap: 4px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 4px;
}
.mode-btn {
  padding: 7px 18px; border-radius: 6px; font-size: 13px; font-weight: 600;
  color: var(--text-dim); white-space: nowrap;
}
.mode-btn.active { background: rgba(77, 195, 255, 0.15); color: var(--accent); }

/* ============ panel ============ */
#panel {
  position: fixed; top: 68px; left: 16px; bottom: 16px; z-index: 19; /* ズーム・角度UI(18)より上 */
  width: 300px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 14px;
  backdrop-filter: blur(12px);
  scrollbar-width: thin; scrollbar-color: #2a3a5c transparent;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#panel.collapsed { transform: translateX(-110%); opacity: 0; pointer-events: none; }
.panel-section-title {
  font-size: 10px; letter-spacing: 0.25em; color: var(--text-dim);
  margin: 14px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--panel-border);
}
.panel-section-title:first-child { margin-top: 0; }

.cat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px; border-radius: 8px; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.cat-row:hover { background: rgba(255, 255, 255, 0.04); }
.cat-row .cat-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
}
.cat-row .cat-name { font-size: 13.5px; font-weight: 600; flex: 1; }
.cat-row .cat-count { font-size: 11px; color: var(--text-dim); }
.cat-row .cat-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: rgba(74, 222, 128, 0.12); color: var(--ok);
}
.cat-row.off .cat-name, .cat-row.off .cat-icon { opacity: 0.35; }
.cat-toggle {
  width: 34px; height: 19px; border-radius: 10px; position: relative;
  background: #232d47; transition: background 0.2s; flex-shrink: 0;
}
.cat-toggle::after {
  content: ""; position: absolute; top: 2.5px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #64748b; transition: all 0.2s;
}
.cat-row.on .cat-toggle { background: rgba(77, 195, 255, 0.35); }
.cat-row.on .cat-toggle::after { left: 17px; background: var(--accent); }

.item-list { margin: 0 0 4px 12px; border-left: 1px solid var(--panel-border); }
.item-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px 5px 12px; font-size: 12.5px; color: var(--text-dim);
  cursor: pointer; border-radius: 0 6px 6px 0;
}
.item-row:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.item-row .item-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.item-row .item-stat { margin-left: auto; font-size: 10px; }
.item-row .item-stat.good { color: var(--ok); }
.item-row .item-stat.bad { color: var(--ng); }

/* 地域バー: 上部中央（ヘッダー下）に固定 */
#region-bar {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%);
  z-index: 17; max-width: calc(100vw - 24px);
  display: flex; gap: 4px; padding: 6px;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; backdrop-filter: blur(12px);
  overflow-x: auto; scrollbar-width: none;
}
@media (min-width: 768px) { #region-bar { top: 90px; } }
/* SP: 右のコントロール列（right:16px + 40px幅）と重ならないよう、バーの右端を手前で止める */
@media (max-width: 767px) {
  #region-bar { left: 12px; right: 68px; transform: none; max-width: none; }
}
/* 下部ドック: 広告のみ最下部中央 */
#bottom-dock {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: 17; padding-bottom: 12px;
}
/* 広告はサイズ固定（メディアクエリで切替）: SP=320x50 / PC=728x90 */
#app-ad { display: flex; justify-content: center; }
.app-ad-ins { display: inline-block; width: 320px; height: 50px; }
@media (min-width: 768px) { .app-ad-ins { width: 728px; height: 90px; } }
#region-bar::-webkit-scrollbar { display: none; }
#region-bar button {
  font-size: 12px; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  color: var(--text-dim); white-space: nowrap; flex-shrink: 0;
}
#region-bar button:hover { color: var(--accent); }
#region-bar button.active { background: rgba(77, 195, 255, 0.14); color: var(--accent); }
body.light #region-bar button.active { background: rgba(2, 132, 199, 0.1); }

.panel-footer { margin-top: 16px; font-size: 10px; line-height: 1.7; color: #55617a; }
.panel-footer .hint { color: #8aa3cc; font-weight: 600; }

/* ============ map labels ============ */
.map-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: #e8eef8;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.6);
  white-space: nowrap; pointer-events: none;
  transform: translate(8px, -50%);
}
.map-label .dot {
  width: 7px; height: 7px; border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.map-label.minor { font-size: 10.5px; font-weight: 500; opacity: 0.85; }
.map-label.highlighted { font-size: 15px; color: #fff; z-index: 5; }
.map-label.station-label { font-size: 10px; font-weight: 500; opacity: 0.8; }

.pref-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.2em;
  color: #55668a; white-space: nowrap; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ============ detail card ============ */
#detail-card {
  position: fixed; right: 16px; bottom: 16px; z-index: 25;
  width: 360px; max-width: calc(100vw - 32px);
  max-height: min(62vh, 520px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 18px 18px 16px;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
#detail-close {
  position: absolute; top: 10px; right: 12px;
  font-size: 18px; color: var(--text-dim); padding: 4px 8px;
}
.detail-cat {
  display: inline-block; font-size: 10px; letter-spacing: 0.1em;
  padding: 2px 8px; border-radius: 10px; border: 1px solid currentColor;
  margin-bottom: 8px;
}
.detail-name { font-size: 21px; font-weight: 800; }
.detail-reading { font-size: 11px; color: var(--text-dim); margin: 2px 0 4px; }
.detail-pref { font-size: 11px; color: #8aa3cc; margin-bottom: 10px; }
.detail-desc { font-size: 13px; line-height: 1.8; margin-bottom: 12px; }
.detail-block { margin-bottom: 12px; }
.detail-block-title {
  font-size: 10.5px; letter-spacing: 0.15em; font-weight: 700;
  margin-bottom: 5px;
}
.detail-block-title.mnemonic { color: #fbbf24; }
.detail-block-title.exam { color: #4dc3ff; }
.detail-mnemonic { font-size: 12.5px; line-height: 1.7; color: #f3e8c8; }
.detail-exam { list-style: none; }
.detail-exam li {
  font-size: 12.5px; line-height: 1.6; padding: 3px 0 3px 16px; position: relative;
}
.detail-exam li::before {
  content: "▸"; position: absolute; left: 2px; color: var(--accent);
}
.detail-related { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-related button {
  font-size: 11px; padding: 4px 10px; border-radius: 12px;
  border: 1px solid var(--panel-border); color: #8aa3cc;
}
.detail-related button:hover { border-color: var(--accent); color: var(--accent); }

/* ============ overlays (quiz setup / result) ============ */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 8, 16, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay-card {
  position: relative;
  width: 480px; max-width: 100%; max-height: 86vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 26px;
}
.overlay-close {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1; color: var(--text-dim);
  background: rgba(120,140,175,0.12); border: none; cursor: pointer;
}
.overlay-close:hover { color: var(--text); background: rgba(120,140,175,0.22); }
.overlay-card h2 {
  font-size: 17px; letter-spacing: 0.2em; margin-bottom: 18px; color: #f0f4fc;
}
.quiz-setup-label { font-size: 11px; letter-spacing: 0.15em; color: var(--text-dim); margin: 16px 0 8px; }
#quiz-mode-select { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-mode-opt {
  padding: 12px; border-radius: 10px; border: 1.5px solid var(--panel-border);
  font-size: 14px; font-weight: 700; color: var(--text); text-align: left;
}
.quiz-mode-opt small { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-dim); margin-top: 4px; }
.quiz-mode-opt.active { border-color: var(--accent); background: rgba(77, 195, 255, 0.08); }
#quiz-category-select { display: flex; flex-wrap: wrap; gap: 6px; }
.quiz-cat-chip {
  font-size: 12px; padding: 6px 12px; border-radius: 16px;
  border: 1.5px solid var(--panel-border); color: var(--text-dim);
}
.quiz-cat-chip.active { border-color: currentColor; }
#quiz-setup-actions, #quiz-result-actions { display: flex; gap: 10px; margin-top: 22px; }
.primary-btn {
  flex: 1; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 700;
  background: linear-gradient(135deg, #2196f3, #4dc3ff); color: #fff;
}
.primary-btn:disabled { opacity: 0.4; cursor: default; }
.ghost-btn {
  padding: 12px 16px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--panel-border); color: var(--text-dim);
}
.ghost-btn:hover { color: var(--text); }

/* ============ support (投げ銭) ============ */
.support-lead {
  font-size: 13.5px; line-height: 1.85; color: var(--text-dim); margin-bottom: 22px;
}
.support-amounts { display: flex; flex-direction: column; gap: 12px; }
.support-amt {
  display: flex; align-items: baseline; gap: 10px;
  padding: 15px 20px; border-radius: 12px;
  border: 1.5px solid var(--panel-border); color: var(--text);
  font-size: 18px; text-align: left;
}
.support-amt small { font-size: 12px; color: var(--text-dim); }
.support-amt:hover { border-color: var(--accent); background: rgba(77, 195, 255, 0.08); }
body.light .support-amt:hover { background: rgba(2, 132, 199, 0.07); }
.support-note {
  font-size: 11.5px; line-height: 1.7; color: var(--text-dim); margin-top: 20px;
}
.support-note a { color: var(--accent); }

/* ============ feedback (フィードバック) ============ */
#feedback-text {
  width: 100%; padding: 14px; border-radius: 12px; resize: vertical;
  background: rgba(120, 140, 175, 0.08); border: 1.5px solid var(--panel-border);
  color: var(--text); font-size: 14px; line-height: 1.7; font-family: inherit;
}
#feedback-text:focus { outline: none; border-color: var(--accent); }
.feedback-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.feedback-count { font-size: 12px; color: var(--text-dim); }
.feedback-count.over { color: var(--ng); }
.feedback-row .primary-btn { flex: 0 0 auto; padding: 12px 28px; }
.feedback-status { margin-top: 16px; font-size: 13.5px; line-height: 1.7; }
.feedback-status.ok { color: var(--ok); }
.feedback-status.err { color: var(--ng); }

/* ============ ライトシェア（解説カード内・チャレンジ結果） ============ */
/* カード下部に吸着させ、スクロールしなくても常に見える */
.detail-share {
  display: flex; gap: 8px; flex-wrap: wrap;
  position: sticky; bottom: -16px;
  background: var(--card);
  padding: 12px 0 16px; margin: 16px 0 -16px;
}
.ds-btn {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid var(--panel-border); color: var(--text);
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ds-btn:hover { border-color: var(--accent); color: var(--accent); }
.ds-btn.ds-challenge { border-color: rgba(77, 195, 255, 0.5); }
#challenge-cta { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
#challenge-cta .primary-btn { padding: 13px; }

/* ☕応援ボタンの気づきツールチップ（1分滞在で左に表示） */
#support-tip {
  position: fixed; z-index: 16; transform: translateY(-50%); /* 全情報UI（地域バー/広告17・コントロール18・パネル19・カード25・クイズHUD30）より下 */
  background: linear-gradient(135deg, #2196f3, #4dc3ff); color: #fff;
  font-size: 13px; font-weight: 700; padding: 9px 14px; border-radius: 999px;
  box-shadow: 0 8px 24px -6px rgba(14, 165, 233, 0.65); cursor: pointer;
  white-space: nowrap;
  animation: tip-pop 0.35s ease, tip-bob 2.4s ease-in-out 0.4s infinite;
}
#support-tip::after {
  content: ""; position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  border: 6px solid transparent; border-left-color: #4dc3ff;
}
@keyframes tip-pop { from { opacity: 0; transform: translateY(-50%) translateX(10px); } }
@keyframes tip-bob {
  0%, 100% { transform: translateY(-50%); }
  50% { transform: translateY(-50%) translateX(-3px); }
}
@media (prefers-reduced-motion: reduce) { #support-tip { animation: none; } }

/* 「どこ？」を出題ボタンの初回説明（解説カード内のボタンに重ねるためカードより上） */
#challenge-tip {
  position: fixed; z-index: 26; transform: translate(-50%, calc(-100% - 10px));
  background: linear-gradient(135deg, #2196f3, #4dc3ff); color: #fff;
  font-size: 12px; font-weight: 700; padding: 8px 13px; border-radius: 999px;
  box-shadow: 0 8px 24px -6px rgba(14, 165, 233, 0.65); cursor: pointer;
  white-space: nowrap;
  animation: chtip-pop 0.35s ease;
}
#challenge-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #4dc3ff;
}
@keyframes chtip-pop { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #challenge-tip { animation: none; } }

/* PC用シェア吹き出し（X/Threads/LINE/Instagram/コピー） */
#share-pop {
  position: fixed; z-index: 60;
  display: flex; flex-direction: column; min-width: 230px;
  background: var(--card); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.45);
}
#share-pop button {
  text-align: left; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; color: var(--text); white-space: nowrap;
}
#share-pop button:hover { background: rgba(77, 195, 255, 0.12); color: var(--accent); }

/* ============ quiz hud ============ */
#quiz-hud {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
  z-index: 30; width: 480px; max-width: calc(100vw - 24px);
  background: var(--card); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 14px 16px;
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 10px;
}
#quiz-progress { font-size: 11px; letter-spacing: 0.15em; color: var(--text-dim); }
#quiz-progress .score { color: #fbbf24; font-weight: 700; }
#quiz-question { font-size: 15px; font-weight: 700; line-height: 1.5; }
#quiz-question .q-target { color: var(--accent); font-size: 19px; }
#quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-choice {
  padding: 10px; border-radius: 9px; border: 1.5px solid var(--panel-border);
  font-size: 13.5px; font-weight: 600; color: var(--text);
  transition: all 0.15s;
}
.quiz-choice:hover:not(:disabled) { border-color: var(--accent); }
.quiz-choice.correct { border-color: var(--ok); background: rgba(74, 222, 128, 0.12); color: var(--ok); }
.quiz-choice.wrong { border-color: var(--ng); background: rgba(248, 113, 113, 0.1); color: var(--ng); }
.quiz-choice:disabled { cursor: default; }
#quiz-feedback { font-size: 13.5px; font-weight: 700; line-height: 1.6; }
#quiz-feedback.ok { color: var(--ok); }
#quiz-feedback.ng { color: var(--ng); }
#quiz-feedback small { display: block; font-weight: 400; font-size: 12px; color: var(--text-dim); margin-top: 3px; }
#quiz-feedback small.fb-point { color: #fbbf24; margin-top: 5px; line-height: 1.55; }
body.light #quiz-feedback small.fb-point { color: #b45309; }
#quiz-quit { align-self: flex-end; padding: 6px 12px; font-size: 11px; }
#quiz-next {
  padding: 10px; border-radius: 9px; font-size: 13.5px; font-weight: 700;
  background: rgba(77, 195, 255, 0.15); color: var(--accent);
}

/* ============ quiz result ============ */
#quiz-score { text-align: center; margin-bottom: 16px; }
#quiz-score .big { font-size: 44px; font-weight: 800; color: #fbbf24; }
#quiz-score .msg { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
#quiz-review { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.review-row {
  padding: 7px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.03);
  min-width: 0;
}
.review-row .rr-head { display: flex; align-items: center; gap: 6px; }
.review-row .mark { font-size: 12px; flex-shrink: 0; }
.review-row .mark.ok { color: var(--ok); }
.review-row .mark.ng { color: var(--ng); }
.review-row .rr-name {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.review-row .rr-point {
  margin-top: 2px; font-size: 10.5px; line-height: 1.45; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ============ quiz share ============ */
#quiz-share {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--panel-border);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#quiz-share .share-title {
  font-size: 11px; letter-spacing: 0.15em; color: var(--text-dim); align-self: flex-start;
}
#share-preview {
  display: block; width: 132px !important; height: 234px !important;
  object-fit: cover; object-position: top; border-radius: 12px;
  border: 1px solid var(--panel-border); box-shadow: 0 8px 22px rgba(0,0,0,0.4);
}
.share-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 700;
  border: 1px solid var(--panel-border); color: var(--text); cursor: pointer;
  transition: filter 0.15s, border-color 0.15s;
}
.share-btn:hover { filter: brightness(1.12); }
.share-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.share-primary {
  width: 100%; color: #fff; border: none;
  background: linear-gradient(135deg, #2196f3, #4dc3ff);
  box-shadow: 0 8px 18px -6px rgba(33,150,243,0.6);
}
.share-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; width: 100%; }
.share-x { background: #000; color: #fff; border-color: #000; }
.share-th { background: #101010; color: #fff; border-color: #101010; }
.share-save { background: transparent; }
body.light .share-save { background: #fff; }

/* ============ loading ============ */
#loading {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: var(--text-dim); font-size: 12px; letter-spacing: 0.2em;
  transition: opacity 0.4s;
}
#loading.fade { opacity: 0; pointer-events: none; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid #1e2a47; border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ light theme overrides ============ */
body.light #title h1 { color: #0f172a; }
body.light .overlay-card h2 { color: #0f172a; }
body.light .map-label {
  color: #1e293b;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.95), 0 0 10px rgba(255, 255, 255, 0.8);
}
body.light .map-label.highlighted { color: #000; }
body.light .pref-label {
  color: #8296b5;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.9);
}
body.light .cat-toggle { background: #cbd5e1; }
body.light .cat-toggle::after { background: #94a3b8; }
body.light .cat-row.on .cat-toggle { background: rgba(2, 132, 199, 0.3); }
body.light .cat-row.on .cat-toggle::after { background: var(--accent); }
body.light .overlay { background: rgba(220, 230, 244, 0.65); }
body.light .detail-block-title.mnemonic { color: #b45309; }
body.light .detail-mnemonic { color: #78500e; }
body.light .detail-block-title.exam { color: #0369a1; }
body.light #quiz-score .big { color: #d97706; }
body.light #quiz-progress .score { color: #d97706; }
body.light .review-row { background: rgba(15, 23, 42, 0.04); }
body.light .panel-footer { color: #8ba0be; }
body.light .panel-footer .hint { color: #4c6a96; }
body.light .spinner { border-color: #cbd8ea; border-top-color: var(--accent); }
body.light .cat-badge { background: rgba(22, 163, 74, 0.1); }

#theme-toggle {
  width: 38px; height: 38px; border-radius: 8px; font-size: 17px;
  background: var(--panel); border: 1px solid var(--panel-border);
  display: flex; align-items: center; justify-content: center;
}
#theme-toggle:hover { border-color: var(--accent); }
/* SP: 月・太陽アイコンをすこし小さく */
@media (max-width: 767px) { #theme-toggle { font-size: 14px; } }

/* ============ mobile ============ */
@media (max-width: 700px) {
  #title h1 { font-size: 16px; letter-spacing: 0.25em; }
  #subtitle { display: none; }
  #header { padding: 10px 12px; gap: 10px; }
  .mode-btn { padding: 6px 12px; font-size: 12px; }
  #panel {
    top: 56px; left: 8px; right: 8px; width: auto; bottom: auto;
    max-height: 55vh;
  }
  #detail-card {
    left: 8px; right: 8px; bottom: 8px; width: auto;
    max-height: 48vh; border-radius: 14px 14px 10px 10px;
  }
  #quiz-hud { top: auto; bottom: 10px; }
  #quiz-choices { grid-template-columns: 1fr; }
}

/* ============ 再アクセス導線（再訪トースト・A2HSガイド） ============ */
#revisit-tip {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
  z-index: 21; display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: calc(100vw - 24px); padding: 12px 14px;
  background: var(--card); border: 1px solid var(--panel-border);
  border-radius: 14px; backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  font-size: 12px; color: var(--text);
  animation: chtip-pop 0.35s ease;
}
#revisit-tip .rt-icon { font-size: 16px; }
#revisit-tip .rt-msg { line-height: 1.5; }
#revisit-tip .rt-action {
  flex-shrink: 0; padding: 8px 12px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #2196f3, #4dc3ff); color: #fff;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
#revisit-tip .rt-close {
  flex-shrink: 0; width: 26px; height: 26px; border: none; border-radius: 50%;
  background: transparent; color: var(--dim); font-size: 15px; cursor: pointer;
}
.a2hs-lead { font-size: 13px; color: var(--dim); margin: 8px 0 14px; line-height: 1.7; }
.a2hs-steps { margin: 0 0 6px 20px; padding: 0; font-size: 13px; line-height: 2.1; }
#result-a2hs {
  margin: 12px 0 4px; font-size: 11px; color: var(--dim); line-height: 1.6;
}
#result-a2hs button {
  border: none; background: none; padding: 0; color: var(--accent);
  font-size: 11px; font-weight: 700; cursor: pointer; text-decoration: underline;
}

/* 2D/3D切替（ヘッダー・テーマ切替の左） */
#view-mode {
  width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid var(--panel-border); border-radius: 8px;
  background: var(--panel);
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
  color: var(--text);
}
#view-mode:hover { border-color: var(--accent); color: var(--accent); }
#zoom-controls button.disabled { opacity: 0.3; pointer-events: none; }

/* 地図ラベルの工芸品アイコンと解説カードのイラスト */
.map-label.has-icon { display: flex; flex-direction: column; align-items: center; }
.map-label .label-icon {
  width: 34px; height: 34px; object-fit: contain; display: block;
  margin-bottom: 1px;
  filter: drop-shadow(0 2px 4px rgba(10, 25, 50, 0.35));
  pointer-events: none;
}
.detail-icon {
  display: block; width: 128px; height: 128px; object-fit: contain;
  margin: 10px auto 6px;
  filter: drop-shadow(0 4px 10px rgba(10, 25, 50, 0.18));
}
