@font-face {
  font-family: 'Special Elite';
  src: url('assets/fonts/SpecialElite.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --teal: #4a9d90;
  --teal-dark: #2f6e64;
  --red: #a3182b;
  --cream: #faf7f0;
  --paper: #ffffff;
  --ink: #2b2620;
  --ink-soft: #6b6357;
  --border: #d8d2c4;
  --shadow: 0 8px 24px rgba(43, 38, 32, 0.18);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 0.9rem 1rem 0.7rem;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-family: 'Special Elite', monospace;
  font-size: 1.3rem;
  margin: 0;
  color: var(--teal-dark);
  letter-spacing: 0.5px;
  flex: 1 1 auto;
}
.topbar h1 span { color: var(--red); }

.progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 220px;
}
.progress-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--teal-dark));
  transition: width 0.3s ease;
}
#progressLabel {
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.toggle-btn {
  border: none;
  background: var(--paper);
  color: var(--ink-soft);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.toggle-btn.active {
  background: var(--teal);
  color: white;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

.view { width: 100%; }
.view.hidden { display: none; }

.passport-scroll {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}
.passport-stage {
  position: relative;
  width: 100%;
  min-width: 760px;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.passport-image {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.hotspot {
  position: absolute;
  width: 9.5%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: none;
  background: rgba(74, 157, 144, 0);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.hotspot:hover,
.hotspot:focus-visible {
  background: rgba(74, 157, 144, 0.16);
  box-shadow: 0 0 0 2px var(--teal);
  outline: none;
}
.hotspot.stamped:hover,
.hotspot.stamped:focus-visible {
  background: rgba(163, 24, 43, 0.1);
  box-shadow: 0 0 0 2px var(--red);
}

.stamp-overlay {
  position: absolute;
  width: 16%;
  aspect-ratio: 420 / 200;
  transform: translate(-50%, -50%) rotate(var(--rot, -6deg));
  pointer-events: none;
  opacity: 0.97;
  mix-blend-mode: multiply;
}
.stamp-overlay img { width: 100%; height: 100%; display: block; }

.hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: 0.8rem 0 0;
  text-align: center;
}

/* List view */
.store-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.store-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  text-align: left;
}
.store-row .badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: transparent;
}
.store-row.stamped .badge {
  border-color: var(--red);
  color: var(--red);
  font-weight: bold;
}
.store-row .info { flex: 1; }
.store-row .name { font-weight: 600; }
.store-row .address { font-size: 0.8rem; color: var(--ink-soft); }

/* Timer view */
.countdown-card {
  width: 100%;
  max-width: 640px;
  margin: 0 auto 1rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.3rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.countdown-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.countdown-value {
  font-family: 'Special Elite', monospace;
  font-size: 2.6rem;
  color: var(--red);
  line-height: 1.2;
}
.countdown-sub {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 0.2rem;
}

.buffer-line {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.buffer-line.hidden { display: none; }
.buffer-line strong.ahead { color: var(--teal-dark); }
.buffer-line strong.behind { color: var(--red); }

.schedule-list {
  list-style: none;
  counter-reset: none;
  margin: 0 auto;
  padding: 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.schedule-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
}
.schedule-index {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.schedule-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.schedule-name { font-weight: 600; }
.schedule-times { font-size: 0.75rem; color: var(--ink-soft); }
.schedule-status {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.schedule-row.status-upcoming { border-left-color: var(--border); }
.schedule-row.status-upcoming .schedule-status { color: var(--ink-soft); }
.schedule-row.status-due { border-left-color: var(--teal); }
.schedule-row.status-due .schedule-status { color: var(--teal-dark); }
.schedule-row.status-done { border-left-color: var(--red); background: rgba(163, 24, 43, 0.05); }
.schedule-row.status-done .schedule-status { color: var(--red); }
.schedule-row.status-missed { border-left-color: var(--ink-soft); opacity: 0.6; }
.schedule-row.status-missed .schedule-status { color: var(--ink-soft); }

.footer {
  padding: 1rem;
  text-align: center;
}
.link-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Popup */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
@media (min-width: 640px) {
  .overlay { align-items: center; }
}

.popup {
  position: relative;
  background: var(--paper);
  width: 100%;
  max-width: 420px;
  border-radius: 16px 16px 0 0;
  padding: 1.5rem 1.25rem 1.25rem;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .popup { border-radius: 16px; }
}

.popup-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}

#popupName {
  font-family: 'Special Elite', monospace;
  color: var(--teal-dark);
  margin: 0 1.4rem 0.3rem 0;
  font-size: 1.15rem;
}
.popup-address {
  margin: 0 0 0.8rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.stamped-note {
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}
.stamped-note.hidden { display: none; }

.popup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.btn {
  display: block;
  text-align: center;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
}
.btn-secondary {
  background: var(--cream);
  color: var(--teal-dark);
  border: 1px solid var(--border);
}
.btn-primary {
  background: var(--red);
  color: white;
}
.btn-primary:disabled {
  background: var(--border);
  color: var(--ink-soft);
  cursor: default;
}
.unstamp-link {
  display: block;
  margin: 0.7rem auto 0;
}
.unstamp-link.hidden { display: none; }

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 200;
  box-shadow: var(--shadow);
}
.toast.hidden { display: none; }
