/* --- Theme tokens --- */
:root,
html[data-theme="dark"] {
  --ink: #16241c;
  --ink-soft: #1e3227;
  --paper: #f4efe2;
  --sage: #7c9184;
  --brick: #b1472f;
  --brick-dark: #8f371f;
  --brass: #c9a227;
  --correct: #5fae72;

  --bg: var(--ink);
  --surface: var(--ink-soft);
  --text: var(--paper);
  --text-soft: var(--sage);
  --border: var(--sage);
  --border-strong: var(--sage);
  --radius: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  --overlay-scrim: rgba(0, 0, 0, 0.55);
}

html[data-theme="light"] {
  --paper: #f4efe2;
  --paper-dim: #e4dcc4;
  --ink: #16241c;
  --sage-dark: #4d5f52;
  --brick: #b1472f;
  --brick-dark: #8f371f;
  --brass: #9c7d1d;
  --correct: #3f7a4e;

  --bg: var(--paper);
  --surface: var(--paper-dim);
  --text: var(--ink);
  --text-soft: var(--sage-dark);
  --border: var(--sage-dark);
  --border-strong: var(--sage-dark);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --overlay-scrim: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Work Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.wrap {
  width: 100%;
  max-width: 440px;
  padding: 20px 18px 32px;
}

/* --- Top bar --- */
.top-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { border-color: var(--brass); color: var(--brass); }
.icon-btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.icon-btn svg { width: 18px; height: 18px; display: block; }

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--brass);
}

.wordmark {
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1;
}

.wordmark span { color: var(--brass); }

.tagline {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-soft);
}

.stats {
  display: flex;
  gap: 18px;
  text-align: right;
}

.stat-label {
  font-size: 10px;
  color: var(--text-soft);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-family: 'Zilla Slab', serif;
  font-weight: 600;
  font-size: 19px;
  color: var(--text);
}

#stat-streak { color: var(--brass); }

/* --- Mode toggle --- */
.mode-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.mode-btn {
  flex: 1;
  padding: 9px 0;
  background: transparent;
  color: var(--text-soft);
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-btn.active {
  background: var(--brass);
  color: #ffffff;
}

.mode-btn:not(.active):hover { color: var(--text); }

/* --- Carousel --- */
.carousel-shell {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.swiper { width: 100%; height: 280px; }
.swiper-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }

.swiper-slide.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  font-size: 13px;
}

.swiper-button-next, .swiper-button-prev {
  width: 32px !important;
  height: 32px !important;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: #ffffff !important;
}
.swiper-button-next::after, .swiper-button-prev::after {
  font-size: 13px !important;
  font-weight: 700;
}

/* Rightmove-style image count badge */
.photo-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
  letter-spacing: 0.02em;
}

.photo-badge svg { width: 13px; height: 13px; display: block; }

.badge-segment {
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.badge-segment.video-segment {
  pointer-events: auto;
  cursor: pointer;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  padding-left: 8px;
}

.sold-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
  border: 4px solid var(--brick);
  color: var(--brick);
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 34px;
  letter-spacing: 0.08em;
  padding: 4px 18px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
html[data-theme="dark"] .sold-stamp { background: rgba(18, 20, 22, 0.92); }
.sold-stamp.show { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }

/* --- Video overlay --- */
.video-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: #000;
}
.video-overlay iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.video-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 31;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  cursor: pointer;
}
.video-close-btn svg { width: 14px; height: 14px; }

/* --- Media & Badge Icons --- */
.media-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}
.media-icon {
  width: 15px;
  height: 15px;
  display: block;
  flex-shrink: 0;
}
.youtube-icon { color: #ff4d4d; }
.tiktok-icon { color: #20d5ec; }

/* --- Area location card --- */
.area-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, background-color 0.2s ease;
}
.area-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brass) 16%, transparent);
  color: var(--brass);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.area-icon svg { width: 18px; height: 18px; display: block; }
.area-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.area-label {
  font-size: 10px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 2px;
}
.area-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Spec cards grid --- */
.specs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.spec-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 6px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.2s ease;
}
.spec-card:hover {
  border-color: var(--brass);
  transform: translateY(-1px);
}

.spec-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brass);
  margin-bottom: 6px;
}
.spec-icon svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: currentColor;
}

.spec-details {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.spec-label {
  font-size: 10px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 2px;
}
.spec-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* --- Guess history --- */
#guess-history { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.ticket {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
}
.ticket.correct { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 12%, transparent); color: var(--correct); }
.ticket.wrong { border-color: var(--brick); background: color-mix(in srgb, var(--brick) 10%, transparent); color: var(--brick); }
.ticket .amount { color: var(--text); }

.reveal-banner {
  text-align: center;
  padding: 12px;
  border: 1px solid var(--brick);
  border-radius: var(--radius);
  color: var(--brick);
  font-weight: 700;
  font-size: 13px;
  background: color-mix(in srgb, var(--brick) 10%, transparent);
}

/* --- Form / actions --- */
form { display: flex; gap: 8px; }

.price-field {
  position: relative;
  flex: 1;
}
.price-field span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  font-weight: 700;
}
.price-field input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 12px 12px 26px;
  box-shadow: var(--shadow);
}
.price-field input:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  border-color: transparent;
}
.price-field input::placeholder { color: var(--text-soft); font-weight: 500; }

button.primary {
  background: var(--brick);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 0 22px;
  cursor: pointer;
  transition: background 0.15s ease;
  box-shadow: var(--shadow);
}
button.primary:hover { background: var(--brick-dark); }
button.primary:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.completion { display: flex; flex-direction: column; gap: 8px; }

/* --- Daily Notice --- */
.daily-notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  background: color-mix(in srgb, var(--brass) 12%, var(--surface));
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.daily-notice-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.daily-notice-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.daily-notice-title {
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.daily-notice-text {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.45;
}
button.accent-btn {
  background: var(--brass);
  color: #ffffff;
  border: none;
  font-weight: 700;
  margin-top: 4px;
  padding: 10px 14px;
  text-align: center;
  border-radius: var(--radius);
}
button.accent-btn:hover {
  filter: brightness(0.92);
}

button.secondary {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
button.secondary:hover { border-color: var(--brass); }
button.secondary:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

button.share { background: var(--brass); color: #ffffff; border: none; }
button.share:hover { filter: brightness(0.92); }

button.danger {
  background: transparent;
  border: 1px solid var(--brick);
  color: var(--brick);
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  padding: 10px;
  cursor: pointer;
}
button.danger:hover { background: color-mix(in srgb, var(--brick) 10%, transparent); }

.hidden { display: none !important; }

/* --- Modals --- */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-title {
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  margin: 0 0 4px;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-soft);
  margin: 0 0 16px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.modal-field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
}

.modal-field input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
}

.modal-field .readonly-value {
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--brass);
}

.modal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions.inline { flex-direction: row; }
.modal-actions.inline > * { flex: 1; }

.tab-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.tab-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
}
.tab-btn.active { background: var(--brass); color: #ffffff; border-color: var(--brass); }

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.leaderboard-row .rank { color: var(--brass); font-weight: 700; width: 22px; }
.leaderboard-row .who { flex: 1; color: var(--text); font-weight: 600; }
.leaderboard-row .score { color: var(--brass); font-weight: 700; }

.leaderboard-empty {
  text-align: center;
  color: var(--text-soft);
  font-size: 12px;
  padding: 20px 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
