:root {
  --paper: #f7efdd;
  --paper-2: #efe2cb;
  --ink: #3e2c22;
  --ink-soft: #6e5a4a;
  --red: #970f0f;
  --red-2: #790000;
  --gold: #ffbc5c;
  --gold-soft: #ffd79e;
  --jade: #2f7b5a;
  --card: #fff8ea;
  --border: rgba(130, 88, 48, 0.24);
  --shadow: 0 10px 30px rgba(76, 40, 25, 0.12);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --tab-height: 76px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 15% 8%, rgba(255, 188, 92, 0.28), transparent 38%),
    radial-gradient(circle at 88% 2%, rgba(151, 15, 15, 0.2), transparent 36%),
    linear-gradient(170deg, var(--paper) 0%, var(--paper-2) 100%);
  color: var(--ink);
  font-family:
    "Microsoft JhengHei",
    "Microsoft JhengHei UI",
    "PingFang TC",
    "PingFang SC",
    "Hiragino Sans GB",
    "Noto Sans TC",
    "Noto Sans SC",
    sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  font-family:
    "Songti TC",
    "STSong",
    "Noto Serif TC",
    "Noto Serif SC",
    serif;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(100%, 420px);
  min-height: 100dvh;
  margin: 0 auto;
  background:
    linear-gradient(120deg, rgba(255, 248, 235, 0.68) 0%, rgba(248, 234, 205, 0.75) 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
}

.main-content {
  padding: 14px 14px calc(var(--tab-height) + env(safe-area-inset-bottom) + 18px);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.hero {
  position: relative;
  overflow: hidden;
  margin: 14px;
  margin-bottom: 4px;
  padding: 18px 16px;
  background:
    linear-gradient(160deg, rgba(151, 15, 15, 0.96), rgba(121, 0, 0, 0.98)),
    radial-gradient(circle at 20% 0%, rgba(255, 188, 92, 0.36), transparent 40%);
  color: #fff8e9;
  border: 1px solid rgba(255, 188, 92, 0.35);
}

.hero-glow {
  position: absolute;
  inset: -25% auto auto -20%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 235, 201, 0.95), rgba(255, 188, 92, 0.45) 32%, rgba(255, 188, 92, 0.08) 70%, transparent 80%);
  opacity: 0.42;
  pointer-events: none;
  animation: hero-glow-pulse 3s ease-in-out infinite;
}

@keyframes hero-glow-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.28;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.5;
  }
  100% {
    transform: scale(0.9);
    opacity: 0.28;
  }
}

.hero-content {
  position: relative;
  z-index: 1;
}

.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-logo {
  width: 168px;
  max-width: 62%;
  height: auto;
}

.brand-mark {
  width: 62px;
  height: auto;
  opacity: 0.95;
}

.eyebrow {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #f9ddb5;
  text-transform: uppercase;
}

h1 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.25;
}

.hero-subtitle {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: #fbead2;
}

.hero-subtitle span,
.helper-text span,
.tab-btn span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: inherit;
  opacity: 0.84;
}

.hero-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-pill {
  background: rgba(255, 239, 211, 0.12);
  border: 1px solid rgba(255, 215, 159, 0.25);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  padding: 8px 12px;
  text-align: center;
}

.stat-pill strong {
  display: block;
  margin-top: 4px;
  color: #ffe2a3;
  font-size: 18px;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

h2 {
  font-size: 18px;
  color: var(--red);
}

.helper-text {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

.progress-wrap {
  margin-top: 14px;
}

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #f0e4cf;
  border: 1px solid rgba(255, 188, 92, 0.34);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red-2), var(--gold));
  transition: width 320ms ease;
}

.brand-icon-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.brand-icon-grid img {
  width: 100%;
  background: #fffdf7;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.progress-label {
  margin-top: 8px;
  text-align: right;
  font-weight: 700;
  color: var(--ink);
}

.tier-list,
.location-list,
.route-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.route-list {
  list-style: decimal;
  padding-left: 20px;
  gap: 8px;
}

.route-list li {
  color: var(--ink);
  line-height: 1.45;
  font-size: 14px;
}

.tier-item,
.location-item {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fffdf7;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.tier-copy,
.location-copy {
  min-width: 0;
}

.tier-copy strong,
.location-copy strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.tier-copy span,
.location-copy span {
  display: block;
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-height: 30px;
  min-width: 68px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  background: #f2e6cf;
  color: #6f5531;
  border: 1px solid rgba(181, 142, 75, 0.32);
}

.badge.unlocked {
  background: rgba(47, 123, 90, 0.1);
  color: var(--jade);
  border-color: rgba(47, 123, 90, 0.4);
}

.badge.collected {
  background: rgba(47, 123, 90, 0.1);
  color: var(--jade);
  border-color: rgba(47, 123, 90, 0.4);
}

.badge.locked {
  background: rgba(176, 52, 45, 0.08);
  color: #a9492f;
  border-color: rgba(176, 52, 45, 0.28);
}

.scan-card {
  position: relative;
}

.camera-frame {
  margin-top: 12px;
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(112, 72, 41, 0.3);
  background: #2c1e16;
  aspect-ratio: 3 / 4;
}

.scan-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}

.scan-corners {
  width: 66%;
  height: 48%;
  border: 2px solid rgba(255, 222, 145, 0.7);
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 246, 225, 0.4);
}

.scan-line {
  position: absolute;
  width: 62%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #f9d273, transparent);
  animation: scan-line 2s ease-in-out infinite;
}

@keyframes scan-line {
  0% {
    transform: translateY(-42px);
    opacity: 0.3;
  }
  50% {
    transform: translateY(42px);
    opacity: 1;
  }
  100% {
    transform: translateY(-42px);
    opacity: 0.3;
  }
}

.scan-status {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  min-height: 18px;
}

.button-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn:focus-visible {
  outline: 3px solid rgba(219, 173, 86, 0.6);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(120deg, var(--red-2), var(--red));
  color: #fff7e6;
  box-shadow: 0 6px 14px rgba(121, 0, 0, 0.3);
}

.btn-outline {
  color: var(--red);
  border: 1px solid rgba(141, 31, 31, 0.34);
  background: rgba(255, 250, 243, 0.9);
}

.btn.full {
  width: 100%;
  margin-top: 12px;
}

.tab-panel {
  animation: fade-in 260ms ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(100%, 420px);
  height: calc(var(--tab-height) + env(safe-area-inset-bottom));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: linear-gradient(180deg, rgba(255, 249, 240, 0.92), rgba(243, 227, 198, 0.97));
  border-top: 1px solid rgba(128, 89, 56, 0.25);
  z-index: 20;
  backdrop-filter: blur(6px);
}

.tab-btn {
  min-height: 52px;
  border: 1px solid rgba(126, 87, 53, 0.2);
  border-radius: 14px;
  background: rgba(255, 252, 245, 0.8);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.tab-btn.active {
  background: rgba(255, 215, 158, 0.72);
  color: var(--red);
  border-color: rgba(255, 188, 92, 0.56);
}

.tab-btn-scan {
  background: linear-gradient(130deg, rgba(151, 15, 15, 0.18), rgba(255, 188, 92, 0.33));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(42, 22, 17, 0.5);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: min(100%, 360px);
  background: #fff9ee;
  border: 1px solid rgba(141, 31, 31, 0.18);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(42, 18, 15, 0.28);
}

.modal-emblem {
  width: 108px;
  height: 108px;
  margin: 0 auto 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 38px;
  font-weight: 800;
  font-family:
    "Songti TC",
    "STSong",
    "Noto Serif TC",
    "Noto Serif SC",
    serif;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 10px 24px rgba(80, 32, 20, 0.16);
  animation: emblem-float 2.2s ease-in-out infinite;
}

.modal-emblem.large {
  width: 140px;
  height: 140px;
  font-size: 50px;
}

.modal-emblem-info {
  color: #fff6e6;
  background: radial-gradient(circle at 30% 20%, #ffcf84 0%, #ffbc5c 36%, #970f0f 100%);
}

.modal-emblem-success {
  color: #fff8e9;
  background: radial-gradient(circle at 30% 20%, #ffd79e 0%, #ffbc5c 40%, #790000 100%);
}

@keyframes emblem-float {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.03);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.modal-card h3 {
  text-align: center;
  color: var(--red);
  font-size: 20px;
}

.modal-card p {
  margin-top: 10px;
  color: var(--ink);
  line-height: 1.5;
  text-align: center;
  font-size: 14px;
}

.success-location {
  font-weight: 700;
}

.success-blessing {
  color: var(--ink-soft);
}

@media (min-width: 421px) {
  .app-shell {
    box-shadow: 0 14px 36px rgba(52, 29, 21, 0.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
