:root {
  --hiq-safe-top: 0px;
  --hiq-safe-right: 0px;
  --hiq-safe-bottom: 0px;
  --hiq-safe-left: 0px;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: #FFF2F8;
  font-family: 'Trebuchet MS', 'Nunito', 'Rounded Mplus 1c', sans-serif;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hiq-safe-probe {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  visibility: hidden;
  pointer-events: none;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  padding-top: max(var(--hiq-safe-top), env(safe-area-inset-top, 0px));
  padding-right: max(var(--hiq-safe-right), env(safe-area-inset-right, 0px));
  padding-bottom: max(var(--hiq-safe-bottom), env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--hiq-safe-left), env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 42%, #FFF7FB 0%, #FFE2F1 55%, #F2DBFF 100%);
  z-index: 9999;
  transition: opacity 0.45s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.hiq-orphan-banner {
  position: fixed;
  left: max(12px, max(var(--hiq-safe-left), env(safe-area-inset-left, 0px)));
  right: max(12px, max(var(--hiq-safe-right), env(safe-area-inset-right, 0px)));
  bottom: max(12px, max(var(--hiq-safe-bottom), env(safe-area-inset-bottom, 0px)));
  margin: 0 auto;
  max-width: 520px;
  box-sizing: border-box;
  padding: 8px 12px 8px 16px;
  border-radius: 28px;
  border: 2px solid #FFB6D9;
  background: rgba(255, 250, 253, 0.96);
  box-shadow: 0 8px 24px rgba(176, 84, 138, 0.22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #6B3258;
  font-size: 14px;
  font-weight: 700;
  z-index: 9500;
}

.hiq-orphan-banner.hidden,
.hiq-fallback-overlay.hidden {
  display: none !important;
}

.hiq-orphan-text {
  flex: 1 1 auto;
}

.hiq-orphan-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 22px;
  background: linear-gradient(135deg, #FF73B9 0%, #B880FF 100%);
  color: #FFFFFF;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
  touch-action: manipulation;
}

.hiq-orphan-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 2px solid #FFD6EA;
  border-radius: 50%;
  background: #FFF2F8;
  color: #88446E;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.hiq-fallback-overlay {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  padding-top: max(16px, max(var(--hiq-safe-top), env(safe-area-inset-top, 0px)));
  padding-right: max(16px, max(var(--hiq-safe-right), env(safe-area-inset-right, 0px)));
  padding-bottom: max(16px, max(var(--hiq-safe-bottom), env(safe-area-inset-bottom, 0px)));
  padding-left: max(16px, max(var(--hiq-safe-left), env(safe-area-inset-left, 0px)));
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 42%, #FFF7FB 0%, #FFE2F1 55%, #F2DBFF 100%);
  z-index: 9998;
}

.hiq-fallback-card {
  width: min(420px, 100%);
  box-sizing: border-box;
  padding: 28px 24px;
  border-radius: 28px;
  border: 3px solid #FFB6D9;
  background: #FFFBFD;
  box-shadow: 0 14px 36px rgba(176, 84, 138, 0.22);
  text-align: center;
  color: #6B3258;
}

.hiq-fallback-star {
  font-size: 46px;
  color: #FF82BF;
  line-height: 1;
  margin-bottom: 10px;
}

.hiq-fallback-title {
  margin: 0 0 10px;
  font-size: 24px;
  color: #7D2D60;
}

.hiq-fallback-desc {
  margin: 0 0 22px;
  font-size: 15px;
  line-height: 1.45;
  color: #7A4B69;
}

.hiq-fallback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.hiq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.hiq-btn-primary {
  border: 0;
  background: linear-gradient(135deg, #FF73B9 0%, #B880FF 100%);
  color: #FFFFFF;
}

.hiq-btn-secondary {
  border: 2px solid #FFB6D9;
  background: #FFF2F8;
  color: #7D2D60;
}

html[data-capacitor-native="true"] #hiq-orphan-banner,
html[data-capacitor-native="true"] #qa-deck {
  display: none !important;
}

.pw-companion-modal {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  padding-top: max(16px, max(var(--hiq-safe-top), env(safe-area-inset-top, 0px)));
  padding-right: max(16px, max(var(--hiq-safe-right), env(safe-area-inset-right, 0px)));
  padding-bottom: max(16px, max(var(--hiq-safe-bottom), env(safe-area-inset-bottom, 0px)));
  padding-left: max(16px, max(var(--hiq-safe-left), env(safe-area-inset-left, 0px)));
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(42, 26, 54, 0.58);
  z-index: 9800;
  overflow-y: auto;
}

.pw-companion-card {
  width: min(440px, 100%);
  margin: auto 0;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0;
  border-radius: 26px;
  border: 3px solid #C69BFF;
  background: #FFFBFD;
  box-shadow: 0 16px 40px rgba(72, 34, 96, 0.28);
  color: #5C2B66;
}

.pw-companion-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 10px;
  margin-bottom: 0;
  border-bottom: 1px solid #F3E6FA;
  background: #FFFBFD;
}

.pw-companion-title {
  margin: 0;
  font-size: 20px;
  color: #6E4299;
}

.pw-companion-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 2px solid #DFC4FF;
  border-radius: 50%;
  background: #F6EEFF;
  color: #6E4299;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.pw-companion-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 20px 20px;
}

.pw-companion-status {
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: #F7F0FF;
  border: 1.5px solid #DFC4FF;
  font-size: 13px;
  font-weight: 700;
  color: #6E4299;
  line-height: 1.35;
}

.pw-companion-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pw-companion-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pw-companion-label {
  font-size: 13px;
  font-weight: 800;
  color: #7A4B6A;
}

.pw-companion-input {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid #E5CBEF;
  background: #FFFFFF;
  color: #4D2558;
  font-size: 16px;
  font-weight: 600;
  user-select: text;
  -webkit-user-select: text;
}

.pw-companion-feedback {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  font-weight: 700;
  color: #C4496D;
}

.pw-companion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pw-companion-btn {
  min-width: 96px;
}

.pw-privacy-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1.5px solid #EFE0FA;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pw-privacy-toggle {
  align-self: flex-start;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 13px;
}

.pw-privacy-panel {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid #DFC4FF;
  background: #FBF7FF;
  color: #5C2B66;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: left;
  user-select: text;
  -webkit-user-select: text;
}

.pw-privacy-panel[hidden] {
  display: none;
}

.pw-privacy-heading {
  margin: 0 0 6px;
  font-size: 13.5px;
  color: #6E4299;
}

.pw-privacy-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#a11y-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
}

.pw-a11y-btn {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  color: transparent;
  cursor: pointer;
}

.pw-a11y-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: 3px solid #FFD147;
  box-shadow: 0 0 0 6px #6E4299;
  border-radius: 16px;
  background: rgba(255, 251, 243, 0.14);
}

.loading-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.loading-star {
  font-size: 86px;
  color: #FFD147;
  text-shadow: 0 4px 16px rgba(255, 130, 190, 0.55), 0 0 28px rgba(255, 224, 102, 0.85);
  animation: starBounce 1.1s ease-in-out infinite;
}

.loading-dots {
  display: flex;
  gap: 12px;
}

.loading-dots span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FF8CC6;
  animation: dotPulse 1.1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  background: #C69BFF;
  animation-delay: 0.18s;
}

.loading-dots span:nth-child(3) {
  background: #7FD8FF;
  animation-delay: 0.36s;
}

@keyframes starBounce {
  0%, 100% {
    transform: translateY(0) scale(1) rotate(-6deg);
  }
  50% {
    transform: translateY(-16px) scale(1.14) rotate(8deg);
  }
}

@keyframes dotPulse {
  0%, 100% {
    transform: scale(0.8);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.25);
    opacity: 1;
  }
}
