:root {
  --bg: #fbfbe7;
  --surface: #ffffff;
  --ink: #333333;
  --muted: #6b6b5e;
  --line: #e4e4cf;
  --brand: #39992d;
  --lime: #abcd03;
  --accent: #2f7f25;
  --accent-ink: #ffffff;
  --lv0: #e8e8dc;
  --lv1: #ecf4c0;
  --lv2: #d2e67a;
  --lv3: #abcd03;
  --lv4: #39992d;
  --stroke: #ffffff;
  --radius: 16px;
  --side: 400px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  line-height: 1.6;
}

.app { max-width: 1200px; margin: 0 auto; }
.main { padding: 16px 16px 112px; }

.hd .brand { margin: 0; font-weight: 800; letter-spacing: .12em; color: var(--accent); font-size: 13px; }
.hd h1 { margin: 2px 0 12px; color: var(--brand); font-size: clamp(24px, 6vw, 36px); line-height: 1.25; }

.progress { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 0 var(--line); }
.count { margin: 0; display: flex; align-items: baseline; gap: 6px; }
.count strong { font-size: 44px; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.count span { font-size: 20px; font-weight: 700; color: var(--muted); }
.bar { height: 10px; background: var(--lv0); border-radius: 99px; overflow: hidden; margin: 10px 0 8px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--lime), var(--brand)); border-radius: 99px; transition: width .6s ease; }
.remain { margin: 0; font-weight: 700; }
.remain b { color: var(--accent); font-size: 1.3em; margin: 0 2px; }

.map { position: relative; margin: 8px -8px 0; }
.map svg { display: block; width: 100%; height: auto; }
.map .prefecture { fill: var(--lv0); stroke: var(--stroke); stroke-width: 1; cursor: pointer; outline: none; transition: fill .4s ease; }
.map .prefecture[data-lv="1"] { fill: var(--lv1); }
.map .prefecture[data-lv="2"] { fill: var(--lv2); }
.map .prefecture[data-lv="3"] { fill: var(--lv3); }
.map .prefecture[data-lv="4"] { fill: var(--lv4); }
.map .prefecture:hover, .map .prefecture:focus-visible, .map .prefecture.sel { stroke: var(--ink); stroke-width: 2; }
.map .prefecture.flash { animation: flash 1.2s ease 2; }
.map .boundary-line { stroke: var(--line); stroke-width: 1.5; fill: none; }
@keyframes flash { 50% { fill: #fff2a8; } }

.hint { margin: 4px 0 20px; text-align: center; color: var(--muted); font-size: 12px; }

.tip {
  position: absolute; left: 0; top: 0; z-index: 3; width: max-content; max-width: min(280px, calc(100% - 8px));
  background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 12px;
  font-size: 20px; font-weight: 700; line-height: 1.3; box-shadow: 0 6px 20px rgb(0 0 0 / .2);
  display: grid; gap: 8px; justify-items: start;
}
.tip[hidden] { display: none; }
.tip p { margin: 0; white-space: nowrap; }
.tip b { font-size: 1.3em; margin: 0 2px; }
.tip-cta { font: inherit; font-weight: 700; font-size: 14px; min-height: 40px; padding: 6px 16px; border: 0; border-radius: 99px; background: var(--accent); color: #fff; cursor: pointer; }
.tip-cta[hidden] { display: none; }

.lead { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.recent { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13px; overflow: hidden; }
.recent[hidden] { display: none; }
.recent-label { flex: none; font-weight: 700; color: var(--accent); }
.recent ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.recent li { color: var(--muted); }
.recent li b { color: var(--ink); margin-right: 4px; }
.recent li:first-child { animation: pop .5s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

.legend { list-style: none; margin: 0 0 4px; padding: 0; display: flex; justify-content: center; gap: 10px; font-size: 11px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 4px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--lv0); }
.legend i[data-lv="1"] { background: var(--lv1); }
.legend i[data-lv="2"] { background: var(--lv2); }
.legend i[data-lv="3"] { background: var(--lv3); }
.legend i[data-lv="4"] { background: var(--lv4); }

.ft { margin-top: 24px; font-size: 11px; color: var(--muted); }
.ft a { color: inherit; }

.side {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%); visibility: hidden; transition: transform .3s ease, visibility .3s;
  box-shadow: 0 -8px 32px rgb(0 0 0 / .15);
}
.side.open { transform: none; visibility: visible; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -8px; z-index: 1; background: var(--surface); padding: 8px 0; }
.sheet-head::before { content: ""; position: absolute; top: 0; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.close { font-size: 26px; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 8px; }

.backdrop { position: fixed; inset: 0; z-index: 10; background: rgb(0 0 0 / .35); opacity: 0; pointer-events: none; transition: opacity .3s; }
.backdrop.open { opacity: 1; pointer-events: auto; }

.fab {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 5;
  font: inherit; font-weight: 800; font-size: 17px; padding: 15px; border: 0; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgb(47 127 37 / .35); cursor: pointer;
}

.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; font-size: 14px; font-weight: 700; }
.field em { color: var(--accent); font-style: normal; margin-left: 2px; }
.field input, .field select, .field textarea {
  font: inherit; font-size: 16px; font-weight: 400; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.field :focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cf-turnstile { min-height: 65px; }
.form-error { margin: 0; font-size: 13px; font-weight: 700; color: #d33; }
.form-error:empty { display: none; }
.field [aria-invalid="true"] { border-color: #d33; }
.submit { font: inherit; font-weight: 800; font-size: 17px; padding: 14px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.note { margin: 0; font-size: 12px; color: var(--muted); }
.preview-note { margin: 0; padding: 10px 12px; font-size: 13px; font-weight: 700; color: var(--accent); background: var(--bg); border: 1px solid var(--accent); border-radius: 10px; }
.submit:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }

.toast {
  position: fixed; left: 50%; top: 16px; z-index: 30; transform: translate(-50%, calc(-100% - 32px)); visibility: hidden;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 700;
  transition: transform .35s ease, visibility .35s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

.prefs { margin-bottom: 20px; }
.prefs h2 { font-size: 15px; margin: 0 0 8px; color: var(--accent); }
.pref-region { margin-bottom: 12px; }
.pref-region h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); }
.pref-region ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.pref-btn {
  font: inherit; font-size: 13px; width: 100%; min-height: 40px; padding: 4px 10px; display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; text-align: left;
}
.pref-btn:hover { border-color: var(--brand); }
.pref-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pref-btn .mk { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--lv0); }
.pref-btn[data-lv="1"] .mk { background: var(--lv1); }
.pref-btn[data-lv="2"] .mk { background: var(--lv2); }
.pref-btn[data-lv="3"] .mk { background: var(--lv3); }
.pref-btn[data-lv="4"] .mk { background: var(--lv4); }
.pref-btn .pn { flex: 1; font-weight: 700; }
.pref-btn .pc { color: var(--ink); font-variant-numeric: tabular-nums; }
.pref-btn[data-lv="0"] { border-style: dashed; background: transparent; color: var(--muted); }
.pref-btn[data-lv="0"] .pn { font-weight: 400; }
.pref-btn[data-lv="0"] .pc { color: var(--muted); }

.hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.photo { display: flex; align-items: flex-end; gap: 12px; }
.photo[hidden] { display: none; }
.photo img { max-width: 160px; max-height: 160px; border-radius: 10px; border: 1px solid var(--line); object-fit: cover; }
.photo-clear { font: inherit; font-size: 13px; font-weight: 700; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--ink); cursor: pointer; }
.counter { justify-self: end; font-weight: 400; font-size: 11px; color: var(--muted); }

@media (min-width: 900px) {
  .pref-region ul { grid-template-columns: repeat(3, 1fr); }
  .app { display: grid; grid-template-columns: 1fr var(--side); gap: 32px; padding: 0 24px; }
  .main { padding: 24px 0 48px; }
  .side {
    position: sticky; top: 24px; inset: auto; align-self: start; transform: none; visibility: visible;
    max-height: calc(100dvh - 48px); border-radius: var(--radius); margin-top: 24px; padding: 8px 20px 20px;
    box-shadow: 0 2px 0 var(--line);
  }
  .sheet-head::before, .close, .fab, .backdrop { display: none; }
}

@media (min-width: 1100px) {
  .pref-region ul { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
