/* ============================================================
   ポストクエスト style.css
   ダークネイビー1テーマ固定 / スマホファースト(375px基準)
   ============================================================ */

:root {
  --bg:           #0F1526;  /* 夜紺・地 */
  --surface:      #1B2336;  /* カード */
  --surface-2:    #242E45;  /* カード段差・チップ */
  --line:         #2E3A55;  /* 罫線・カード境界 */
  --ink:          #F2F5FA;  /* 本文 */
  --ink-sub:      #93A0B8;  /* 副文・キャプション */
  --primary:      #E94E3C;  /* ポスト赤: CTA・確定ピン */
  --primary-hi:   #FF6B57;  /* :active */
  --gold:         #F5B841;  /* 推奨★・バッジ・急げ判定 */
  --success:      #3DDC97;  /* 間に合う・レーダースイープ */
  --danger:       #FF5A5A;  /* 残り10分未満・間に合わない */
  --undiscovered: #5B6779;  /* 未発見シルエット・未獲得バッジ */
  --paper:        #F7EFD8;  /* リザルトカードの紙色 */
  --sheet-ease:   cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }

b { font-weight: 700; }

/* ---------- header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: rgba(15, 21, 38, 0.88);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.brand-icon { width: 26px; height: 26px; color: var(--primary); }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.04em; }

.rank-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
}
.rank-chip .lv { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */

main {
  padding: 12px 16px calc(76px + env(safe-area-inset-bottom));
}

.section-title {
  margin: 20px 0 8px;
  font-size: 14px;
  color: var(--ink-sub);
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ---------- tab bar ---------- */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 60;
}

.tab-bar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  color: var(--ink-sub);
}
.tab-bar a svg { width: 22px; height: 22px; }
.tab-bar a[aria-current="page"] { color: var(--primary); font-weight: 700; }

/* ---------- search bar ---------- */

.search-bar {
  display: flex;
  gap: 8px;
}

#addr-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* iOS zoom 防止 */
}
#addr-input::placeholder { color: var(--ink-sub); }
#addr-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.btn-search {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.btn-search:active { background: var(--primary-hi); }
.btn-search:disabled { opacity: 0.6; }
.btn-search.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  vertical-align: -1px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

.btn-geo {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-geo svg { width: 22px; height: 22px; }
.btn-geo:active { background: var(--surface-2); }
.btn-geo.loading svg { animation: spin 1.2s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.inline-error {
  margin: 8px 2px 0;
  font-size: 13px;
  color: var(--danger);
}

#geo-candidates {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
#geo-candidates li + li { border-top: 1px solid var(--line); }
.candidate-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
}
.candidate-btn:active { background: var(--surface-2); }

/* ---------- radius chips ---------- */

.radius-chips {
  display: flex;
  gap: 0;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.radius-chips button {
  flex: 1;
  min-height: 44px;
  font-size: 13px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}
.radius-chips button + button { border-left: 1px solid var(--line); }
.radius-chips button.selected {
  background: var(--surface-2);
  color: var(--gold);
  font-weight: 700;
}

/* ---------- map shell / radar ---------- */

#map-shell {
  position: relative;
  height: 45vh;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

#map, #radar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-sub);
  font-size: 13px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(61, 220, 151, 0.05), transparent 65%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(46, 58, 85, 0.5) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(46, 58, 85, 0.5) 39px 40px);
}
#map-placeholder svg { width: 44px; height: 44px; color: var(--undiscovered); }

.map-note {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 5;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(15, 21, 38, 0.85);
  border: 1px solid var(--line);
  color: var(--ink-sub);
  font-size: 12px;
  text-align: center;
}

/* map ピン (MapLibre custom element) */
.pin-official {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: var(--primary);
  border: 2px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.pin-osm {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--undiscovered);
  border: 2px solid var(--bg);
  cursor: pointer;
}
/* 視覚サイズは据え置きで、44px の透明ヒット領域を中央に重ねる */
.pin-official::after,
.pin-osm::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}
.pin-osm.found { background: var(--gold); }
.pin-self {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid var(--success);
  filter: drop-shadow(0 0 2px var(--bg));
}

/* SCANNING オーバーレイ (CSSのみのスイープ) */
#scan-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(15, 21, 38, 0.82);
}
.scan-sweep {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background:
    conic-gradient(from 0deg, rgba(61, 220, 151, 0.55), transparent 70deg, transparent 360deg),
    radial-gradient(circle, transparent 58%, rgba(46, 58, 85, 0.8) 59% 60%, transparent 61%),
    radial-gradient(circle, transparent 28%, rgba(46, 58, 85, 0.8) 29% 30%, transparent 31%);
  animation: sweep 1.2s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.scan-text { margin: 0; font-size: 13px; color: var(--success); letter-spacing: 0.2em; }

/* ---------- day banner / notes / errors ---------- */

#day-banner {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--gold);
  text-align: center;
}

.muted-note {
  margin: 10px 2px;
  font-size: 13px;
  color: var(--ink-sub);
}

.error-box {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--danger);
  border-radius: 12px;
  background: var(--surface);
}
.error-box p { margin: 0 0 10px; font-size: 14px; }

#empty-state {
  margin: 16px 0;
  padding: 20px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
}
.empty-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.empty-sub { margin: 0 0 12px; font-size: 13px; color: var(--ink-sub); }

.btn-secondary {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 700;
}
.btn-secondary:active { background: var(--line); }

/* ---------- result cards ---------- */

#result-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  animation: card-in 0.32s both;
  /* stagger は9枚目以降で頭打ち (最大80件でも末尾が数秒 opacity:0 のままにならない) */
  animation-delay: calc(min(var(--i, 0), 8) * 60ms);
}
/* サイレント更新・部分再描画時は出現アニメなしで即時表示 */
.card.no-anim { animation: none; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.card:active { background: var(--surface-2); }

.card-icon { flex-shrink: 0; padding-top: 2px; }
.card-icon svg { width: 34px; height: 34px; color: var(--primary); }
.post-slot { fill: var(--bg); }
.card.osm .card-icon svg { color: var(--undiscovered); }
.card.osm.found .card-icon svg { color: var(--gold); }

.card-main { flex: 1; min-width: 0; }

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card-name {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.reco-star {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--bg);
  background: var(--gold);
  border-radius: 6px;
  padding: 1px 7px;
}
.found-chip {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 1px 7px;
}

.card-next {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-sub);
}

.day-chip {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-sub);
}

.countdown {
  margin-top: 2px;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.cd-ok     { color: var(--success); }
.cd-gold   { color: var(--gold); }
.cd-danger { color: var(--danger); animation: cd-pulse 1s ease-in-out infinite; }
.cd-collected { color: var(--ink-sub); font-size: 20px; }
@keyframes cd-pulse { 50% { opacity: 0.55; } }

.no-times {
  margin-top: 2px;
  font-size: 13px;
  color: var(--undiscovered);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}
.meta-dir { display: inline-flex; align-items: center; gap: 3px; }
.dir-arrow { width: 12px; height: 12px; color: var(--success); }

.judge {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
  font-size: 13px;
}
.judge-label {
  align-self: flex-start;
  padding: 2px 9px;
  border-radius: 7px;
  font-weight: 700;
}
.judge-ok     .judge-label { color: var(--bg); background: var(--success); }
.judge-hurry  .judge-label { color: var(--bg); background: var(--gold); }
.judge-miss   .judge-label { color: #fff; background: var(--danger); }
.judge-closed .judge-label { color: var(--ink-sub); background: var(--surface-2); border: 1px solid var(--line); }
.judge-sub { font-size: 12px; color: var(--ink-sub); }

.btn-discover {
  margin-top: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--undiscovered);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.btn-discover:active { border-color: var(--gold); color: var(--gold); }

/* ---------- record tab ---------- */

.rank-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.rank-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
#rank-name { font-size: 20px; font-weight: 700; }
.lv { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }

.exp-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.exp-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--primary-hi));
  transition: width 0.8s var(--sheet-ease);
}
.exp-text {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.tile b { font-size: 20px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 10px; color: var(--ink-sub); white-space: nowrap; }

.badge-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
}
.badge-icon svg { width: 30px; height: 30px; color: var(--gold); }
.badge.locked .badge-icon svg { color: var(--undiscovered); }
.badge.locked .badge-name { color: var(--ink-sub); }
.badge-name { font-size: 12px; }
.badge-desc { font-size: 10px; color: var(--ink-sub); line-height: 1.35; }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.history-row {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.history-row + .history-row { border-top: 1px solid var(--line); }
.h-time {
  flex-shrink: 0;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  padding-top: 1px;
}
.h-text { min-width: 0; overflow-wrap: anywhere; }
.history-row.type-report .h-text { color: var(--gold); }

/* ---------- bottom sheet ---------- */

#sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.26s var(--sheet-ease);
}
#sheet-backdrop.show { opacity: 1; }

#sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 100;
  width: 100%;
  max-width: 480px;
  height: 85%;
  display: flex;
  flex-direction: column;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  transform: translate(-50%, 100%);
  transition: transform 0.26s var(--sheet-ease);
  touch-action: none;
}
#sheet.show { transform: translate(-50%, 0); }
#sheet.dragging { transition: none; }

.sheet-grabber {
  flex-shrink: 0;
  /* バー5px と合わせて実効ヒット高 44px。負マージン+前面重ねで視覚上の高さは従来どおり */
  padding: 14px 0 25px;
  margin-bottom: -19px;
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  cursor: grab;
}
.sheet-grabber span {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 20px calc(20px + env(safe-area-inset-bottom));
  touch-action: pan-y;
}

.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-icon svg { width: 40px; height: 40px; color: var(--primary); }
#sheet.osm .sheet-icon svg { color: var(--undiscovered); }
#sheet.osm.found .sheet-icon svg { color: var(--gold); }
.sheet-head-text h2 {
  margin: 0;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.src-badge {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 6px;
}
.src-badge.official { color: var(--success); border: 1px solid var(--success); }
.src-badge.osm { color: var(--ink-sub); border: 1px dashed var(--undiscovered); }

#sheet-countdown-wrap {
  margin: 14px 0 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  text-align: center;
}
.countdown-xl {
  font-size: clamp(2.2rem, 11vw, 3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.sheet-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink-sub);
}

.osm-note-box {
  margin: 14px 0 4px;
  padding: 16px 14px;
  border: 1px dashed var(--undiscovered);
  border-radius: 12px;
  font-size: 14px;
  color: var(--ink-sub);
  text-align: center;
}

#sheet-judge { margin-top: 10px; }

.sheet-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}

.times-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.times-table th, .times-table td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
}
.times-table th { width: 4.5em; color: var(--ink-sub); font-weight: 700; background: var(--surface-2); }
.times-table tr.today th { color: var(--gold); }
.times-table tr.today td { color: var(--gold); font-weight: 700; }

.btn-primary {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.btn-primary:active { background: var(--primary-hi); }
.btn-primary:disabled {
  background: var(--undiscovered);
  color: var(--ink-sub);
  opacity: 0.7;
}

.btn-link {
  display: block;
  margin-top: 12px;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  color: var(--success);
  min-height: 44px;
}

/* ---------- result modal ---------- */

#result-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 8, 16, 0.8);
  animation: fade-in 0.2s both;
}
@keyframes fade-in { from { opacity: 0; } }

.result-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 28px 22px 22px;
  border-radius: 16px;
  background: var(--paper);
  color: var(--bg);
  text-align: center;
  overflow: hidden;
  animation: card-pop 0.3s var(--sheet-ease) both;
}
@keyframes card-pop {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.quest-clear {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--primary);
}
#result-name {
  margin: 10px 0 0;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.result-exp {
  margin: 12px 0 8px;
  font-size: 30px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.result-bar { background: rgba(15, 21, 38, 0.12); border-color: rgba(15, 21, 38, 0.2); }
#result-exp-text {
  margin: 6px 0 0;
  font-size: 12px;
  color: rgba(15, 21, 38, 0.65);
  font-variant-numeric: tabular-nums;
}
.result-card .btn-primary { margin-top: 18px; }

/* 紙吹雪 (CSSのみ・12個) */
#confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti-piece {
  position: absolute;
  top: -12px;
  left: var(--x, 50%);
  width: 8px;
  height: 13px;
  background: var(--clr, var(--gold));
  transform: rotate(0deg);
  animation: confetti-fall 1.6s ease-in var(--delay, 0s) both;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(420px) rotate(var(--rot, 540deg)); opacity: 0; }
}

/* ============================================================
   エリア獲得 (陣取り)
   ============================================================ */

/* 獲得アニメーション用オーバーレイ */
#territory-anim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
}

/* 探索タブの進捗インジケータ */
#territory-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-sub);
}
.tp-dots { display: inline-flex; gap: 5px; flex-shrink: 0; }
.tp-dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--undiscovered);
  background: transparent;
}
.tp-dots i.on {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: 0 0 6px rgba(245, 184, 65, 0.7);
}

/* 写真登録ボタン (シート) */
.btn-photo {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 1px solid var(--gold);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--gold);
  font-size: 15px;
  font-weight: 700;
}
.btn-photo:active { background: var(--line); }
.btn-photo.registered {
  border-style: dashed;
  color: var(--ink-sub);
  border-color: var(--line);
}

/* カードの写真登録済みマーク */
.card.has-photo .card-icon { position: relative; }
.card.has-photo .card-icon::after {
  content: "📷";
  position: absolute;
  right: -4px;
  bottom: -2px;
  font-size: 12px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px var(--bg));
}

/* ---------- 写真プレビューモーダル ---------- */

#photo-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 8, 16, 0.85);
  animation: fade-in 0.2s both;
}
.photo-card {
  width: 100%;
  max-width: 360px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}
.photo-title { margin: 0; font-size: 15px; font-weight: 700; }
#photo-post-name {
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--ink-sub);
  overflow-wrap: anywhere;
}
#photo-preview {
  display: block;
  width: 100%;
  max-height: 46dvh;
  object-fit: contain;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.photo-actions .btn-secondary { flex: 1; }
.photo-card .btn-primary { margin-top: 10px; }

/* ---------- エリア獲得リザルト ---------- */

#area-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 8, 16, 0.85);
  animation: fade-in 0.2s both;
}
#area-names {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.area-size {
  margin: 12px 0 10px;
  font-size: 14px;
  color: rgba(15, 21, 38, 0.7);
}
.area-size b {
  font-size: 26px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.area-points {
  margin-top: 4px;
  border-top: 1px dashed rgba(15, 21, 38, 0.25);
  padding-top: 8px;
  font-variant-numeric: tabular-nums;
}
.pt-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 3px 0;
  color: rgba(15, 21, 38, 0.75);
}
.pt-row small { font-size: 10px; opacity: 0.75; }
.pt-row.total {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(15, 21, 38, 0.25);
  font-size: 15px;
  font-weight: 700;
  color: var(--bg);
}
.pt-row.total b { font-size: 22px; color: var(--primary); }

/* ---------- 記録タブ: 獲得エリア / 写真図鑑 ---------- */

.territory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.territory-row {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.territory-row + .territory-row { border-top: 1px solid var(--line); }
.t-time {
  flex-shrink: 0;
  color: var(--ink-sub);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.t-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.t-names { overflow-wrap: anywhere; }
.t-meta { font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; }
.territory-row.summary {
  justify-content: flex-end;
  background: var(--surface-2);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.photo-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.photo-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  padding-bottom: 6px;
}
.photo-cell img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.p-name {
  font-size: 10px;
  color: var(--ink-sub);
  padding: 0 6px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- toast ---------- */

#toast {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 300;
  max-width: min(90vw, 440px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .card { animation-delay: 0s !important; }
  .cd-danger { animation: none !important; }
  .scan-sweep { animation: none !important; }
  .confetti-piece { display: none !important; }
}
