:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.hc-header {
  text-align: center;
  max-width: 540px;
  margin-bottom: 24px;
}

.hc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 9999px;
  margin-bottom: 12px;
  border: 1px solid #fde68a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hc-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 10px;
  color: #0f172a;
  letter-spacing: -0.6px;
}

.hc-ticker-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  color: #475569;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  line-height: 1.4;
}

.hc-ticker-box.updated {
  border-color: var(--primary);
  background: #f0fdf4;
}

/* Status Bar & Lives */
.hc-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 380px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.hc-lives {
  display: flex;
  gap: 4px;
  font-size: 18px;
}

.hc-lives .heart {
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.hc-lives .heart.lost {
  opacity: 0.2;
  filter: grayscale(1);
  transform: scale(0.85);
}

.hc-score-label {
  color: var(--text-muted);
}

.hc-score-val {
  font-weight: 700;
  color: var(--primary);
}

.hc-progress-container {
  width: 100%;
  max-width: 380px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.hc-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 9999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The Authentic CAPTCHA Box */
.hc-widget {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.hc-widget:hover {
  border-color: #94a3b8;
  box-shadow: var(--shadow-lg);
}

.hc-widget-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Checkbox and strict state management */
.hc-checkbox {
  width: 28px;
  height: 28px;
  border: 2px solid #94a3b8;
  border-radius: 6px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.hc-widget:hover .hc-checkbox {
  border-color: #64748b;
}

/* STRICT ICON STATES: Only ONE icon can ever render! */
.hc-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: hc-spin 0.75s linear infinite;
}

.hc-check-icon {
  display: none;
  width: 20px;
  height: 20px;
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.hc-fail-icon {
  display: none;
  width: 18px;
  height: 18px;
  stroke: var(--error);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Active State 1: Verifying */
.hc-widget.verifying .hc-checkbox {
  border-color: var(--primary);
  background: #eff6ff;
}
.hc-widget.verifying .hc-spinner {
  display: block !important;
}
.hc-widget.verifying .hc-check-icon,
.hc-widget.verifying .hc-fail-icon {
  display: none !important;
}

/* Active State 2: Success */
.hc-widget.success .hc-checkbox {
  border-color: var(--success);
  background: #ecfdf5;
}
.hc-widget.success .hc-check-icon {
  display: block !important;
}
.hc-widget.success .hc-spinner,
.hc-widget.success .hc-fail-icon {
  display: none !important;
}

/* Active State 3: Failed */
.hc-widget.failed .hc-checkbox {
  border-color: var(--error);
  background: #fef2f2;
}
.hc-widget.failed .hc-fail-icon {
  display: block !important;
}
.hc-widget.failed .hc-spinner,
.hc-widget.failed .hc-check-icon {
  display: none !important;
}

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

.hc-widget-label {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.hc-widget-branding {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
}

.hc-widget-logo-svg {
  width: 32px;
  height: 32px;
}

.hc-widget-brand-name {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
}

.hc-widget-legal {
  font-size: 10px;
  color: #94a3b8;
  display: flex;
  gap: 4px;
}

.hc-widget-legal a {
  color: #94a3b8;
  text-decoration: none;
}

.hc-widget-legal a:hover {
  text-decoration: underline;
}

/* Modal Overlay */
.hc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 1000;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.hc-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.hc-modal-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  margin: auto;
}

.hc-modal-backdrop.active .hc-modal-card {
  transform: translateY(0) scale(1);
}

.hc-modal-header {
  background: #1e40af;
  color: #ffffff;
  padding: 14px 18px;
  flex-shrink: 0;
}

.hc-modal-round-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 6px;
}

.hc-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.hc-modal-prompt {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.95;
}

.hc-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 180px;
  flex: 1 1 auto;
  overflow-y: auto;
  background: #f8fafc;
}

.hc-modal-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 12px;
  width: 100%;
  display: none;
}

.hc-modal-error.visible {
  display: block;
}

.hc-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.hc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  outline: none;
}

.hc-btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.hc-btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.hc-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hc-btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
}

.hc-btn-secondary:hover {
  background: #e2e8f0;
}

/* Dev Bar */
.hc-dev-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
}

.hc-dev-select {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
}

.hc-footer-links {
  margin-top: 36px;
  display: flex;
  gap: 16px;
  font-size: 14px;
}

.hc-footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.hc-footer-links a:hover {
  text-decoration: underline;
}

/* Infinite lives toggle (iOS switch style) */
.hc-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  background: #ffffff;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.hc-toggle-container:hover {
  border-color: #94a3b8;
}

.hc-toggle-container input {
  display: none;
}

.hc-toggle-switch {
  width: 32px;
  height: 18px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.hc-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.hc-toggle-container input:checked + .hc-toggle-switch {
  background: #10b981;
}

.hc-toggle-container input:checked + .hc-toggle-switch::after {
  transform: translateX(14px);
}

/* Modal header controls */
.hc-modal-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.hc-modal-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.hc-modal-lives-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Smooth 3-Second Processing Overlay for Auto-Submit Puzzles */
.hc-processing-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  border-radius: 0 0 16px 16px;
  animation: hc-fade-in 0.25s ease-out;
}

.hc-processing-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: hc-spin 0.75s linear infinite;
  margin-bottom: 14px;
}

.hc-processing-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  text-align: center;
}

.hc-processing-sub {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 16px;
  text-align: center;
  min-height: 18px;
}

.hc-processing-bar-track {
  width: 100%;
  max-width: 270px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.hc-processing-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 999px;
  transition: width 3s linear;
}

@keyframes hc-fade-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
