/* Geo Tap */
:root {
  --bg: #e8f4f8; --panel: #ffffff; --ink: #1d3340; --muted: #6b8090; --line: #d5e3ea;
  --brand: #1f7a8c; --brand-d: #155866; --accent: #ff8a3d; --accent-d: #d96a1f;
  --sea: #bfe1ee; --sea2: #a8d4e6; --land: #f4ecd6; --border: #ffffff; --coast: #4f6670;
  --blink1: #ffb703; --blink2: #fb5607; --wrong: #e9b8b8; --hint: #cfe3ff;
  --ok: #1a9e5c; --ng: #d6453d; --star: #f5b301;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1d24; --panel: #1a2a33; --ink: #e6f0f4; --muted: #92a8b4; --line: #2b3d47;
    --brand: #3fb0c4; --brand-d: #2b8596; --sea: #133445; --sea2: #102c3a; --land: #3a4a4f; --border: #20323a; --coast: #a9c2cc;
    --wrong: #6b3a3a; --hint: #2f4866; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1d24; --panel: #1a2a33; --ink: #e6f0f4; --muted: #92a8b4; --line: #2b3d47;
  --brand: #3fb0c4; --brand-d: #2b8596; --sea: #133445; --sea2: #102c3a; --land: #3a4a4f; --border: #20323a; --coast: #a9c2cc;
  --wrong: #6b3a3a; --hint: #2f4866; color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: 'M PLUS Rounded 1c', system-ui, sans-serif; font-weight: 500; overscroll-behavior: none; }
#app { position: relative; height: 100%; height: 100dvh; max-width: 760px; margin: 0 auto; overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

/* ---------- ボタン類 ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: min(320px, 100%); padding: 13px 18px; border: 0; border-radius: 16px;
  background: var(--panel); color: var(--ink); font-size: 17px; font-weight: 800; box-shadow: 0 3px 0 var(--line), 0 1px 0 var(--line) inset; }
.btn svg { width: 22px; height: 22px; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: linear-gradient(var(--accent), var(--accent-d)); color: #fff; box-shadow: 0 4px 0 #b4561a; font-size: 20px; padding: 15px 18px; }
.btn.primary:active { box-shadow: 0 1px 0 #b4561a; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 800; }
.chip svg { width: 16px; height: 16px; }
.chip.off { opacity: .45; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- ホーム ---------- */
.screen { height: 100%; }
#home { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 56px 16px 64px; overflow-y: auto; position: relative;
  background: radial-gradient(120% 70% at 50% 0%, rgba(31,122,140,.16), transparent 70%); }
.corner-r { position: absolute; right: 12px; top: max(12px, env(safe-area-inset-top)); }
.corner-l { position: absolute; left: 12px; top: max(12px, env(safe-area-inset-top)); color: var(--ink); text-decoration: none; }
.title { text-align: center; margin-bottom: 6px; }
.title .pin { width: 46px; height: 46px; margin: 0 auto -4px; color: var(--ng); filter: drop-shadow(0 3px 0 rgba(0,0,0,.15)); animation: pinBob 2.4s ease-in-out infinite; }
@keyframes pinBob { 50% { transform: translateY(-6px); } }
.title h1 { margin: 0; font-size: clamp(44px, 13vw, 64px); font-weight: 800; letter-spacing: .02em; color: var(--brand); text-shadow: 0 4px 0 rgba(0,0,0,.08); }
.title .sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.seg { display: flex; gap: 8px; width: min(320px, 100%); }
.seg button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 6px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); }
.seg b { font-size: 18px; } .seg small { font-size: 11px; color: var(--muted); }
.seg button.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.seg button.on small { color: rgba(255,255,255,.85); }
.seg button[data-mode="oni"].on { border-color: #8d2b2b; background: #a83232; }
.seg-z button.on { border-color: #6b3fa0; background: #7a4fb5; } /* 雑学モード(2026-10-11) */
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.who { border: 0; background: none; color: var(--brand); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }
.debug { width: min(320px, 100%); display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 2px dashed var(--accent); border-radius: 12px; font-size: 13px; }
.foot { position: absolute; left: 0; right: 0; bottom: max(8px, env(safe-area-inset-bottom)); text-align: center; font-size: 10.5px; color: var(--muted); line-height: 1.5; padding: 0 16px; }

/* ---------- プレイ ---------- */
#play { display: flex; flex-direction: column; position: relative; }
.hud { display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 12px 6px; }
.hp { display: flex; gap: 2px; font-size: 26px; line-height: 1; }
.hp .star { font-style: normal; color: var(--line); transition: color .2s; }
.hp .star.on { color: var(--star); text-shadow: 0 2px 0 rgba(0,0,0,.12); }
.hp .star.lost { animation: lost .6s ease-out; }
.hp .star.got { animation: got .7s ease-out; }
@keyframes lost { 0% { color: var(--star); transform: scale(1.4) rotate(0); } 100% { transform: scale(1) rotate(-20deg); } }
@keyframes got { 0% { transform: scale(.2); } 60% { transform: scale(1.5); } 100% { transform: scale(1); } }
.stat { display: flex; flex-direction: column; align-items: center; margin-left: auto; line-height: 1.1; }
.stat + .stat { margin-left: 4px; }
.stat span { font-size: 10.5px; color: var(--muted); }
.stat b { font-size: 22px; font-weight: 800; }
.stat.rec b { font-size: 15px; } .stat.rec i { font-style: normal; font-size: 22px; color: var(--brand); }
.stat.bump b { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--ok); } }
.ask { margin: 0 12px 8px; padding: 10px 14px; border-radius: 14px; background: var(--panel); text-align: center; box-shadow: 0 2px 0 var(--line); font-size: 15px; }
.ask b { font-size: 26px; font-weight: 800; color: var(--brand); margin-right: 4px; }
.ask.long b { font-size: 20px; } /* 雑学の長い問題文(2026-10-11) */
.ask.pop { animation: askPop .35s ease-out; }
@keyframes askPop { 0% { transform: scale(.92); opacity: .4; } 100% { transform: none; opacity: 1; } }
#play.oni .ask b { color: #a83232; }
.map-wrap { position: relative; flex: 1; min-height: 0; margin: 0 8px max(8px, env(safe-area-inset-bottom)); border-radius: 16px; overflow: hidden;
  background: radial-gradient(130% 100% at 50% 30%, var(--sea), var(--sea2)); }
.map { width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.zoom { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.zoom .icon-btn { box-shadow: 0 2px 0 rgba(0,0,0,.1); }
.toast { position: absolute; left: 50%; top: 10px; transform: translate(-50%, -8px); opacity: 0; transition: .2s; pointer-events: none; white-space: nowrap;
  background: rgba(20,40,50,.85); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 999px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 地図の中身 */
.land { fill: var(--land); stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; fill-rule: evenodd; }
.coast-line { fill: none; stroke: none; }
/* 鬼: となり同士のすき間(アンチエイリアス)から下の線が見えないよう、陸と同じ色でふちを塗る */
.map.oni .land { stroke: var(--land); stroke-width: 1.4; }
.mini.oni .land { stroke: var(--land); stroke-width: 3; }
.map.oni .coast-line { stroke: var(--coast); stroke-width: 4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.mini.oni .coast-line { fill: none; stroke: var(--coast); stroke-width: 9; stroke-linejoin: round; }
.land.hint { fill: var(--hint); }
.land.wrong { fill: var(--wrong); }
.land.blink { animation: blink .5s ease-in-out infinite alternate; stroke: #fff; stroke-width: 1.6; }
@keyframes blink { from { fill: var(--blink1); } to { fill: var(--blink2); } }
.inset-box { fill: none; stroke: var(--coast); stroke-opacity: .55; stroke-width: 1.2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.mk-label { font-size: 19px; font-weight: 800; fill: var(--ink); stroke: var(--panel); stroke-width: 5px; paint-order: stroke; stroke-linejoin: round; pointer-events: none; }
.mk-label.ok { fill: var(--ok); }
.mk-x { stroke: var(--ng); stroke-width: 4.5; stroke-linecap: round; fill: none; }
.mk-x-bg { fill: rgba(255,255,255,.75); }
.mk-line { stroke: var(--ng); stroke-width: 2.5; stroke-dasharray: 6 5; opacity: .8; }
.mk-ripple { fill: none; stroke: #fff; stroke-width: 2.5; animation: ripple .6s ease-out forwards; }
@keyframes ripple { to { r: 34; opacity: 0; } }

/* 判定後の下の帯 */
.judge { position: absolute; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px; border-radius: 16px; background: var(--panel); box-shadow: 0 -2px 12px rgba(0,0,0,.15); animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }
.judge-msg { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.4; }
.judge-msg .ok { font-size: 22px; color: var(--ok); } .judge-msg .ng { font-size: 22px; color: var(--ng); }
.judge-msg .rec { color: var(--star); font-weight: 800; font-size: 15px; }
.judge .btn { width: auto; min-width: 120px; padding: 12px 18px; }

/* ---------- 重ねて出す画面 ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border-radius: 22px; padding: 20px; width: min(360px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.card h2 { margin: 0 0 4px; font-size: 22px; }
.newbest { font-weight: 800; color: var(--accent); font-size: 20px; animation: got .6s ease-out; }
.big-score { display: flex; align-items: baseline; gap: 6px; } .big-score b { font-size: 56px; color: var(--brand); line-height: 1; }
.res-mode { color: var(--muted); font-size: 13px; }
.res-rank { font-size: 14px; text-align: center; min-height: 1.4em; }
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; } .tabs button { padding: 6px 18px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); font-weight: 800; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.rank-card { width: min(380px, 100%); }
.rank-list { list-style: none; margin: 0; padding: 0; width: 100%; overflow-y: auto; min-height: 120px; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.rank-list li b { width: 2em; text-align: right; color: var(--muted); }
.rank-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list li em { font-style: normal; font-weight: 800; }
.rank-list li.me { background: rgba(255,138,61,.15); border-radius: 8px; }
.rank-list li:nth-child(1) b { color: #d4a000; } .rank-list li:nth-child(2) b { color: #8a9aa5; } .rank-list li:nth-child(3) b { color: #b0723a; }
.rank-list .empty { justify-content: center; color: var(--muted); border: 0; }
.rank-info { font-size: 12px; color: var(--muted); }
.lead { margin: -4px 0 2px; font-size: 12px; color: var(--muted); text-align: center; }
.steps { margin: 0; padding-left: 1.4em; font-size: 14px; line-height: 1.6; align-self: stretch; }
.rules-card { width: min(400px, 100%); }
.rules-body { overflow-y: auto; font-size: 14px; line-height: 1.6; width: 100%; }
.rules-body h3 { margin: 12px 0 4px; font-size: 15px; color: var(--brand); } .rules-body h3:first-child { margin-top: 0; }
.rules-body p { margin: 0 0 6px; }
.rules-body .st { color: var(--star); letter-spacing: 1px; }
.rules-body .figs { display: flex; gap: 10px; justify-content: center; margin: 4px 0 8px; }
.rules-body figure { margin: 0; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rules-body figcaption { font-size: 12px; line-height: 1.4; text-align: center; color: var(--muted); }
.rules-body figcaption b { color: var(--ink); }
.mini { width: 100%; max-width: 160px; height: auto; aspect-ratio: 1246 / 1202; background: var(--sea); border-radius: 10px; }
.mini .land { stroke-width: 2; vector-effect: none; }
.mini .mk-line { stroke-width: 6; }
.rules-body .src { font-size: 11px; color: var(--muted); margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .land.blink { animation-duration: 1.2s; } .title .pin { animation: none; } }
/* 複数カテゴリ(2026-10-08) */
.ask small { display: inline-block; margin-bottom: 2px; padding: 1px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 800; }
.ask > div { line-height: 1.3; }
.mk-label.dim { font-size: 15px; opacity: .85; }
.mk-label.city { font-size: 17px; fill: #c2410c; }
.mk-dot { fill: #e5484d; stroke: #fff; stroke-width: 2.5; }
.mk-dot-ring { fill: none; stroke: #e5484d; stroke-width: 2; animation: dotRing 1s ease-out infinite; }
@keyframes dotRing { from { r: 7; opacity: 1; } to { r: 22; opacity: 0; } }
.rules-body .cats { margin: 0 0 6px; padding-left: 1.2em; font-size: 13px; }
.land.deco { fill: var(--line); opacity: .7; }
/* 海・砂漠・半島・山脈(2026-10-08): 背景はふつうの陸地、正解の形は答えの後だけ見せる */
.land.base { pointer-events: none; }
.land.feature { fill: transparent; stroke: none; }
.land.feature.blink { fill-opacity: .6; stroke: #fff; stroke-width: 2; }
.map.oni .land.feature.blink { stroke: #fff; }
/* 小さすぎる地域の丸い印 */
.pin { fill: var(--land); stroke: var(--coast); stroke-width: 1.5; }
.pin.on { fill: var(--blink1); stroke: #fff; }
.map.oni .land.feature { stroke: none; }
/* 山の印・湖(簡単モードだけ水の色で見せる) */
.mtn { fill: #8a6a4a; stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; }
.mtn.on { fill: var(--blink2); }
.map:not(.oni) .land.feature.water { fill: var(--sea2); stroke: var(--coast); stroke-opacity: .35; stroke-width: .8; vector-effect: non-scaling-stroke; }
/* 結果画面の名前入力(ゲストの時) */
.name-box { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.name-box input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--brand); background: var(--panel); color: var(--ink); font: inherit; font-size: 16px; }
.name-box .btn { width: 100%; }
.name-box .btn:disabled { opacity: .45; }

/* ゲーム中の音ボタン(BGMと効果音をまとめてON/OFF) */
.snd-all .snd-x { display: none; } .snd-all.off .snd-x { display: inline; } .snd-all.off .snd-w { display: none; }
.snd-all.off svg { opacity: .55; }

/* 共有 */
.share-card .qr { display: block; width: min(220px, 62vw); height: auto; aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 8px; }
.share-card .qr-note { margin: -2px 0 4px; font-size: 13px; color: var(--muted); }

/* 国旗の問題 */
.ask b .flag { display: inline-block; height: 52px; width: auto; aspect-ratio: 4 / 3; vertical-align: middle; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); margin: 2px 2px 2px 0; }
/* ホームの背景で回る地球(globe.js、2026-10-12)。ボタン・文字が読めるように少し薄く */
#home { isolation: isolate; }
.globe-bg { position: absolute; left: 0; top: 0; z-index: -1; pointer-events: none; opacity: .55; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .globe-bg { opacity: .7; } }
:root[data-theme="dark"] .globe-bg { opacity: .7; }
/* 高さの低い画面(Android・表示サイズ大きめなど)では、スクロールしなくても全部見えるように詰める(2026-10-12 ユーザー「androidで下が切れてた」)。
   中身は真ん中、出典はいちばん下に並べる(重ならない)。高さに合わせて文字・余白を小さくする */
@media (max-height: 800px) {
  #home { justify-content: flex-start; gap: clamp(5px, 1.3vh, 12px); padding: max(48px, calc(env(safe-area-inset-top) + 40px)) 16px max(6px, env(safe-area-inset-bottom)); }
  #home .title { margin-top: auto; margin-bottom: 0; }
  .title .pin { width: clamp(26px, 5vh, 46px); height: clamp(26px, 5vh, 46px); }
  .title h1 { font-size: clamp(34px, 7.4vh, 64px); }
  .title .sub { font-size: 13px; }
  .seg button { padding: clamp(4px, 0.9vh, 9px) 6px; }
  .seg b { font-size: clamp(15px, 2.3vh, 18px); }
  #home .btn { padding-top: clamp(7px, 1.4vh, 13px); padding-bottom: clamp(7px, 1.4vh, 13px); }
  #home .btn.primary { padding-top: clamp(9px, 1.8vh, 15px); padding-bottom: clamp(9px, 1.8vh, 15px); font-size: clamp(17px, 2.6vh, 20px); }
  #home .chip { padding-top: clamp(4px, 0.8vh, 7px); padding-bottom: clamp(4px, 0.8vh, 7px); }
  #home .foot { position: static; margin-top: auto; padding-top: 4px; font-size: 9.5px; line-height: 1.35; }
}
@media (max-height: 600px) {
  .title .sub, .seg small { display: none; }
}
/* 雑学の固有名詞のふりがな(2026-10-12)。<ruby> の上の小さい字 */
.ask ruby, .judge-msg ruby { ruby-position: over; }
.ask rt { font-size: .42em; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.judge-msg rt { font-size: .6em; color: var(--muted); }
.ask b { line-height: 1.45; }
