:root {
  --surface: rgba(255, 255, 255, 0.94);
  --surface-border: rgba(15, 23, 42, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --heart-red: #ef4444;
  --shadow-lg: 0 12px 30px -4px rgba(0, 0, 0, 0.18), 0 4px 10px -2px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #0f172a;
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

/* Street View Frame below the top bar; clips the bottom-right zoom buttons */
.streetview-frame-wrapper {
  position: fixed;
  top: 58px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: calc(100vh - 58px);
  height: calc(100dvh - 58px);
  overflow: hidden;
  z-index: 1;
  background: #0f172a;
}

#streetViewFrame {
  width: 100%;
  height: calc(100% + 104px);
  border: none;
  display: block;
}

/* Subtle Loading Pill */
.panorama-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  background: rgba(15, 23, 42, 0.86);
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.25s ease;
}

.panorama-loader.loaded {
  opacity: 0;
}

.loader-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Fallback Overlay */
.embed-fallback {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.fallback-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 22px;
  padding: 28px 26px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.fallback-pano-preview {
  position: relative;
  width: 100%;
  height: 120px;
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #1e3a8a 0%, #0f172a 75%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.fallback-pano-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.16) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(circle at center, black 45%, transparent 100%);
  -webkit-mask-image: radial-gradient(circle at center, black 45%, transparent 100%);
}

.fallback-icon {
  position: relative;
  font-size: 2.2rem;
  line-height: 1;
}

.fallback-badge {
  position: relative;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fde047;
  background: rgba(15, 23, 42, 0.7);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(253, 224, 71, 0.35);
}

.fallback-card h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}

.fallback-card p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #475569;
}

.fallback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

/* Duh! Games! Home Pill */
.ww-home-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  padding: 6px 13px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  color: #0f172a;
  transition: all 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.ww-home-pill:hover {
  background: #ffffff;
  transform: translateY(-1px);
  color: #0f172a;
}

.ww-home-pill .ww-logo-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex-shrink: 0;
  display: block;
}

.ww-home-pill .ww-text-full {
  display: inline;
}

.ww-home-pill .ww-text-short {
  display: none;
}

/* Top Nav Bar */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 58px;
  z-index: 20;
  padding: 0 18px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: auto;
}

.brand-logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-wordmark {
  display: block;
  height: 38px;
  width: auto;
}

/* Action Buttons */
.btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
  pointer-events: auto;
}

.btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn:active {
  transform: scale(0.96);
}

.btn-random {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 800;
  padding: 9px 18px;
  font-size: 0.88rem;
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.55), 0 6px 16px rgba(37, 99, 235, 0.35);
  animation: pulseRandom 2.2s ease-in-out infinite;
}

@keyframes pulseRandom {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.55), 0 6px 16px rgba(37, 99, 235, 0.35);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 10px rgba(37, 99, 235, 0), 0 8px 20px rgba(37, 99, 235, 0.45);
  }
}

.btn-random:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #64748b;
}

.btn-link-subtle {
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-link-subtle:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Floating Right-Side Vertical Tab Sidebar */
.right-sidebar {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-right: none;
  border-radius: 14px 0 0 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.sidebar-tab {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding: 12px 10px;
  min-width: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: #334155;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-tab:last-child {
  border-bottom: none;
}

.sidebar-tab:hover {
  background: rgba(15, 23, 42, 0.05);
}

.sidebar-tab.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
}

.sidebar-icon {
  display: block;
}

.heart-icon {
  fill: none;
  stroke: var(--heart-red);
  transition: transform 0.15s ease, fill 0.15s ease;
}

.saved-drawer-header h2 .heart-icon { display: inline-block; margin-inline-end: .4em; vertical-align: -.15em; }

.sidebar-tab.liked .heart-icon {
  fill: var(--heart-red);
  transform: scale(1.1);
}

.sidebar-tab.liked .sidebar-label {
  color: var(--heart-red);
}

.sidebar-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Saved / Likes Drawer */
.saved-drawer {
  position: fixed;
  right: 68px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 26;
  width: 290px;
  max-height: 380px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.saved-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.saved-drawer-header h2 {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
}

.saved-close-btn {
  background: none;
  border: none;
  font-size: 1rem;
  color: #64748b;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.saved-close-btn:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-main);
}

.saved-drawer-list {
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.saved-empty {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.45;
  padding: 16px 10px;
  text-align: center;
}

.saved-item-btn {
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.saved-item-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.saved-item-btn.current {
  border-color: var(--primary);
  background: #eff6ff;
}

.saved-item-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.saved-item-country {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
}

/* Bottom HUD Container (non-blocking wrapper for Location Card + Guessing Bar) */
.bottom-hud {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

/* Floating Bottom-Left Location Card & Info Popover */
.bottom-card-wrap {
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
  flex-shrink: 1;
}

.info-popover {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.bottom-card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.info-circle-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #94a3b8;
  background: transparent;
  color: #475569;
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all 0.15s ease;
}

.info-circle-btn:hover,
.info-circle-btn[aria-expanded="true"] {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.card-country-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
}

.red-pin-icon {
  flex-shrink: 0;
  display: block;
}

.card-desc {
  font-size: 0.84rem;
  color: #334155;
  line-height: 1.48;
  user-select: text;
  -webkit-user-select: text;
}

.card-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.card-link:hover {
  text-decoration: underline;
}

.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Non-intrusive Guessing Bar */
.guess-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: 450px;
  width: 100%;
  pointer-events: auto;
  flex-shrink: 0;
}

.guess-bar {
  width: 100%;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 5px 6px 5px 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.guess-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 6px 4px;
  user-select: text;
  -webkit-user-select: text;
}

.guess-input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}

.guess-submit-btn {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.12s ease;
}

.guess-submit-btn:hover {
  background: var(--primary-hover);
}

.guess-submit-btn:active {
  transform: scale(0.96);
}

.guess-result-card {
  width: 100%;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 13px 15px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guess-result-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guess-score-badge {
  background: #dcfce7;
  color: #166534;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.guess-score-badge.partial {
  background: #fef9c3;
  color: #854d0e;
}

.guess-score-badge.miss {
  background: #f1f5f9;
  color: #475569;
}

.guess-tier-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-main);
  flex: 1;
}

.guess-reveal-loc {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--primary);
}

.guess-story-text {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #334155;
  user-select: text;
  -webkit-user-select: text;
}

.guess-result-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

.btn-next-wonder {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
  padding: 6px 13px;
  font-size: 0.78rem;
}

.btn-next-wonder:hover {
  background: #1e293b;
  border-color: #1e293b;
}

/* Toast Message */
.toast-msg {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.toast-msg.show {
  opacity: 1;
}

/* Responsive */
@media (max-width: 860px) {
  .bottom-hud {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    right: 70px;
  }

  .bottom-card-wrap {
    max-width: 100%;
  }

  .guess-bar-wrap {
    max-width: 100%;
    align-items: stretch;
  }
}

@media (max-width: 720px) {
  .brand-wordmark {
    height: 30px;
  }
}

@media (max-width: 600px) {
  .top-nav {
    height: 52px;
    padding: 0 12px;
  }

  .streetview-frame-wrapper {
    top: 52px;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
  }

  .right-sidebar {
    top: 40%;
  }

  .brand-logo {
    display: none;
  }

  .ww-home-pill {
    padding: 5px 9px 5px 5px;
    gap: 6px;
    font-size: 12px;
  }

  .ww-home-pill .ww-text-full {
    display: none;
  }

  .ww-home-pill .ww-text-short {
    display: inline;
  }

  .btn-random {
    padding: 7px 14px;
    font-size: 0.82rem;
  }

  .bottom-hud {
    bottom: 12px;
    left: 12px;
    right: 68px;
    gap: 8px;
  }

  .bottom-card {
    padding: 10px 12px;
  }

  .card-title {
    font-size: 0.96rem;
  }

  .card-desc {
    font-size: 0.8rem;
  }

  .guess-input {
    font-size: 0.82rem;
  }

  .saved-drawer {
    right: 62px;
    width: calc(100vw - 76px);
    max-width: 290px;
  }
}
