/* ===== Base ===== */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f7f3ed;
  color: #3a2f28;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 32px 20px 24px;
}

.seal {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
  border-radius: 6px;
  overflow: hidden;
  border: 6px solid #a52a2a;
  box-shadow: 0 4px 16px rgba(165, 42, 42, 0.25);
}

.seal::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid #a52a2a;
  border-radius: 2px;
  z-index: 3;
  pointer-events: none;
}

.seal-pattern {
  position: absolute;
  inset: 0;
  background-color: #fdfaf3;
}

.seal-pattern svg { width: 100%; height: 100%; display: block; }

.seal-kanji {
  position: absolute;
  inset: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  z-index: 2;
}

.seal-kanji span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Yuji Syuku", serif;
  font-weight: 400;
  font-size: 2.8rem;
  line-height: 1;
  color: #a52a2a;
  transform: scale(1.1, 1.15);
}

h1 {
  font-family: "Yuji Syuku", serif;
  font-size: 1.8rem;
  margin: 0 0 6px;
  color: #8b2323;
  letter-spacing: 0.08em;
  font-weight: 400;
}

.subtitle {
  color: #6b5d53;
  font-size: 0.9rem;
  margin: 0;
}

/* ===== Main ===== */
.app-main {
  flex: 1;
  padding: 0 20px 20px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.loading, .qr-loading {
  text-align: center;
  color: #999;
  padding: 40px 0;
}

.error-box {
  background: #fee;
  color: #c0392b;
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  margin: 20px;
}

/* ===== Auth Box ===== */
.auth-box {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #e8e0d5;
}

.tab {
  flex: 1;
  padding: 16px;
  background: #faf7f1;
  border: none;
  font-size: 1rem;
  color: #6b5d53;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.tab.active {
  background: white;
  color: #8b2323;
  font-weight: bold;
  border-bottom: 2px solid #8b2323;
}

.form-section { padding: 24px; }
.form-section.hidden { display: none; }

.form-section input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e0d5c7;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 12px;
  font-family: inherit;
  background: #fdfbf7;
}

.form-section input:focus {
  outline: none;
  border-color: #8b2323;
  background: white;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: #8b2323;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-primary:hover { background: #6e1b1b; }
.btn-primary:active { background: #5a1515; }

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: #6b5d53;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  margin-top: 10px;
}

.btn-secondary:hover { background: #f5f5f5; }

.message {
  padding: 0 24px 20px;
  font-size: 0.9rem;
  min-height: 20px;
  text-align: center;
}

.message.error { color: #c0392b; }
.message.success { color: #27ae60; }
.message.info { color: #6b5d53; }

/* ===== Main Screen ===== */
.main-screen {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 70vh;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #faf7f1;
  border-bottom: 1px solid #e8e0d5;
}

.user-icon-small { font-size: 1.5rem; }

.user-name {
  flex: 1;
  font-weight: bold;
  color: #3a2f28;
}

.btn-sound, .btn-logout-small {
  background: transparent;
  color: #999;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.btn-sound {
  padding: 6px 10px;
  font-size: 1rem;
}

.btn-logout-small {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-sound:hover, .btn-logout-small:hover { background: #f5f5f5; }

/* ===== Main Tabs (top) ===== */
.main-tabs {
  display: flex;
  border-bottom: 1px solid #e8e0d5;
  background: #faf7f1;
}

.main-tab {
  flex: 1;
  padding: 12px 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #888;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}

.main-tab.active {
  color: #8b2323;
  border-bottom-color: #8b2323;
  background: white;
}

.main-tab.active .tab-label { font-weight: bold; }

.tab-icon { font-size: 1.25rem; line-height: 1.1; }
.tab-label { font-size: 0.7rem; }

.tab-content {
  flex: 1;
  min-height: 400px;
  overflow-y: auto;
}

/* ===== Sub Tabs ===== */
.sub-tabs {
  display: flex;
  border-bottom: 1px solid #e8e0d5;
  padding: 0 12px;
  gap: 4px;
}

.sub-tab {
  flex: 1;
  padding: 12px 6px;
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.sub-tab.active {
  color: #8b2323;
  border-bottom-color: #8b2323;
  font-weight: bold;
}

/* ===== Map ===== */
#map-container { width: 100%; height: 500px; }

.shop-marker-inner {
  width: 40px;
  height: 40px;
  background: #a52a2a;
  color: white;
  border: 3px solid white;
  border-radius: 50% 50% 50% 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  font-family: "Yuji Syuku", serif;
  cursor: pointer;
}

.shop-marker-inner.acquired {
  background: #27ae60;
  font-family: -apple-system, sans-serif;
  font-size: 1.3rem;
}

/* ===== Shop List ===== */
.shop-list { padding: 16px; }

.shop-card {
  background: #fdfbf7;
  border: 1px solid #e8e0d5;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  gap: 12px;
}

.shop-card:hover {
  background: white;
  border-color: #a52a2a;
  transform: translateY(-1px);
}

.shop-card.acquired {
  background: #f0fff4;
  border-color: #27ae60;
}

.shop-card.acquired:hover {
  background: white;
  border-color: #27ae60;
}

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

.shop-card-main h3 {
  margin: 0 0 8px;
  color: #8b2323;
  font-size: 1.1rem;
}

.shop-card.acquired .shop-card-main h3 { color: #27ae60; }

.shop-desc {
  color: #6b5d53;
  font-size: 0.9rem;
  margin: 0 0 12px;
  line-height: 1.5;
}

.shop-meta {
  font-size: 0.85rem;
  color: #6b5d53;
  margin: 4px 0;
}

.shop-card-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.quick-link {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: white;
  border: 1px solid #e0d5c7;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-link:hover {
  background: #fef0ea;
  border-color: #a52a2a;
  transform: scale(1.05);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  grid-column: 1 / -1;
  width: 100%;
  line-height: 1.6;
}

/* ===== Collection ===== */
.collection-screen { padding: 0; display: flex; flex-direction: column; }

.collection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}

.collection-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: background 0.15s;
  min-width: 0;
}

.collection-item:hover { background: #fdfbf7; }

.mini-seal {
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 5px solid #a52a2a;
  background: #fdfaf3;
}

.mini-seal::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1.5px solid #a52a2a;
  border-radius: 2px;
  pointer-events: none;
}

.mini-seal-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Yuji Syuku", serif;
  font-size: 3rem;
  color: #a52a2a;
  font-weight: bold;
}

.collection-item.not-acquired .mini-seal {
  filter: grayscale(100%) opacity(0.3);
}

.collection-item.not-acquired .mini-seal-inner { color: #999; }

.collection-item-name {
  font-size: 0.9rem;
  margin: 0;
  text-align: center;
  color: #3a2f28;
  line-height: 1.3;
  word-break: break-word;
  font-weight: bold;
}

.collection-item.not-acquired .collection-item-name { color: #999; font-weight: normal; }

/* ===== Ranking ===== */
.ranking-screen { padding: 24px 20px; text-align: center; }

.ranking-screen h2 {
  color: #8b2323;
  margin: 0 0 20px;
  font-size: 1.3rem;
}

.stat-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fdfbf7;
  border: 1px solid #e8e0d5;
  border-radius: 10px;
  padding: 14px 8px;
}

.stat-value {
  font-size: 1.6rem;
  color: #8b2323;
  font-weight: bold;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  color: #6b5d53;
  margin-top: 4px;
}

.ranking-note { color: #999; font-size: 0.9rem; margin-top: 20px; }

/* ===== Shop Page ===== */
.shop-page { padding: 16px; }

.btn-back {
  background: transparent;
  border: none;
  color: #8b2323;
  font-size: 1rem;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 12px;
  font-family: inherit;
}

.btn-back:hover { text-decoration: underline; }

.shop-header h2 {
  color: #8b2323;
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.shop-page-desc {
  color: #6b5d53;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 16px;
}

.shop-info {
  background: #fdfbf7;
  border: 1px solid #e8e0d5;
  border-radius: 10px;
  padding: 8px 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 0;
  font-size: 0.9rem;
  color: #3a2f28;
  text-decoration: none;
  border-bottom: 1px solid #efe6d8;
}

.info-row:last-child { border-bottom: none; }
.info-row.info-link { color: #3a2f28; cursor: pointer; transition: background 0.15s; }
.info-row.info-link:hover { background: #fef0ea; }

.info-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.info-text { flex: 1; word-break: break-word; }

.info-action {
  font-size: 0.8rem;
  color: #a52a2a;
  flex-shrink: 0;
  font-weight: bold;
}

.shop-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-item {
  background: #fef0ea;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.stat-item-label {
  display: block;
  font-size: 0.75rem;
  color: #6b5d53;
  margin-bottom: 4px;
}

.stat-item-value {
  display: block;
  font-size: 1.2rem;
  color: #8b2323;
  font-weight: bold;
}

.shop-goshuin-section {
  background: #fdfbf7;
  border: 1px solid #e8e0d5;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}

.section-title {
  color: #8b2323;
  font-weight: bold;
  margin: 0 0 16px;
  font-size: 1rem;
}

.qr-wrapper {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

#qrcode-box {
  padding: 12px;
  background: white;
  border-radius: 12px;
  border: 2px solid #a52a2a;
  display: inline-block;
}

#qrcode-box img { display: block; }

.qr-hint {
  font-size: 0.9rem;
  color: #3a2f28;
  margin: 8px 0 12px;
  font-weight: bold;
}

.qr-hint-small {
  font-size: 0.75rem;
  color: #aaa;
  margin: 8px 0 0;
}

.acquired-seal {
  margin: 0 auto 16px;
  max-width: 200px;
}

.large-seal {
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.large-seal .mini-seal-inner { font-size: 5rem; }

/* ===== 押印演出 ===== */
.goshuin-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
  cursor: pointer;
  padding: 20px;
}

.goshuin-overlay.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

.goshuin-stamp-container {
  text-align: center;
  animation: stampDrop 0.8s cubic-bezier(0.5, 0, 0.2, 1.5);
}

.goshuin-stamp {
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
}

.huge-seal {
  width: 250px;
  height: 250px;
  margin: 0 auto;
  box-shadow: 0 0 60px rgba(165, 42, 42, 0.6);
}

.huge-seal .mini-seal-inner { font-size: 6rem; }

.goshuin-message h2 {
  color: white;
  font-family: "Yuji Syuku", serif;
  font-size: 2rem;
  margin: 0 0 12px;
  font-weight: 400;
}

.goshuin-shop-name {
  color: #fdfaf3;
  font-size: 1.2rem;
  margin: 0 0 12px;
}

.goshuin-points {
  color: #fdde5a;
  font-size: 1.8rem;
  font-weight: bold;
  margin: 0;
}

.first-badge {
  display: inline-block;
  background: #e8593c;
  color: white;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.85rem;
  margin-left: 10px;
  font-weight: normal;
  vertical-align: middle;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes stampDrop {
  0% {
    transform: scale(3) rotate(-15deg);
    opacity: 0;
  }
  60% {
    transform: scale(0.9) rotate(3deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 20px;
  color: #aaa;
  font-size: 0.85rem;
}

.app-footer p { margin: 0; }
