/* ===========================
   ベース
   =========================== */

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

body {
  background-color: #f4f8f2;
  font-family: sans-serif;
  text-align: center;
  padding-bottom: 72px;
}

.container {
  max-width: 500px;
  margin: auto;
  padding: 20px 16px;
}

h1 {
  font-size: 22px;
  color: #2c3e50;
  margin-bottom: 16px;
}

/* ===========================
   ページ切り替え
   =========================== */

.page {
  display: none;
}

.page.active {
  display: block;
}

/* ===========================
   ステータスグリッド（2列）
   =========================== */

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 16px;
}

.status-card {
  background: white;
  border-radius: 12px;
  padding: 12px 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.status-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
}

.status-value {
  font-size: 28px;
  font-weight: bold;
  color: #2c3e50;
}

.gold   { color: #f1c40f !important; }
.boiled { color: #e67e22 !important; }

/* ===========================
   メッセージ
   =========================== */

#message, #qr-message {
  min-height: 1.5em;
  color: #555;
  font-size: 15px;
  margin: 8px 0;
}

#caterpillar {
  font-size: 24px;
  margin: 4px;
}

.warning-banner {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 14px;
  color: #856404;
}

/* ===========================
   ボタン
   =========================== */

button {
  display: block;
  width: 100%;
  max-width: 320px;
  font-size: 16px;
  padding: 13px;
  margin: 7px auto;
  background-color: #7c9a6d;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:active { background-color: #5e7a52; }

#boilButton { background-color: #c0392b; }
#boilButton:active { background-color: #922b21; }

.gold-btn { background-color: #d4a017; }
.gold-btn:active { background-color: #a87c10; }


/* ===========================
   森ページ
   =========================== */

.forest-display {
  font-size: 28px;
  letter-spacing: 4px;
  margin: 8px 0 4px;
  min-height: 2em;
}

#forestLevel {
  font-size: 16px;
  color: #555;
  margin-bottom: 4px;
}

#map {
  height: 420px;
  width: 100%;
  margin-top: 12px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  touch-action: manipulation;
}

/* ===========================
   金どんぐりショップ
   =========================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 16px;
  padding: 24px 20px;
  z-index: 1000;
  width: 92%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal h2 { color: #2c3e50; margin-bottom: 8px; }

.shop-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f8f9fa;
  border-radius: 10px;
  padding: 14px;
  margin: 10px 0;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}

.shop-item:hover { background: #e8f5e9; }
.shop-item p { margin: 4px 0 0; font-size: 13px; color: #666; }
.shop-icon { font-size: 32px; flex-shrink: 0; }

/* ===========================
   QRページ
   =========================== */

.qr-desc {
  color: #666;
  font-size: 15px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.qr-desc small {
  font-size: 12px;
  color: #999;
}

#scanner-wrap {
  width: 300px;
  height: 300px;
  margin: 0 auto 12px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===========================
   下部ナビゲーション
   =========================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: white;
  border-top: 1px solid #e0e0e0;
  display: flex;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  z-index: 800;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 8px 0;
  max-width: none;
  width: auto;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s;
}

.nav-btn.active {
  color: #5a8a4a;
  background: transparent;
}

.nav-btn:active {
  background: #f0f0f0;
}

.nav-icon { font-size: 24px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 500; }

.nav-btn.active::after {
  content: '';
  display: block;
  width: 32px;
  height: 3px;
  background: #5a8a4a;
  border-radius: 2px;
  margin-top: 2px;
}

/* ===========================
   お店管理ページ
   =========================== */

.shop-mgmt-desc {
  color: #666;
  font-size: 15px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.shop-mgmt-desc small {
  font-size: 12px;
  color: #999;
}

.add-shop-btn {
  background-color: #3d7a8a;
  margin-bottom: 16px;
}

.add-shop-btn:active { background-color: #2c5f6d; }

.shop-empty-msg {
  color: #aaa;
  font-size: 14px;
  line-height: 1.8;
  margin-top: 24px;
}

.shop-mgmt-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-radius: 12px;
  padding: 14px 12px;
  margin: 10px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  text-align: left;
}

.shop-mgmt-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.shop-mgmt-name {
  font-size: 15px;
  font-weight: bold;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-mgmt-id {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-visit-stats {
  font-size: 11px;
  color: #2c7a2c;
  font-weight: 600;
}

.shop-mgmt-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 10px;
}

.shop-action-btn {
  display: inline-block;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.qr-btn  { background-color: #5a8a4a; }
.qr-btn:active { background-color: #3e6435; }

.edit-btn { background-color: #e67e22; }
.edit-btn:active { background-color: #b55c10; }

.del-btn  { background-color: #c0392b; }
.del-btn:active { background-color: #922b21; }

/* ===========================
   お店追加フォーム
   =========================== */

.shop-form {
  text-align: left;
  margin: 12px 0;
}

.form-label {
  display: block;
  font-size: 13px;
  color: #555;
  margin: 10px 0 4px;
  font-weight: 600;
}

.form-label small {
  font-size: 11px;
  color: #999;
  font-weight: normal;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  color: #2c3e50;
  background: #fafafa;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #5a8a4a;
  background: white;
}

.form-input:disabled {
  background: #f0f0f0;
  color: #999;
}

.shop-form-msg {
  font-size: 13px;
  color: #c0392b;
  min-height: 1.4em;
  margin-top: 8px;
}

.cancel-btn { background-color: #95a5a6; }
.cancel-btn:active { background-color: #717d7e; }

/* ===========================
   QRコード表示モーダル
   =========================== */

.qr-canvas-wrap {
  display: flex;
  justify-content: center;
  margin: 16px auto;
}

.qr-canvas-wrap canvas,
.qr-canvas-wrap img {
  border-radius: 8px;
  border: 4px solid #f0f0f0;
}

.qr-shop-id-text {
  font-size: 13px;
  color: #888;
  margin: 4px 0;
  font-family: monospace;
}

.qr-countdown {
  font-size: 13px;
  color: #e67e22;
  font-weight: 600;
  margin: 4px 0 8px;
}

.qr-hint {
  font-size: 13px;
  color: #777;
  margin-bottom: 12px;
}

@media (min-width: 768px) {
  .bottom-nav {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
  }
}

/* ===========================
   認証・お店管理 追加スタイル
   =========================== */

.shop-owner-info {
  font-size: 13px;
  color: #555;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.logout-btn {
  background: none;
  border: 1px solid #c0392b;
  color: #c0392b;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
  margin: 0;
  width: auto;
  display: inline-block;
}

.logout-btn:hover {
  background: #c0392b;
  color: #fff;
}

.location-btn {
  background: #7c9a6d;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 4px;
}

.location-btn:hover {
  background: #5a8a4a;
}

/* ===========================
   位置情報同意モーダル
   =========================== */

.consent-text {
  font-size: 15px;
  color: #444;
  margin: 8px 0 12px;
  line-height: 1.6;
}

.consent-list {
  list-style: none;
  text-align: left;
  background: #f8f9fa;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 12px;
}

.consent-list li {
  font-size: 13px;
  color: #555;
  padding: 4px 0;
  line-height: 1.5;
}

.consent-note {
  font-size: 12px;
  color: #999;
  margin-bottom: 12px;
}

/* ===========================
   ボタン disabled 状態
   =========================== */

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===========================
   フッターリンク
   =========================== */

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.footer-sep {
  color: #ccc;
  font-size: 12px;
}

.text-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: unset;
  border-radius: 0;
  box-shadow: none;
}

.text-btn:hover {
  color: #555;
}

.text-btn.danger-text {
  color: #c0392b;
}

.text-btn.danger-text:hover {
  color: #922b21;
}
