:root {
  --sea: #d8e8f2;
  --blank: #ffffff;   /* パレットに #f2f2b0 など淡色があるので、未回答は純白にして差を確保 */
  --correct: #57b87b;
  --correct-new: #2f9e5a;
  --border: #9aa5ad;
  --frame: #8ba3b5;
  --ink: #2b3a45;
  --bar: #29404f;
}

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

html, body {
  height: 100%;
  font-family: system-ui, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--ink);
  background: #fff;
}
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; }

/* ---------- ヘッダ ---------- */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  background: var(--bar); color: #f0f4f7;
  flex-wrap: wrap;
}
#topbar h1 { font-size: 18px; font-weight: 600; white-space: nowrap; }
#score { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#scoreNum { font-weight: 700; font-size: 20px; }
#timer {
  font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 2px 10px; border-radius: 6px; background: rgba(255,255,255,.12);
}
#timer.warn { background: #b4483e; }
#topBtns { margin-left: auto; display: flex; gap: 8px; }
#topBtns button {
  padding: 6px 14px; font-size: 14px; border: 1px solid rgba(255,255,255,.45);
  background: transparent; color: inherit; border-radius: 5px; cursor: pointer;
}
#topBtns button:hover:not(:disabled) { background: rgba(255,255,255,.15); }
#topBtns button:disabled { opacity: .4; cursor: default; }

/* ---------- 入力欄 ---------- */
#answerBar { padding: 10px 16px 8px; background: #f2f5f7; border-bottom: 1px solid #dde4e9; text-align: center; }
#answerForm { display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
#answerInput {
  flex: 1; min-width: 0; font-size: 18px; padding: 8px 12px;
  border: 2px solid #b7c4cd; border-radius: 6px; outline: none;
}
#answerInput:focus { border-color: #3a7ca5; }
#btnAnswer {
  padding: 0 18px; font-size: 15px; border: none; border-radius: 6px;
  background: #3a7ca5; color: #fff; cursor: pointer;
}
#btnAnswer:disabled, #answerInput:disabled { opacity: .5; cursor: default; }
#answerBar.ended #answerForm { display: none; }

#feedback { min-height: 1.6em; margin-top: 6px; font-size: 15px; }
#feedback .ok { color: #23824a; font-weight: 600; }
#feedback .ng { color: #b4483e; font-weight: 600; }
#feedback .dup { color: #7a6a2b; font-weight: 600; }
#feedback .sub { font-size: 12.5px; color: #6b7a84; font-weight: normal; margin-left: 6px; }

#result { font-size: 18px; font-weight: 700; padding: 4px 0; }
#result.clear { color: #23824a; font-size: 22px; }

/* ---------- 地図 ---------- */
#mapWrap { position: relative; flex: 1; min-height: 0; background: var(--sea); }
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map.panning { cursor: grabbing; }

#land path {
  fill: var(--blank);
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  fill-rule: evenodd;
}
#land path.ok { fill: var(--pc, var(--correct)); }
#land path.ok.new { animation: flash 1.6s ease-out; }
#land path.miss { fill: url(#hatch); }
#land path.hoppo { stroke-dasharray: 5 4; fill: #fbfaf6; opacity: .55; }
/* 正解直後: 白く光ってから県の色へ（パレットに黄色系があるので白で光らせる） */
@keyframes flash {
  0%   { fill: #fff; stroke: #000; stroke-width: 3; }
  100% { fill: var(--pc, var(--correct)); }
}

#frames rect { fill: none; stroke: var(--frame); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#frames text { fill: #5c7891; font-size: 90px; font-weight: 600; }

#zoomBtns {
  position: absolute; right: 14px; top: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
#zoomBtns button {
  width: 36px; height: 36px; font-size: 18px;
  border: 1px solid #b7c4cd; border-radius: 6px;
  background: #fff; color: var(--ink); cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
#zoomBtns button:hover { background: #eef4f8; }

#tooltip {
  position: absolute; pointer-events: none; z-index: 10;
  background: rgba(30,44,54,.92); color: #fff;
  padding: 6px 10px; border-radius: 6px; font-size: 13px;
  max-width: 240px; line-height: 1.5;
}
#tooltip .tt-sub { font-size: 11px; opacity: .8; }

/* ---------- スタート画面 ---------- */
#startOverlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(41,64,79,.35); padding: 16px;
}
#startOverlay[hidden] { display: none; }
#startOverlay .card {
  background: #fff; border-radius: 12px; padding: 24px 28px; max-width: 420px; width: 100%;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); text-align: center;
}
#startOverlay h2 { font-size: 20px; margin-bottom: 6px; }
#startOverlay .lead { font-size: 13.5px; color: #55656f; margin-bottom: 16px; }
#startOverlay fieldset { border: none; display: flex; justify-content: center; gap: 24px; margin-bottom: 18px; }
#startOverlay legend { font-size: 13px; color: #6b7a84; margin: 0 auto 8px; }
#startOverlay label { font-size: 17px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
#startOverlay input[type=radio] { width: 18px; height: 18px; }
#btnStart {
  width: 100%; padding: 12px; font-size: 18px; font-weight: 700;
  border: none; border-radius: 8px; background: var(--correct); color: #fff; cursor: pointer;
}
#btnStart:disabled { opacity: .6; cursor: default; }
#startOverlay .note { font-size: 12.5px; color: #6b7a84; margin-top: 14px; line-height: 1.6; }

/* ---------- ヒントパネル ---------- */
#hintPanel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(340px, 88vw);
  background: #fff; box-shadow: -4px 0 20px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
  transform: translateX(105%); transition: transform .25s ease;
}
#hintPanel.open { transform: none; }
#hintHead {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px; background: var(--bar);
}
#hintJump { flex: 1; font-size: 14px; padding: 4px 6px; border-radius: 4px; }
#hintClose {
  border: none; background: none; color: #fff; font-size: 24px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
#hintBody { flex: 1; overflow-y: auto; padding: 8px 12px 40px; }
#hintBody table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; font-size: 14px; }
#hintBody th {
  position: sticky; top: -8px; z-index: 1;
  background: #e3ebf1; text-align: left; padding: 6px 8px; font-size: 15px;
  border: 1px solid #c9d4dc;
  border-left: 10px solid var(--pc, #c9d4dc);
}
#hintBody th .cnt { float: right; font-weight: normal; font-size: 12.5px; color: #55656f; }
#hintBody td { border: 1px solid #dde4e9; padding: 3px 8px; height: 26px; }
#hintBody td.ok { color: #1f7040; }
#hintBody td.miss { color: #b4483e; }
#hintBody td.new { animation: rowflash 1.6s ease-out; }
@keyframes rowflash { 0% { background: #fff3a6; } 100% { background: transparent; } }

/* ---------- フッタ ---------- */
#credit {
  padding: 5px 16px; font-size: 11px; color: #5f6d77; background: #f2f5f7;
  border-top: 1px solid #dde4e9;
}
#credit a { color: #3a7ca5; }

@media (max-width: 600px) {
  #topbar { gap: 10px; padding: 6px 12px; }
  #topbar h1 { display: none; }
  #topBtns button { padding: 5px 10px; font-size: 13px; }
  #timer, #scoreNum { font-size: 17px; }
  #answerBar { padding: 8px 12px 6px; }
  #answerInput { font-size: 16px; }
  #credit { display: none; }
}
