/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:   #1a6b3c;
  --green-l: #2d9157;
  --accent:  #e8820c;
  --bg:      #f5f7f4;
  --card:    #ffffff;
  --border:  #dde3d8;
  --text:    #1e2a1e;
  --muted:   #6b7f6b;
  --radius:  12px;
  --shadow:  0 2px 8px rgba(0,0,0,.10);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ===== 画面制御 ===== */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ===== TOP画面 ===== */
.hero {
  background: linear-gradient(160deg, var(--green) 0%, var(--green-l) 100%);
  color: #fff;
  text-align: center;
  padding: 56px 24px 40px;
}
.hero-icon { font-size: 56px; margin-bottom: 12px; }
.hero h1 { font-size: 26px; font-weight: 700; letter-spacing: .04em; }
.hero-sub { margin-top: 8px; font-size: 14px; opacity: .85; }

.card {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  margin-top: -16px;
  padding: 28px 24px 32px;
  flex: 1;
  box-shadow: var(--shadow);
}

.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color .2s;
}
input[type="text"]:focus { border-color: var(--green); }

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn-block { width: 100%; margin-top: 16px; }
.btn-primary { background: var(--green); color: #fff; }
.btn-secondary { background: var(--accent); color: #fff; }
.btn-close {
  background: none; border: none; font-size: 20px;
  color: var(--muted); cursor: pointer; padding: 4px 8px;
}

.error-msg { color: #c0392b; font-size: 13px; margin-top: 8px; min-height: 18px; }
.muted { color: var(--muted); font-size: 14px; }

/* ===== アプリヘッダー ===== */
.app-header {
  background: var(--green);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 14px;
  flex-shrink: 0;
}
.header-nick { font-weight: 600; font-size: 15px; }
.header-stamp { background: rgba(255,255,255,.18); border-radius: 20px; padding: 3px 10px; }

/* ===== タブコンテンツ ===== */
.tab-content { display: none; flex: 1; overflow-y: auto; padding: 16px 12px 80px; }
.tab-content.active { display: block; }
.section-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; color: var(--green); }

/* ===== スポットグリッド ===== */
.spots-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spot-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.spot-card img {
  width: 100%; height: 80px;
  object-fit: cover; display: block;
}
.spot-card-body { padding: 8px 10px 10px; }
.spot-card-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.spot-card-desc { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.3; }

/* スタンプ済みオーバーレイ */
.spot-card.stamped::after {
  content: "✔ 取得済";
  position: absolute;
  inset: 0;
  background: rgba(26,107,60,.72);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

/* ===== ランキング ===== */
.ranking-list { display: flex; flex-direction: column; gap: 8px; }
.ranking-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ranking-item.me { border: 2px solid var(--green); }
.rank-num { font-size: 20px; font-weight: 800; width: 32px; text-align: center; color: var(--muted); }
.rank-num.top1 { color: #d4a000; }
.rank-num.top2 { color: #9b9b9b; }
.rank-num.top3 { color: #a0632a; }
.rank-name { flex: 1; font-weight: 600; }
.rank-count { font-size: 18px; font-weight: 700; color: var(--green); }

/* ===== 投票エリア ===== */
.vote-timer {
  font-size: 22px; font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 16px;
}
.vote-candidates { display: flex; flex-direction: column; gap: 10px; }
.vote-candidate-btn {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.vote-candidate-btn.voted { border-color: var(--green); background: #e8f4ed; }
.vote-bar {
  height: 4px;
  background: var(--green-l);
  border-radius: 4px;
  margin-top: 6px;
  transition: width .4s;
}
.vote-result-list { display: flex; flex-direction: column; gap: 8px; }
.vote-result-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.vote-result-item.winner { border: 2px solid var(--accent); }

/* ===== ボトムナビ ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  height: 60px;
  z-index: 100;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  transition: color .15s;
}
.nav-btn.active { color: var(--green); }
.nav-icon { font-size: 22px; }
.scan-btn { position: relative; }
.scan-icon {
  background: var(--green);
  border-radius: 50%;
  width: 48px; height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-top: -16px;
  box-shadow: 0 2px 8px rgba(26,107,60,.4);
}

/* ===== モーダル ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  padding: 0 0 32px;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; }

/* QRリーダー */
#qr-reader { width: 100%; }
.scan-status { text-align: center; padding: 12px; }

/* スタンプ演出 */
.modal-box--stamp { text-align: center; padding: 40px 24px 36px; }
.stamp-animation {
  font-size: 72px;
  animation: stamp-bounce .5s ease;
  margin-bottom: 12px;
}
@keyframes stamp-bounce {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}
.modal-box--stamp h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.modal-box--stamp p  { color: var(--muted); margin-bottom: 24px; }
